use of com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection in project pinpoint by naver.
the class GrpcAgentConnectionTest method equalsTest.
@Test
public void equalsTest() {
PinpointGrpcServer mockGrpcServer1 = Mockito.mock(PinpointGrpcServer.class);
List<Integer> supportCommandList = Collections.singletonList(Short.toUnsignedInt(TCommandType.ECHO.getCode()));
GrpcAgentConnection grpcAgentConnection = new GrpcAgentConnection(mockGrpcServer1, supportCommandList);
Assert.assertEquals(grpcAgentConnection, grpcAgentConnection);
Assert.assertEquals(grpcAgentConnection, new GrpcAgentConnection(mockGrpcServer1, supportCommandList));
PinpointGrpcServer mockGrpcServer2 = Mockito.mock(PinpointGrpcServer.class);
Assert.assertNotEquals(grpcAgentConnection, new GrpcAgentConnection(mockGrpcServer2, supportCommandList));
}
use of com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection in project pinpoint by naver.
the class GrpcAgentConnectionTest method requestTest.
@Test
public void requestTest() {
PinpointGrpcServer mockGrpcServer = Mockito.mock(PinpointGrpcServer.class);
List<Integer> supportCommandList = Collections.singletonList(Short.toUnsignedInt(TCommandType.ECHO.getCode()));
GrpcAgentConnection grpcAgentConnection = new GrpcAgentConnection(mockGrpcServer, supportCommandList);
boolean supportCommand = grpcAgentConnection.isSupportCommand(TCommandType.TRANSFER.getBodyFactory().getObject());
Assert.assertFalse(supportCommand);
supportCommand = grpcAgentConnection.isSupportCommand(TCommandType.RESULT.getBodyFactory().getObject());
Assert.assertFalse(supportCommand);
supportCommand = grpcAgentConnection.isSupportCommand(TCommandType.ECHO.getBodyFactory().getObject());
Assert.assertTrue(supportCommand);
Future<ResponseMessage> future = grpcAgentConnection.request(new TResult());
Assert.assertFalse(future.isSuccess());
Assert.assertNotNull(future.getCause());
TCommandEcho commandEcho = new TCommandEcho("hello");
// check to pass validation
future = grpcAgentConnection.request(commandEcho);
Assert.assertNull(future);
}
use of com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection in project pinpoint by naver.
the class PinpointGrpcServer method toState.
private SocketStateChangeResult toState(SocketStateCode socketStateCode) {
SocketStateChangeResult result = state.to(socketStateCode);
if (result.isChange()) {
if (SocketStateCode.RUN_DUPLEX == socketStateCode) {
GrpcAgentConnection grpcAgentConnection = new GrpcAgentConnection(this, supportCommandServiceList.get());
profilerClusterManager.register(grpcAgentConnection);
} else if (SocketStateCode.isClosed(socketStateCode)) {
GrpcAgentConnection grpcAgentConnection = new GrpcAgentConnection(this, Collections.emptyList());
profilerClusterManager.unregister(grpcAgentConnection);
}
} else {
logger.warn("Failed to change state. agent:{}, result:{}", agentInfo, result);
}
if (logger.isDebugEnabled()) {
logger.debug(result.toString());
}
return result;
}
Aggregations