use of com.navercorp.pinpoint.collector.cluster.AgentInfo in project pinpoint by naver.
the class ClusterManager method getConnectedAgentList.
@Override
public List<String> getConnectedAgentList() {
List<String> result = new ArrayList<>();
List<? extends ClusterPoint<?>> clusterPointList = clusterPointLocator.getClusterPointList();
for (ClusterPoint<?> clusterPoint : clusterPointList) {
AgentInfo destAgentInfo = clusterPoint.getDestAgentInfo();
result.add(destAgentInfo.getAgentKey());
}
return result;
}
use of com.navercorp.pinpoint.collector.cluster.AgentInfo in project pinpoint by naver.
the class ClusterPointController method getGrpcAgentConnectionList.
private List<GrpcAgentConnection> getGrpcAgentConnectionList(final String applicationName, final String agentId, final long startTimestamp) {
Objects.requireNonNull(applicationName, "applicationName");
List<GrpcAgentConnection> result = new ArrayList<>();
List<ClusterPoint<?>> clusterPointList = clusterPointLocator.getClusterPointList();
for (ClusterPoint<?> clusterPoint : clusterPointList) {
if (!(clusterPoint instanceof GrpcAgentConnection)) {
continue;
}
AgentInfo destAgentInfo = clusterPoint.getDestAgentInfo();
if (!destAgentInfo.getApplicationName().equals(applicationName)) {
continue;
}
if (StringUtils.hasText(agentId) && !destAgentInfo.getAgentId().equals(agentId)) {
continue;
}
if (startTimestamp > 0 && destAgentInfo.getStartTimestamp() != startTimestamp) {
continue;
}
result.add((GrpcAgentConnection) clusterPoint);
}
return result;
}
use of com.navercorp.pinpoint.collector.cluster.AgentInfo in project pinpoint by naver.
the class AbstractRouteHandler method findClusterPoint.
protected ClusterPoint<?> findClusterPoint(TCommandTransfer deliveryCommand) {
String applicationName = deliveryCommand.getApplicationName();
String agentId = deliveryCommand.getAgentId();
long startTimeStamp = deliveryCommand.getStartTime();
List<ClusterPoint<?>> result = new ArrayList<>();
for (ClusterPoint<?> targetClusterPoint : targetClusterPointLocator.getClusterPointList()) {
AgentInfo destAgentInfo = targetClusterPoint.getDestAgentInfo();
if (destAgentInfo.equals(applicationName, agentId, startTimeStamp)) {
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;
}
use of com.navercorp.pinpoint.collector.cluster.AgentInfo in project pinpoint by naver.
the class GrpcCommandService method handleCommandV2.
@Override
public StreamObserver<PCmdMessage> handleCommandV2(StreamObserver<PCmdRequest> requestObserver) {
final Long transportId = getTransportId();
final AgentInfo agentInfo = getAgentInfo();
final List<Integer> supportCommandCodeList = getSupportCommandCodeList();
logger.info("{} => local. handleCommandV2(). transportId:{}, supportCommandCodeList{}", agentInfo, transportId, supportCommandCodeList);
if (supportCommandCodeList == Header.SUPPORT_COMMAND_CODE_LIST_NOT_EXIST) {
logger.warn("handleCommandV2() not allow empty Header:{}. Connection will be disconnected.", Header.SUPPORT_COMMAND_CODE.name());
requestObserver.onError(new StatusException(Status.INVALID_ARGUMENT));
return DisabledStreamObserver.instance();
}
final PinpointGrpcServer pinpointGrpcServer = registerNewPinpointGrpcServer(requestObserver, agentInfo, transportId);
if (pinpointGrpcServer == null) {
return handleServerRegistrationFailed(requestObserver, agentInfo, transportId);
}
final ServerCallStreamObserver<PCmdRequest> serverCallStreamObserver = (ServerCallStreamObserver<PCmdRequest>) requestObserver;
serverCallStreamObserver.setOnReadyHandler(new Runnable() {
public void run() {
if (serverCallStreamObserver.isReady()) {
logger.info("{} => local. ready() transportId:{}", agentInfo.getAgentKey(), transportId);
pinpointGrpcServer.connected();
registerAgentCommandList(pinpointGrpcServer, supportCommandCodeList);
}
pinpointGrpcServer.setOnCloseHandler(new Runnable() {
@Override
public void run() {
unregisterPinpointGrpcServer(transportId);
}
});
}
});
final StreamObserver<PCmdMessage> responseObserver = new StreamObserver<PCmdMessage>() {
@Override
public void onNext(PCmdMessage value) {
if (value.hasFailMessage()) {
PCmdResponse failMessage = value.getFailMessage();
pinpointGrpcServer.handleFail(failMessage);
}
}
@Override
public void onError(Throwable t) {
handleOnError(t, pinpointGrpcServer, agentInfo);
}
@Override
public void onCompleted() {
handleOnCompleted(pinpointGrpcServer, agentInfo);
}
};
return responseObserver;
}
use of com.navercorp.pinpoint.collector.cluster.AgentInfo in project pinpoint by naver.
the class GrpcCommandService method handleCommand.
@Override
public StreamObserver<PCmdMessage> handleCommand(StreamObserver<PCmdRequest> requestObserver) {
final Long transportId = getTransportId();
final AgentInfo agentInfo = getAgentInfo();
logger.info("{} => local. handleCommand(). transportId:{}.", agentInfo, transportId);
final List<Integer> supportCommandCodeList = getSupportCommandCodeList();
if (supportCommandCodeList != Header.SUPPORT_COMMAND_CODE_LIST_NOT_EXIST) {
logger.warn("handleCommand() not support included Header:{}. Connection will be disconnected.", Header.SUPPORT_COMMAND_CODE.name());
requestObserver.onError(new StatusException(Status.INVALID_ARGUMENT));
return DisabledStreamObserver.instance();
}
final PinpointGrpcServer pinpointGrpcServer = registerNewPinpointGrpcServer(requestObserver, agentInfo, transportId);
if (pinpointGrpcServer == null) {
return handleServerRegistrationFailed(requestObserver, agentInfo, transportId);
}
final ServerCallStreamObserver<PCmdRequest> serverCallStreamObserver = (ServerCallStreamObserver<PCmdRequest>) requestObserver;
serverCallStreamObserver.setOnReadyHandler(new Runnable() {
public void run() {
if (serverCallStreamObserver.isReady()) {
logger.info("{} => local. ready() transportId:{}", agentInfo.getAgentKey(), transportId);
pinpointGrpcServer.connected();
}
pinpointGrpcServer.setOnCloseHandler(new Runnable() {
@Override
public void run() {
unregisterPinpointGrpcServer(transportId);
}
});
}
});
final StreamObserver<PCmdMessage> responseObserver = new StreamObserver<PCmdMessage>() {
@Override
public void onNext(PCmdMessage value) {
// old operation for handshake
if (value.hasHandshakeMessage()) {
List<Integer> supportCommandServiceKeyList = value.getHandshakeMessage().getSupportCommandServiceKeyList();
registerAgentCommandList(pinpointGrpcServer, supportCommandServiceKeyList);
} else if (value.hasFailMessage()) {
PCmdResponse failMessage = value.getFailMessage();
pinpointGrpcServer.handleFail(failMessage);
}
}
@Override
public void onError(Throwable t) {
handleOnError(t, pinpointGrpcServer, agentInfo);
}
@Override
public void onCompleted() {
handleOnCompleted(pinpointGrpcServer, agentInfo);
}
};
return responseObserver;
}
Aggregations