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 19, 2023
1 parent 38b6629 commit b956293
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
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 b956293

Please sign in to comment.