use of com.navercorp.pinpoint.rpc.DefaultFuture in project pinpoint by naver.
the class RequestManager method register.
public ChannelWriteFailListenableFuture<ResponseMessage> register(int requestId, long timeoutMillis) {
// shutdown check
final ChannelWriteFailListenableFuture<ResponseMessage> responseFuture = new ChannelWriteFailListenableFuture<>(timeoutMillis);
final DefaultFuture old = this.requestMap.put(requestId, responseFuture);
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);
responseFuture.setFailureEventHandler(removeTable);
addTimeoutTask(responseFuture, timeoutMillis);
return responseFuture;
}
use of com.navercorp.pinpoint.rpc.DefaultFuture in project pinpoint by naver.
the class RequestManager method close.
// public ChannelWriteFailListenableFuture<ResponseMessage> register(final int requestId, final long timeoutMillis) {
// // shutdown check
// final ChannelWriteFailListenableFuture<ResponseMessage> responseFuture = new ChannelWriteFailListenableFuture<ResponseMessage>(timeoutMillis) {
// @Override
// public void operationComplete(ChannelFuture future) throws Exception {
// fireWriteComplete(requestId, future, this, timeoutMillis);
// }
// };
// return responseFuture;
// }
//
// private void fireWriteComplete(int requestId, ChannelFuture ioWriteFuture, DefaultFuture<ResponseMessage> responseFuture, long timeoutMillis) {
// if (ioWriteFuture.isSuccess()) {
// final DefaultFuture old = requestMap.put(requestId, responseFuture);
// if (old != null) {
// PinpointSocketException pinpointSocketException = new PinpointSocketException("unexpected error. old responseFuture exist:" + old + " id:" + requestId);
// responseFuture.setFailure(pinpointSocketException);
// return;
// } else {
// FailureEventHandler removeTable = createFailureEventHandler(requestId);
// responseFuture.setFailureEventHandler(removeTable);
// addTimeoutTask(responseFuture, timeoutMillis);
// }
// } else {
// responseFuture.setFailure(ioWriteFuture.getCause());
// }
// }
public void close() {
logger.debug("close()");
final PinpointSocketException closed = new PinpointSocketException("socket closed");
// Could you handle race conditions of "close" more precisely?
// final Timer timer = this.timer;
// if (timer != null) {
// Set<Timeout> stop = timer.stop();
// for (Timeout timeout : stop) {
// DefaultFuture future = (DefaultFuture)timeout.getTask();
// future.setFailure(closed);
// }
// }
int requestFailCount = 0;
for (Map.Entry<Integer, DefaultFuture<ResponseMessage>> entry : requestMap.entrySet()) {
if (entry.getValue().setFailure(closed)) {
requestFailCount++;
}
}
this.requestMap.clear();
if (requestFailCount > 0) {
logger.info("requestManager failCount:{}", requestFailCount);
}
}
Aggregations