Java Code Examples for net.spy.memcached.internal.OperationFuture#get()

The following examples show how to use net.spy.memcached.internal.OperationFuture#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractCouchBaseOutputOperator.java    From attic-apex-malhar with Apache License 2.0 6 votes vote down vote up
@Override
public void onComplete(OperationFuture<?> f) throws Exception
{
  if (!((Boolean)f.get())) {
    logger.error("Operation failed {}", f);
    failure = true;
    return;
  }
  synchronized (syncObj) {
    long idProcessed = mapFuture.get(f);
    mapTuples.remove(idProcessed);
    mapFuture.remove(f);
    numTuples--;
    syncObj.notify();
  }
}
 
Example 2
Source File: ProtocolBaseTestFile.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
public void testSetReturnsCAS() throws Exception {

        OperationFuture<Boolean> setOp = client.set("testSetReturnsCAS",
                0, "testSetReturnsCAS");
        setOp.get();
        assertTrue(setOp.getCas() > 0);
    }
 
Example 3
Source File: CouchBaseSetTest.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
@Override
public void onComplete(OperationFuture<?> f) throws Exception
{
  if (!((Boolean)f.get())) {
    logger.error("Operation failed " + f);
  }
  logger.info("Operation completed");
}
 
Example 4
Source File: MemcachedCache.java    From lsmtree with Apache License 2.0 5 votes vote down vote up
public boolean checkAvailability(String key) {
    long time = System.nanoTime();
    key += "-"+UUID.randomUUID().toString();
    OperationFuture<Boolean> future = memcache.set(key, CACHE_EXPIRY_SECONDS, Longs.toByteArray(time), identityTranscoder);
    try {
        if (!future.get()) return false;
    } catch (Exception e) {
        return false;
    }
    byte[] bytes = memcache.get(key, identityTranscoder);
    memcache.delete(key);
    return bytes != null && Longs.fromByteArray(bytes) == time;
}
 
Example 5
Source File: ArcusCache.java    From arcus-spring with Apache License 2.0 5 votes vote down vote up
@Override
public void clear() {
  try {
    String prefixName = (prefix != null) ? prefix : name;
    if (logger.isDebugEnabled()) {
      logger.debug("evicting every key that uses the name: {}",
              prefixName);
    }

    OperationFuture<Boolean> future = arcusClient.flush(serviceId
            + prefixName);

    boolean success = future.get(timeoutMilliSeconds,
            TimeUnit.MILLISECONDS);

    if (logger.isDebugEnabled() && !success) {
      logger.debug(
              "failed to evicting every key that uses the name: {}",
              prefixName);
    }
  } catch (Exception e) {
    logger.info(e.getMessage());
    if (wantToGetException) {
      throw new RuntimeException(e);
    }
  }
}
 
Example 6
Source File: EVCacheFutures.java    From EVCache with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean get() throws InterruptedException, ExecutionException {
    for (OperationFuture<Boolean> future : futures) {
        if (future.get() == false) return false;
    }
    return true;
}
 
Example 7
Source File: EVCacheFutures.java    From EVCache with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
    for (OperationFuture<Boolean> future : futures) {
        if (future.get(timeout, unit) == false) return false;
    }
    return true;

}