Search in sources :

Example 1 with ClusterOption

use of com.navercorp.pinpoint.rpc.cluster.ClusterOption in project pinpoint by naver.

the class PinpointClientHandshaker method handshakeComplete.

public boolean handshakeComplete(ControlHandshakeResponsePacket responsePacket) {
    logger.info("{} handshakeComplete() started. responsePacket:{}", simpleClassNameAndHashCodeString(), responsePacket);
    synchronized (lock) {
        if (!this.state.compareAndSet(STATE_STARTED, STATE_FINISHED)) {
            // state can be 0 or 2.
            logger.info("{} handshakeComplete() failed. caused:unexpected state.", simpleClassNameAndHashCodeString());
            this.state.set(STATE_FINISHED);
            return false;
        }
        Map handshakeResponse = decode(responsePacket);
        HandshakeResponseCode code = getResponseCode(handshakeResponse);
        handshakeResult.compareAndSet(null, code);
        ClusterOption clusterOption = getClusterOption(handshakeResponse);
        this.clusterOption.compareAndSet(null, clusterOption);
        logger.info("{} handshakeComplete() completed. handshake-response:{}.", simpleClassNameAndHashCodeString(), handshakeResponse);
        return true;
    }
}
Also used : ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) HandshakeResponseCode(com.navercorp.pinpoint.rpc.packet.HandshakeResponseCode) Map(java.util.Map)

Example 2 with ClusterOption

use of com.navercorp.pinpoint.rpc.cluster.ClusterOption in project pinpoint by naver.

the class PinpointClientHandshaker method getClusterOption.

private ClusterOption getClusterOption(Map handshakeResponse) {
    if (handshakeResponse == Collections.EMPTY_MAP) {
        return ClusterOption.DISABLE_CLUSTER_OPTION;
    }
    Map cluster = (Map) handshakeResponse.get(ControlHandshakeResponsePacket.CLUSTER);
    if (cluster == null) {
        return ClusterOption.DISABLE_CLUSTER_OPTION;
    }
    String id = MapUtils.getString(cluster, "id", "");
    List<Role> roles = getRoles((List) cluster.get("roles"));
    if (StringUtils.isEmpty(id)) {
        return ClusterOption.DISABLE_CLUSTER_OPTION;
    } else {
        return new ClusterOption(true, id, roles);
    }
}
Also used : Role(com.navercorp.pinpoint.rpc.cluster.Role) ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) Map(java.util.Map)

Example 3 with ClusterOption

use of com.navercorp.pinpoint.rpc.cluster.ClusterOption in project pinpoint by naver.

the class CollectorClusterAcceptor method start.

@Override
public void start() {
    logger.info("{} initialization started.", ClassUtils.simpleClassName(this));
    ClusterOption clusterOption = new ClusterOption(true, option.getClusterId(), Role.ROUTER);
    PinpointServerAcceptor serverAcceptor = new PinpointServerAcceptor(clusterOption);
    serverAcceptor.setMessageListener(new ClusterServerMessageListener(option.getClusterId(), option.getRouteMessageHandler()));
    serverAcceptor.setServerStreamChannelMessageListener(option.getRouteStreamMessageHandler());
    serverAcceptor.addStateChangeEventHandler(new WebClusterServerChannelStateChangeHandler());
    serverAcceptor.bind(bindAddress);
    this.serverAcceptor = serverAcceptor;
    logger.info("{} initialization completed.", ClassUtils.simpleClassName(this));
}
Also used : ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) PinpointServerAcceptor(com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)

Example 4 with ClusterOption

use of com.navercorp.pinpoint.rpc.cluster.ClusterOption in project pinpoint by naver.

the class ClusterConnector method start.

@Override
public void start() {
    logger.info("start() started.");
    clientFactory.setTimeoutMillis(1000 * 5);
    clientFactory.setMessageListener(UnsupportOperationMessageListener.getInstance());
    clientFactory.addStateChangeEventListener(LoggingStateChangeEventListener.INSTANCE);
    clientFactory.setProperties(Collections.EMPTY_MAP);
    ClusterOption clusterOption = new ClusterOption(true, WebUtils.getServerIdentifier(), Role.CALLER);
    clientFactory.setClusterOption(clusterOption);
    List<InetSocketAddress> connectHostList = parseConnectString(connectString);
    for (InetSocketAddress host : connectHostList) {
        PinpointSocket pinpointSocket = ClientFactoryUtils.createPinpointClient(host, clientFactory);
        clusterSocketList.add(pinpointSocket);
    }
    logger.info("start completed.");
}
Also used : ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) PinpointSocket(com.navercorp.pinpoint.rpc.PinpointSocket) InetSocketAddress(java.net.InetSocketAddress)

Example 5 with ClusterOption

use of com.navercorp.pinpoint.rpc.cluster.ClusterOption in project pinpoint by naver.

the class CollectorClusterConnector method start.

@Override
public void start() {
    logger.info("{} initialization started.", ClassUtils.simpleClassName(this));
    ClusterOption clusterOption = new ClusterOption(true, option.getClusterId(), Role.ROUTER);
    this.clientFactory = new DefaultPinpointClientFactory();
    this.clientFactory.setTimeoutMillis(1000 * 5);
    this.clientFactory.setMessageListener(option.getRouteMessageHandler());
    this.clientFactory.setServerStreamChannelMessageListener(option.getRouteStreamMessageHandler());
    this.clientFactory.setClusterOption(clusterOption);
    Map<String, Object> properties = new HashMap<>();
    properties.put("id", option.getClusterId());
    clientFactory.setProperties(properties);
    logger.info("{} initialization completed.", ClassUtils.simpleClassName(this));
}
Also used : ClusterOption(com.navercorp.pinpoint.rpc.cluster.ClusterOption) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) HashMap(java.util.HashMap)

Aggregations

ClusterOption (com.navercorp.pinpoint.rpc.cluster.ClusterOption)5 Map (java.util.Map)2 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)1 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)1 Role (com.navercorp.pinpoint.rpc.cluster.Role)1 HandshakeResponseCode (com.navercorp.pinpoint.rpc.packet.HandshakeResponseCode)1 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1