Search in sources :

Example 1 with RequestOptions

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);
    }
}
Also used : Message(org.jgroups.Message) RequestOptions(org.jgroups.blocks.RequestOptions) CommandDispatcherException(org.wildfly.clustering.dispatcher.CommandDispatcherException) 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)

Example 2 with RequestOptions

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);
    }
}
Also used : Message(org.jgroups.Message) RequestOptions(org.jgroups.blocks.RequestOptions) CommandDispatcherException(org.wildfly.clustering.dispatcher.CommandDispatcherException) ExecutionException(java.util.concurrent.ExecutionException) 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)

Example 3 with RequestOptions

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);
    }
}
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)

Example 4 with RequestOptions

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();
}
Also used : RequestOptions(org.jgroups.blocks.RequestOptions) MethodCall(org.jgroups.blocks.MethodCall)

Example 5 with RequestOptions

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;
}
Also used : RequestOptions(org.jgroups.blocks.RequestOptions) MethodCall(org.jgroups.blocks.MethodCall) IOException(java.io.IOException)

Aggregations

RequestOptions (org.jgroups.blocks.RequestOptions)31 MethodCall (org.jgroups.blocks.MethodCall)15 Rsp (org.jgroups.util.Rsp)10 RpcDispatcher (org.jgroups.blocks.RpcDispatcher)8 IOException (java.io.IOException)7 CancellationException (java.util.concurrent.CancellationException)4 ExecutionException (java.util.concurrent.ExecutionException)4 TimeoutException (java.util.concurrent.TimeoutException)4 BytesMessage (org.jgroups.BytesMessage)4 Message (org.jgroups.Message)4 MessageDispatcher (org.jgroups.blocks.MessageDispatcher)4 ResponseMode (org.jgroups.blocks.ResponseMode)4 RspList (org.jgroups.util.RspList)4 Map (java.util.Map)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 org.jgroups (org.jgroups)3 Address (org.jgroups.Address)3 CommandDispatcherException (org.wildfly.clustering.dispatcher.CommandDispatcherException)3 Method (java.lang.reflect.Method)2 InetAddress (java.net.InetAddress)2