use of com.navercorp.pinpoint.rpc.stream.StreamException in project pinpoint by naver.
the class GrpcClientStreamChannelTest method connectTimeoutTest.
@Test
public void connectTimeoutTest() throws StreamException {
GrpcClientStreamChannel grpcClientStreamChannel = new GrpcClientStreamChannel(mockRemoteAddress, 20, new StreamChannelRepository(), ClientStreamChannelEventHandler.DISABLED_INSTANCE);
grpcClientStreamChannel.init();
StreamException streamException = null;
try {
grpcClientStreamChannel.connect(new Runnable() {
@Override
public void run() {
}
}, 500);
} catch (StreamException e) {
streamException = e;
}
Assert.assertEquals(StreamCode.CONNECTION_TIMEOUT, streamException.getStreamCode());
Assert.assertEquals(StreamChannelStateCode.CLOSED, grpcClientStreamChannel.getCurrentState());
}
use of com.navercorp.pinpoint.rpc.stream.StreamException in project pinpoint by naver.
the class GrpcClientStreamChannelTest method connectFailTest.
@Test
public void connectFailTest() throws StreamException {
GrpcClientStreamChannel grpcClientStreamChannel = new GrpcClientStreamChannel(mockRemoteAddress, 20, new StreamChannelRepository(), ClientStreamChannelEventHandler.DISABLED_INSTANCE);
grpcClientStreamChannel.init();
StreamException streamException = null;
try {
grpcClientStreamChannel.connect(new Runnable() {
@Override
public void run() {
throw new IllegalStateException("fail");
}
}, 500);
} catch (StreamException e) {
streamException = e;
}
Assert.assertEquals(StreamCode.CONNECTION_ERRROR, streamException.getStreamCode());
Assert.assertEquals(StreamChannelStateCode.CLOSED, grpcClientStreamChannel.getCurrentState());
}
use of com.navercorp.pinpoint.rpc.stream.StreamException 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.stream.StreamException 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.stream.StreamException in project pinpoint by naver.
the class ActiveThreadCountWorker method connect.
@Override
public StreamChannel connect(AgentInfo agentInfo) {
if (!applicationName.equals(agentInfo.getApplicationName())) {
return null;
}
if (!agentId.equals(agentInfo.getAgentId())) {
return null;
}
synchronized (lock) {
if (!started) {
started = true;
logger.info("ActiveThreadCountWorker start. applicationName:{}, agentId:{}", applicationName, agentId);
StreamChannel streamChannel = null;
try {
streamChannel = connect0(agentInfo);
return streamChannel;
} catch (StreamException streamException) {
if (streamChannel != null) {
streamChannel.close(streamException.getStreamCode());
}
StreamCode streamCode = streamException.getStreamCode();
if (streamCode == StreamCode.CONNECTION_NOT_FOUND) {
workerActiveManager.addReactiveWorker(agentInfo);
}
setDefaultErrorMessage(streamCode.name());
} catch (TException exception) {
if (streamChannel != null) {
streamChannel.close(StreamCode.TYPE_UNKNOWN);
}
setDefaultErrorMessage(TRouteResult.NOT_SUPPORTED_REQUEST.name());
}
}
}
return null;
}
Aggregations