use of com.navercorp.pinpoint.rpc.DefaultFuture 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.DefaultFuture in project pinpoint by naver.
the class RequestManagerTest method testRemoveMessageFuture.
@Test
public void testRemoveMessageFuture() throws Exception {
HashedWheelTimer timer = getTimer();
RequestManager requestManager = new RequestManager(timer, 3000);
try {
RequestPacket packet = new RequestPacket(1, new byte[0]);
DefaultFuture future = requestManager.register(packet, 2000);
future.setFailure(new RuntimeException());
Future nullFuture = requestManager.removeMessageFuture(packet.getRequestId());
Assert.assertNull(nullFuture);
} finally {
requestManager.close();
timer.stop();
}
}
use of com.navercorp.pinpoint.rpc.DefaultFuture in project pinpoint by naver.
the class DefaultPinpointClientHandler method request.
public Future<ResponseMessage> request(byte[] bytes) {
Objects.requireNonNull(bytes, "bytes");
final boolean isEnable = state.isEnableCommunication();
if (!isEnable) {
DefaultFuture<ResponseMessage> closedException = new DefaultFuture<>();
closedException.setFailure(new PinpointSocketException("invalid state:" + state.getCurrentStateCode() + " channel:" + channel));
return closedException;
}
final int requestId = this.requestManager.nextRequestId();
final RequestPacket request = new RequestPacket(requestId, bytes);
final ChannelWriteFailListenableFuture<ResponseMessage> messageFuture = this.requestManager.register(request.getRequestId(), clientOption.getRequestTimeoutMillis());
write0(request, messageFuture);
return messageFuture;
}
use of com.navercorp.pinpoint.rpc.DefaultFuture in project pinpoint by naver.
the class GrpcAgentConnection method request.
@Override
public Future<ResponseMessage> request(TBase<?, ?> request) {
GeneratedMessageV3 message = messageConverter.toMessage(request);
if (message == null) {
DefaultFuture<ResponseMessage> failedFuture = new DefaultFuture<>();
failedFuture.setFailure(new PinpointSocketException(TRouteResult.NOT_SUPPORTED_REQUEST.name()));
return failedFuture;
}
return pinpointGrpcServer.request(message);
}
use of com.navercorp.pinpoint.rpc.DefaultFuture in project pinpoint by naver.
the class DefaultPinpointClient method returnFailureFuture.
private Future<ResponseMessage> returnFailureFuture() {
DefaultFuture<ResponseMessage> future = new DefaultFuture<>();
future.setFailure(new PinpointSocketException("pinpointClientHandler is null"));
return future;
}
Aggregations