Tabnine Logo
Promise.getResult
Code IndexAdd Tabnine to your IDE (free)

How to use
getResult
method
in
org.jgroups.util.Promise

Best Java code snippets using org.jgroups.util.Promise.getResult (Showing top 20 results out of 315)

origin: wildfly/wildfly

/**
 * Returns the result, but never throws a TimeoutException; returns null instead.
 * @param timeout in ms
 * @return T
 */
public T getResult(long timeout) {
  return getResult(timeout, false);
}
origin: wildfly/wildfly

public boolean waitForAllAcks() {
  if(missing_acks.isEmpty())
    return true;
  Boolean result=all_acks_received.getResult();
  return result != null && result;
}
origin: wildfly/wildfly

protected void start(String host, int port, String cluster_name, boolean nio) {
  try {
    stub=new RouterStub(null, 0, InetAddress.getByName(host), port, nio, null);
    stub.connect();
    stub.getMembers(cluster_name, this);
    promise.getResult(5000);
  }
  catch(Exception ex) {
    ex.printStackTrace();
    stub.destroy();
  }
}
origin: wildfly/wildfly

if(!ack_mode || !running || flushing)
  break;
Long ack=ack_promise.getResult(500);
if((Objects.equals(ack, seqno)) || !forward_table.containsKey(seqno))
  break;
origin: wildfly/wildfly

/**
 * Sends a leave request to coord and blocks until a leave response has been received, or the leave timeout has elapsed
 */
protected void sendLeaveReqTo(Address coord) {
  leave_promise.reset();
  leaving=true;
  log.trace("%s: sending LEAVE request to %s", gms.local_addr, coord);
  long start=System.currentTimeMillis();
  sendLeaveMessage(coord, gms.local_addr);
  Boolean result=leave_promise.getResult(gms.leave_timeout);
  long time=System.currentTimeMillis()-start;
  if(result != null)
    log.trace("%s: got LEAVE response from %s in %d ms", gms.local_addr, coord, time);
  else
    log.trace("%s: timed out waiting for LEAVE response from %s (after %d ms)", gms.local_addr, coord, time);
}
origin: wildfly/wildfly

Bits.writeLong(start, req_buf, 3);
tp.send(target, req_buf, 0, req_buf.length);
promise.getResult(0);
long time=time(use_ms)-start;
rtt.add(time);
origin: wildfly/wildfly

protected boolean installViewIfValidJoinRsp(final Promise<JoinRsp> join_promise, boolean block_for_rsp) {
  boolean success=false;
  JoinRsp rsp=null;
  try {
    if(join_promise.hasResult())
      rsp=join_promise.getResult(1, true);
    else if(block_for_rsp)
      rsp=join_promise.getResult(gms.join_timeout, true);
    return success=rsp != null && isJoinResponseValid(rsp) && installView(rsp.getView(), rsp.getDigest());
  }
  finally {
    if(success)
      gms.sendViewAck(rsp.getView().getCreator());
  }
}
origin: wildfly/wildfly

long start=System.currentTimeMillis();
down(new Event(Event.GET_STATE, state_info));
StateTransferResult result=state_promise.getResult(state_info.timeout);
origin: wildfly/wildfly

ack_promise.reset();
down_prot.down(forward_msg);
Long ack=ack_promise.getResult(500);
if((Objects.equals(ack, key)) || !forward_table.containsKey(key))
  break;
origin: wildfly/wildfly

/**
 Attempts to obtain the ping_addr first from the cache, then by unicasting q request to {@code mbr},
 then by multicasting a request to all members.
 */
protected IpAddress fetchPingAddress(final Address mbr) {
  IpAddress ret;
  if(mbr == null)
    return null;
  // 1. Try to get the server socket address from the cache
  if((ret=cache.get(mbr)) != null)
    return ret;
  if(!isPingerThreadRunning()) return null;
  // 2. Try to get the server socket address from mbr (or all, as fallback)
  ping_addr_promise.reset();
  for(Address dest: Arrays.asList(mbr, null)) {
    Message msg=new Message(dest).setFlag(Message.Flag.INTERNAL)
     .putHeader(this.id, new FdHeader(FdHeader.WHO_HAS_SOCK, mbr));
    down_prot.down(msg);
    if((ret=ping_addr_promise.getResult(500)) != null)
      return ret;
    if(!isPingerThreadRunning()) return null;
  }
  return null;
}
origin: wildfly/wildfly

/**
 * Determines coordinator C. If C is null and we are the first member, return. Else loop: send GET_CACHE message
 * to coordinator and wait for GET_CACHE_RSP response. Loop until valid response has been received.
 */
protected void getCacheFromCoordinator() {
  Address coord;
  int attempts=num_tries;
  get_cache_promise.reset();
  while(attempts > 0 && isPingerThreadRunning()) {
    if((coord=determineCoordinator()) != null) {
      if(coord.equals(local_addr)) { // we are the first member --> empty cache
        return;
      }
      Message msg=new Message(coord).setFlag(Message.Flag.INTERNAL)
       .putHeader(this.id, new FdHeader(FdHeader.GET_CACHE));
      down_prot.down(msg);
      Map<Address,IpAddress> result=get_cache_promise.getResult(get_cache_timeout);
      if(result != null) {
        cache.addAll(result);
        log.trace("%s: got cache from %s: cache is %s", local_addr, coord, cache);
        return;
      }
    }
    --attempts;
  }
}
origin: wildfly/wildfly

ack_promise.reset();
down_prot.down(forward_msg);
Long ack=ack_promise.getResult(500);
if((Objects.equals(ack, key)) || !forward_table.containsKey(key))
  break;
origin: org.jboss.eap/wildfly-client-all

/**
 * Returns the result, but never throws a TimeoutException; returns null instead.
 * @param timeout in ms
 * @return T
 */
public T getResult(long timeout) {
  return getResult(timeout, false);
}
origin: org.jboss.eap/wildfly-client-all

public boolean waitForAllAcks() {
  if(missing_acks.isEmpty())
    return true;
  Boolean result=all_acks_received.getResult();
  return result != null && result;
}
origin: org.jgroups/com.springsource.org.jgroups

public boolean waitForAllAcks() {
  if(missing_acks.size() == 0)
    return true;
  Object result=all_acks_received.getResult();
  return result != null && result instanceof Boolean && ((Boolean)result).booleanValue();
}
origin: org.jgroups/com.springsource.org.jgroups

/**
 * Returns a list of PingRsp pairs.
 */
Vector findInitialMembers() {
  PingRsp tmp=new PingRsp(local_addr, local_addr, true);
  find_promise.reset();
  down_prot.down(Event.FIND_INITIAL_MBRS_EVT);
  Vector retval=(Vector)find_promise.getResult(0); // wait indefinitely until response is received
  if(retval != null && is_coord && local_addr != null && !retval.contains(tmp))
    retval.add(tmp);
  return retval;
}
origin: org.jboss.eap/wildfly-client-all

protected void start(String host, int port, String cluster_name, boolean nio) {
  try {
    stub=new RouterStub(null, 0, InetAddress.getByName(host), port, nio, null);
    stub.connect();
    stub.getMembers(cluster_name, this);
    promise.getResult(5000);
  }
  catch(Exception ex) {
    ex.printStackTrace();
    stub.destroy();
  }
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Sends a leave request to coord and blocks until a leave response has been received, or the leave timeout has elapsed
 */
protected void sendLeaveReqTo(Address coord) {
  leave_promise.reset();
  leaving=true;
  log.trace("%s: sending LEAVE request to %s", gms.local_addr, coord);
  long start=System.currentTimeMillis();
  sendLeaveMessage(coord, gms.local_addr);
  Boolean result=leave_promise.getResult(gms.leave_timeout);
  long time=System.currentTimeMillis()-start;
  if(result != null)
    log.trace("%s: got LEAVE response from %s in %d ms", gms.local_addr, coord, time);
  else
    log.trace("%s: timed out waiting for LEAVE response from %s (after %d ms)", gms.local_addr, coord, time);
}
origin: org.jboss.eap/wildfly-client-all

protected boolean installViewIfValidJoinRsp(final Promise<JoinRsp> join_promise, boolean block_for_rsp) {
  boolean success=false;
  JoinRsp rsp=null;
  try {
    if(join_promise.hasResult())
      rsp=join_promise.getResult(1, true);
    else if(block_for_rsp)
      rsp=join_promise.getResult(gms.join_timeout, true);
    return success=rsp != null && isJoinResponseValid(rsp) && installView(rsp.getView(), rsp.getDigest());
  }
  finally {
    if(success)
      gms.sendViewAck(rsp.getView().getCreator());
  }
}
origin: org.jgroups/com.springsource.org.jgroups

  public void run() {
    Message msg;
    int num_missed_hbs=0;
    dest=getHeartbeatDest();
    if(dest == null) {
      if(log.isWarnEnabled()) log.warn("heartbeat destination was null, will not send ARE_YOU_ALIVE message");
      return;
    }
    if(log.isInfoEnabled())
      log.info("sending ARE_YOU_ALIVE message to " + dest + ", counters are\n" + printCounters());
    promise.reset();
    msg=new Message(dest);
    msg.putHeader(name, new FdHeader(FdHeader.ARE_YOU_ALIVE));
    down_prot.down(new Event(Event.MSG, msg));
    promise.getResult(timeout);
    num_missed_hbs=incrementCounter(dest);
    if(num_missed_hbs >= max_missed_hbs) {
      if(log.isInfoEnabled())
        log.info("missed " + num_missed_hbs + " from " + dest + ", suspecting member");
      up_prot.up(new Event(Event.SUSPECT, dest));
    }
  }
}
org.jgroups.utilPromisegetResult

Javadoc

Returns the result, but never throws a TimeoutException; returns null instead.

Popular methods of Promise

  • _getResultWithTimeout
    Blocks until a result is available, or timeout milliseconds have elapsed. Needs to be called with a
  • getResultWithTimeout
  • hasResult
    Checks whether result is available. Does not block.
  • reset
  • setResult
    Sets the result and notifies any threads waiting for it
  • <init>
  • doWait

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now