Exemplo n.º 1
0
  /**
   * Invokes a method in all members and expects responses from members contained in dests (or all
   * members if dests is null).
   *
   * @param dests A list of addresses. If null, we'll wait for responses from all cluster members
   * @param method_call The method (plus args) to be invoked
   * @param options A collection of call options, e.g. sync versus async, timeout etc
   * @param listener A FutureListener which will be registered (if non null) with the future
   *     <em>before</em> the call is invoked
   * @return NotifyingFuture A future from which the results can be fetched
   * @throws Exception If the sending of the message threw an exception. Note that <em>no</em>
   *     exception will be thrown if any of the target members threw an exception; such an exception
   *     will be in the Rsp element for the particular member in the RspList
   */
  public <T> NotifyingFuture<RspList<T>> callRemoteMethodsWithFuture(
      Collection<Address> dests,
      MethodCall method_call,
      RequestOptions options,
      FutureListener<RspList<T>> listener)
      throws Exception {
    if (dests != null && dests.isEmpty()) { // don't send if dest list is empty
      if (log.isTraceEnabled())
        log.trace(
            "destination list of %s() is empty: no need to send message", method_call.getName());
      return new NullFuture<>(new RspList());
    }

    if (log.isTraceEnabled())
      log.trace("dests=%s, method_call=%s, options=%s", dests, method_call, options);

    Buffer buf =
        req_marshaller != null
            ? req_marshaller.objectToBuffer(method_call)
            : Util.objectToBuffer(method_call);
    Message msg = new Message().setBuffer(buf);

    NotifyingFuture<RspList<T>> retval = super.castMessageWithFuture(dests, msg, options, listener);
    if (log.isTraceEnabled()) log.trace("responses: %s", retval);
    return retval;
  }
Exemplo n.º 2
0
 /**
  * Invokes a method in a cluster member and - if blocking - returns the result
  *
  * @param dest The target member on which to invoke the method
  * @param call The call to be invoked, including method are arguments
  * @param options The options (e.g. blocking, timeout etc)
  * @param listener A FutureListener which will be registered (if non null) with the future
  *     <em>before</em> the call is invoked
  * @return A future from which the result can be fetched. If the callee threw an invocation, an
  *     ExecutionException will be thrown on calling Future.get().
  * @throws Exception Thrown if the method invocation threw an exception
  */
 public <T> NotifyingFuture<T> callRemoteMethodWithFuture(
     Address dest, MethodCall call, RequestOptions options, FutureListener<T> listener)
     throws Exception {
   if (log.isTraceEnabled()) log.trace("dest=%s, method_call=%s, options=%s", dest, call, options);
   Buffer buf =
       req_marshaller != null ? req_marshaller.objectToBuffer(call) : Util.objectToBuffer(call);
   Message msg = new Message(dest, null, null).setBuffer(buf);
   return super.sendMessageWithFuture(msg, options, listener);
 }
Exemplo n.º 3
0
  /**
   * Invokes a method in a cluster member and - if blocking - returns the result
   *
   * @param dest The target member on which to invoke the method
   * @param call The call to be invoked, including method are arguments
   * @param options The options (e.g. blocking, timeout etc)
   * @return The result
   * @throws Exception Thrown if the method invocation threw an exception, either at the caller or
   *     the callee
   */
  public <T> T callRemoteMethod(Address dest, MethodCall call, RequestOptions options)
      throws Exception {
    if (log.isTraceEnabled()) log.trace("dest=%s, method_call=%s, options=%s", dest, call, options);

    Buffer buf =
        req_marshaller != null ? req_marshaller.objectToBuffer(call) : Util.objectToBuffer(call);
    Message msg = new Message(dest, null, null).setBuffer(buf);

    T retval = super.sendMessage(msg, options);
    if (log.isTraceEnabled()) log.trace("retval: %s", retval);
    return retval;
  }