Search in sources :

Example 1 with ClientStreamChannel

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

the class DefaultPinpointServer method openStream.

@Override
public ClientStreamChannel openStream(byte[] payload, ClientStreamChannelEventHandler streamChannelEventHandler) throws StreamException {
    logger.info("{} createStream() started.", objectUniqName);
    ClientStreamChannel streamChannel = streamChannelManager.openStream(payload, streamChannelEventHandler);
    logger.info("{} createStream() completed.", objectUniqName);
    return streamChannel;
}
Also used : ClientStreamChannel(com.navercorp.pinpoint.rpc.stream.ClientStreamChannel)

Example 2 with ClientStreamChannel

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

the class StreamRouteHandler method onRoute0.

private TCommandTransferResponse onRoute0(StreamEvent event) {
    TBase<?, ?> requestObject = event.getRequestObject();
    if (requestObject == null) {
        return createResponse(TRouteResult.EMPTY_REQUEST);
    }
    ClusterPoint<?> clusterPoint = findClusterPoint(event.getDeliveryCommand());
    if (clusterPoint == null) {
        return createResponse(TRouteResult.NOT_FOUND);
    }
    if (!clusterPoint.isSupportCommand(requestObject)) {
        logger.warn("Create StreamChannel failed. target:{}, message:{} is not supported command", clusterPoint, requestObject.getClass().getName());
        return createResponse(TRouteResult.NOT_SUPPORTED_REQUEST);
    }
    try {
        if (clusterPoint instanceof ThriftAgentConnection) {
            StreamRouteManager routeManager = new StreamRouteManager(event);
            ServerStreamChannel consumerStreamChannel = event.getStreamChannel();
            consumerStreamChannel.setAttributeIfAbsent(ATTACHMENT_KEY, routeManager);
            ClientStreamChannel producerStreamChannel = createStreamChannel((ThriftAgentConnection) clusterPoint, event.getDeliveryCommand().getPayload(), routeManager);
            routeManager.setProducer(producerStreamChannel);
            return createResponse(TRouteResult.OK);
        } else if (clusterPoint instanceof GrpcAgentConnection) {
            StreamRouteManager routeManager = new StreamRouteManager(event);
            ServerStreamChannel consumerStreamChannel = event.getStreamChannel();
            consumerStreamChannel.setAttributeIfAbsent(ATTACHMENT_KEY, routeManager);
            ClientStreamChannel producerStreamChannel = ((GrpcAgentConnection) clusterPoint).openStream(event.getRequestObject(), routeManager);
            routeManager.setProducer(producerStreamChannel);
            return createResponse(TRouteResult.OK);
        } else {
            return createResponse(TRouteResult.NOT_SUPPORTED_SERVICE);
        }
    } catch (StreamException e) {
        StreamCode streamCode = e.getStreamCode();
        return createResponse(TRouteResult.STREAM_CREATE_ERROR, streamCode.name());
    } catch (Exception e) {
        if (logger.isWarnEnabled()) {
            logger.warn("Create StreamChannel failed. target:{}, message:{}", clusterPoint, e.getMessage(), e);
        }
    }
    return createResponse(TRouteResult.UNKNOWN);
}
Also used : ThriftAgentConnection(com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection) GrpcAgentConnection(com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection) ClientStreamChannel(com.navercorp.pinpoint.rpc.stream.ClientStreamChannel) StreamCode(com.navercorp.pinpoint.rpc.packet.stream.StreamCode) StreamException(com.navercorp.pinpoint.rpc.stream.StreamException) ServerStreamChannel(com.navercorp.pinpoint.rpc.stream.ServerStreamChannel) StreamException(com.navercorp.pinpoint.rpc.stream.StreamException)

Example 3 with ClientStreamChannel

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

the class DefaultPinpointServer method openStreamAndAwait.

@Override
public ClientStreamChannel openStreamAndAwait(byte[] payload, ClientStreamChannelEventHandler streamChannelEventHandler, long timeout) throws StreamException {
    logger.info("{} createStreamAndAwait() started.", objectUniqName);
    ClientStreamChannel streamChannel = streamChannelManager.openStreamAndAwait(payload, streamChannelEventHandler, timeout);
    logger.info("{} createStreamAndAwait() completed.", objectUniqName);
    return streamChannel;
}
Also used : ClientStreamChannel(com.navercorp.pinpoint.rpc.stream.ClientStreamChannel)

Aggregations

ClientStreamChannel (com.navercorp.pinpoint.rpc.stream.ClientStreamChannel)3 GrpcAgentConnection (com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection)1 ThriftAgentConnection (com.navercorp.pinpoint.collector.cluster.ThriftAgentConnection)1 StreamCode (com.navercorp.pinpoint.rpc.packet.stream.StreamCode)1 ServerStreamChannel (com.navercorp.pinpoint.rpc.stream.ServerStreamChannel)1 StreamException (com.navercorp.pinpoint.rpc.stream.StreamException)1