From 1d7035242c0e12c84949f7c9dba1a8d8fdab6489 Mon Sep 17 00:00:00 2001 From: emeroad Date: Thu, 18 May 2023 13:02:59 +0900 Subject: [PATCH] [#9932] Removed thrift dependency of Agent module` --- .../profiler/receiver/grpc/GrpcCommandService.java | 10 +++++----- .../profiler/sender/grpc/PingStreamContext.java | 6 +++--- .../pinpoint/profiler/sender/grpc/StreamUtils.java | 12 ++++++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) 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); + } + } } } }