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


Java OperationStatus.isSuccess方法代码示例

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


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

示例1: create

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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

示例2: save

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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

示例3: login

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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

示例4: create

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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

示例5: play

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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

示例6: readMissedKeys

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
private final void readMissedKeys(ByteBuffer bb) {
	if (lookingFor == '\0' && data == null) {
		for (int i = 0; bb.remaining() > 0; i++) {
			byte b = bb.get();

			// Ready to finish.
			if (b == '\r') {
				continue;
			}

			// Finish the operation.
			if (b == '\n') {
				OperationStatus status = matchStatus(byteBuffer.toString(),
						END, TRIMMED, DUPLICATED, DUPLICATED_TRIMMED,
						OUT_OF_RANGE, ATTR_MISMATCH, TYPE_MISMATCH,
						BKEY_MISMATCH);

				if (status.isSuccess()) {
					getCallback().receivedStatus(status);
					transitionState(OperationState.COMPLETE);
					return;
				} else {
					((BTreeSortMergeGetOperationOld.Callback) getCallback())
							.gotMissedKey(byteBuffer.toByteArray());
				}
				byteBuffer.reset();
			} else
				byteBuffer.write(b);
		}
		return;
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:33,代码来源:BTreeSortMergeGetOperationOldImpl.java

示例7: verify

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:16,代码来源:SessionController.java

示例8: logout

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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);
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:12,代码来源:SessionController.java

示例9: add

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的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);
    }
}
 
开发者ID:couchbaselabs,项目名称:boot-training-example,代码行数:16,代码来源:GenreController.java

示例10: run

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
@Override
public void run() {
  OperationStatus priorStatus = null;
  final AtomicBoolean done = new AtomicBoolean();

  while (!done.get()) {
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<OperationStatus> foundStatus =
        new AtomicReference<OperationStatus>();

    final OperationCallback cb = new OperationCallback() {
      public void receivedStatus(OperationStatus val) {
        // If the status we found was null, we're done.
        if (val.getMessage().length() == 0) {
          done.set(true);
          node.authComplete();
          getLogger().info("Authenticated to " + node.getSocketAddress());
        } else {
          foundStatus.set(val);
        }
      }

      public void complete() {
        latch.countDown();
      }
    };

    // Get the prior status to create the correct operation.
    final Operation op = buildOperation(priorStatus, cb);
    conn.insertOperation(node, op);

    try {
      latch.await();
      Thread.sleep(100);
    } catch (InterruptedException e) {
      // we can be interrupted if we were in the
      // process of auth'ing and the connection is
      // lost or dropped due to bad auth
      Thread.currentThread().interrupt();
      if (op != null) {
        op.cancel();
      }
      done.set(true); // If we were interrupted, tear down.
    }

    // Get the new status to inspect it.
    priorStatus = foundStatus.get();
    if (priorStatus != null) {
      if (!priorStatus.isSuccess()) {
        getLogger().warn(
            "Authentication failed to " + node.getSocketAddress());
      }
    }
  }
  return;
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:57,代码来源:AuthThread.java

示例11: waitForResponse

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
public static boolean waitForResponse(OperationFuture<Boolean> rv,
    int tries, String operation) throws Exception {
OperationStatus status;
int backoffexp = 0;
try {
    do {
	if (backoffexp > tries) {
	    throw new RuntimeException("Could not perform a "
		    + operation + " after " + tries + " tries.");
	}
	status = getStatusWithretriesOnTimeout(rv, 3);

	if (status == null) {
	    throw new IllegalStateException(
		    "Couchbase returned status as null.");
	}

	if (status.isSuccess()) {
	    return Boolean.TRUE;
	} else {
	    if ("remove".equalsIgnoreCase(operation)
		    && ("NOT_FOUND".equals(status.getMessage()) || "Not found"
			    .equals(status.getMessage()))) {
		log.debug("Remove operation failed, object not found it the cache.");
	    } else {
		log.warn(operation + " failed with status=" + status);
	    }
	}
	if (backoffexp > 0) {
	    double backoffMillis = Math.pow(2, backoffexp);
	    backoffMillis = Math.min(1000, backoffMillis); // 1 sec max
	    Thread.sleep((int) backoffMillis);
	    log.info(operation + " backing off, tries so far="
		    + backoffexp);
	}
	backoffexp++;
    } while ("Temporary failure".equals(status.getMessage()));
} catch (InterruptedException ex) {
    log.error("Interrupted while trying to set.  Exception:"
	    + ex.getMessage());
}
return Boolean.FALSE;
   }
 
开发者ID:forcedotcom,项目名称:3levelmemcache,代码行数:44,代码来源:WaitResponseUtils.java

示例12: readMissedKeys

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
private final void readMissedKeys(ByteBuffer bb) {
	int count = 0;
	if (lookingFor == '\0' && data == null) {
		for (int i = 0; bb.remaining() > 0; i++) {
			byte b = bb.get();

			// Ready to finish.
			if (b == '\r') {
				continue;
			}

			// Finish the operation.
			if (b == '\n') {
				String sep = new String(byteBuffer.toByteArray());
				if (sep.startsWith("TRIMMED_KEYS")) {
					readState = ReadState.TRIMMED_KEYS;
					byteBuffer.reset();
					spaceCount = 0;

					String[] stuff = sep.split(" ");
					lineCount = Integer.parseInt(stuff[1]);

					return;
				}

				OperationStatus status = matchStatus(byteBuffer.toString(),
						END, TRIMMED, DUPLICATED, DUPLICATED_TRIMMED,
						OUT_OF_RANGE, ATTR_MISMATCH, TYPE_MISMATCH,
						BKEY_MISMATCH);

				if (status.isSuccess()) {
					getCallback().receivedStatus(status);
					transitionState(OperationState.COMPLETE);
					return;
				} else if (count < lineCount) {
					String chunk[] = new String(byteBuffer.toByteArray()).split(" ");
					if (chunk.length == 2) {
						((BTreeSortMergeGetOperation.Callback) getCallback())
							.gotMissedKey(chunk[0], matchStatus(chunk[1],
									NOT_FOUND, UNREADABLE, OUT_OF_RANGE));
					} else {
						((BTreeSortMergeGetOperation.Callback) getCallback())
							.gotMissedKey(chunk[0], new CollectionOperationStatus(false,
														"UNDEFINED", CollectionResponse.UNDEFINED));
					}
					count++;
				} else {
					/* unexpected response */
					getCallback().receivedStatus(status);
					transitionState(OperationState.COMPLETE);
					return;
				}
				byteBuffer.reset();
			} else
				byteBuffer.write(b);
		}
		return;
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:60,代码来源:BTreeSortMergeGetOperationImpl.java

示例13: readTrimmedKeys

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
private final void readTrimmedKeys(ByteBuffer bb) {
	int count = 0;
	if (lookingFor == '\0' && data == null) {
		for (int i = 0; bb.remaining() > 0; i++) {
			byte b = bb.get();

			// Ready to finish.
			if (b == '\r') {
				continue;
			}

			// Finish the operation.
			if (b == '\n') {
				OperationStatus status = matchStatus(byteBuffer.toString(),
						END, DUPLICATED, OUT_OF_RANGE, ATTR_MISMATCH,
						TYPE_MISMATCH, BKEY_MISMATCH);

				if (status.isSuccess()) {
					getCallback().receivedStatus(status);
					transitionState(OperationState.COMPLETE);
					return;
				} else if (count < lineCount){
					String[] chunk = new String(byteBuffer.toByteArray())
							.split(" ");
					if (smGet instanceof BTreeSMGetWithLongTypeBkey)
						((BTreeSortMergeGetOperation.Callback) getCallback())
							.gotTrimmedKey(chunk[0], Long.parseLong(chunk[1]));
					else if (smGet instanceof BTreeSMGetWithByteTypeBkey)
						((BTreeSortMergeGetOperation.Callback) getCallback())
							.gotTrimmedKey(chunk[0],
										BTreeUtil.hexStringToByteArrays(chunk[1].substring(2)));
					count++;
				} else {
					/* unexpected response */
					getCallback().receivedStatus(status);
					transitionState(OperationState.COMPLETE);
					return;
				}
				byteBuffer.reset();
			} else
				byteBuffer.write(b);
		}
		return;
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:46,代码来源:BTreeSortMergeGetOperationImpl.java

示例14: run

import net.spy.memcached.ops.OperationStatus; //导入方法依赖的package包/类
@Override
public void run() {
	OperationStatus priorStatus = null;
	final AtomicBoolean done = new AtomicBoolean();

	while(!done.get()) {
		final CountDownLatch latch = new CountDownLatch(1);
		final AtomicReference<OperationStatus> foundStatus =
			new AtomicReference<OperationStatus>();

		final OperationCallback cb=new OperationCallback() {
			public void receivedStatus(OperationStatus val) {
				// If the status we found was null, we're done.
				if(val.getMessage().length() == 0) {
					done.set(true);
					node.authComplete();
					getLogger().info("Authenticated to "
							+ node.getSocketAddress());
				} else {
					foundStatus.set(val);
				}
			}

			public void complete() {
				latch.countDown();
			}
		};

		// Get the prior status to create the correct operation.
		final Operation op = buildOperation(priorStatus, cb);

		conn.insertOperation(node, op);

		try {
			latch.await();
			Thread.sleep(100);
		} catch(InterruptedException e) {
			// we can be interrupted if we were in the
			// process of auth'ing and the connection is
			// lost or dropped due to bad auth
			Thread.currentThread().interrupt();
			if (op != null) {
				op.cancel("interruption to authentication" + e);
			}
			done.set(true); // If we were interrupted, tear down.
		}

		// Get the new status to inspect it.
		priorStatus = foundStatus.get();
		if(priorStatus != null) {
			if(!priorStatus.isSuccess()) {
				getLogger().warn("Authentication failed to "
						+ node.getSocketAddress());
			}
		}
	}
	return;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:59,代码来源:AuthThread.java


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