当前位置: 首页>>代码示例>>Java>>正文


Java OperationFuture类代码示例

本文整理汇总了Java中net.spy.memcached.internal.OperationFuture的典型用法代码示例。如果您正苦于以下问题:Java OperationFuture类的具体用法?Java OperationFuture怎么用?Java OperationFuture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OperationFuture类属于net.spy.memcached.internal包,在下文中一共展示了OperationFuture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTouch

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testTouch() throws Exception {
  if (serverSupportsTouch()) {
    return;
  }
  String value = UUID.randomUUID().toString();
  Boolean didSet = memcacheClient.set("key", 0, value).get();
  assertTrue(didSet);

  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("touch");
  OperationFuture<Boolean> operationFuture = memcacheClient.touch("key", 0);
  Boolean touched = operationFuture.get();
  assertTrue(touched);
  tracker.validate(expectedValues);
  /*
  //Touch operation does not return cas value

  String value1 = UUID.randomUUID().toString();
  CASResponse response = memcacheClient.cas("key", operationFuture.getCas(), value1);
  assertEquals(CASResponse.OK, response);
  */
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:24,代码来源:AbstractSpyMemcachedInstrumentationTest.java

示例2: testAppendCas

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testAppendCas() throws Exception {
  String value = UUID.randomUUID().toString();
  OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
  Boolean didSet = setFuture.get();
  assertTrue(didSet);
  Long cas = setFuture.getCas();

  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("append");
  String value1 = UUID.randomUUID().toString();
  Boolean appended = memcacheClient.append(cas, "key", value1).get();
  assertTrue(appended);
  tracker.validate(expectedValues);

  Object val = memcacheClient.get("key");
  assertEquals(value + value1, val);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例3: testPrependCas

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testPrependCas() throws Exception {
  String value = UUID.randomUUID().toString();
  OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
  Boolean didSet = setFuture.get();
  assertTrue(didSet);
  Long cas = setFuture.getCas();

  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("prepend");
  String value1 = UUID.randomUUID().toString();
  Boolean appended = memcacheClient.prepend(cas, "key", value1).get();
  assertTrue(appended);
  tracker.validate(expectedValues);

  Object val = memcacheClient.get("key");
  assertEquals(value1 + value, val);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例4: testAsyncCas

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testAsyncCas() throws Exception {
  String value = UUID.randomUUID().toString();
  OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
  Boolean didSet = setFuture.get();
  assertTrue(didSet);

  Long cas = setFuture.getCas();
  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("set");
  String value1 = UUID.randomUUID().toString();
  CASResponse response = memcacheClient.asyncCAS("key", cas, value1).get();
  assertEquals(CASResponse.OK, response);
  tracker.validate(expectedValues);

  Object val = memcacheClient.get("key");
  assertEquals(value1, val);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例5: testCas

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testCas() throws Exception {
  String value = UUID.randomUUID().toString();
  OperationFuture<Boolean> setFuture = memcacheClient.set("key", 0, value);
  Boolean didSet = setFuture.get();
  assertTrue(didSet);

  Long cas = setFuture.getCas();
  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("set");
  String value1 = UUID.randomUUID().toString();
  CASResponse response = memcacheClient.cas("key", cas, value1);
  assertEquals(CASResponse.OK, response);
  tracker.validate(expectedValues);

  Object val = memcacheClient.get("key");
  assertEquals(value1, val);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:19,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例6: testDeleteCas

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Test
public void testDeleteCas() throws Exception {
  String value = UUID.randomUUID().toString();
  OperationFuture<Boolean> future = memcacheClient.set("key", 0, value);
  assertTrue(future.get());
  long cas = future.getCas();

  Snapshot expectedValues = tracker.snapshot();
  expectedValues.increment("delete");
  Boolean deleted = memcacheClient.delete("key", cas).get();
  assertTrue(deleted);
  tracker.validate(expectedValues);

  Object val = memcacheClient.get("key");
  assertNull(val);
}
 
开发者ID:ApptuitAI,项目名称:JInsight,代码行数:17,代码来源:BinarySpyMemcachedInstrumentationTest.java

示例7: setKeyValueInCouchBase

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
public void setKeyValueInCouchBase(T tuple)
{
  id++;
  String key = getKey(tuple);
  Object value = getValue(tuple);
  if (!(value instanceof Boolean) && !(value instanceof Integer) && !(value instanceof String) && !(value instanceof Float) && !(value instanceof Double) && !(value instanceof Character) && !(value instanceof Long) && !(value instanceof Short) && !(value instanceof Byte)) {
    if (serializer != null) {
      value = serializer.serialize(value);
    }
  }
  OperationFuture<Boolean> future = processKeyValue(key, value);
  synchronized (syncObj) {
    future.addListener(listener);
    mapFuture.put(future, id);
    if (!mapTuples.containsKey(id)) {
      mapTuples.put(id, tuple);
    }
    numTuples++;
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:22,代码来源:AbstractCouchBaseOutputOperator.java

示例8: onComplete

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@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();
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:AbstractCouchBaseOutputOperator.java

示例9: setInternal

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Override
protected void setInternal(final MemcachedClient mc, final String path,
    final List<INode> inodes) {
  if (INode.getPathNames(path).length != inodes.size()) {
    return;
  }
  final String key = getKey(path);
  final int[] inodeIds = getINodeIds(inodes);
  final long startTime = System.currentTimeMillis();
  mc.set(key, keyExpiry, new CacheEntry(inodeIds))
      .addListener(new OperationCompletionListener() {
        @Override
        public void onComplete(OperationFuture<?> f) throws Exception {
          long elapsed = System.currentTimeMillis() - startTime;
          LOG.debug("SET for path (" + path + ")  " + key + "=" +
              Arrays.toString(inodeIds) + " in " + elapsed + " msec");
        }
      });
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:20,代码来源:PathMemcache.java

示例10: getStatusWithretriesOnTimeout

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
private static OperationStatus getStatusWithretriesOnTimeout(
    OperationFuture<Boolean> rv, int tries) {
int i = 0;
boolean shouldRetry = false;
do {
    try {
	shouldRetry = false;
	return rv.getStatus();
    } catch (Exception exception) {
	if (exception.getCause() instanceof CheckedOperationTimeoutException
		|| exception instanceof CheckedOperationTimeoutException) {
	    log.warn("Try[" + (tries - i) + "] Wait for response. Of:"
		    + rv);
	    shouldRetry = true;
	}
    }

} while (++i < tries && shouldRetry);

return rv.getStatus();
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:22,代码来源:WaitResponseUtils.java

示例11: add

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
@Override
   public boolean add(Object key, Serializable obj) {
try {
    if (key == null) {
	return Boolean.TRUE;
    } else {
	String _key = getKey(key);
	OperationFuture<Boolean> f = (OperationFuture<Boolean>) client
		.add(_key, expireTime, obj);
	return WaitResponseUtils.waitForResponse(f, 3, "add");
    }
} catch (Exception alle) {
    log.warn("For information only, there is exception in memcached add method, please ignore it,"
	    + " unable to add key:" + key);
    if (log.isDebugEnabled()) {
	log.debug(
		"For information only, there is exception in memcached add method, please ignore it,"
			+ " unable to add key:" + key, alle);
    }
    return Boolean.FALSE;
} finally {
    if (listener != null)
	listener.put(key, obj);
}
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:26,代码来源:MemcachedCacheService.java

示例12: putWithSlowDownLogic

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
private OperationFuture<Boolean> putWithSlowDownLogic(Object key,
    int expiration, Serializable obj) {
OperationFuture<Boolean> rv = null;
while (rv == null) {
    try {
	rv = (OperationFuture<Boolean>) client.set(getKey(key),
		expiration, obj);
    } catch (IllegalStateException ex) {
	log.debug("slow down"); // Need to slow down a bit when
				// we start getting rejections.
	try {
	    if (rv != null) {
		rv.get(250, TimeUnit.MILLISECONDS);
	    } else {
		Thread.sleep(250);
	    }
	} catch (InterruptedException ie) {
	    Thread.currentThread().interrupt();
	} catch (Exception e2) {
	    // Ignore exceptions here. We're just trying to slow
	    // down input.
	}
    }
}
return rv;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:27,代码来源:MemcachedCacheService.java

示例13: unlock

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
private void unlock(Message<JsonObject> message) throws InterruptedException, ExecutionException {
  JsonObject json = message.body(); 
  
  String key = getMandatoryString("key", message);   
  Long cas = json.getLong("cas");
  
  if (key == null || cas == null) {
    sendError(message, "key and cas must be specified");
    return;
  }
      
  OperationFuture<Boolean> unlockFuture = client.asyncUnlock(key, cas);
  boolean response = unlockFuture.get();
  
  if (response) {
    JsonObject reply = new JsonObject();
    reply.putString("key", unlockFuture.getKey());
    sendOK(message, reply);
  }
  else {
    sendError(message, unlockFuture.getStatus().getMessage());
  }
}
 
开发者ID:jmusacchio,项目名称:mod-couchbase-persistor,代码行数:24,代码来源:CouchbasePersistor.java

示例14: touch

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
private void touch(Message<JsonObject> message) throws InterruptedException, ExecutionException {
  JsonObject json = message.body(); 
  
  String key = getMandatoryString("key", message);   
  int expiration = json.getInteger("expiration", 0);
  
  if (key == null) {
    sendError(message, "key must be specified");
    return;
  }
      
  OperationFuture<Boolean> touchFuture = client.touch(key, expiration);
  boolean response = touchFuture.get();
  
  if (response) {
    JsonObject reply = new JsonObject();
    reply.putString("key", touchFuture.getKey());
    sendOK(message, reply);
  }
  else {
    sendError(message, touchFuture.getStatus().getMessage());
  }
}
 
开发者ID:jmusacchio,项目名称:mod-couchbase-persistor,代码行数:24,代码来源:CouchbasePersistor.java

示例15: store

import net.spy.memcached.internal.OperationFuture; //导入依赖的package包/类
protected OperationFuture<Boolean> store(CouchbaseOperation operation,
                                         String key, Object value, int expiry) {
  switch (operation) {
    case SET:
      return couchbaseClient.set(key, expiry, value);
    case ADD:
      return couchbaseClient.add(key, expiry, value);
    case REPLACE:
      return couchbaseClient.replace(key, expiry, value);
    case APPEND:
      return couchbaseClient.append(key, value);
    case PREPEND:
      return couchbaseClient.prepend(key, value);
    case DELETE:
      return couchbaseClient.delete(key);
    case TOUCH:
      return couchbaseClient.touch(key, expiry);
    case EXISTS:
      return couchbaseClient.touch(key, expiry);
    default:
      // Ignore this action.
      return null;
  }
}
 
开发者ID:Avira,项目名称:couchdoop,代码行数:25,代码来源:CouchbaseOutputFormat.java


注:本文中的net.spy.memcached.internal.OperationFuture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。