You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2021/12/08 02:57:31 UTC
[GitHub] [incubator-inlong] doleyzi opened a new pull request #1929: [INLONG][feature][audit] audit-sdk module
doleyzi opened a new pull request #1929:
URL: https://github.com/apache/incubator-inlong/pull/1929
add audit-sdk module
Fixes #1734
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-inlong] dockerzhang commented on a change in pull request #1929: [INLONG][feature][audit] audit-sdk module
Posted by GitBox <gi...@apache.org>.
dockerzhang commented on a change in pull request #1929:
URL: https://github.com/apache/incubator-inlong/pull/1929#discussion_r765429407
##########
File path: inlong-audit/audit-sdk/README.md
##########
@@ -0,0 +1,21 @@
+# Description
+## overview
+The audit sdk is used to count the receiving and sending volume of each module in real time according to the cycle,
+and the statistical results are sent to the audit access layer according to the cycle.
+
+##features
+### data uniqueness
+The audit sdk will add a unique mark to each audit audit, which can be used to remove duplicates.
+
+### unified audit standard
+The audit sdk uses log production time as the audit standard,
+which can ensure that each module is reconciled in accordance with the unified audit standard.
+
+## usage
Review comment:
here we can add more guides about how to use this SDK.
##########
File path: inlong-audit/audit-sdk/pom.xml
##########
@@ -0,0 +1,85 @@
+<?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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.inlong</groupId>
+ <artifactId>inlong-audit</artifactId>
+ <version>0.12.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>audit-sdk</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache InLong - Audit Sdk</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <compiler.source>1.8</compiler.source>
+ <compiler.target>1.8</compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.10.6.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.inlong</groupId>
+ <artifactId>audit-common</artifactId>
+ <version>0.12.0-incubating-SNAPSHOT</version>
Review comment:
use `${project.version}`.
##########
File path: inlong-audit/pom.xml
##########
@@ -38,6 +38,7 @@
<module>audit-docker</module>
<module>audit-store</module>
<module>audit-common</module>
+ <module>audit-sdk</module>
Review comment:
more spaces should be moved before `<module>`.
##########
File path: inlong-audit/audit-sdk/README.md
##########
@@ -0,0 +1,21 @@
+# Description
+## overview
+The audit sdk is used to count the receiving and sending volume of each module in real time according to the cycle,
+and the statistical results are sent to the audit access layer according to the cycle.
+
+##features
Review comment:
Add a space before `features`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-inlong] codecov-commenter commented on pull request #1929: [INLONG][feature][audit] audit-sdk module
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #1929:
URL: https://github.com/apache/incubator-inlong/pull/1929#issuecomment-988457427
# [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#1929](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9608f05) into [master](https://codecov.io/gh/apache/incubator-inlong/commit/1a905c6a1682351fadef81fc082f3a036efd37c0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (1a905c6) will **decrease** coverage by `0.00%`.
> The diff coverage is `n/a`.
[![Impacted file tree graph](https://codecov.io/gh/apache/incubator-inlong/pull/1929/graphs/tree.svg?width=650&height=150&src=pr&token=1EUK92O9K2&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #1929 +/- ##
============================================
- Coverage 12.26% 12.26% -0.01%
- Complexity 1155 1157 +2
============================================
Files 413 413
Lines 35225 35225
Branches 5542 5542
============================================
- Hits 4322 4320 -2
Misses 30133 30133
- Partials 770 772 +2
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [.../java/org/apache/flume/sink/tubemq/TubemqSink.java](https://codecov.io/gh/apache/incubator-inlong/pull/1929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY29ubmVjdG9ycy90dWJlbXEtY29ubmVjdG9yLWZsdW1lL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9mbHVtZS9zaW5rL3R1YmVtcS9UdWJlbXFTaW5rLmphdmE=) | `51.42% <0.00%> (-4.00%)` | :arrow_down: |
| [.../producer/qltystats/DefaultBrokerRcvQltyStats.java](https://codecov.io/gh/apache/incubator-inlong/pull/1929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pbmxvbmcvdHViZW1xL2NsaWVudC9wcm9kdWNlci9xbHR5c3RhdHMvRGVmYXVsdEJyb2tlclJjdlFsdHlTdGF0cy5qYXZh) | `45.31% <0.00%> (+1.17%)` | :arrow_up: |
| [.../client/producer/qltystats/BrokerStatsItemSet.java](https://codecov.io/gh/apache/incubator-inlong/pull/1929/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-aW5sb25nLXR1YmVtcS90dWJlbXEtY2xpZW50L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9pbmxvbmcvdHViZW1xL2NsaWVudC9wcm9kdWNlci9xbHR5c3RhdHMvQnJva2VyU3RhdHNJdGVtU2V0LmphdmE=) | `72.09% <0.00%> (+4.65%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [1a905c6...9608f05](https://codecov.io/gh/apache/incubator-inlong/pull/1929?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-inlong] healchow commented on a change in pull request #1929: [INLONG][feature][audit] audit-sdk module
Posted by GitBox <gi...@apache.org>.
healchow commented on a change in pull request #1929:
URL: https://github.com/apache/incubator-inlong/pull/1929#discussion_r765435107
##########
File path: inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package org.apache.inlong.audit.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+public class Config {
+ private String localIP = "";
+ private String dockerId = "";
+
+ public void init() {
+ initIP();
+ initDockerId();
+ }
+
+ public String getLocalIP() {
+ return localIP;
+ }
+
+ public String getDockerId() {
+ return dockerId;
+ }
+
+ private void initIP() {
+ try {
+ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
+ NetworkInterface intf = en.nextElement();
+ String name = intf.getName();
+ if (!name.contains("docker") && !name.contains("lo")) {
+ for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
+ enumIpAddr.hasMoreElements(); ) {
+ InetAddress inetAddress = enumIpAddr.nextElement();
+ if (!inetAddress.isLoopbackAddress()) {
+ String ipaddress = inetAddress.getHostAddress();
+ if (!ipaddress.contains("::") && !ipaddress.contains("0:0:")
+ && !ipaddress.contains("fe80")) {
+ localIP = ipaddress;
+ }
+ }
+ }
+ }
+ }
+ } catch (SocketException ex) {
+ localIP = "127.0.0.1";
+ return;
+ }
+ }
+
+ private void initDockerId() {
+ BufferedReader in = null;
+ try {
+ File file = new File("/proc/self/cgroup");
+ if (file.exists() == false) {
+ return;
+ }
+ in = new BufferedReader(new FileReader("/proc/self/cgroup"));
+ String dockerID = in.readLine();
+ if (dockerID.equals("") == false) {
+ int n = dockerID.indexOf("/");
+ String dockerID2 = dockerID.substring(n + 1, (dockerID.length() - n - 1));
+ n = dockerID2.indexOf("/");
+ dockerId = dockerID2.substring(n + 1, 12);
+ }
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ return;
+ } catch (NullPointerException e2) {
+ System.out.println(e2.getMessage());
+ return;
+ } catch (Exception e3) {
+ System.out.println(e3.getMessage());
+ return;
+ } finally {
Review comment:
It's recommended to use try-with-resource instead of try-finally.
##########
File path: inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.
+ */
+
+package org.apache.inlong.audit.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Enumeration;
+
+public class Config {
+ private String localIP = "";
+ private String dockerId = "";
+
+ public void init() {
+ initIP();
+ initDockerId();
+ }
+
+ public String getLocalIP() {
+ return localIP;
+ }
+
+ public String getDockerId() {
+ return dockerId;
+ }
+
+ private void initIP() {
+ try {
+ for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); ) {
+ NetworkInterface intf = en.nextElement();
+ String name = intf.getName();
+ if (!name.contains("docker") && !name.contains("lo")) {
+ for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
+ enumIpAddr.hasMoreElements(); ) {
+ InetAddress inetAddress = enumIpAddr.nextElement();
+ if (!inetAddress.isLoopbackAddress()) {
+ String ipaddress = inetAddress.getHostAddress();
+ if (!ipaddress.contains("::") && !ipaddress.contains("0:0:")
+ && !ipaddress.contains("fe80")) {
+ localIP = ipaddress;
+ }
+ }
+ }
+ }
+ }
+ } catch (SocketException ex) {
+ localIP = "127.0.0.1";
+ return;
+ }
+ }
+
+ private void initDockerId() {
+ BufferedReader in = null;
+ try {
+ File file = new File("/proc/self/cgroup");
+ if (file.exists() == false) {
+ return;
+ }
+ in = new BufferedReader(new FileReader("/proc/self/cgroup"));
+ String dockerID = in.readLine();
+ if (dockerID.equals("") == false) {
+ int n = dockerID.indexOf("/");
+ String dockerID2 = dockerID.substring(n + 1, (dockerID.length() - n - 1));
+ n = dockerID2.indexOf("/");
+ dockerId = dockerID2.substring(n + 1, 12);
+ }
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
Review comment:
do not print exceptions to the console.
##########
File path: inlong-audit/audit-sdk/src/test/java/org/apache/inlong/audit/send/SenderChannelTest.java
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package org.apache.inlong.audit.send;
+
+import org.apache.inlong.audit.util.Encoder;
+import org.apache.inlong.audit.util.IpPort;
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.junit.Test;
+
+import java.util.concurrent.Executors;
+
+public class SenderChannelTest {
+ private ClientBootstrap client = new ClientBootstrap();
+ private IpPort ipPortObj = new IpPort("127.0.0.1", 80);
+ private ChannelFuture future;
+ SenderChannel senderChannel;
+
+ /**
+ * test SenderChannel
+ */
+ public SenderChannelTest() {
+ try {
+ client.setFactory(new NioClientSocketChannelFactory(
+ Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool(),
+ 10));
+
+ client.setPipelineFactory(() -> {
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("encoder", new Encoder());
+ return pipeline;
+ });
+ client.setOption("tcpNoDelay", true);
+ client.setOption("child.tcpNoDelay", true);
+ client.setOption("keepAlive", true);
+ client.setOption("child.keepAlive", true);
+ client.setOption("reuseAddr", true);
+
+ future = client.connect(ipPortObj.addr).await();
+ senderChannel = new SenderChannel(future.getChannel(), ipPortObj, 10);
+ } catch (InterruptedException e) {
+ System.out.println(e.getMessage());
+ }
+ }
+
+ @Test
+ public void tryAcquire() {
+ boolean ret = senderChannel.tryAcquire();
+ System.out.println(ret);
+ }
+
+ @Test
+ public void release() {
+ senderChannel.release();
+ }
+
+ @Test
+ public void testToString() {
+ IpPort ipPort = senderChannel.getIpPort();
+ System.out.println(ipPort);
+ }
+
+ @Test
+ public void getIpPort() {
+ String toString = senderChannel.toString();
+ System.out.println(toString);
+ }
+
+ @Test
+ public void getChannel() {
+ Channel channel = senderChannel.getChannel();
+ System.out.println(channel.getConfig().getConnectTimeoutMillis());
+ System.out.println(channel.getRemoteAddress());
Review comment:
use assert instead of print to the console.
##########
File path: inlong-audit/audit-sdk/src/test/java/org/apache/inlong/audit/send/SenderGroupTest.java
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+package org.apache.inlong.audit.send;
+
+import org.apache.inlong.audit.protocol.AuditApi;
+import org.apache.inlong.audit.util.AuditData;
+import org.apache.inlong.audit.util.Config;
+import org.apache.inlong.audit.util.Decoder;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+public class SenderGroupTest {
+ Config testConfig = new Config();
+ SenderManager testManager = new SenderManager(testConfig);
+ SenderHandler clientHandler = new org.apache.inlong.audit.send.SenderHandler(testManager);
+ SenderGroup sender = new org.apache.inlong.audit.send.SenderGroup(10, new Decoder(), clientHandler);
+
+ @Test
+ public void send() {
+ AuditApi.AuditMessageHeader header = AuditApi.AuditMessageHeader.newBuilder().setIp("127.0.0.1").build();
+ AuditApi.AuditMessageBody body = AuditApi.AuditMessageBody.newBuilder().setAuditId("1").build();
+ AuditApi.AuditRequest content = AuditApi.AuditRequest.newBuilder().setMsgHeader(header)
+ .addMsgBody(body).build();
+ AuditData testData = new AuditData(System.currentTimeMillis(), content, 1L);
+ ChannelBuffer dataBuf = ChannelBuffers.wrappedBuffer(testData.getDataByte());
+ sender.send(dataBuf);
+ }
+
+ @Test
+ public void release() {
+ sender.release("127.0.9.1:80");
+ }
+
+ @Test
+ public void updateConfig() {
+ Set<String> ipLists = new LinkedHashSet<>();
+ ipLists.add("127.0.9.1:80");
+ ipLists.add("127.0.9.1:81");
+ ipLists.add("127.0.9.1:82");
+ sender.updateConfig(ipLists);
+ }
+
+ @Test
+ public void isHasSendError() {
+ sender.setHasSendError(false);
+ boolean isError = sender.isHasSendError();
+ System.out.println(isError);
+
+ sender.setHasSendError(true);
+ isError = sender.isHasSendError();
+ System.out.println(isError);
Review comment:
ditto
##########
File path: inlong-audit/audit-sdk/src/test/java/org/apache/inlong/audit/send/SenderChannelTest.java
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+package org.apache.inlong.audit.send;
+
+import org.apache.inlong.audit.util.Encoder;
+import org.apache.inlong.audit.util.IpPort;
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+import org.junit.Test;
+
+import java.util.concurrent.Executors;
+
+public class SenderChannelTest {
+ private ClientBootstrap client = new ClientBootstrap();
+ private IpPort ipPortObj = new IpPort("127.0.0.1", 80);
+ private ChannelFuture future;
+ SenderChannel senderChannel;
+
+ /**
+ * test SenderChannel
+ */
+ public SenderChannelTest() {
+ try {
+ client.setFactory(new NioClientSocketChannelFactory(
+ Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool(),
+ 10));
+
+ client.setPipelineFactory(() -> {
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("encoder", new Encoder());
+ return pipeline;
+ });
+ client.setOption("tcpNoDelay", true);
+ client.setOption("child.tcpNoDelay", true);
+ client.setOption("keepAlive", true);
+ client.setOption("child.keepAlive", true);
+ client.setOption("reuseAddr", true);
+
+ future = client.connect(ipPortObj.addr).await();
+ senderChannel = new SenderChannel(future.getChannel(), ipPortObj, 10);
+ } catch (InterruptedException e) {
+ System.out.println(e.getMessage());
Review comment:
ditto
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-inlong] doleyzi closed pull request #1929: [INLONG][feature][audit] audit-sdk module
Posted by GitBox <gi...@apache.org>.
doleyzi closed pull request #1929:
URL: https://github.com/apache/incubator-inlong/pull/1929
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org