use of herddb.network.ReplyCallback in project herddb by diennea.
the class NettyChannel method handleReply.
private void handleReply(Message anwermessage) {
final ReplyCallback callback = pendingReplyMessages.get(anwermessage.getReplyMessageId());
pendingReplyMessages.remove(anwermessage.getReplyMessageId());
pendingReplyMessagesDeadline.remove(anwermessage.getReplyMessageId());
Message original = pendingReplyMessagesSource.remove(anwermessage.getReplyMessageId());
if (callback != null && original != null) {
submitCallback(() -> {
callback.replyReceived(original, anwermessage, null);
});
}
}
use of herddb.network.ReplyCallback in project herddb by diennea.
the class NettyChannel method processPendingReplyMessagesDeadline.
private void processPendingReplyMessagesDeadline() {
List<String> messagesWithNoReply = new ArrayList<>();
long now = System.currentTimeMillis();
pendingReplyMessagesDeadline.forEach((messageId, deadline) -> {
if (deadline < now) {
messagesWithNoReply.add(messageId);
}
});
if (messagesWithNoReply.isEmpty()) {
return;
}
LOGGER.log(Level.SEVERE, this + " found " + messagesWithNoReply + " without reply, channel will be closed");
ioErrors = true;
for (String messageId : messagesWithNoReply) {
Message original = pendingReplyMessagesSource.remove(messageId);
ReplyCallback callback = pendingReplyMessages.remove(messageId);
pendingReplyMessagesDeadline.remove(messageId);
if (original != null && callback != null) {
submitCallback(() -> {
callback.replyReceived(original, null, new IOException(this + " reply timeout expired, channel will be closed"));
});
}
}
close();
}
Aggregations