Search in sources :

Example 1 with CommandResponse

use of org.wildfly.clustering.dispatcher.CommandResponse 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);
    }
}
Also used : Message(org.jgroups.Message) Address(org.jgroups.Address) RequestOptions(org.jgroups.blocks.RequestOptions) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CommandDispatcherException(org.wildfly.clustering.dispatcher.CommandDispatcherException) Node(org.wildfly.clustering.group.Node) CommandResponse(org.wildfly.clustering.dispatcher.CommandResponse) Rsp(org.jgroups.util.Rsp) TimeoutException(java.util.concurrent.TimeoutException) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CommandDispatcherException(org.wildfly.clustering.dispatcher.CommandDispatcherException) HashMap(java.util.HashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CancellationException (java.util.concurrent.CancellationException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Address (org.jgroups.Address)1 Message (org.jgroups.Message)1 RequestOptions (org.jgroups.blocks.RequestOptions)1 Rsp (org.jgroups.util.Rsp)1 CommandDispatcherException (org.wildfly.clustering.dispatcher.CommandDispatcherException)1 CommandResponse (org.wildfly.clustering.dispatcher.CommandResponse)1 Node (org.wildfly.clustering.group.Node)1