Skip to content

Commit

Permalink
[#9932] Remove thrift dependency of Agent module
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed May 22, 2023
1 parent 346eeea commit 8a44f2e
Show file tree
Hide file tree
Showing 239 changed files with 1,177 additions and 7,882 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class DefaultProfilerConfig implements ProfilerConfig {

private final Properties properties;

private static final TransportModule DEFAULT_TRANSPORT_MODULE = TransportModule.THRIFT;
private static final TransportModule DEFAULT_TRANSPORT_MODULE = TransportModule.GRPC;

@Value("${profiler.enable:true}")
private boolean profileEnable = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,19 @@
* @author Woonduk Kang(emeroad)
*/
public enum TransportModule {
THRIFT,
GRPC;

public static TransportModule parse(String transportModule) {
Objects.requireNonNull(transportModule, "transportModule");

if (isEquals(THRIFT, transportModule)) {
return THRIFT;
}
if (isEquals(GRPC, transportModule)) {
if (equalsIgnoreCase(TransportModule.GRPC.name(), transportModule)) {
return GRPC;
}
return null;
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 @@ -27,9 +27,8 @@ public class TransportModuleTest {
@Test
public void parse() {
Assertions.assertEquals(TransportModule.parse("GRPC"), TransportModule.GRPC);
Assertions.assertEquals(TransportModule.parse("THRIFT"), TransportModule.THRIFT);

Assertions.assertNull(TransportModule.parse("ERROR"));
Assertions.assertEquals(TransportModule.parse("ERROR"), TransportModule.GRPC);
}

@Test
Expand Down
4 changes: 4 additions & 0 deletions collector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-thrift</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>thrift-datasender</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-grpc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.navercorp.pinpoint.collector.cluster;

import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.io.ResponseMessage;
import org.apache.thrift.TBase;

import java.util.concurrent.CompletableFuture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
import com.navercorp.pinpoint.rpc.common.SocketStateCode;
import com.navercorp.pinpoint.rpc.server.PinpointServer;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package com.navercorp.pinpoint.collector.cluster;

import com.google.protobuf.GeneratedMessageV3;
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.profiler.context.grpc.CommandThriftToGrpcMessageConverter;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.rpc.PinpointSocketException;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.rpc.packet.stream.StreamCode;
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannel;
import com.navercorp.pinpoint.rpc.stream.ClientStreamChannelEventHandler;
Expand Down Expand Up @@ -117,4 +117,4 @@ public String toString() {
return String.format("GrpcAgentConnection {clusterKey: %s}", pinpointGrpcServer.getClusterKey());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.navercorp.pinpoint.collector.cluster;

import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.rpc.server.ChannelProperties;
import com.navercorp.pinpoint.rpc.server.PinpointServer;
import com.navercorp.pinpoint.thrift.io.TCommandType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import com.navercorp.pinpoint.collector.sender.FlinkRequestFactory;
import com.navercorp.pinpoint.collector.sender.FlinkTcpDataSender;
import com.navercorp.pinpoint.collector.util.Address;
import com.navercorp.pinpoint.profiler.sender.TcpDataSender;
import com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory;
import com.navercorp.pinpoint.rpc.client.PinpointClientFactory;
import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer;
import com.navercorp.pinpoint.thrift.io.SerializerFactory;
import com.navercorp.pinpoint.thrift.sender.TcpDataSender;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.navercorp.pinpoint.collector.cluster.flink;

import com.navercorp.pinpoint.profiler.sender.TcpDataSender;
import com.navercorp.pinpoint.thrift.sender.TcpDataSender;
import org.apache.thrift.TBase;

import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import com.navercorp.pinpoint.collector.service.SendDataToFlinkService;
import com.navercorp.pinpoint.collector.util.Address;
import com.navercorp.pinpoint.profiler.sender.TcpDataSender;
import com.navercorp.pinpoint.thrift.sender.TcpDataSender;
import org.apache.thrift.TBase;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,87 +1,86 @@
/*
* Copyright 2019 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.grpc;

import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadCount;
import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadDump;
import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadLightDump;
import com.navercorp.pinpoint.grpc.trace.PCmdEcho;
import com.navercorp.pinpoint.profiler.context.thrift.MessageConverter;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump;
import com.navercorp.pinpoint.thrift.dto.command.TCommandEcho;

import com.google.protobuf.GeneratedMessageV3;

/**
* @author Taejin Koo
*/
public class CommandThriftToGrpcMessageConverter implements MessageConverter<Object, GeneratedMessageV3> {

@Override
public GeneratedMessageV3 toMessage(Object message) {
if (message instanceof TCommandEcho) {
return buildPCommandEcho((TCommandEcho) message);
} else if (message instanceof TCmdActiveThreadCount) {
return buildPCmdActiveThreadCount((TCmdActiveThreadCount) message);
} else if (message instanceof TCmdActiveThreadDump) {
return buildPCmdActiveThreadDump((TCmdActiveThreadDump) message);
} else if (message instanceof TCmdActiveThreadLightDump) {
return buildPCmdActiveThreadLightDump((TCmdActiveThreadLightDump) message);
}
return null;
}

private PCmdEcho buildPCommandEcho(TCommandEcho tCommandEcho) {
PCmdEcho.Builder builder = PCmdEcho.newBuilder();
builder.setMessage(tCommandEcho.getMessage());
return builder.build();
}

private PCmdActiveThreadCount buildPCmdActiveThreadCount(TCmdActiveThreadCount tCmdActiveThreadCount) {
PCmdActiveThreadCount.Builder builder = PCmdActiveThreadCount.newBuilder();
return builder.build();
}

private PCmdActiveThreadDump buildPCmdActiveThreadDump(TCmdActiveThreadDump tCmdActiveThreadDump) {
PCmdActiveThreadDump.Builder builder = PCmdActiveThreadDump.newBuilder();
builder.setLimit(tCmdActiveThreadDump.getLimit());
if (tCmdActiveThreadDump.isSetLocalTraceIdList()) {
builder.addAllLocalTraceId(tCmdActiveThreadDump.getLocalTraceIdList());
}
if (tCmdActiveThreadDump.isSetThreadNameList()) {
builder.addAllThreadName(tCmdActiveThreadDump.getThreadNameList());
}

return builder.build();
}

private PCmdActiveThreadLightDump buildPCmdActiveThreadLightDump(TCmdActiveThreadLightDump tCmdActiveThreadLightDump) {
PCmdActiveThreadLightDump.Builder builder = PCmdActiveThreadLightDump.newBuilder();
builder.setLimit(tCmdActiveThreadLightDump.getLimit());
if (tCmdActiveThreadLightDump.isSetLocalTraceIdList()) {
builder.addAllLocalTraceId(tCmdActiveThreadLightDump.getLocalTraceIdList());
}
if (tCmdActiveThreadLightDump.isSetThreadNameList()) {
builder.addAllThreadName(tCmdActiveThreadLightDump.getThreadNameList());
}

return builder.build();
}

}
/*
* Copyright 2019 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.collector.cluster.grpc;

import com.google.protobuf.GeneratedMessageV3;
import com.navercorp.pinpoint.common.profiler.message.MessageConverter;
import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadCount;
import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadDump;
import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadLightDump;
import com.navercorp.pinpoint.grpc.trace.PCmdEcho;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump;
import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump;
import com.navercorp.pinpoint.thrift.dto.command.TCommandEcho;

/**
* @author Taejin Koo
*/
public class CommandThriftToGrpcMessageConverter implements MessageConverter<Object, GeneratedMessageV3> {

@Override
public GeneratedMessageV3 toMessage(Object message) {
if (message instanceof TCommandEcho) {
return buildPCommandEcho((TCommandEcho) message);
} else if (message instanceof TCmdActiveThreadCount) {
return buildPCmdActiveThreadCount((TCmdActiveThreadCount) message);
} else if (message instanceof TCmdActiveThreadDump) {
return buildPCmdActiveThreadDump((TCmdActiveThreadDump) message);
} else if (message instanceof TCmdActiveThreadLightDump) {
return buildPCmdActiveThreadLightDump((TCmdActiveThreadLightDump) message);
}
return null;
}

private PCmdEcho buildPCommandEcho(TCommandEcho tCommandEcho) {
PCmdEcho.Builder builder = PCmdEcho.newBuilder();
builder.setMessage(tCommandEcho.getMessage());
return builder.build();
}

private PCmdActiveThreadCount buildPCmdActiveThreadCount(TCmdActiveThreadCount tCmdActiveThreadCount) {
PCmdActiveThreadCount.Builder builder = PCmdActiveThreadCount.newBuilder();
return builder.build();
}

private PCmdActiveThreadDump buildPCmdActiveThreadDump(TCmdActiveThreadDump tCmdActiveThreadDump) {
PCmdActiveThreadDump.Builder builder = PCmdActiveThreadDump.newBuilder();
builder.setLimit(tCmdActiveThreadDump.getLimit());
if (tCmdActiveThreadDump.isSetLocalTraceIdList()) {
builder.addAllLocalTraceId(tCmdActiveThreadDump.getLocalTraceIdList());
}
if (tCmdActiveThreadDump.isSetThreadNameList()) {
builder.addAllThreadName(tCmdActiveThreadDump.getThreadNameList());
}

return builder.build();
}

private PCmdActiveThreadLightDump buildPCmdActiveThreadLightDump(TCmdActiveThreadLightDump tCmdActiveThreadLightDump) {
PCmdActiveThreadLightDump.Builder builder = PCmdActiveThreadLightDump.newBuilder();
builder.setLimit(tCmdActiveThreadLightDump.getLimit());
if (tCmdActiveThreadLightDump.isSetLocalTraceIdList()) {
builder.addAllLocalTraceId(tCmdActiveThreadLightDump.getLocalTraceIdList());
}
if (tCmdActiveThreadLightDump.isSetThreadNameList()) {
builder.addAllThreadName(tCmdActiveThreadLightDump.getThreadNameList());
}

return builder.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection;
import com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection;
import com.navercorp.pinpoint.collector.cluster.route.filter.RouteFilter;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse;
import com.navercorp.pinpoint.thrift.dto.command.TRouteResult;
import org.apache.commons.lang3.ArrayUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
import com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer;
import com.navercorp.pinpoint.thrift.io.SerializerFactory;
import com.navercorp.pinpoint.thrift.util.SerializationUtils;

import org.apache.thrift.TBase;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TBase;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import com.navercorp.pinpoint.common.server.cluster.ClusterKey;
import com.navercorp.pinpoint.common.util.Assert;
import com.navercorp.pinpoint.common.util.StringUtils;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.io.request.Message;
import com.navercorp.pinpoint.rpc.PinpointSocketException;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.rpc.common.SocketStateCode;
import com.navercorp.pinpoint.thrift.dto.command.TCommandEcho;
import com.navercorp.pinpoint.thrift.io.CommandHeaderTBaseDeserializerFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
import com.navercorp.pinpoint.grpc.trace.PCmdEcho;
import com.navercorp.pinpoint.grpc.trace.PCmdRequest;
import com.navercorp.pinpoint.grpc.trace.PCmdResponse;
import com.navercorp.pinpoint.profiler.context.thrift.CommandGrpcToThriftMessageConverter;
import com.navercorp.pinpoint.io.ResponseMessage;
import com.navercorp.pinpoint.rpc.PinpointSocketException;
import com.navercorp.pinpoint.rpc.ResponseMessage;
import com.navercorp.pinpoint.rpc.client.RequestManager;
import com.navercorp.pinpoint.rpc.common.SocketState;
import com.navercorp.pinpoint.rpc.common.SocketStateChangeResult;
Expand All @@ -45,6 +44,7 @@
import com.navercorp.pinpoint.rpc.stream.StreamException;
import com.navercorp.pinpoint.thrift.dto.command.TRouteResult;
import com.navercorp.pinpoint.thrift.io.CommandHeaderTBaseSerializerFactory;
import com.navercorp.pinpoint.thrift.sender.message.CommandGrpcToThriftMessageConverter;
import com.navercorp.pinpoint.thrift.util.SerializationUtils;
import io.grpc.Status;
import io.grpc.StatusException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
package com.navercorp.pinpoint.collector.sender;

import com.navercorp.pinpoint.io.request.FlinkRequest;
import com.navercorp.pinpoint.profiler.sender.TcpDataSender;
import com.navercorp.pinpoint.rpc.client.PinpointClientFactory;
import com.navercorp.pinpoint.thrift.io.TBaseSerializer;
import org.apache.thrift.TBase;
import org.apache.logging.log4j.Logger;
import com.navercorp.pinpoint.thrift.sender.TcpDataSender;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TBase;
import org.springframework.util.Assert;

import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/
package com.navercorp.pinpoint.collector.service;

import com.navercorp.pinpoint.profiler.sender.TcpDataSender;
import org.apache.thrift.TBase;
import org.apache.logging.log4j.Logger;
import com.navercorp.pinpoint.thrift.sender.TcpDataSender;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TBase;

import java.util.ArrayList;
import java.util.List;
Expand Down
Loading

0 comments on commit 8a44f2e

Please sign in to comment.