Search in sources :

Example 6 with GrpcAgentConnection

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));
}
Also used : PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer) GrpcAgentConnection(com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection) Test(org.junit.Test)

Example 7 with GrpcAgentConnection

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);
}
Also used : PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer) GrpcAgentConnection(com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection) TCommandEcho(com.navercorp.pinpoint.thrift.dto.command.TCommandEcho) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 8 with GrpcAgentConnection

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;
}
Also used : GrpcAgentConnection(com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection) SocketStateChangeResult(com.navercorp.pinpoint.rpc.common.SocketStateChangeResult)

Aggregations

GrpcAgentConnection (com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection)8 ArrayList (java.util.ArrayList)3 ThriftAgentConnection (com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection)2 PinpointGrpcServer (com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 Test (org.junit.Test)2 AgentInfo (com.navercorp.pinpoint.collector.cluster.AgentInfo)1 ClusterPoint (com.navercorp.pinpoint.collector.cluster.ClusterPoint)1 SocketStateChangeResult (com.navercorp.pinpoint.rpc.common.SocketStateChangeResult)1 StreamCode (com.navercorp.pinpoint.rpc.packet.stream.StreamCode)1 ClientStreamChannel (com.navercorp.pinpoint.rpc.stream.ClientStreamChannel)1 ServerStreamChannel (com.navercorp.pinpoint.rpc.stream.ServerStreamChannel)1 StreamException (com.navercorp.pinpoint.rpc.stream.StreamException)1 TResult (com.navercorp.pinpoint.thrift.dto.TResult)1 TCommandEcho (com.navercorp.pinpoint.thrift.dto.command.TCommandEcho)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1