DelayedResult<QueryResult> waitingResult;
waitingResults.put(id,
waitingResult = new DelayedResult<QueryResult>());
network.sendMessage(p2pKey, messageToSend.toString());
QueryResult queryResult = new QueryResult();
try {
queryResult = waitingResult.get(SLEEP, TimeUnit.SECONDS);
l.debug(String.format("Waiting for answer of message-id: %s: finished", id));
} catch (ExecutionException e) {
l.error(String.format(
"Error waiting for result of message-id %s", id), e);
RuntimeException re = new RuntimeException(String.format(
"Error waiting for result of message-id %s", id));
re.addSuppressed(e);
throw re;
} catch (TimeoutException e) {
l.error(String.format(
"Error waiting for result of message-id %s, timeout!",
id), e);
RuntimeException re = new RuntimeException(String.format(
"Error waiting for result of message-id %s, timout!",
id));
re.addSuppressed(e);
throw re;
}
return queryResult;
} catch (InterruptedException e) {
l.error(String
.format("Error waiting of result for subgraph from node %s",
p2pKey), e);
}
// Wait for answer of message id
l.warn(String
.format("Error waiting of result for subgraph from node %s. So return empty query-result.",
p2pKey));
return new QueryResult();
}