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

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

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

origin: wildfly/wildfly

public T getResult(long timeout, boolean reset) {
  try {
    return getResultWithTimeout(timeout, reset);
  }
  catch(TimeoutException e) {
    return null;
  }
}
origin: wildfly/wildfly

public T getResult() {
  try {
    return getResultWithTimeout(0);
  }
  catch(TimeoutException e) {
    return null;
  }
}
origin: wildfly/wildfly

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

private void waitForUnblock() {
  try {
    flush_unblock_promise.reset();
    flush_unblock_promise.getResultWithTimeout(end_flush_timeout);
  } catch (TimeoutException t) {
    if (log.isWarnEnabled())
      log.warn(localAddress + ": waiting for UNBLOCK timed out after " + end_flush_timeout + " ms");
  }
}
origin: wildfly/wildfly

public Counter getOrCreateCounter(String name, long initial_value) {
  if(local_addr == null)
    throw new IllegalArgumentException("the channel needs to be connected before creating or getting a counter");
  Owner owner=getOwner();
  GetOrCreateRequest req=new GetOrCreateRequest(owner, name, initial_value);
  Promise<long[]> promise=new Promise<>();
  pending_requests.put(owner, new Tuple<>(req, promise));
  sendRequest(coord, req);
  long[] result=new long[0];
  try {
    result=promise.getResultWithTimeout(timeout);
    long value=result[0], version=result[1];
    if(!coord.equals(local_addr))
      counters.put(name, new VersionedValue(value, version));
    return new CounterImpl(name);
  }
  catch(TimeoutException e) {
    throw new RuntimeException(e);
  }
}
origin: wildfly/wildfly

FlushStartResult r = flush_promise.getResultWithTimeout(start_flush_timeout);
if(r.failed())
  throw new RuntimeException(r.getFailureCause());
origin: wildfly/wildfly

@Override
public long addAndGet(long delta) {
  if(local_addr.equals(coord)) {
    VersionedValue val=getCounter(name);
    long retval=val.addAndGet(delta)[0];
    if(backup_coords != null)
      updateBackups(name, val.value, val.version);
    return retval;
  }
  Owner owner=getOwner();
  Request req=new AddAndGetRequest(owner, name, delta);
  Promise<long[]> promise=new Promise<>();
  pending_requests.put(owner, new Tuple<>(req, promise));
  sendRequest(coord, req);
  Object obj=null;
  try {
    obj=promise.getResultWithTimeout(timeout);
    if(obj instanceof Throwable)
      throw new IllegalStateException((Throwable)obj);
    long[] result=(long[])obj;
    long value=result[0], version=result[1];
    if(!coord.equals(local_addr))
      counters.put(name, new VersionedValue(value, version));
    return value;
  }
  catch(TimeoutException e) {
    throw new RuntimeException(e);
  }
}
origin: wildfly/wildfly

Object obj=null;
try {
  obj=promise.getResultWithTimeout(timeout);
  if(obj instanceof Throwable)
    throw new IllegalStateException((Throwable)obj);
origin: wildfly/wildfly

@Override
public void set(long new_value) {
  if(local_addr.equals(coord)) {
    VersionedValue val=getCounter(name);
    val.set(new_value);
    if(backup_coords != null)
      updateBackups(name, val.value, val.version);
    return;
  }
  Owner owner=getOwner();
  Request req=new SetRequest(owner, name, new_value);
  Promise<long[]> promise=new Promise<>();
  pending_requests.put(owner, new Tuple<>(req, promise));
  sendRequest(coord, req);
  Object obj=null;
  try {
    obj=promise.getResultWithTimeout(timeout);
    if(obj instanceof Throwable)
      throw new IllegalStateException((Throwable)obj);
    long[] result=(long[])obj;
    long value=result[0], version=result[1];
    if(!coord.equals(local_addr))
      counters.put(name, new VersionedValue(value, version));
  }
  catch(TimeoutException e) {
    throw new RuntimeException(e);
  }
}
origin: org.jgroups/com.springsource.org.jgroups

public Object getResult() {
  try {
    return getResultWithTimeout(0);
  }
  catch(TimeoutException e) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

public T getResult() {
  try {
    return getResultWithTimeout(0);
  }
  catch(TimeoutException e) {
    return null;
  }
}
origin: org.jboss.eap/wildfly-client-all

public T getResult(long timeout, boolean reset) {
  try {
    return getResultWithTimeout(timeout, reset);
  }
  catch(TimeoutException e) {
    return null;
  }
}
origin: org.jgroups/com.springsource.org.jgroups

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

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

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

public void stopFlush() {
  if(!flush_supported) {
    throw new IllegalStateException("Flush is not supported, add pbcast.FLUSH protocol to your configuration");
  }
  
  flush_unblock_promise.reset();
  down(new Event(Event.RESUME));
  
  //do not return until UNBLOCK event is received        
  boolean shouldWaitForUnblock = receive_blocks;        
  if(shouldWaitForUnblock){
    try{              
     flush_unblock_promise.getResultWithTimeout(5000);
    }
    catch (TimeoutException te){              
    }
  }
}
origin: org.jboss.eap/wildfly-client-all

private void waitForUnblock() {
  try {
    flush_unblock_promise.reset();
    flush_unblock_promise.getResultWithTimeout(end_flush_timeout);
  } catch (TimeoutException t) {
    if (log.isWarnEnabled())
      log.warn(localAddress + ": waiting for UNBLOCK timed out after " + end_flush_timeout + " ms");
  }
}
origin: org.jboss.eap/wildfly-client-all

public Counter getOrCreateCounter(String name, long initial_value) {
  if(local_addr == null)
    throw new IllegalArgumentException("the channel needs to be connected before creating or getting a counter");
  Owner owner=getOwner();
  GetOrCreateRequest req=new GetOrCreateRequest(owner, name, initial_value);
  Promise<long[]> promise=new Promise<>();
  pending_requests.put(owner, new Tuple<>(req, promise));
  sendRequest(coord, req);
  long[] result=new long[0];
  try {
    result=promise.getResultWithTimeout(timeout);
    long value=result[0], version=result[1];
    if(!coord.equals(local_addr))
      counters.put(name, new VersionedValue(value, version));
    return new CounterImpl(name);
  }
  catch(TimeoutException e) {
    throw new RuntimeException(e);
  }
}
origin: org.jgroups/com.springsource.org.jgroups

if(shouldWaitForUnblock){
  try{
   flush_unblock_promise.getResultWithTimeout(FLUSH_UNBLOCK_TIMEOUT);
origin: org.jboss.eap/wildfly-client-all

@Override
public void set(long new_value) {
  if(local_addr.equals(coord)) {
    VersionedValue val=getCounter(name);
    val.set(new_value);
    if(backup_coords != null)
      updateBackups(name, val.value, val.version);
    return;
  }
  Owner owner=getOwner();
  Request req=new SetRequest(owner, name, new_value);
  Promise<long[]> promise=new Promise<>();
  pending_requests.put(owner, new Tuple<>(req, promise));
  sendRequest(coord, req);
  Object obj=null;
  try {
    obj=promise.getResultWithTimeout(timeout);
    if(obj instanceof Throwable)
      throw new IllegalStateException((Throwable)obj);
    long[] result=(long[])obj;
    long value=result[0], version=result[1];
    if(!coord.equals(local_addr))
      counters.put(name, new VersionedValue(value, version));
  }
  catch(TimeoutException e) {
    throw new RuntimeException(e);
  }
}
org.jgroups.utilPromisegetResultWithTimeout

Javadoc

Blocks until a result is available, or timeout milliseconds have elapsed

Popular methods of Promise

  • _getResultWithTimeout
    Blocks until a result is available, or timeout milliseconds have elapsed. Needs to be called with a
  • getResult
  • 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

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Menu (java.awt)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Top 12 Jupyter Notebook Extensions
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