本文整理汇总了Java中net.spy.memcached.internal.OperationFuture.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java OperationFuture.getStatus方法的具体用法?Java OperationFuture.getStatus怎么用?Java OperationFuture.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.spy.memcached.internal.OperationFuture
的用法示例。
在下文中一共展示了OperationFuture.getStatus方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: put
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@Override // it is so weird but we use as workaround "region" field to pass "expiration" for put operation
public void put(String expirationInSeconds, String key, Object object) {
try {
int expiration = putExpiration(expirationInSeconds);
OperationFuture<Boolean> set = client.set(key, expiration, object);
OperationStatus status = set.getStatus();// block
log.trace("set - key:" + key + ", expiration: " + expiration + ", status:" + status + ", get:" + get(key));
} catch (Exception e) {
log.error("Failed to put object in cache, key: " + key, e);
}
}
示例8: verify
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/verify/{username}")
public ResponseEntity<String> verify(@PathVariable String username) throws Exception {
OperationFuture<Boolean> future = db.touch("session::" + username, TIMEOUT);
future.get();
OperationStatus status = future.getStatus();
if (status.isSuccess()) {
return new ResponseEntity<String>(HttpStatus.OK);
} else if (status.getMessage().equals("Not Found")) {
return new ResponseEntity<String>(HttpStatus.UNAUTHORIZED);
} else {
LOGGER.warn("/verify/{} failed because of {}", username, status.getMessage());
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
示例9: logout
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/logout/{username}")
public ResponseEntity<String> logout(@PathVariable String username) throws Exception {
OperationFuture<Boolean> future = db.delete("session::" + username);
future.get();
OperationStatus status = future.getStatus();
if (!status.isSuccess()) {
LOGGER.warn("/logout/{} failed because of {}", username, status.getMessage());
}
return new ResponseEntity<String>("logged out", HttpStatus.OK);
}
示例10: add
import net.spy.memcached.internal.OperationFuture; //导入方法依赖的package包/类
@RequestMapping("/add/{name}")
public ResponseEntity<String> add(@PathVariable String name) throws Exception {
Genre genre = new Genre(name, Collections.<String>emptyList());
OperationFuture<Boolean> future = db.add("genre::" + name, mapper.writeValueAsString(genre));
future.get();
OperationStatus status = future.getStatus();
if (status.isSuccess()) {
return new ResponseEntity<String>(HttpStatus.CREATED);
} else {
LOGGER.warn("/add/{} failed because of {}", name, status.getMessage());
return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}