use of org.jgroups.blocks.RequestOptions in project wildfly by wildfly.
the class ChannelCommandDispatcher method submitOnNode.
@Override
public <R> Future<R> submitOnNode(Command<R, ? super C> command, Node node) throws CommandDispatcherException {
// Bypass MessageDispatcher if target node is local
if (this.isLocal(node)) {
return this.localDispatcher.submitOnNode(command, node);
}
Message message = this.createMessage(command, node);
RequestOptions options = this.createRequestOptions();
try {
return this.dispatcher.sendMessageWithFuture(message, options);
} catch (Exception e) {
throw new CommandDispatcherException(e);
}
}
use of org.jgroups.blocks.RequestOptions in project wildfly by wildfly.
the class ChannelCommandDispatcher method executeOnNode.
@Override
public <R> CommandResponse<R> executeOnNode(Command<R, ? super C> command, Node node) throws CommandDispatcherException {
// Bypass MessageDispatcher if target node is local
if (this.isLocal(node)) {
return this.localDispatcher.executeOnNode(command, node);
}
Message message = this.createMessage(command, node);
RequestOptions options = this.createRequestOptions();
try {
// Use sendMessageWithFuture(...) instead of sendMessage(...) since we want to differentiate between sender exceptions and receiver exceptions
Future<R> future = this.dispatcher.sendMessageWithFuture(message, options);
return new SimpleCommandResponse<>(future.get());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return new SimpleCommandResponse<>(e);
} catch (ExecutionException e) {
return new SimpleCommandResponse<>(e);
} catch (Exception e) {
throw new CommandDispatcherException(e);
}
}
use of org.jgroups.blocks.RequestOptions in project wildfly by wildfly.
the class ChannelCommandDispatcher method executeOnCluster.
@Override
public <R> Map<Node, CommandResponse<R>> executeOnCluster(Command<R, ? super C> command, Node... excludedNodes) throws CommandDispatcherException {
Message message = this.createMessage(command);
RequestOptions options = this.createRequestOptions(excludedNodes);
try {
Map<Address, Rsp<R>> responses = this.dispatcher.castMessage(null, message, options);
Map<Node, CommandResponse<R>> results = new HashMap<>();
for (Map.Entry<Address, Rsp<R>> entry : responses.entrySet()) {
Address address = entry.getKey();
Rsp<R> response = entry.getValue();
if (response.wasReceived() && !response.wasSuspected()) {
results.put(this.factory.createNode(address), createCommandResponse(response));
}
}
return results;
} catch (Exception e) {
throw new CommandDispatcherException(e);
}
}
use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.
the class GraphPanel method start.
public void start(String name) {
myname = name;
int xloc = (int) (10 + 250 * Math.random());
int yloc = (int) (10 + 250 * Math.random());
try {
MethodCall call = new MethodCall("addNode", new Object[] { name, my_addr, Integer.valueOf(xloc), Integer.valueOf(yloc) }, new Class[] { String.class, Address.class, int.class, int.class });
wb.disp.callRemoteMethods(null, call, new RequestOptions(ResponseMode.GET_ALL, 0));
} catch (Exception e) {
log.error(e.toString());
}
repaint();
}
use of org.jgroups.blocks.RequestOptions in project teiid by teiid.
the class JGroupsOutputStream method close.
public void close() throws IOException {
if (closed) {
return;
}
flush();
try {
disp.callRemoteMethods(dests, new MethodCall((short) (methodOffset + 2), new Object[] { stateId }), new RequestOptions(ResponseMode.GET_NONE, 0).setAnycasting(dests != null));
} catch (Exception e) {
}
closed = true;
}
Aggregations