use of com.navercorp.pinpoint.collector.cluster.TargetClusterPoint in project pinpoint by naver.
the class ClusterManager method getConnectedAgentList.
@Override
public List<String> getConnectedAgentList() {
List<String> result = new ArrayList<>();
List clusterPointList = clusterPointLocator.getClusterPointList();
for (Object clusterPoint : clusterPointList) {
if (clusterPoint instanceof TargetClusterPoint) {
TargetClusterPoint agentClusterPoint = (TargetClusterPoint) clusterPoint;
result.add(createAgentKey(agentClusterPoint));
}
}
return result;
}
use of com.navercorp.pinpoint.collector.cluster.TargetClusterPoint in project pinpoint by naver.
the class DefaultRouteHandler method onRoute0.
private TCommandTransferResponse onRoute0(RequestEvent 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);
}
Future<ResponseMessage> future = clusterPoint.request(event.getDeliveryCommand().getPayload());
boolean isCompleted = future.await();
if (!isCompleted) {
return createResponse(TRouteResult.TIMEOUT);
}
ResponseMessage responseMessage = future.getResult();
if (responseMessage == null) {
return createResponse(TRouteResult.EMPTY_RESPONSE);
}
byte[] responsePayload = responseMessage.getMessage();
if (responsePayload == null || responsePayload.length == 0) {
return createResponse(TRouteResult.EMPTY_RESPONSE, new byte[0]);
}
return createResponse(TRouteResult.OK, responsePayload);
}
use of com.navercorp.pinpoint.collector.cluster.TargetClusterPoint 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);
}
use of com.navercorp.pinpoint.collector.cluster.TargetClusterPoint in project pinpoint by naver.
the class AbstractRouteHandler method findClusterPoint.
protected TargetClusterPoint findClusterPoint(TCommandTransfer deliveryCommand) {
String applicationName = deliveryCommand.getApplicationName();
String agentId = deliveryCommand.getAgentId();
long startTimeStamp = deliveryCommand.getStartTime();
List<TargetClusterPoint> result = new ArrayList<>();
for (TargetClusterPoint targetClusterPoint : targetClusterPointLocator.getClusterPointList()) {
if (!targetClusterPoint.getApplicationName().equals(applicationName)) {
continue;
}
if (!targetClusterPoint.getAgentId().equals(agentId)) {
continue;
}
if (!(targetClusterPoint.getStartTimeStamp() == startTimeStamp)) {
continue;
}
result.add(targetClusterPoint);
}
if (result.size() == 1) {
return result.get(0);
}
if (result.size() > 1) {
logger.warn("Ambiguous ClusterPoint {}, {}, {} (Valid Agent list={}).", applicationName, agentId, startTimeStamp, result);
return null;
}
return null;
}
Aggregations