Search in sources :

Example 1 with PinpointGrpcServer

use of com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer in project pinpoint by naver.

the class GrpcCommandService method registerNewPinpointGrpcServer.

private PinpointGrpcServer registerNewPinpointGrpcServer(StreamObserver<PCmdRequest> requestObserver, AgentInfo agentInfo, Long transportId) {
    PinpointGrpcServer pinpointGrpcServer = createPinpointGrpcServer(requestObserver, agentInfo);
    final boolean registered = grpcServerRepository.registerIfAbsent(transportId, pinpointGrpcServer);
    if (registered) {
        return pinpointGrpcServer;
    } else {
        return null;
    }
}
Also used : PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)

Example 2 with PinpointGrpcServer

use of com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer in project pinpoint by naver.

the class GrpcCommandService method commandActiveThreadLightDump.

@Override
public void commandActiveThreadLightDump(PCmdActiveThreadLightDumpRes activeThreadLightDumpResponse, StreamObserver<Empty> responseObserver) {
    final Long transportId = getTransportId();
    PinpointGrpcServer pinpointGrpcServer = grpcServerRepository.get(transportId);
    if (pinpointGrpcServer != null) {
        activeThreadLightDumpService.handle(pinpointGrpcServer, activeThreadLightDumpResponse, responseObserver);
        responseObserver.onNext(Empty.getDefaultInstance());
        responseObserver.onCompleted();
    } else {
        logger.info("{} => local. Can't find PinpointGrpcServer(transportId={})", getAgentInfo().getAgentKey(), transportId);
        responseObserver.onError(new StatusException(Status.NOT_FOUND));
    }
}
Also used : StatusException(io.grpc.StatusException) PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)

Example 3 with PinpointGrpcServer

use of com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer 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 4 with PinpointGrpcServer

use of com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer 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 5 with PinpointGrpcServer

use of com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer in project pinpoint by naver.

the class ClusterPointController method clearConnection.

private void clearConnection(GrpcAgentConnection grpcAgentConnection) {
    PinpointGrpcServer pinpointGrpcServer = grpcAgentConnection.getPinpointGrpcServer();
    pinpointGrpcServer.close(SocketStateCode.ERROR_UNKNOWN);
}
Also used : PinpointGrpcServer(com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)

Aggregations

PinpointGrpcServer (com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)11 StatusException (io.grpc.StatusException)6 AgentInfo (com.navercorp.pinpoint.collector.cluster.AgentInfo)2 GrpcAgentConnection (com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection)2 PCmdMessage (com.navercorp.pinpoint.grpc.trace.PCmdMessage)2 PCmdRequest (com.navercorp.pinpoint.grpc.trace.PCmdRequest)2 PCmdResponse (com.navercorp.pinpoint.grpc.trace.PCmdResponse)2 ServerCallStreamObserver (io.grpc.stub.ServerCallStreamObserver)2 StreamObserver (io.grpc.stub.StreamObserver)2 Test (org.junit.Test)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)1 PinpointServer (com.navercorp.pinpoint.rpc.server.PinpointServer)1 TResult (com.navercorp.pinpoint.thrift.dto.TResult)1 TCommandEcho (com.navercorp.pinpoint.thrift.dto.command.TCommandEcho)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1