Search in sources :

Example 1 with PinpointServerClusterPoint

use of com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint 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)

Example 2 with PinpointServerClusterPoint

use of com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint in project pinpoint by naver.

the class ZookeeperProfilerClusterManager method eventPerformed.

@Override
public void eventPerformed(PinpointServer pinpointServer, SocketStateCode stateCode) {
    if (workerState.isStarted()) {
        logger.info("eventPerformed() started. (PinpointServer={}, State={})", pinpointServer, stateCode);
        Map agentProperties = pinpointServer.getChannelProperties();
        // skip when applicationName and agentId is unknown
        if (skipAgent(agentProperties)) {
            return;
        }
        synchronized (lock) {
            if (SocketStateCode.RUN_DUPLEX == stateCode) {
                profileCluster.addClusterPoint(new PinpointServerClusterPoint(pinpointServer));
                worker.addPinpointServer(pinpointServer);
            } else if (SocketStateCode.isClosed(stateCode)) {
                profileCluster.removeClusterPoint(new PinpointServerClusterPoint(pinpointServer));
                worker.removePinpointServer(pinpointServer);
            }
        }
    } else {
        logger.info("eventPerformed() failed. caused:unexpected state.");
    }
}
Also used : Map(java.util.Map) PinpointServerClusterPoint(com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint)

Aggregations

PinpointServerClusterPoint (com.navercorp.pinpoint.collector.cluster.PinpointServerClusterPoint)2 TargetClusterPoint (com.navercorp.pinpoint.collector.cluster.TargetClusterPoint)1 ClientStreamChannelContext (com.navercorp.pinpoint.rpc.stream.ClientStreamChannelContext)1 ServerStreamChannelContext (com.navercorp.pinpoint.rpc.stream.ServerStreamChannelContext)1 Map (java.util.Map)1