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;
}
}
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);
}
}
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));
}
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.");
}
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));
}
Aggregations