Skip to content

Commit

Permalink
[#9932] Removed thrift dependency of Agent module`
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed May 18, 2023
1 parent 1b36f28 commit 1d70352
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
}
}
}
}

0 comments on commit 1d70352

Please sign in to comment.