use of org.infinispan.commons.util.logging.TraceException in project infinispan by infinispan.
the class JGroupsBackupResponse method waitForBackupToFinish.
@Override
public void waitForBackupToFinish() throws Exception {
long deductFromTimeout = timeService.timeDuration(sendTimeNanos, MILLISECONDS);
errors = new HashMap<>(backupCalls.size());
long elapsedTime = 0;
boolean hasSyncBackups = false;
for (Map.Entry<XSiteBackup, CompletableFuture<ValidResponse>> entry : backupCalls.entrySet()) {
XSiteBackup xSiteBackup = entry.getKey();
if (!xSiteBackup.isSync()) {
continue;
}
hasSyncBackups = true;
long timeout = xSiteBackup.getTimeout();
String siteName = xSiteBackup.getSiteName();
if (timeout > 0) {
// 0 means wait forever
timeout -= deductFromTimeout;
timeout -= elapsedTime;
if (timeout <= 0 && !entry.getValue().isDone()) {
log.tracef("Timeout period %d exhausted with site %s", xSiteBackup.getTimeout(), siteName);
errors.put(siteName, newTimeoutException(xSiteBackup.getTimeout(), xSiteBackup));
addCommunicationError(siteName);
continue;
}
}
long startNanos = timeService.time();
Response response = null;
try {
response = entry.getValue().get(timeout, MILLISECONDS);
} catch (java.util.concurrent.TimeoutException te) {
errors.put(siteName, newTimeoutException(xSiteBackup.getTimeout(), xSiteBackup));
addCommunicationError(siteName);
} catch (ExecutionException ue) {
Throwable cause = ue.getCause();
cause.addSuppressed(new TraceException());
log.tracef(cause, "Communication error with site %s", siteName);
errors.put(siteName, filterException(cause));
addCommunicationError(siteName);
} finally {
elapsedTime += timeService.timeDuration(startNanos, MILLISECONDS);
}
log.tracef("Received response from site %s: %s", siteName, response);
}
if (hasSyncBackups) {
timeElapsedConsumer.accept(timeService.timeDuration(sendTimeNanos, MILLISECONDS));
}
}
use of org.infinispan.commons.util.logging.TraceException in project infinispan by infinispan.
the class JGroupsTransport method invokeRemotely.
@Override
@Deprecated
public Map<Address, Response> invokeRemotely(Map<Address, ReplicableCommand> commands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast) throws Exception {
if (commands == null || commands.isEmpty()) {
// don't send if recipients list is empty
log.trace("Destination list is empty: no need to send message");
return Collections.emptyMap();
}
if (mode.isSynchronous()) {
MapResponseCollector collector = MapResponseCollector.validOnly(commands.size());
CompletionStage<Map<Address, Response>> request = invokeCommands(commands.keySet(), commands::get, collector, deliverOrder, timeout, TimeUnit.MILLISECONDS);
try {
return CompletableFutures.await(request.toCompletableFuture());
} catch (ExecutionException e) {
Throwable cause = e.getCause();
cause.addSuppressed(new TraceException());
throw Util.rewrapAsCacheException(cause);
}
} else {
commands.forEach((a, command) -> {
logCommand(command, a);
sendCommand(a, command, Request.NO_REQUEST_ID, deliverOrder, true, true);
});
return Collections.emptyMap();
}
}
use of org.infinispan.commons.util.logging.TraceException in project infinispan by infinispan.
the class RemoteInnerPublisherHandler method handleThrowableInResponse.
@Override
protected void handleThrowableInResponse(Throwable t, Map.Entry<SocketAddress, IntSet> target) {
if (t instanceof TransportException || t instanceof RemoteIllegalLifecycleStateException) {
log.throwableDuringPublisher(t);
if (log.isTraceEnabled()) {
IntSet targetSegments = target.getValue();
if (targetSegments != null) {
log.tracef("There are still outstanding segments %s that will need to be retried", targetSegments);
}
}
publisher.erroredServer(target.getKey());
// Try next target if possible
targetComplete();
accept(0);
} else {
t.addSuppressed(new TraceException());
super.handleThrowableInResponse(t, target);
}
}
use of org.infinispan.commons.util.logging.TraceException in project infinispan by infinispan.
the class Transport method invokeRemotely.
/**
* @deprecated Since 9.2, please use {@link #invokeRemotelyAsync(Collection, ReplicableCommand, ResponseMode, long, ResponseFilter, DeliverOrder, boolean)} instead.
*/
@Deprecated
default Map<Address, Response> invokeRemotely(Map<Address, ReplicableCommand> rpcCommands, ResponseMode mode, long timeout, ResponseFilter responseFilter, DeliverOrder deliverOrder, boolean anycast) throws Exception {
// This overload didn't have an async version, so implement it on top of the regular invokeRemotelyAsync
Map<Address, Response> result = new ConcurrentHashMap<>(rpcCommands.size());
ResponseFilter partResponseFilter = new ResponseFilter() {
@Override
public boolean isAcceptable(Response response, Address sender) {
// Guarantee collector.addResponse() isn't called concurrently
synchronized (result) {
result.put(sender, response);
return responseFilter.isAcceptable(response, sender);
}
}
@Override
public boolean needMoreResponses() {
return responseFilter.needMoreResponses();
}
};
List<CompletableFuture<Map<Address, Response>>> futures = new ArrayList<>(rpcCommands.size());
for (Map.Entry<Address, ReplicableCommand> e : rpcCommands.entrySet()) {
futures.add(invokeRemotelyAsync(Collections.singleton(e.getKey()), e.getValue(), mode, timeout, partResponseFilter, deliverOrder, anycast));
}
try {
// no need to set a timeout for the future. The rpc invocation is guaranteed to complete within the timeout
// milliseconds
CompletableFutures.await(CompletableFuture.allOf(futures.toArray(new CompletableFuture[rpcCommands.size()])));
return result;
} catch (ExecutionException e) {
Throwable cause = e.getCause();
cause.addSuppressed(new TraceException());
throw Util.rewrapAsCacheException(cause);
}
}
Aggregations