use of com.navercorp.pinpoint.rpc.PinpointSocketException in project pinpoint by naver.
the class RequestManager method register.
public ChannelWriteFailListenableFuture<ResponseMessage> register(RequestPacket requestPacket, long timeoutMillis) {
// shutdown check
final int requestId = getNextRequestId();
requestPacket.setRequestId(requestId);
final ChannelWriteFailListenableFuture<ResponseMessage> future = new ChannelWriteFailListenableFuture<ResponseMessage>(timeoutMillis);
final DefaultFuture old = this.requestMap.put(requestId, future);
if (old != null) {
throw new PinpointSocketException("unexpected error. old future exist:" + old + " id:" + requestId);
}
// when future fails, put a handle in order to remove a failed future in the requestMap.
FailureEventHandler removeTable = createFailureEventHandler(requestId);
future.setFailureEventHandler(removeTable);
addTimeoutTask(timeoutMillis, future);
return future;
}
use of com.navercorp.pinpoint.rpc.PinpointSocketException in project pinpoint by naver.
the class RequestManager method addTimeoutTask.
private void addTimeoutTask(long timeoutMillis, DefaultFuture future) {
if (future == null) {
throw new NullPointerException("future");
}
try {
Timeout timeout = timer.newTimeout(future, timeoutMillis, TimeUnit.MILLISECONDS);
future.setTimeout(timeout);
} catch (IllegalStateException e) {
// this case is that timer has been shutdown. That maybe just means that socket has been closed.
future.setFailure(new PinpointSocketException("socket closed"));
}
}
use of com.navercorp.pinpoint.rpc.PinpointSocketException in project pinpoint by naver.
the class ReconnectTest method scheduledConnectStateTest.
@Test
public void scheduledConnectStateTest() {
PinpointClient client = clientFactory.scheduledConnect("localhost", bindPort);
client.send(new byte[10]);
try {
Future future = client.sendAsync(new byte[10]);
future.await();
future.getResult();
Assert.fail();
} catch (PinpointSocketException e) {
}
try {
client.sendSync(new byte[10]);
Assert.fail();
} catch (PinpointSocketException e) {
}
try {
PinpointRPCTestUtils.request(client, new byte[10]);
Assert.fail();
} catch (PinpointSocketException e) {
}
PinpointRPCTestUtils.close(client);
}
use of com.navercorp.pinpoint.rpc.PinpointSocketException in project pinpoint by naver.
the class ClientFactoryUtils method createPinpointClient.
public static PinpointClient createPinpointClient(InetSocketAddress connectAddress, PinpointClientFactory clientFactory) {
PinpointClient pinpointClient = null;
for (int i = 0; i < 3; i++) {
try {
pinpointClient = clientFactory.connect(connectAddress);
LOGGER.info("tcp connect success. remote:{}", connectAddress);
return pinpointClient;
} catch (PinpointSocketException e) {
LOGGER.warn("tcp connect fail. remote:{} try reconnect, retryCount:{}", connectAddress, i);
}
}
LOGGER.warn("change background tcp connect mode remote:{} ", connectAddress);
pinpointClient = clientFactory.scheduledConnect(connectAddress);
return pinpointClient;
}
use of com.navercorp.pinpoint.rpc.PinpointSocketException in project pinpoint by naver.
the class NioUDPDataSender method sendPacket.
protected void sendPacket(Object message) {
if (closed) {
throw new PinpointSocketException("NioUDPDataSender already closed.");
}
if (message instanceof TBase) {
byteBufferOutputStream.clear();
final TBase dto = (TBase) message;
try {
serializer.serialize(dto, byteBufferOutputStream);
} catch (TException e) {
throw new PinpointSocketException("Serialize " + dto + " failed. Error:" + e.getMessage(), e);
}
ByteBuffer byteBuffer = byteBufferOutputStream.getByteBuffer();
int bufferSize = byteBuffer.remaining();
try {
datagramChannel.write(byteBuffer);
} catch (IOException e) {
final Thread currentThread = Thread.currentThread();
if (currentThread.isInterrupted()) {
logger.warn("{} thread interrupted.", currentThread.getName());
throw new PinpointSocketException(currentThread.getName() + " thread interrupted.", e);
} else {
throw new PinpointSocketException("packet send error. size:" + bufferSize + ", " + dto, e);
}
}
} else {
logger.warn("sendPacket fail. invalid type:{}", message != null ? message.getClass() : null);
return;
}
}
Aggregations