Search in sources :

Example 1 with StreamCreateFailPacket

use of com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket in project pinpoint by naver.

the class ActiveThreadCountWorker method active0.

private boolean active0(AgentInfo agentInfo) {
    synchronized (lock) {
        boolean active = false;
        try {
            ClientStreamChannelContext clientStreamChannelContext = agentService.openStream(agentInfo, COMMAND_INSTANCE, messageListener, stateChangeListener);
            if (clientStreamChannelContext == null) {
                setDefaultErrorMessage(StreamCode.CONNECTION_NOT_FOUND.name());
                workerActiveManager.addReactiveWorker(agentInfo);
            } else {
                if (clientStreamChannelContext.getCreateFailPacket() == null) {
                    streamChannel = clientStreamChannelContext.getStreamChannel();
                    setDefaultErrorMessage(TRouteResult.TIMEOUT.name());
                    active = true;
                } else {
                    StreamCreateFailPacket createFailPacket = clientStreamChannelContext.getCreateFailPacket();
                    setDefaultErrorMessage(createFailPacket.getCode().name());
                }
            }
        } catch (TException exception) {
            setDefaultErrorMessage(TRouteResult.NOT_SUPPORTED_REQUEST.name());
        }
        return active;
    }
}
Also used : TException(org.apache.thrift.TException) ClientStreamChannelContext(com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext) StreamCreateFailPacket(com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket)

Example 2 with StreamCreateFailPacket

use of com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket in project pinpoint by naver.

the class StreamChannelManagerTest method streamClosedTest1.

@Test
public void streamClosedTest1() throws IOException, InterruptedException {
    PinpointServerAcceptor serverAcceptor = createServerFactory(SimpleServerMessageListener.DUPLEX_ECHO_INSTANCE, null);
    serverAcceptor.bind("localhost", bindPort);
    PinpointClientFactory clientFactory = createSocketFactory();
    try {
        PinpointClient client = clientFactory.connect("127.0.0.1", bindPort);
        RecordedStreamChannelMessageListener clientListener = new RecordedStreamChannelMessageListener(4);
        ClientStreamChannelContext clientContext = client.openStream(new byte[0], clientListener);
        StreamCreateFailPacket createFailPacket = clientContext.getCreateFailPacket();
        if (createFailPacket == null) {
            Assert.fail();
        }
        clientContext.getStreamChannel().close();
        PinpointRPCTestUtils.close(client);
    } finally {
        clientFactory.release();
        PinpointRPCTestUtils.close(serverAcceptor);
    }
}
Also used : PinpointClient(com.navercorp.pinpoint.rpc.client.PinpointClient) PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor) StreamCreateFailPacket(com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket) Test(org.junit.Test)

Aggregations

StreamCreateFailPacket (com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket)2 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 PinpointClient (com.navercorp.pinpoint.rpc.client.PinpointClient)1 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)1 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)1 ClientStreamChannelContext (com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext)1 TException (org.apache.thrift.TException)1 Test (org.junit.Test)1