use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class AgentServiceImpl method invoke.
@Override
public Map<AgentInfo, PinpointRouteResponse> invoke(List<AgentInfo> agentInfoList, byte[] payload, long timeout) throws TException {
Map<AgentInfo, Future<ResponseMessage>> futureMap = new HashMap<>();
for (AgentInfo agentInfo : agentInfoList) {
TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
List<PinpointSocket> socketList = clusterManager.getSocket(agentInfo);
if (CollectionUtils.nullSafeSize(socketList) == 1) {
PinpointSocket socket = socketList.get(0);
Future<ResponseMessage> future = socket.request(serializeRequest(transferObject));
futureMap.put(agentInfo, future);
} else {
futureMap.put(agentInfo, null);
}
}
long startTime = System.currentTimeMillis();
Map<AgentInfo, PinpointRouteResponse> result = new HashMap<>();
for (Map.Entry<AgentInfo, Future<ResponseMessage>> futureEntry : futureMap.entrySet()) {
AgentInfo agentInfo = futureEntry.getKey();
Future<ResponseMessage> future = futureEntry.getValue();
PinpointRouteResponse response = getResponse(future, getTimeoutMillis(startTime, timeout));
result.put(agentInfo, response);
}
return result;
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class AgentServiceImpl method invoke.
@Override
public PinpointRouteResponse invoke(AgentInfo agentInfo, byte[] payload, long timeout) throws TException {
TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
List<PinpointSocket> socketList = clusterManager.getSocket(agentInfo);
Future<ResponseMessage> future = null;
if (CollectionUtils.nullSafeSize(socketList) == 1) {
PinpointSocket socket = socketList.get(0);
future = socket.request(serializeRequest(transferObject));
}
PinpointRouteResponse response = getResponse(future, timeout);
return response;
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class AgentServiceImpl method openStreamAndAwait.
@Override
public ClientStreamChannel openStreamAndAwait(AgentInfo agentInfo, byte[] payload, ClientStreamChannelEventHandler streamChannelEventHandler, long timeout) throws TException, StreamException {
assertClusterEnabled();
TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
List<PinpointSocket> socketList = clusterManager.getSocket(agentInfo);
if (CollectionUtils.nullSafeSize(socketList) == 1) {
PinpointSocket socket = socketList.get(0);
return socket.openStreamAndAwait(serializeRequest(transferObject), streamChannelEventHandler, timeout);
} else if (CollectionUtils.isEmpty(socketList)) {
throw new StreamException(StreamCode.CONNECTION_NOT_FOUND);
} else {
throw new StreamException(StreamCode.CONNECTION_DUPLICATED);
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class AgentServiceImpl method openStream.
@Override
public ClientStreamChannel openStream(AgentInfo agentInfo, byte[] payload, ClientStreamChannelEventHandler streamChannelEventHandler) throws TException, StreamException {
assertClusterEnabled();
TCommandTransfer transferObject = createCommandTransferObject(agentInfo, payload);
List<PinpointSocket> socketList = clusterManager.getSocket(agentInfo);
if (CollectionUtils.nullSafeSize(socketList) == 1) {
PinpointSocket socket = socketList.get(0);
return socket.openStream(serializeRequest(transferObject), streamChannelEventHandler);
} else if (CollectionUtils.isEmpty(socketList)) {
throw new StreamException(StreamCode.CONNECTION_NOT_FOUND);
} else {
throw new StreamException(StreamCode.CONNECTION_DUPLICATED);
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocket in project pinpoint by naver.
the class HandshakeTest method handshakeTest2.
@Test
public void handshakeTest2() throws InterruptedException {
TestPinpointServerAcceptor testPinpointServerAcceptor = new TestPinpointServerAcceptor(testServerMessageListenerFactory);
int bindPort = testPinpointServerAcceptor.bind();
Map<String, Object> params = PinpointRPCTestUtils.getParams();
TestPinpointClient testPinpointClient = new TestPinpointClient(testServerMessageListenerFactory.create(), params);
try {
testPinpointClient.connect(bindPort);
testPinpointServerAcceptor.assertAwaitClientConnected(1, 3000);
PinpointSocket writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()), testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNotNull(writableServer);
writableServer = getWritableServer("application", "agent", (Long) params.get(HandshakePropertyType.START_TIMESTAMP.getName()) + 1, testPinpointServerAcceptor.getConnectedPinpointSocketList());
Assert.assertNull(writableServer);
} finally {
testPinpointClient.closeAll();
testPinpointServerAcceptor.close();
}
}
Aggregations