Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INLONG-2880][SDK] Upgrade netty version to 4.x and upgrade log4j to log4j2 #2881

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions inlong-agent/agent-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@
<artifactId>gson</artifactId>
<groupId>com.google.code.gson</groupId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
Expand All @@ -59,11 +71,6 @@
<groupId>org.rocksdb</groupId>
<artifactId>rocksdbjni</artifactId>
</dependency>
<dependency>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down Expand Up @@ -106,6 +113,12 @@
<groupId>org.apache.inlong</groupId>
<artifactId>audit-sdk</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public class CommonConstants {
public static final String PROXY_IS_FILE = "proxy.isFile";
public static final boolean DEFAULT_IS_FILE = false;

public static final String PROXY_CLIENT_IO_THREAD_NUM = "client.iothread.num";
public static final int DEFAULT_PROXY_CLIENT_IO_THREAD_NUM =
Runtime.getRuntime().availableProcessors();

public static final String PROXY_CLIENT_ENABLE_BUSY_WAIT = "client.enable.busy.wait";
public static final boolean DEFAULT_PROXY_CLIENT_ENABLE_BUSY_WAIT = false;

public static final String PROXY_RETRY_SLEEP = "proxy.retry.sleep";
public static final long DEFAULT_PROXY_RETRY_SLEEP = 500;

Expand Down
17 changes: 10 additions & 7 deletions inlong-agent/agent-plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
<groupId>io.debezium</groupId>
<artifactId>debezium-embedded</artifactId>
<version>${version.debezium}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.debezium</groupId>
Expand Down Expand Up @@ -91,7 +97,6 @@
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</dependency>

<dependency>
<groupId>org.apache.inlong</groupId>
<artifactId>dataproxy-sdk</artifactId>
Expand All @@ -101,19 +106,17 @@
<artifactId>log4j-slf4j-impl</artifactId>
<groupId>org.apache.logging.log4j</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</dependency>

<dependency>
<artifactId>junit</artifactId>
<groupId>junit</groupId>
<scope>test</scope>
</dependency>

<dependency>
<artifactId>mockito-core</artifactId>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
import static org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_VIP_HTTP_HOST;
import static org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_VIP_HTTP_PORT;

import io.netty.util.concurrent.DefaultThreadFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.inlong.agent.common.AgentThreadFactory;
import org.apache.inlong.agent.conf.AgentConfiguration;
import org.apache.inlong.agent.conf.JobProfile;
import org.apache.inlong.agent.constant.CommonConstants;
Expand All @@ -43,7 +42,6 @@
import org.apache.inlong.sdk.dataproxy.DefaultMessageSender;
import org.apache.inlong.sdk.dataproxy.SendMessageCallback;
import org.apache.inlong.sdk.dataproxy.SendResult;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -62,14 +60,8 @@ public class SenderManager {

// sharing worker threads between sender client
// in case of thread abusing.
private static final NioClientSocketChannelFactory SHARED_FACTORY =
new NioClientSocketChannelFactory(
new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), new AgentThreadFactory("SenderManager")),
new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60L, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), new AgentThreadFactory("SenderManager")));
private static final ThreadFactory SHARED_FACTORY = new DefaultThreadFactory("agent-client-io",
Thread.currentThread().isDaemon());

private final String managerHost;
private final int managerPort;
Expand All @@ -90,6 +82,9 @@ public class SenderManager {
private final String sourcePath;
private final PluginMetric metric;

private int ioThreadNum;
private boolean enableBusyWait;

public SenderManager(JobProfile jobConf, String inlongGroupId, String sourcePath) {
AgentConfiguration conf = AgentConfiguration.getAgentConf();
managerHost = conf.get(AGENT_MANAGER_VIP_HTTP_HOST);
Expand Down Expand Up @@ -117,6 +112,12 @@ public SenderManager(JobProfile jobConf, String inlongGroupId, String sourcePath
CommonConstants.PROXY_RETRY_SLEEP, CommonConstants.DEFAULT_PROXY_RETRY_SLEEP);
isFile = jobConf.getBoolean(CommonConstants.PROXY_IS_FILE, CommonConstants.DEFAULT_IS_FILE);
taskPositionManager = TaskPositionManager.getTaskPositionManager();

ioThreadNum = jobConf.getInt(CommonConstants.PROXY_CLIENT_IO_THREAD_NUM,
CommonConstants.DEFAULT_PROXY_CLIENT_IO_THREAD_NUM);
enableBusyWait = jobConf.getBoolean(CommonConstants.PROXY_CLIENT_ENABLE_BUSY_WAIT,
CommonConstants.DEFAULT_PROXY_CLIENT_ENABLE_BUSY_WAIT);

this.sourcePath = sourcePath;
this.inlongGroupId = inlongGroupId;

Expand Down Expand Up @@ -152,6 +153,9 @@ private DefaultMessageSender createMessageSender(String groupId) throws Exceptio
proxyClientConfig.setFile(isFile);
proxyClientConfig.setAliveConnections(aliveConnectionNum);

proxyClientConfig.setIoThreadNum(ioThreadNum);
proxyClientConfig.setEnableBusyWait(enableBusyWait);

DefaultMessageSender sender = new DefaultMessageSender(proxyClientConfig, SHARED_FACTORY);
sender.setMsgtype(msgType);
sender.setCompress(isCompress);
Expand Down Expand Up @@ -206,7 +210,9 @@ public void onMessageAck(SendResult result) {
return;
}
metric.incSendSuccessNum(bodyList.size());
taskPositionManager.updateSinkPosition(jobId, sourcePath, bodyList.size());
if (sourcePath != null) {
taskPositionManager.updateSinkPosition(jobId, sourcePath, bodyList.size());
}
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions inlong-agent/bin/agent-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export CLASSPATH=$CLASSPATH:$BASE_DIR/conf:$(ls $BASE_DIR/lib/*.jar | tr '\n' :)

JMX_ENABLED=$(grep -c "agent.prometheus.enable=false" $BASE_DIR/conf/agent.properties)
if [[ $JMX_ENABLED == 1 ]]; then
export AGENT_ARGS="$AGENT_JVM_ARGS $AGENT_RMI_ARGS -cp $CLASSPATH -Dagent.home=$BASE_DIR -Dlog4j.configuration=file:$BASE_DIR/conf/log4j.properties"
export AGENT_ARGS="$AGENT_JVM_ARGS $AGENT_RMI_ARGS -cp $CLASSPATH -Dagent.home=$BASE_DIR"
else
export AGENT_ARGS="$AGENT_JVM_ARGS -cp $CLASSPATH -Dagent.home=$BASE_DIR -Dlog4j.configuration=file:$BASE_DIR/conf/log4j.properties"
export AGENT_ARGS="$AGENT_JVM_ARGS -cp $CLASSPATH -Dagent.home=$BASE_DIR"
fi
2 changes: 1 addition & 1 deletion inlong-agent/bin/agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function start_agent() {
echo "agent is running."
exit 1
fi
nohup $JAVA $AGENT_ARGS org.apache.inlong.agent.core.AgentMain > "$CONSOLE_OUTPUT_FILE" 2>&1 < /dev/null &
nohup $JAVA $AGENT_ARGS org.apache.inlong.agent.core.AgentMain > /dev/null 2>&1 &
echo $! > $PID_FILE
chmod 755 $PID_FILE
}
Expand Down
57 changes: 0 additions & 57 deletions inlong-agent/conf/log4j.properties

This file was deleted.

123 changes: 123 additions & 0 deletions inlong-agent/conf/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<configuration status="WARN" monitorInterval="30">
<Properties>
<property name="basePath">${sys:agent.home}/logs</property>
<property name="log_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} -%5p ${PID:-} [%15.15t] %-30.30C{1.} : %m%n</property>
<property name="every_file_size">1G</property>
<property name="output_log_level">DEBUG</property>
<property name="rolling_max">50</property>
<property name="debug_fileName">${basePath}/debug.log</property>
<property name="debug_filePattern">${basePath}/debug-%d{yyyy-MM-dd}-%i.log.gz</property>
<property name="debug_max">10</property>
<property name="info_fileName">${basePath}/info.log</property>
<property name="info_filePattern">${basePath}/info-%d{yyyy-MM-dd}-%i.log.gz</property>
<property name="info_max">10</property>
<property name="warn_fileName">${basePath}/warn.log</property>
<property name="warn_filePattern">${basePath}/warn-%d{yyyy-MM-dd}-%i.log.gz</property>
<property name="warn_max">10</property>
<property name="error_fileName">${basePath}/error.log</property>
<property name="error_filePattern">${basePath}/error-%d{yyyy-MM-dd}-%i.log.gz</property>
<property name="error_max">10</property>
<property name="console_print_level">DEBUG</property>
<property name="index_fileName">${basePath}/index.log</property>
<property name="index_filePattern">${basePath}/index-%d{yyyy-MM-dd}-%i.log.gz</property>
<property name="monitors_fileName">${basePath}/monitors.log</property>
<property name="monitors_filePattern">${basePath}/monitors-%d{yyyy-MM-dd}-%i.log.gz</property>
</Properties>

<appenders>
<Console name="Console" target="SYSTEM_OUT">
<ThresholdFilter level="${console_print_level}" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="${log_pattern}"/>
</Console>

<RollingFile name="DebugFile" fileName="${debug_fileName}" filePattern="${debug_filePattern}">
<PatternLayout pattern="${log_pattern}"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${debug_max}" />
<Filters>
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="INFO" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="InfoFile" fileName="${info_fileName}" filePattern="${info_filePattern}">
<PatternLayout pattern="${log_pattern}"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${info_max}" />
<Filters>
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="IndexFile" fileName="${index_fileName}" filePattern="${index_filePattern}">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %m%n"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${info_max}" />
<Filters>
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="MonitorFile" fileName="${monitors_fileName}" filePattern="${monitors_filePattern}">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %m%n"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${info_max}" />
<Filters>
<ThresholdFilter level="WARN" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="WarnFile" fileName="${warn_fileName}" filePattern="${warn_filePattern}">
<PatternLayout pattern="${log_pattern}"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${warn_max}" />
<Filters>
<ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="WARN" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>

<RollingFile name="ErrorFile" fileName="${error_fileName}" filePattern="${error_filePattern}">
<PatternLayout pattern="${log_pattern}"/>
<SizeBasedTriggeringPolicy size="${every_file_size}"/>
<DefaultRolloverStrategy max="${error_max}" />
<Filters>
<ThresholdFilter level="FATAL" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY"/>
</Filters>
</RollingFile>
</appenders>

<loggers>
<root level="${output_log_level}">
<appender-ref ref="Console"/>
<appender-ref ref="DebugFile"/>
<appender-ref ref="InfoFile"/>
<appender-ref ref="WarnFile"/>
<appender-ref ref="ErrorFile"/>
</root>
</loggers>
</configuration>
Loading