Search in sources :

Example 1 with ClientStreamChannelContext

use of com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext 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 ClientStreamChannelContext

use of com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext 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);
    }
    TargetClusterPoint clusterPoint = findClusterPoint(event.getDeliveryCommand());
    if (clusterPoint == null) {
        return createResponse(TRouteResult.NOT_FOUND);
    }
    if (!clusterPoint.isSupportCommand(requestObject)) {
        return createResponse(TRouteResult.NOT_SUPPORTED_REQUEST);
    }
    try {
        if (clusterPoint instanceof PinpointServerClusterPoint) {
            StreamRouteManager routeManager = new StreamRouteManager(event);
            ServerStreamChannelContext consumerContext = event.getStreamChannelContext();
            consumerContext.setAttributeIfAbsent(ATTACHMENT_KEY, routeManager);
            ClientStreamChannelContext producerContext = createStreamChannel((PinpointServerClusterPoint) clusterPoint, event.getDeliveryCommand().getPayload(), routeManager);
            if (producerContext.getCreateFailPacket() == null) {
                routeManager.setProducer(producerContext.getStreamChannel());
                producerContext.getStreamChannel().addStateChangeEventHandler(routeManager);
                return createResponse(TRouteResult.OK);
            }
        } else {
            return createResponse(TRouteResult.NOT_SUPPORTED_SERVICE);
        }
    } catch (Exception e) {
        if (logger.isWarnEnabled()) {
            logger.warn("Create StreamChannel({}) failed. Error:{}", clusterPoint, e.getMessage(), e);
        }
    }
    return createResponse(TRouteResult.UNKNOWN);
}
Also used : TargetClusterPoint(com.navercorp.pinpoint.collector.cluster.TargetClusterPoint) ClientStreamChannelContext(com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext) ServerStreamChannelContext(com.navercorp.pinpoint.rpc.stream.ServerStreamChannelContext) PinpointServerClusterPoint(com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint)

Aggregations

ClientStreamChannelContext (com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext)2 PinpointServerClusterPoint (com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint)1 TargetClusterPoint (com.navercorp.pinpoint.collector.cluster.TargetClusterPoint)1 StreamCreateFailPacket (com.navercorp.pinpoint.rpc.packet.stream.StreamCreateFailPacket)1 ServerStreamChannelContext (com.navercorp.pinpoint.rpc.stream.ServerStreamChannelContext)1 TException (org.apache.thrift.TException)1