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


Java OperationFuture.get方法代码示例

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


在下文中一共展示了OperationFuture.get方法的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: 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

示例7: 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

示例8: 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

示例9: 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

示例10: create

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/create")
public ResponseEntity<String> create() throws Exception {

    BlogPost.Comment comment = new BlogPost.Comment("[email protected]", "some nice content");

    String title = "A post title";
    BlogPost post = new BlogPost(title, Arrays.asList(comment));
    OperationFuture<Boolean> future = db.add("blogpost::" + nextPostId(), mapper.writeValueAsString(post));
    future.get();
    OperationStatus status = future.getStatus();

    if (status.isSuccess()) {
        return new ResponseEntity<String>(HttpStatus.CREATED);
    } else {
        LOGGER.warn("/create/{} failed because of {}", title, status.getMessage());
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:19,代码来源:BlogPostController.java

示例11: save

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/save/{username}")
public ResponseEntity<String> save(@PathVariable String username) throws Exception {
    long now = System.currentTimeMillis() / 1000L;
    User user = new User(username, true, now);

    OperationFuture<Boolean> future = db.set("user::" + username, mapper.writeValueAsString(user));
    future.get();
    OperationStatus status = future.getStatus();

    if (status.isSuccess()) {
        return new ResponseEntity<String>(HttpStatus.CREATED);
    } else {
        LOGGER.warn("/add/{} failed because of {}", username, status.getMessage());
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:17,代码来源:UserController.java

示例12: login

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/login/{username}")
public ResponseEntity<String> login(@PathVariable String username) throws Exception {
    long now = System.currentTimeMillis() / 1000L;
    Session session = new Session(username, now);

    OperationFuture<Boolean> future = db.add("session::" + username, TIMEOUT, mapper.writeValueAsString(session));
    future.get();
    OperationStatus status = future.getStatus();

    if (status.isSuccess()) {
        return new ResponseEntity<String>("logged in", HttpStatus.OK);
    } else if (status.getMessage().equals("Data exists for key")) {
        return new ResponseEntity<String>("already logged in", HttpStatus.OK);
    } else {
        LOGGER.warn("/login/{} failed because of {}", username, status.getMessage());
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:19,代码来源:SessionController.java

示例13: create

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/create/{name}")
public ResponseEntity<String> create(@PathVariable String name) throws Exception {
    Cinema cinema = new Cinema();
    cinema.setName(name);

    OperationFuture<Boolean> future = db.add("cinema::" + name, mapper.writeValueAsString(cinema));
    future.get();
    OperationStatus status = future.getStatus();

    if (status.isSuccess()) {
        return new ResponseEntity<String>(HttpStatus.CREATED);
    } else {
        LOGGER.warn("/create/{} failed because of {}", name, status.getMessage());
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:17,代码来源:CinemaController.java

示例14: play

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/play/{cinema}/{show}")
public ResponseEntity<String> play(@PathVariable String cinema, @PathVariable String show) throws Exception {
    Show s = new Show();
    s.setCinema_id("cinema::" + cinema);
    s.setDuration(TimeUnit.HOURS.toSeconds(2));
    s.setName(show);
    s.setStart(System.currentTimeMillis() / 1000L);

    String showId = s.getCinema_id() + "::" + nextShowId(s.getCinema_id());
    OperationFuture<Boolean> future = db.add(showId, mapper.writeValueAsString(s));
    future.get();
    OperationStatus status = future.getStatus();
    if (status.isSuccess()) {
        return new ResponseEntity<String>(HttpStatus.CREATED);
    } else {
        LOGGER.warn("/play/{}/{} failed because of {}", cinema, show, status.getMessage());
        return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:20,代码来源:CinemaController.java

示例15: gets

import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
public com.quickserverlab.quickcached.client.CASValue gets(String key, long timeoutMiliSec) 
		throws TimeoutException, com.quickserverlab.quickcached.client.MemcachedException{
	com.quickserverlab.quickcached.client.CASValue value = null;
	try{
		OperationFuture <CASValue<Object>> f =  getCache().asyncGets(key);
		try {
			CASValue<Object> cv = (CASValue<Object>) f.get(timeoutMiliSec, TimeUnit.MILLISECONDS);
			if(cv != null){
				value = new com.quickserverlab.quickcached.client.CASValue(cv.getCas(), cv.getValue());
			}else{
				throw new com.quickserverlab.quickcached.client.MemcachedException("Object not found");
			}
		}catch(InterruptedException ie){
			throw new com.quickserverlab.quickcached.client.MemcachedException("InterruptedException "+ ie);
		}catch(ExecutionException ee){
			throw new com.quickserverlab.quickcached.client.MemcachedException("ExecutionException "+ ee);
		}catch(java.util.concurrent.TimeoutException te){
			throw new TimeoutException("Timeout "+ te);
		}finally{
			f.cancel(false);
		}
	}catch(IllegalStateException ise){
		throw new com.quickserverlab.quickcached.client.MemcachedException("IllegalStateException "+ ise);
	}
	return value;				
}
 
开发者ID:QuickServerLab,项目名称:QuickCached,代码行数:27,代码来源:SpyMemcachedImpl.java


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