From fc19f4527063a72e0de1830de2ddf301b4a61341 Mon Sep 17 00:00:00 2001 From: "koo.taejin" Date: Wed, 30 Aug 2017 18:02:01 +0900 Subject: [PATCH] [#3275] Supports TCP transport type for Span and Stat data 1. implement profiler side 2. add config --- .../src/main/resources-local/pinpoint.config | 8 ++ .../main/resources-release/pinpoint.config | 8 ++ ...inpoint-real-env-lowoverhead-sample.config | 8 ++ .../client/pinpoint-activemq-client.config | 8 ++ .../pinpoint-disabled-plugin-test.config | 8 ++ .../pinpoint-netty-plugin-test.config | 8 ++ .../pinpoint-spring-bean-test.config | 8 ++ .../config/DefaultProfilerConfig.java | 16 +++ .../bootstrap/config/ProfilerConfig.java | 4 + .../receiver/DataReceiverGroupTest.java | 21 ++-- .../src/test/resources/pinpoint.config | 8 ++ .../src/test/resources/pinpoint.config | 8 ++ .../src/test/resources/pinpoint.config | 8 ++ .../jboss/src/test/resources/pinpoint.config | 8 ++ .../jsp/src/test/resources/pinpoint.config | 8 ++ .../redis/src/test/resources/pinpoint.config | 8 ++ .../tomcat/src/test/resources/pinpoint.config | 8 ++ .../user/src/test/resources/pinpoint.config | 8 ++ .../vertx/src/test/resources/pinpoint.config | 8 ++ .../resources/pinpoint-lambda-test.config | 8 ++ .../module/ApplicationContextModule.java | 15 +-- .../module/DefaultApplicationContext.java | 13 ++- .../context/module/DefaultClientFactory.java | 34 ++++++ .../context/module/SpanStatClientFactory.java | 34 ++++++ .../provider/SpanDataSenderProvider.java | 102 ++++++++++++++++++ .../SpanStatClientFactoryProvider.java | 60 +++++++++++ .../provider/StatDataSenderProvider.java | 102 ++++++++++++++++++ .../provider/TcpDataSenderProvider.java | 10 +- .../provider/UdpSpanDataSenderProvider.java | 81 -------------- .../provider/UdpStatDataSenderProvider.java | 71 ------------ .../profiler/sender/TcpDataSender.java | 37 ++++--- .../profiler/AgentInfoSenderTest.java | 28 +++-- .../sender/TcpDataSenderReconnectTest.java | 4 +- .../profiler/sender/TcpDataSenderTest.java | 6 +- .../pinpoint-spring-bean-test.config | 8 ++ profiler/src/test/resources/pinpoint.config | 8 ++ .../agent/src/main/resources/pinpoint.config | 8 ++ 37 files changed, 595 insertions(+), 203 deletions(-) create mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultClientFactory.java create mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/SpanStatClientFactory.java create mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanDataSenderProvider.java create mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanStatClientFactoryProvider.java create mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/StatDataSenderProvider.java delete mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/UdpSpanDataSenderProvider.java delete mode 100644 profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/UdpStatDataSenderProvider.java diff --git a/agent/src/main/resources-local/pinpoint.config b/agent/src/main/resources-local/pinpoint.config index cd93a0ed1e53..85f80c45554b 100644 --- a/agent/src/main/resources-local/pinpoint.config +++ b/agent/src/main/resources-local/pinpoint.config @@ -56,6 +56,10 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 profiler.spandatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP # Capacity of the StatDataSender write queue. profiler.statdatasender.write.queue.size=5120 @@ -63,6 +67,10 @@ profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 profiler.statdatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP # Interval to retry sending agent info. Unit is milliseconds. profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/main/resources-release/pinpoint.config b/agent/src/main/resources-release/pinpoint.config index 33a0af47ead5..9a50bea965f8 100644 --- a/agent/src/main/resources-release/pinpoint.config +++ b/agent/src/main/resources-release/pinpoint.config @@ -56,6 +56,10 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 profiler.spandatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP # Capacity of the StatDataSender write queue. profiler.statdatasender.write.queue.size=5120 @@ -63,6 +67,10 @@ profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 profiler.statdatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP # Interval to retry sending agent info. Unit is milliseconds. profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/main/resources/pinpoint-real-env-lowoverhead-sample.config b/agent/src/main/resources/pinpoint-real-env-lowoverhead-sample.config index 337c1b7d4a71..5ff984b57eeb 100644 --- a/agent/src/main/resources/pinpoint-real-env-lowoverhead-sample.config +++ b/agent/src/main/resources/pinpoint-real-env-lowoverhead-sample.config @@ -44,12 +44,20 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP # Capacity of the StatDataSender write queue. profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP # Interval to retry sending agent info. Unit is milliseconds. profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/test/resources/activemq/client/pinpoint-activemq-client.config b/agent/src/test/resources/activemq/client/pinpoint-activemq-client.config index 3596fcfcf394..042ee98f7d87 100644 --- a/agent/src/test/resources/activemq/client/pinpoint-activemq-client.config +++ b/agent/src/test/resources/activemq/client/pinpoint-activemq-client.config @@ -47,12 +47,20 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP # Capacity of the StatDataSender write queue. profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP # Interval to retry sending agent info. Unit is milliseconds. profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/test/resources/pinpoint-disabled-plugin-test.config b/agent/src/test/resources/pinpoint-disabled-plugin-test.config index 1721328d5e35..f3d3243610f0 100644 --- a/agent/src/test/resources/pinpoint-disabled-plugin-test.config +++ b/agent/src/test/resources/pinpoint-disabled-plugin-test.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/test/resources/pinpoint-netty-plugin-test.config b/agent/src/test/resources/pinpoint-netty-plugin-test.config index 825fbadd81f4..013ca8b6ddef 100644 --- a/agent/src/test/resources/pinpoint-netty-plugin-test.config +++ b/agent/src/test/resources/pinpoint-netty-plugin-test.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/agent/src/test/resources/pinpoint-spring-bean-test.config b/agent/src/test/resources/pinpoint-spring-bean-test.config index 5e352ce8b09a..b00a56a92340 100644 --- a/agent/src/test/resources/pinpoint-spring-bean-test.config +++ b/agent/src/test/resources/pinpoint-spring-bean-test.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java index 1c24b83004ee..0859e7ca577c 100644 --- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/DefaultProfilerConfig.java @@ -111,12 +111,14 @@ public static ProfilerConfig load(String pinpointConfigFileName) throws IOExcept private int spanDataSenderSocketSendBufferSize = 1024 * 64 * 16; private int spanDataSenderSocketTimeout = 1000 * 3; private int spanDataSenderChunkSize = 1024 * 16; + private String spanDataSenderTransportType = "UDP"; private String spanDataSenderSocketType = "OIO"; private int statDataSenderWriteQueueSize = 1024 * 5; private int statDataSenderSocketSendBufferSize = 1024 * 64 * 16; private int statDataSenderSocketTimeout = 1000 * 3; private int statDataSenderChunkSize = 1024 * 16; + private String statDataSenderTransportType = "UDP"; private String statDataSenderSocketType = "OIO"; private boolean tcpDataSenderCommandAcceptEnable = false; @@ -235,6 +237,11 @@ public String getStatDataSenderSocketType() { return statDataSenderSocketType; } + @Override + public String getStatDataSenderTransportType() { + return statDataSenderTransportType; + } + @Override public int getSpanDataSenderWriteQueueSize() { return spanDataSenderWriteQueueSize; @@ -305,6 +312,11 @@ public String getSpanDataSenderSocketType() { return spanDataSenderSocketType; } + @Override + public String getSpanDataSenderTransportType() { + return spanDataSenderTransportType; + } + @Override public int getSpanDataSenderChunkSize() { return spanDataSenderChunkSize; @@ -487,12 +499,14 @@ void readPropertyValues() { this.spanDataSenderSocketTimeout = readInt("profiler.spandatasender.socket.timeout", 1000 * 3); this.spanDataSenderChunkSize = readInt("profiler.spandatasender.chunk.size", 1024 * 16); this.spanDataSenderSocketType = readString("profiler.spandatasender.socket.type", "OIO"); + this.spanDataSenderTransportType = readString("profiler.spandatasender.transport.type", "UDP"); this.statDataSenderWriteQueueSize = readInt("profiler.statdatasender.write.queue.size", 1024 * 5); this.statDataSenderSocketSendBufferSize = readInt("profiler.statdatasender.socket.sendbuffersize", 1024 * 64 * 16); this.statDataSenderSocketTimeout = readInt("profiler.statdatasender.socket.timeout", 1000 * 3); this.statDataSenderChunkSize = readInt("profiler.statdatasender.chunk.size", 1024 * 16); this.statDataSenderSocketType = readString("profiler.statdatasender.socket.type", "OIO"); + this.statDataSenderTransportType = readString("profiler.statdatasender.transport.type", "UDP"); this.tcpDataSenderCommandAcceptEnable = readBoolean("profiler.tcpdatasender.command.accept.enable", false); this.tcpDataSenderCommandActiveThreadEnable = readBoolean("profiler.tcpdatasender.command.activethread.enable", false); @@ -691,11 +705,13 @@ public String toString() { sb.append(", spanDataSenderSocketTimeout=").append(spanDataSenderSocketTimeout); sb.append(", spanDataSenderChunkSize=").append(spanDataSenderChunkSize); sb.append(", spanDataSenderSocketType='").append(spanDataSenderSocketType).append('\''); + sb.append(", spanDataSenderTransportType='").append(spanDataSenderTransportType).append('\''); sb.append(", statDataSenderWriteQueueSize=").append(statDataSenderWriteQueueSize); sb.append(", statDataSenderSocketSendBufferSize=").append(statDataSenderSocketSendBufferSize); sb.append(", statDataSenderSocketTimeout=").append(statDataSenderSocketTimeout); sb.append(", statDataSenderChunkSize=").append(statDataSenderChunkSize); sb.append(", statDataSenderSocketType='").append(statDataSenderSocketType).append('\''); + sb.append(", statDataSenderTransportType='").append(statDataSenderTransportType).append('\''); sb.append(", tcpDataSenderCommandAcceptEnable=").append(tcpDataSenderCommandAcceptEnable); sb.append(", tcpDataSenderCommandActiveThreadEnable=").append(tcpDataSenderCommandActiveThreadEnable); sb.append(", tcpDataSenderCommandActiveThreadCountEnable=").append(tcpDataSenderCommandActiveThreadCountEnable); diff --git a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java index 960dee0e3e75..37639b9ac6e0 100644 --- a/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java +++ b/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/ProfilerConfig.java @@ -46,6 +46,8 @@ public interface ProfilerConfig { String getStatDataSenderSocketType(); + String getStatDataSenderTransportType(); + int getSpanDataSenderWriteQueueSize(); int getSpanDataSenderSocketSendBufferSize(); @@ -74,6 +76,8 @@ public interface ProfilerConfig { String getSpanDataSenderSocketType(); + String getSpanDataSenderTransportType(); + int getSpanDataSenderChunkSize(); int getStatDataSenderChunkSize(); diff --git a/collector/src/test/java/com/navercorp/pinpoint/collector/receiver/DataReceiverGroupTest.java b/collector/src/test/java/com/navercorp/pinpoint/collector/receiver/DataReceiverGroupTest.java index bd38519e49af..d1b46173dc59 100644 --- a/collector/src/test/java/com/navercorp/pinpoint/collector/receiver/DataReceiverGroupTest.java +++ b/collector/src/test/java/com/navercorp/pinpoint/collector/receiver/DataReceiverGroupTest.java @@ -21,7 +21,6 @@ import com.navercorp.pinpoint.profiler.sender.TcpDataSender; import com.navercorp.pinpoint.profiler.sender.UdpDataSender; import com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory; -import com.navercorp.pinpoint.rpc.client.PinpointClient; import com.navercorp.pinpoint.rpc.client.PinpointClientFactory; import com.navercorp.pinpoint.thrift.dto.TResult; import org.apache.thrift.TBase; @@ -31,6 +30,7 @@ import org.slf4j.LoggerFactory; import org.springframework.util.SocketUtils; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -64,7 +64,8 @@ public void receiverGroupTest1() throws Exception { udpDataSender = new UdpDataSender("127.0.0.1", mockConfig.getUdpBindPort(), "test", 10, 1000, 1024 * 64 * 100); pinpointClientFactory = createPinpointClientFactory(); - tcpDataSender = new TcpDataSender("127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory); + InetSocketAddress address = new InetSocketAddress("127.0.0.1", mockConfig.getTcpBindPort()); + tcpDataSender = new TcpDataSender(address, pinpointClientFactory); udpDataSender.send(new TResult()); @@ -104,7 +105,8 @@ public void receiverGroupTest2() throws Exception { Assert.assertFalse(sendLatch.await(1000, TimeUnit.MILLISECONDS)); pinpointClientFactory = createPinpointClientFactory(); - tcpDataSender = new TcpDataSender("127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory); + InetSocketAddress address = new InetSocketAddress("127.0.0.1", mockConfig.getTcpBindPort()); + tcpDataSender = new TcpDataSender(address, pinpointClientFactory); Assert.assertTrue(tcpDataSender.isConnected()); @@ -141,7 +143,8 @@ public void receiverGroupTest3() throws Exception { Assert.assertTrue(sendLatch.await(1000, TimeUnit.MILLISECONDS)); pinpointClientFactory = createPinpointClientFactory(); - tcpDataSender = new TcpDataSender("127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory); + InetSocketAddress address = new InetSocketAddress("127.0.0.1", mockConfig.getTcpBindPort()); + tcpDataSender = new TcpDataSender(address, pinpointClientFactory); Assert.assertFalse(tcpDataSender.isConnected()); } finally { @@ -178,16 +181,6 @@ private void closeDataSender(DataSender dataSender) { } } - private void closeClient(PinpointClient client) { - try { - if (client != null) { - client.close(); - } - } catch (Exception e) { - // ignore - } - } - private void closeClientFactory(PinpointClientFactory factory) { try { if (factory != null) { diff --git a/plugins/google-httpclient/src/test/resources/pinpoint.config b/plugins/google-httpclient/src/test/resources/pinpoint.config index 726a9238d4cc..24c6ff50b3c5 100644 --- a/plugins/google-httpclient/src/test/resources/pinpoint.config +++ b/plugins/google-httpclient/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/httpclient3/src/test/resources/pinpoint.config b/plugins/httpclient3/src/test/resources/pinpoint.config index 81a007def4ed..be776742ab1e 100644 --- a/plugins/httpclient3/src/test/resources/pinpoint.config +++ b/plugins/httpclient3/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/httpclient4/src/test/resources/pinpoint.config b/plugins/httpclient4/src/test/resources/pinpoint.config index f05b331b1755..6f129d30b62e 100644 --- a/plugins/httpclient4/src/test/resources/pinpoint.config +++ b/plugins/httpclient4/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/jboss/src/test/resources/pinpoint.config b/plugins/jboss/src/test/resources/pinpoint.config index 23e8d108f623..c857838c2f7a 100644 --- a/plugins/jboss/src/test/resources/pinpoint.config +++ b/plugins/jboss/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/jsp/src/test/resources/pinpoint.config b/plugins/jsp/src/test/resources/pinpoint.config index c7feb2798d09..afeff24f5e4e 100644 --- a/plugins/jsp/src/test/resources/pinpoint.config +++ b/plugins/jsp/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/redis/src/test/resources/pinpoint.config b/plugins/redis/src/test/resources/pinpoint.config index c8918466696d..8834fa3788cc 100644 --- a/plugins/redis/src/test/resources/pinpoint.config +++ b/plugins/redis/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/tomcat/src/test/resources/pinpoint.config b/plugins/tomcat/src/test/resources/pinpoint.config index c7feb2798d09..afeff24f5e4e 100644 --- a/plugins/tomcat/src/test/resources/pinpoint.config +++ b/plugins/tomcat/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/user/src/test/resources/pinpoint.config b/plugins/user/src/test/resources/pinpoint.config index ad0d7bf26eee..4a7b98362cc9 100644 --- a/plugins/user/src/test/resources/pinpoint.config +++ b/plugins/user/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/plugins/vertx/src/test/resources/pinpoint.config b/plugins/vertx/src/test/resources/pinpoint.config index 64d8e9318651..b8c457ca8099 100644 --- a/plugins/vertx/src/test/resources/pinpoint.config +++ b/plugins/vertx/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/profiler-optional/profiler-optional-jdk8/src/test/resources/pinpoint-lambda-test.config b/profiler-optional/profiler-optional-jdk8/src/test/resources/pinpoint-lambda-test.config index ae4365a23648..e5195687fd0c 100644 --- a/profiler-optional/profiler-optional-jdk8/src/test/resources/pinpoint-lambda-test.config +++ b/profiler-optional/profiler-optional-jdk8/src/test/resources/pinpoint-lambda-test.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/ApplicationContextModule.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/ApplicationContextModule.java index 02e9481f5d0d..0e1568b50155 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/ApplicationContextModule.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/ApplicationContextModule.java @@ -93,13 +93,14 @@ import com.navercorp.pinpoint.profiler.context.provider.ServerMetaDataHolderProvider; import com.navercorp.pinpoint.profiler.context.provider.ServerMetaDataRegistryServiceProvider; import com.navercorp.pinpoint.profiler.context.provider.SpanChunkFactoryProvider; +import com.navercorp.pinpoint.profiler.context.provider.SpanDataSenderProvider; import com.navercorp.pinpoint.profiler.context.provider.SpanPostProcessorProvider; +import com.navercorp.pinpoint.profiler.context.provider.SpanStatClientFactoryProvider; +import com.navercorp.pinpoint.profiler.context.provider.StatDataSenderProvider; import com.navercorp.pinpoint.profiler.context.provider.StorageFactoryProvider; import com.navercorp.pinpoint.profiler.context.provider.TcpDataSenderProvider; import com.navercorp.pinpoint.profiler.context.provider.TraceContextProvider; import com.navercorp.pinpoint.profiler.context.provider.TraceFactoryProvider; -import com.navercorp.pinpoint.profiler.context.provider.UdpSpanDataSenderProvider; -import com.navercorp.pinpoint.profiler.context.provider.UdpStatDataSenderProvider; import com.navercorp.pinpoint.profiler.context.provider.stat.activethread.ActiveTraceMetricCollectorProvider; import com.navercorp.pinpoint.profiler.context.provider.stat.activethread.ActiveTraceMetricProvider; import com.navercorp.pinpoint.profiler.context.provider.stat.cpu.CpuLoadMetricCollectorProvider; @@ -279,14 +280,16 @@ private void bindDataTransferComponent() { // create tcp channel bind(CommandDispatcher.class).toProvider(CommandDispatcherProvider.class).in(Scopes.SINGLETON); - - bind(PinpointClientFactory.class).toProvider(PinpointClientFactoryProvider.class).in(Scopes.SINGLETON); + bind(PinpointClientFactory.class).annotatedWith(DefaultClientFactory.class). + toProvider(PinpointClientFactoryProvider.class).in(Scopes.SINGLETON); bind(EnhancedDataSender.class).toProvider(TcpDataSenderProvider.class).in(Scopes.SINGLETON); + bind(PinpointClientFactory.class).annotatedWith(SpanStatClientFactory.class). + toProvider(SpanStatClientFactoryProvider.class).in(Scopes.SINGLETON); bind(DataSender.class).annotatedWith(SpanDataSender.class) - .toProvider(UdpSpanDataSenderProvider.class).in(Scopes.SINGLETON); + .toProvider(SpanDataSenderProvider.class).in(Scopes.SINGLETON); bind(DataSender.class).annotatedWith(StatDataSender.class) - .toProvider(UdpStatDataSenderProvider.class).in(Scopes.SINGLETON); + .toProvider(StatDataSenderProvider.class).in(Scopes.SINGLETON); } private void bindServiceComponent() { diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultApplicationContext.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultApplicationContext.java index aff06df5eb9a..3764712e59c4 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultApplicationContext.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultApplicationContext.java @@ -63,8 +63,9 @@ public class DefaultApplicationContext implements ApplicationContext { private final PinpointClientFactory clientFactory; private final EnhancedDataSender tcpDataSender; - private final DataSender statDataSender; + private final PinpointClientFactory spanStatClientFactory; private final DataSender spanDataSender; + private final DataSender statDataSender; private final AgentInformation agentInformation; private final AgentOption agentOption; @@ -109,13 +110,16 @@ public DefaultApplicationContext(AgentOption agentOption, final InterceptorRegis ClassFileTransformer classFileTransformer = wrap(classFileDispatcher); instrumentation.addTransformer(classFileTransformer, true); + this.spanStatClientFactory = injector.getInstance(Key.get(PinpointClientFactory.class, SpanStatClientFactory.class)); + logger.info("spanStatClientFactory:{}", spanStatClientFactory); + this.spanDataSender = newUdpSpanDataSender(); logger.info("spanDataSender:{}", spanDataSender); this.statDataSender = newUdpStatDataSender(); logger.info("statDataSender:{}", statDataSender); - this.clientFactory = injector.getInstance(PinpointClientFactory.class); + this.clientFactory = injector.getInstance(Key.get(PinpointClientFactory.class, DefaultClientFactory.class)); logger.info("clientFactory:{}", clientFactory); this.tcpDataSender = injector.getInstance(EnhancedDataSender.class); @@ -133,7 +137,6 @@ public DefaultApplicationContext(AgentOption agentOption, final InterceptorRegis } public ClassFileTransformer wrap(ClassFileTransformerDispatcher classFileTransformerDispatcher) { - final boolean enableBytecodeDump = profilerConfig.readBoolean(ASMBytecodeDumpService.ENABLE_BYTECODE_DUMP, ASMBytecodeDumpService.ENABLE_BYTECODE_DUMP_DEFAULT_VALUE); if (enableBytecodeDump) { logger.info("wrapBytecodeDumpTransformer"); @@ -147,7 +150,6 @@ protected Module newApplicationContextModule(AgentOption agentOption, Intercepto } private DataSender newUdpStatDataSender() { - Key statDataSenderKey = Key.get(DataSender.class, StatDataSender.class); return injector.getInstance(statDataSenderKey); } @@ -216,6 +218,9 @@ public void close() { // Need to process stop this.spanDataSender.stop(); this.statDataSender.stop(); + if (spanStatClientFactory != null) { + spanStatClientFactory.release(); + } closeTcpDataSender(); } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultClientFactory.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultClientFactory.java new file mode 100644 index 000000000000..9b78c9727480 --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/DefaultClientFactory.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.profiler.context.module; + +import com.google.inject.BindingAnnotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * @author Taejin Koo + */ +@BindingAnnotation +@Target(PARAMETER) +@Retention(RUNTIME) +public @interface DefaultClientFactory { +} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/SpanStatClientFactory.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/SpanStatClientFactory.java new file mode 100644 index 000000000000..64ebfbff97b6 --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/module/SpanStatClientFactory.java @@ -0,0 +1,34 @@ +/* + * Copyright 2017 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.profiler.context.module; + +import com.google.inject.BindingAnnotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * @author Taejin Koo + */ +@BindingAnnotation +@Target(PARAMETER) +@Retention(RUNTIME) +public @interface SpanStatClientFactory { +} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanDataSenderProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanDataSenderProvider.java new file mode 100644 index 000000000000..375860f9b4f7 --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanDataSenderProvider.java @@ -0,0 +1,102 @@ +/* + * Copyright 2017 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.profiler.context.provider; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; +import com.navercorp.pinpoint.profiler.context.module.SpanStatClientFactory; +import com.navercorp.pinpoint.profiler.sender.DataSender; +import com.navercorp.pinpoint.profiler.sender.TcpDataSender; +import com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory; +import com.navercorp.pinpoint.rpc.client.PinpointClientFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetSocketAddress; + +/** + * @author Taejin Koo + */ +public class SpanDataSenderProvider implements Provider { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static final String UDP_EXECUTOR_NAME = "Pinpoint-UdpSpanDataExecutor"; + + private final Provider clientFactoryProvider; + + private final String ip; + private final int port; + private final int writeQueueSize; + private final int timeout; + private final int sendBufferSize; + private final String ioType; + private final String transportType; + + @Inject + public SpanDataSenderProvider(ProfilerConfig profilerConfig, @SpanStatClientFactory Provider clientFactoryProvider) { + if (profilerConfig == null) { + throw new NullPointerException("profilerConfig must not be null"); + } + if (clientFactoryProvider == null) { + throw new NullPointerException("clientFactoryProvider must not be null"); + } + + this.clientFactoryProvider = clientFactoryProvider; + + this.ip = profilerConfig.getCollectorSpanServerIp(); + this.port = profilerConfig.getCollectorSpanServerPort(); + this.writeQueueSize = profilerConfig.getSpanDataSenderWriteQueueSize(); + this.timeout = profilerConfig.getSpanDataSenderSocketTimeout(); + this.sendBufferSize = profilerConfig.getSpanDataSenderSocketSendBufferSize(); + this.ioType = profilerConfig.getSpanDataSenderSocketType(); + this.transportType = profilerConfig.getSpanDataSenderTransportType(); + } + + @Override + public DataSender get() { + if ("TCP".equalsIgnoreCase(transportType)) { + if ("OIO".equalsIgnoreCase(ioType)) { + logger.warn("TCP transport not support OIO type.(only support NIO)"); + } + + PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get(); + InetSocketAddress address = new InetSocketAddress(ip, port); + return new TcpDataSender("SpanDataSender", address, pinpointClientFactory); + } else { + UdpDataSenderFactory factory = new UdpDataSenderFactory(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize); + return factory.create(ioType); + } + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("SpanDataSenderProvider{"); + sb.append("ip='").append(ip).append('\''); + sb.append(", port=").append(port); + sb.append(", writeQueueSize=").append(writeQueueSize); + sb.append(", timeout=").append(timeout); + sb.append(", sendBufferSize=").append(sendBufferSize); + sb.append(", ioType='").append(ioType).append('\''); + sb.append(", transportType='").append(transportType).append('\''); + sb.append('}'); + return sb.toString(); + } + +} + diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanStatClientFactoryProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanStatClientFactoryProvider.java new file mode 100644 index 000000000000..63866c6ba00e --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/SpanStatClientFactoryProvider.java @@ -0,0 +1,60 @@ +/* + * Copyright 2017 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.profiler.context.provider; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; +import com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory; +import com.navercorp.pinpoint.rpc.client.PinpointClientFactory; + +/** + * @author Taejin Koo + */ +public class SpanStatClientFactoryProvider implements Provider { + + private final ProfilerConfig profilerConfig; + + @Inject + public SpanStatClientFactoryProvider(ProfilerConfig profilerConfig) { + if (profilerConfig == null) { + throw new NullPointerException("profilerConfig must not be null"); + } + + this.profilerConfig = profilerConfig; + } + + public PinpointClientFactory get() { + int workerCount = 0; + + if ("TCP".equalsIgnoreCase(profilerConfig.getSpanDataSenderTransportType())) { + workerCount++; + } + if ("TCP".equalsIgnoreCase(profilerConfig.getStatDataSenderTransportType())) { + workerCount++; + } + + if (workerCount == 0) { + return null; + } else { + PinpointClientFactory pinpointClientFactory = new DefaultPinpointClientFactory(1, workerCount); + pinpointClientFactory.setTimeoutMillis(1000 * 5); + return pinpointClientFactory; + } + } + +} \ No newline at end of file diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/StatDataSenderProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/StatDataSenderProvider.java new file mode 100644 index 000000000000..be60905e2e87 --- /dev/null +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/StatDataSenderProvider.java @@ -0,0 +1,102 @@ +/* + * Copyright 2017 NAVER Corp. + * + * Licensed 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 com.navercorp.pinpoint.profiler.context.provider; + +import com.google.inject.Inject; +import com.google.inject.Provider; +import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; +import com.navercorp.pinpoint.profiler.context.module.SpanStatClientFactory; +import com.navercorp.pinpoint.profiler.sender.DataSender; +import com.navercorp.pinpoint.profiler.sender.TcpDataSender; +import com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory; +import com.navercorp.pinpoint.rpc.client.PinpointClientFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetSocketAddress; + +/** + * @author Taejin Koo + */ +public class StatDataSenderProvider implements Provider { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + private static final String UDP_EXECUTOR_NAME = "Pinpoint-UdpStatDataExecutor"; + + private final Provider clientFactoryProvider; + + private final String ip; + private final int port; + private final int writeQueueSize; + private final int timeout; + private final int sendBufferSize; + private final String ioType; + private final String transportType; + + @Inject + public StatDataSenderProvider(ProfilerConfig profilerConfig, @SpanStatClientFactory Provider clientFactoryProvider) { + if (profilerConfig == null) { + throw new NullPointerException("profilerConfig must not be null"); + } + if (clientFactoryProvider == null) { + throw new NullPointerException("clientFactoryProvider must not be null"); + } + + this.clientFactoryProvider = clientFactoryProvider; + + this.ip = profilerConfig.getCollectorStatServerIp(); + this.port = profilerConfig.getCollectorStatServerPort(); + this.writeQueueSize = profilerConfig.getStatDataSenderWriteQueueSize(); + this.timeout = profilerConfig.getStatDataSenderSocketTimeout(); + this.sendBufferSize = profilerConfig.getStatDataSenderSocketSendBufferSize(); + this.ioType = profilerConfig.getStatDataSenderSocketType(); + this.transportType = profilerConfig.getStatDataSenderTransportType(); + } + + @Override + public DataSender get() { + if ("TCP".equalsIgnoreCase(transportType)) { + if ("OIO".equalsIgnoreCase(ioType)) { + logger.warn("TCP transport not support OIO type.(only support NIO)"); + } + + PinpointClientFactory pinpointClientFactory = clientFactoryProvider.get(); + InetSocketAddress address = new InetSocketAddress(ip, port); + return new TcpDataSender("StatDataSender", address, pinpointClientFactory); + } else { + UdpDataSenderFactory factory = new UdpDataSenderFactory(ip, port, UDP_EXECUTOR_NAME, writeQueueSize, timeout, sendBufferSize); + return factory.create(ioType); + } + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("StatDataSenderProvider{"); + sb.append("ip='").append(ip).append('\''); + sb.append(", port=").append(port); + sb.append(", writeQueueSize=").append(writeQueueSize); + sb.append(", timeout=").append(timeout); + sb.append(", sendBufferSize=").append(sendBufferSize); + sb.append(", ioType='").append(ioType).append('\''); + sb.append(", transportType='").append(transportType).append('\''); + sb.append('}'); + return sb.toString(); + } + +} + diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/TcpDataSenderProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/TcpDataSenderProvider.java index 3ed9b2c0e28c..c1a5684bbeb3 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/TcpDataSenderProvider.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/TcpDataSenderProvider.java @@ -19,10 +19,13 @@ import com.google.inject.Inject; import com.google.inject.Provider; import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; +import com.navercorp.pinpoint.profiler.context.module.DefaultClientFactory; import com.navercorp.pinpoint.profiler.sender.EnhancedDataSender; import com.navercorp.pinpoint.profiler.sender.TcpDataSender; import com.navercorp.pinpoint.rpc.client.PinpointClientFactory; +import java.net.InetSocketAddress; + /** * @author Woonduk Kang(emeroad) */ @@ -31,7 +34,7 @@ public class TcpDataSenderProvider implements Provider { private final Provider clientFactoryProvider; @Inject - public TcpDataSenderProvider(ProfilerConfig profilerConfig, Provider clientFactoryProvider) { + public TcpDataSenderProvider(ProfilerConfig profilerConfig, @DefaultClientFactory Provider clientFactoryProvider) { if (profilerConfig == null) { throw new NullPointerException("profilerConfig must not be null"); } @@ -41,12 +44,13 @@ public TcpDataSenderProvider(ProfilerConfig profilerConfig, Provider { - - private static final String threadName = "Pinpoint-UdpSpanDataExecutor"; - - private final String ip; - private final int port; - private final int writeQueueSize; - private final int timeout; - private final int sendBufferSize; - private final String senderType; - - @Inject - public UdpSpanDataSenderProvider(ProfilerConfig profilerConfig) { - if (profilerConfig == null) { - throw new NullPointerException("profilerConfig must not be null"); - } - this.ip = profilerConfig.getCollectorSpanServerIp(); - this.port = profilerConfig.getCollectorSpanServerPort(); - this.writeQueueSize = profilerConfig.getSpanDataSenderWriteQueueSize(); - this.timeout = profilerConfig.getSpanDataSenderSocketTimeout(); - this.sendBufferSize = profilerConfig.getSpanDataSenderSocketSendBufferSize(); - this.senderType = profilerConfig.getSpanDataSenderSocketType(); - } - - public UdpSpanDataSenderProvider(String ip, int port, int writeQueueSize, int timeout, int sendBufferSize, String senderType) { - this.ip = ip; - this.port = port; - this.writeQueueSize = writeQueueSize; - this.timeout = timeout; - this.sendBufferSize = sendBufferSize; - this.senderType = senderType; - } - - - @Override - public DataSender get() { - UdpDataSenderFactory factory = new UdpDataSenderFactory(ip, port, threadName, writeQueueSize, timeout, sendBufferSize); - return factory.create(senderType); - } - - - @Override - public String toString() { - return "UdpSpanDataSenderProvider{" + - "ip='" + ip + '\'' + - ", port=" + port + - ", writeQueueSize=" + writeQueueSize + - ", timeout=" + timeout + - ", sendBufferSize=" + sendBufferSize + - ", senderType='" + senderType + '\'' + - '}'; - } - -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/UdpStatDataSenderProvider.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/UdpStatDataSenderProvider.java deleted file mode 100644 index c02eae25057a..000000000000 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/provider/UdpStatDataSenderProvider.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2017 NAVER Corp. - * - * Licensed 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 com.navercorp.pinpoint.profiler.context.provider; - -import com.google.inject.Inject; -import com.google.inject.Provider; -import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; -import com.navercorp.pinpoint.profiler.sender.DataSender; -import com.navercorp.pinpoint.profiler.sender.UdpDataSenderFactory; - -/** - * @author Woonduk Kang(emeroad) - */ -public class UdpStatDataSenderProvider implements Provider { - - private static final String threadName = "Pinpoint-UdpStatDataExecutor"; - - private final String ip; - private final int port; - private final int writeQueueSize; - private final int timeout; - private final int sendBufferSize; - private final String senderType; - - @Inject - public UdpStatDataSenderProvider(ProfilerConfig profilerConfig) { - if (profilerConfig == null) { - throw new NullPointerException("profilerConfig must not be null"); - } - this.ip = profilerConfig.getCollectorStatServerIp(); - this.port = profilerConfig.getCollectorStatServerPort(); - this.writeQueueSize = profilerConfig.getStatDataSenderWriteQueueSize(); - this.timeout = profilerConfig.getStatDataSenderSocketTimeout(); - this.sendBufferSize = profilerConfig.getStatDataSenderSocketSendBufferSize(); - this.senderType = profilerConfig.getStatDataSenderSocketType(); - } - - - - @Override - public DataSender get() { - UdpDataSenderFactory factory = new UdpDataSenderFactory(ip, port, threadName, writeQueueSize, timeout, sendBufferSize); - return factory.create(senderType); - } - - @Override - public String toString() { - return "UdpStatDataSenderProvider{" + - "ip='" + ip + '\'' + - ", port=" + port + - ", writeQueueSize=" + writeQueueSize + - ", timeout=" + timeout + - ", sendBufferSize=" + sendBufferSize + - ", senderType='" + senderType + '\'' + - '}'; - } -} diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java index e534389a5dec..488356c56228 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/TcpDataSender.java @@ -51,7 +51,7 @@ */ public class TcpDataSender extends AbstractDataSender implements EnhancedDataSender { - private final Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger logger; static { // preClassLoad ChannelBuffers.buffer(2); @@ -71,19 +71,19 @@ public class TcpDataSender extends AbstractDataSender implements EnhancedDataSen private AsyncQueueingExecutor executor; - public TcpDataSender(String host, int port, PinpointClientFactory clientFactory) { - this(new InetSocketAddress(host, port), clientFactory, HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer()); + public TcpDataSender(InetSocketAddress address, PinpointClientFactory clientFactory) { + this(null, address, clientFactory, HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer()); } - public TcpDataSender(String host, int port, PinpointClientFactory clientFactory, HeaderTBaseSerializer serializer) { - this(new InetSocketAddress(host, port), clientFactory, serializer); + public TcpDataSender(InetSocketAddress address, PinpointClientFactory clientFactory, HeaderTBaseSerializer serializer) { + this(null, address, clientFactory, serializer); } - public TcpDataSender(InetSocketAddress address, PinpointClientFactory clientFactory) { - this(address, clientFactory, HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer()); + public TcpDataSender(String name, InetSocketAddress address, PinpointClientFactory clientFactory) { + this(name, address, clientFactory, HeaderTBaseSerializerFactory.DEFAULT_FACTORY.createSerializer()); } - public TcpDataSender(InetSocketAddress address, PinpointClientFactory clientFactory, HeaderTBaseSerializer serializer) { + public TcpDataSender(String name, InetSocketAddress address, PinpointClientFactory clientFactory, HeaderTBaseSerializer serializer) { if (address == null) { throw new NullPointerException("address must not be null"); } @@ -94,17 +94,30 @@ public TcpDataSender(InetSocketAddress address, PinpointClientFactory clientFact throw new NullPointerException("serializer must not be null"); } + String executorName = "Pinpoint-TcpDataSender-Executor"; + if (name != null) { + logger = LoggerFactory.getLogger(this.getClass().getName() + "@" + name); + executorName = String.format("Pinpoint-TcpDataSender(%s)-Executor", name); + } else { + logger = LoggerFactory.getLogger(this.getClass()); + } + PinpointClient client = ClientFactoryUtils.createPinpointClient(address, clientFactory); this.client = client; this.serializer = serializer; - this.timer = createTimer(); + this.timer = createTimer(name); writeFailFutureListener = new WriteFailFutureListener(logger, "io write fail.", "host", -1); - this.executor = createAsyncQueueingExecutor(1024 * 5, "Pinpoint-TcpDataExecutor"); + this.executor = createAsyncQueueingExecutor(1024 * 5, executorName); } - private Timer createTimer() { - HashedWheelTimer timer = TimerFactory.createHashedWheelTimer("Pinpoint-DataSender-Timer", 100, TimeUnit.MILLISECONDS, 512); + private Timer createTimer(String name) { + String timerName = "Pinpoint-TcpDataSender-Timer"; + if (name != null) { + timerName = String.format("Pinpoint-TcpDataSender(%s)-Timer", name); + } + + HashedWheelTimer timer = TimerFactory.createHashedWheelTimer(timerName, 100, TimeUnit.MILLISECONDS, 512); timer.start(); return timer; } diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java index 348f2ac80f09..391ea56b95a9 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/AgentInfoSenderTest.java @@ -51,6 +51,7 @@ import org.slf4j.LoggerFactory; import org.springframework.util.SocketUtils; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.Map; import java.util.Queue; @@ -101,7 +102,8 @@ public void agentInfoShouldBeSent() throws InterruptedException { PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, clientFactory); AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory).sendInterval(agentInfoSendRetryIntervalMs).build(); try { @@ -128,7 +130,8 @@ public void agentInfoShouldRetryUntilSuccess() throws InterruptedException { PinpointClientFactory socketFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, socketFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, socketFactory); AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory) .maxTryPerAttempt(maxTryPerAttempt) .sendInterval(agentInfoSendRetryIntervalMs) @@ -158,7 +161,8 @@ public void agentInfoShouldInitiallyRetryIndefinitely() throws InterruptedExcept PinpointClientFactory socketFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, socketFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, socketFactory); AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory) .maxTryPerAttempt(maxTryPerAttempt) .sendInterval(agentInfoSendRetryIntervalMs) @@ -194,7 +198,8 @@ public void agentInfoShouldRetryUntilAttemptsAreExhaustedWhenRefreshing() throws PinpointClientFactory socketFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, socketFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, socketFactory); dataSender.addReconnectEventListener(new PinpointClientReconnectEventListener() { @Override public void reconnectPerformed(PinpointClient client) { @@ -241,7 +246,8 @@ public void agentInfoShouldBeSentOnlyOnceEvenAfterReconnect() throws Exception { PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, clientFactory); dataSender.addReconnectEventListener(new PinpointClientReconnectEventListener() { @Override public void reconnectPerformed(PinpointClient client) { @@ -295,7 +301,8 @@ public void agentInfoShouldKeepRefreshing() throws InterruptedException { PinpointClientFactory socketFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, socketFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, socketFactory); AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory) .refreshInterval(agentInfoSendRefreshIntervalMs) .sendInterval(agentInfoSendRetryIntervalMs) @@ -327,7 +334,8 @@ public void agentInfoShouldBeRefreshedOnServerMetaDataChange() throws Interrupte PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, clientFactory); final AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory).sendInterval(agentInfoSendRetryIntervalMs).build(); serverMetaDataRegistryService.addListener(new ServerMetaDataRegistryService.OnChangeListener() { @Override @@ -370,7 +378,8 @@ public void agentInfoShouldBeRefreshedOnServerMetaDataChangeFromMultipleThreads( PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, clientFactory); final AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory).sendInterval(agentInfoSendRetryIntervalMs).build(); serverMetaDataRegistryService.addListener(new ServerMetaDataRegistryService.OnChangeListener() { @Override @@ -428,7 +437,8 @@ public void reconnectionStressTest() throws InterruptedException { PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender dataSender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender dataSender = new TcpDataSender(address, clientFactory); AgentInfoSender agentInfoSender = new AgentInfoSender.Builder(dataSender, agentInfoFactory) .sendInterval(agentInfoSendRetryIntervalMs) .maxTryPerAttempt(maxTryPerAttempt) diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderReconnectTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderReconnectTest.java index 908861bee539..40347d4fd8f9 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderReconnectTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderReconnectTest.java @@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory; import org.springframework.util.SocketUtils; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.Map; @@ -89,7 +90,8 @@ public void connectAndSend() throws InterruptedException { PinpointClientFactory clientFactory = createPinpointClientFactory(); - TcpDataSender sender = new TcpDataSender(HOST, PORT, clientFactory); + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender sender = new TcpDataSender(address, clientFactory); waitClientConnected(oldAcceptor); oldAcceptor.close(); diff --git a/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderTest.java b/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderTest.java index f3b118593413..4931cf87041d 100644 --- a/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderTest.java +++ b/profiler/src/test/java/com/navercorp/pinpoint/profiler/sender/TcpDataSenderTest.java @@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory; import org.springframework.util.SocketUtils; +import java.net.InetSocketAddress; import java.util.Collections; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -97,8 +98,9 @@ public void connectAndSend() throws InterruptedException { this.sendLatch = new CountDownLatch(2); PinpointClientFactory clientFactory = createPinpointClientFactory(); - - TcpDataSender sender = new TcpDataSender(HOST, PORT, clientFactory); + + InetSocketAddress address = new InetSocketAddress(HOST, PORT); + TcpDataSender sender = new TcpDataSender(address, clientFactory); try { sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi")); sender.send(new TApiMetaData("test", System.currentTimeMillis(), 1, "TestApi")); diff --git a/profiler/src/test/resources/pinpoint-spring-bean-test.config b/profiler/src/test/resources/pinpoint-spring-bean-test.config index c684359e4194..d11a6167efa3 100644 --- a/profiler/src/test/resources/pinpoint-spring-bean-test.config +++ b/profiler/src/test/resources/pinpoint-spring-bean-test.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/profiler/src/test/resources/pinpoint.config b/profiler/src/test/resources/pinpoint.config index 87ca37fa589a..4a0283ad21ae 100644 --- a/profiler/src/test/resources/pinpoint.config +++ b/profiler/src/test/resources/pinpoint.config @@ -39,11 +39,19 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.sendbuffersize=1048576 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000 diff --git a/quickstart/agent/src/main/resources/pinpoint.config b/quickstart/agent/src/main/resources/pinpoint.config index 0109ff5ff10f..5771df230cc9 100644 --- a/quickstart/agent/src/main/resources/pinpoint.config +++ b/quickstart/agent/src/main/resources/pinpoint.config @@ -46,12 +46,20 @@ profiler.spandatasender.write.queue.size=5120 #profiler.spandatasender.socket.timeout=3000 profiler.spandatasender.chunk.size=16384 profiler.spandatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.spandatasender.transport.type=UDP profiler.statdatasender.write.queue.size=5120 #profiler.statdatasender.socket.sendbuffersize=1048576 #profiler.statdatasender.socket.timeout=3000 profiler.statdatasender.chunk.size=16384 profiler.statdatasender.socket.type=OIO +# Should keep in mind +# 1. Loadbancing : TCP transport load balancing is per connection.(UDP transport loadbalancing is per packet) +# 2. In unexpected situations, UDP has its own protection feature (like packet loss etc.), but tcp does not have such a feature. (We will add protection later) +profiler.statdatasender.transport.type=UDP profiler.agentInfo.send.retry.interval=300000