diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/TransportModule.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/TransportModule.java index dcb23d5bf7e14..df99b45c59c5c 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/TransportModule.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/config/TransportModule.java @@ -26,15 +26,15 @@ public enum TransportModule { public static TransportModule parse(String transportModule) { Objects.requireNonNull(transportModule, "transportModule"); - if (isEquals(GRPC, transportModule)) { + + if (equalsIgnoreCase(TransportModule.GRPC.name(), transportModule)) { return GRPC; } return GRPC; } - private static boolean isEquals(TransportModule transportModule, String transportModuleString) { - final String transportModuleName = transportModule.name(); - return transportModuleName.equalsIgnoreCase(transportModuleString); + private static boolean equalsIgnoreCase(String str1, String str2) { + return str1.equalsIgnoreCase(str2); } public static TransportModule parse(String transportModule, TransportModule defaultModule) { diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/ClusterPointRepository.java b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/ClusterPointRepository.java index 36bddd3e66130..d2803a0e9cf0c 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/ClusterPointRepository.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/ClusterPointRepository.java @@ -16,7 +16,6 @@ package com.navercorp.pinpoint.collector.cluster; -import com.navercorp.pinpoint.collector.cluster.grpc.GrpcAgentConnection; import com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer; import com.navercorp.pinpoint.common.server.cluster.ClusterKey; import com.navercorp.pinpoint.rpc.common.SocketStateCode; diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/grpc/GrpcAgentConnection.java b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/GrpcAgentConnection.java similarity index 95% rename from collector/src/main/java/com/navercorp/pinpoint/collector/cluster/grpc/GrpcAgentConnection.java rename to collector/src/main/java/com/navercorp/pinpoint/collector/cluster/GrpcAgentConnection.java index 58615a96176de..64f279de2da9c 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/grpc/GrpcAgentConnection.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/GrpcAgentConnection.java @@ -14,11 +14,10 @@ * limitations under the License. */ -package com.navercorp.pinpoint.collector.cluster.grpc; +package com.navercorp.pinpoint.collector.cluster; import com.google.protobuf.GeneratedMessageV3; -import com.navercorp.pinpoint.collector.cluster.ClusterPoint; -import com.navercorp.pinpoint.collector.cluster.SupportedCommandUtils; +import com.navercorp.pinpoint.collector.cluster.grpc.CommandThriftToGrpcMessageConverter; import com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer; import com.navercorp.pinpoint.common.server.cluster.ClusterKey; import com.navercorp.pinpoint.rpc.PinpointSocketException; diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/DefaultRouteHandler.java b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/DefaultRouteHandler.java index 5ced686c87f4d..413e656f52c55 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/DefaultRouteHandler.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/DefaultRouteHandler.java @@ -18,8 +18,8 @@ import com.navercorp.pinpoint.collector.cluster.ClusterPoint; import com.navercorp.pinpoint.collector.cluster.ClusterPointLocator; +import com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection; import com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection; -import com.navercorp.pinpoint.collector.cluster.grpc.GrpcAgentConnection; import com.navercorp.pinpoint.collector.cluster.route.filter.RouteFilter; import com.navercorp.pinpoint.rpc.ResponseMessage; import com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse; diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/StreamRouteHandler.java b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/StreamRouteHandler.java index 105b0869eb8d8..c830a1b7899cf 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/StreamRouteHandler.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/cluster/route/StreamRouteHandler.java @@ -18,8 +18,8 @@ import com.navercorp.pinpoint.collector.cluster.ClusterPoint; import com.navercorp.pinpoint.collector.cluster.ClusterPointLocator; +import com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection; import com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection; -import com.navercorp.pinpoint.collector.cluster.grpc.GrpcAgentConnection; import com.navercorp.pinpoint.collector.cluster.route.filter.RouteFilter; import com.navercorp.pinpoint.rpc.packet.stream.StreamClosePacket; import com.navercorp.pinpoint.rpc.packet.stream.StreamCode; diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/controller/ClusterPointController.java b/collector/src/main/java/com/navercorp/pinpoint/collector/controller/ClusterPointController.java index c3ee9a5669e95..30d7d596c1aa7 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/controller/ClusterPointController.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/controller/ClusterPointController.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.navercorp.pinpoint.collector.cluster.ClusterPoint; import com.navercorp.pinpoint.collector.cluster.ClusterPointLocator; -import com.navercorp.pinpoint.collector.cluster.grpc.GrpcAgentConnection; +import com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection; import com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer; import com.navercorp.pinpoint.common.server.cluster.ClusterKey; import com.navercorp.pinpoint.common.util.Assert; diff --git a/collector/src/main/java/com/navercorp/pinpoint/collector/receiver/grpc/PinpointGrpcServer.java b/collector/src/main/java/com/navercorp/pinpoint/collector/receiver/grpc/PinpointGrpcServer.java index c6f53e5db299e..79ca9e6263280 100644 --- a/collector/src/main/java/com/navercorp/pinpoint/collector/receiver/grpc/PinpointGrpcServer.java +++ b/collector/src/main/java/com/navercorp/pinpoint/collector/receiver/grpc/PinpointGrpcServer.java @@ -18,8 +18,8 @@ import com.google.protobuf.Empty; import com.google.protobuf.GeneratedMessageV3; +import com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection; import com.navercorp.pinpoint.collector.cluster.ProfilerClusterManager; -import com.navercorp.pinpoint.collector.cluster.grpc.GrpcAgentConnection; import com.navercorp.pinpoint.common.server.cluster.ClusterKey; import com.navercorp.pinpoint.grpc.MessageFormatUtils; import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadCount; diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/receiver/grpc/GrpcCommandService.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/receiver/grpc/GrpcCommandService.java index 40fefa0ae9366..332a070728553 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/receiver/grpc/GrpcCommandService.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/receiver/grpc/GrpcCommandService.java @@ -16,7 +16,6 @@ package com.navercorp.pinpoint.profiler.receiver.grpc; -import java.util.Objects; import com.navercorp.pinpoint.grpc.StatusError; import com.navercorp.pinpoint.grpc.StatusErrors; import com.navercorp.pinpoint.grpc.client.SupportCommandCodeClientInterceptor; @@ -27,11 +26,12 @@ import com.navercorp.pinpoint.profiler.sender.grpc.ReconnectExecutor; import com.navercorp.pinpoint.profiler.sender.grpc.Reconnector; import com.navercorp.pinpoint.profiler.sender.grpc.StreamUtils; - import io.grpc.stub.ClientCallStreamObserver; import io.grpc.stub.ClientResponseObserver; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Objects; /** * @author Taejin Koo @@ -157,14 +157,14 @@ public void onError(Throwable t) { @Override public void onCompleted() { logger.info("onCompleted"); - StreamUtils.close(requestStream); + StreamUtils.close(requestStream, GrpcCommandService.this.logger); // TODO : needs to check whether needs new action reserveReconnect(); } private void stop() { logger.info("stop"); - StreamUtils.close(requestStream); + StreamUtils.close(requestStream, GrpcCommandService.this.logger); commandDispatcher.close(); } diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/PingStreamContext.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/PingStreamContext.java index ac3dc59ad6aef..55e4f5be64807 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/PingStreamContext.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/PingStreamContext.java @@ -16,7 +16,6 @@ package com.navercorp.pinpoint.profiler.sender.grpc; -import java.util.Objects; import com.navercorp.pinpoint.grpc.MessageFormatUtils; import com.navercorp.pinpoint.grpc.StatusError; import com.navercorp.pinpoint.grpc.StatusErrors; @@ -25,9 +24,10 @@ import io.grpc.stub.ClientCallStreamObserver; import io.grpc.stub.ClientResponseObserver; import io.grpc.stub.StreamObserver; -import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import java.util.Objects; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -140,7 +140,7 @@ private ScheduledFuture schedule(Runnable command) { public void close() { logger.info("{} close()", streamId); - StreamUtils.close(this.requestObserver); + StreamUtils.close(this.requestObserver, this.logger); } @Override diff --git a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StreamUtils.java b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StreamUtils.java index 1fc358877aef0..f008579b7f609 100644 --- a/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StreamUtils.java +++ b/profiler/src/main/java/com/navercorp/pinpoint/profiler/sender/grpc/StreamUtils.java @@ -17,6 +17,8 @@ package com.navercorp.pinpoint.profiler.sender.grpc; import io.grpc.stub.StreamObserver; +import org.apache.logging.log4j.Logger; + /** * @author Woonduk Kang(emeroad) @@ -26,9 +28,15 @@ public final class StreamUtils { private StreamUtils() { } - public static void close(final StreamObserver streamObserver) { + public static void close(final StreamObserver streamObserver, Logger logger) { if (streamObserver != null) { - streamObserver.onCompleted(); + try { + streamObserver.onCompleted(); + } catch (Throwable th) { + if (logger != null) { + logger.info("StreamObserver.onCompleted error", th); + } + } } } }