• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OperationStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: finishedPayload

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
@Override
protected void finishedPayload(byte[] pl) throws IOException {
  if (keyLen > 0) {
    final byte[] keyBytes = new byte[keyLen];
    final byte[] data = new byte[pl.length - keyLen];
    System.arraycopy(pl, 0, keyBytes, 0, keyLen);
    System.arraycopy(pl, keyLen, data, 0, pl.length - keyLen);
    Callback cb = (Callback) getCallback();
    cb.gotStat(new String(keyBytes, "UTF-8"), new String(data, "UTF-8"));
  } else {
    OperationStatus status = getStatusForErrorCode(errorCode, pl);
    getCallback().receivedStatus(status);
    transitionState(OperationState.COMPLETE);
  }
  resetInput();
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:17,代码来源:KeyStatsOperationImpl.java


示例2: finishedPayload

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
protected void finishedPayload(byte[] pl) throws IOException {
  OperationStatus status = getStatusForErrorCode(errorCode, pl);

  if (status == null) {
    handleError(OperationErrorType.SERVER, new String(pl));
  } else if (errorCode == SUCCESS) {
    decodePayload(pl);
    transitionState(OperationState.COMPLETE);
  } else if (errorCode == ERR_NOT_MY_VBUCKET
      && !getState().equals(OperationState.COMPLETE)) {
    transitionState(OperationState.RETRY);
  } else {
    getCallback().receivedStatus(status);
    transitionState(OperationState.COMPLETE);
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:17,代码来源:OperationImpl.java


示例3: waitForQueues

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * Wait for the queues to die down.
 *
 * @param timeout the amount of time time for shutdown
 * @param unit the TimeUnit for the timeout
 * @return result of the request for the wait
 * @throws IllegalStateException in the rare circumstance where queue is too
 *           full to accept any more requests
 */
public boolean waitForQueues(long timeout, TimeUnit unit) {
  CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
    public Operation newOp(final MemcachedNode n,
        final CountDownLatch latch) {
      return opFact.noop(new OperationCallback() {
        public void complete() {
          latch.countDown();
        }

        public void receivedStatus(OperationStatus s) {
          // Nothing special when receiving status, only
          // necessary to complete the interface
        }
      });
    }
  }, conn.getLocator().getAll(), false);
  try {
    // XXX: Perhaps IllegalStateException should be caught here
    // and the check retried.
    return blatch.await(timeout, unit);
  } catch (InterruptedException e) {
    throw new RuntimeException("Interrupted waiting for queues", e);
  }
}
 
开发者ID:Alachisoft,项目名称:TayzGrid,代码行数:34,代码来源:TapConnectionProvider.java


示例4: sendSpyMemcached

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
private static void sendSpyMemcached(final MemcachedClient client,
                                     final List<String> keys,
                                     final Map<String, String> expectedMap,
                                     final ProgressMeter meter,
                                     final ScheduledExecutorService backoffExecutor) {
  final long start = System.nanoTime();
  final BulkFuture<Map<String, Object>> future = client.asyncGetBulk(keys);
  future.addListener(getFuture -> {
    final OperationStatus status = getFuture.getStatus();
    if (status.isSuccess()) {
      final Map<String, String> response = (Map<String, String>) getFuture.get();
      final long end = System.nanoTime();
      final long latency = end - start;
      meter.inc(keys.size(), latency);
      if (!expectedMap.equals(response)) {
        throw new AssertionError("expected: " + expectedMap + ", got: " + response);
      }
      sendSpyMemcached(client, keys, expectedMap, meter, backoffExecutor);
    } else {
      System.err.println("failure!");
    }
  });
}
 
开发者ID:spotify,项目名称:folsom,代码行数:24,代码来源:SimpleMemcacheClientBenchmark.java


示例5: getStatusWithretriesOnTimeout

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


示例6: getStatusForErrorCode

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
@Override
protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) {
	OperationStatus rv=null;
	switch(errCode) {
		case ERR_EXISTS:
			rv=EXISTS_STATUS;
			break;
		case ERR_NOT_FOUND:
			rv=NOT_FOUND_STATUS;
			break;
		case ERR_NOT_STORED:
			rv=NOT_FOUND_STATUS;
			break;
	}
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:ConcatenationOperationImpl.java


示例7: handleLine

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * <result value>\r\n
 */
public void handleLine(String line) {

	OperationStatus status = null;

	/* ENABLE_REPLICATION if */
	if (line.equals("SWITCHOVER") || line.equals("REPL_SLAVE")) {
		receivedMoveOperations(line);
		return;
	}

	/* ENABLE_REPLICATION end */
	try {
		Long.valueOf(line);
		getCallback().receivedStatus(new OperationStatus(true, line));
	} catch (NumberFormatException e) {
		status = matchStatus(line, NOT_FOUND, NOT_FOUND_ELEMENT, TYPE_MISMATCH, BKEY_MISMATCH,
				UNREADABLE, OVERFLOWED, OUT_OF_RANGE);

		getLogger().debug(status);
		getCallback().receivedStatus(status);
	}

	transitionState(OperationState.COMPLETE);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:28,代码来源:CollectionMutateOperationImpl.java


示例8: handleLine

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
public void handleLine(String line) {
	getLogger().debug("Got line %s", line);

	if (line.startsWith("VALUE ")) {
		readKey(line);
		setReadType(OperationReadType.DATA);
	} else {
		OperationStatus status = matchStatus(line, END);

		getLogger().debug(status);
		getCallback().receivedStatus(status);

		transitionState(OperationState.COMPLETE);
		return;
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:BTreeGetBulkOperationImpl.java


示例9: handleLine

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
@Override
public void handleLine(String line) {
	/* ENABLE_REPLICATION if */
	if (line.equals("SWITCHOVER") || line.equals("REPL_SLAVE")) {
		receivedMoveOperations(line);
	}

	/* ENABLE_REPLICATION end */
	OperationStatus status=null;
	try {
		Long.valueOf(line);
		getCallback().receivedStatus(new OperationStatus(true, line));
	} catch (NumberFormatException e) {
		status = matchStatus(line, NOT_FOUND, TYPE_MISMATCH);
		getCallback().receivedStatus(status);
	}
	transitionState(OperationState.COMPLETE);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:19,代码来源:MutatorOperationImpl.java


示例10: asyncStore

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
Future<Boolean> asyncStore(StoreType storeType, String key,
		int exp, CachedData co) {
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
			operationTimeout);
	Operation op=opFact.store(storeType, key, co.getFlags(),
			exp, co.getData(), new OperationCallback() {
		public void receivedStatus(OperationStatus val) {
			rv.set(val.isSuccess());
		}
		public void complete() {
			latch.countDown();
		}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:ArcusClient.java


示例11: asyncSetAttr

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
@Override
public CollectionFuture<Boolean> asyncSetAttr(String key,
		Attributes attrs) {
	final CountDownLatch latch = new CountDownLatch(1);
	final CollectionFuture<Boolean> rv = new CollectionFuture<Boolean>(
			latch, operationTimeout);
	Operation op = opFact.setAttr(key, attrs, new OperationCallback() {
		public void receivedStatus(OperationStatus status) {
			if (status instanceof CollectionOperationStatus) {
				rv.set(status.isSuccess(), (CollectionOperationStatus) status);
			} else {
				getLogger().warn("Unhandled state: " + status);
				rv.set(status.isSuccess(), new CollectionOperationStatus(status));
			}
		}
		public void complete() {
			latch.countDown();
		}
	});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:24,代码来源:ArcusClient.java


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


示例13: asyncCat

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
private <T> Future<Boolean> asyncCat(
		ConcatenationType catType, long cas, String key,
		T value, Transcoder<T> tc) {
	CachedData co=tc.encode(value);
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
			operationTimeout);
	Operation op=opFact.cat(catType, cas, key, co.getData(),
			new OperationCallback() {
		public void receivedStatus(OperationStatus val) {
			rv.set(val.isSuccess());
		}
		public void complete() {
			latch.countDown();
		}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:20,代码来源:MemcachedClient.java


示例14: asyncCAS

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * Asynchronous CAS operation.
 *
 * @param <T>
 * @param key the key
 * @param casId the CAS identifier (from a gets operation)
 * @param exp the expiration of this object
 * @param value the new value
 * @param tc the transcoder to serialize and unserialize the value
 * @return a future that will indicate the status of the CAS
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public <T> Future<CASResponse> asyncCAS(String key, long casId, int exp, T value,
		Transcoder<T> tc) {
	CachedData co=tc.encode(value);
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<CASResponse> rv=new OperationFuture<CASResponse>(
			latch, operationTimeout);
	Operation op=opFact.cas(StoreType.set, key, casId, co.getFlags(), exp,
			co.getData(), new OperationCallback() {
				public void receivedStatus(OperationStatus val) {
					if(val instanceof CASOperationStatus) {
						rv.set(((CASOperationStatus)val).getCASResponse());
					} else if(val instanceof CancelledOperationStatus) {
						rv.set(CASResponse.CANCELED);
					} else {
						rv.set(CASResponse.UNDEFINED);
					}
				}
				public void complete() {
					latch.countDown();
				}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:38,代码来源:MemcachedClient.java


示例15: getVersions

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * Get the versions of all of the connected memcacheds.
 *
 * @return a Map of SocketAddress to String for connected servers
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Map<SocketAddress, String> getVersions() {
	final Map<SocketAddress, String>rv=
		new ConcurrentHashMap<SocketAddress, String>();

	CountDownLatch blatch = broadcastOp(new BroadcastOpFactory(){
		public Operation newOp(final MemcachedNode n,
				final CountDownLatch latch) {
			final SocketAddress sa=n.getSocketAddress();
			return opFact.version(
					new OperationCallback() {
						public void receivedStatus(OperationStatus s) {
							rv.put(sa, s.getMessage());
						}
						public void complete() {
							latch.countDown();
						}
					});
		}});
	try {
		blatch.await(operationTimeout, TimeUnit.MILLISECONDS);
	} catch (InterruptedException e) {
		throw new RuntimeException("Interrupted waiting for versions", e);
	}
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:33,代码来源:MemcachedClient.java


示例16: mutate

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
private long mutate(Mutator m, String key, int by, long def, int exp) {
	final AtomicLong rv=new AtomicLong();
	final CountDownLatch latch=new CountDownLatch(1);
	addOp(key, opFact.mutate(m, key, by, def, exp, new OperationCallback() {
				public void receivedStatus(OperationStatus s) {
					// XXX:  Potential abstraction leak.
					// The handling of incr/decr in the binary protocol
					// Allows us to avoid string processing.
					rv.set(new Long(s.isSuccess()?s.getMessage():"-1"));
				}
				public void complete() {
					latch.countDown();
				}}));
	try {
		if (!latch.await(operationTimeout, TimeUnit.MILLISECONDS)) {
			throw new OperationTimeoutException(
				"Mutate operation timed out, unable to modify counter ["
					+ key + "]");
		}
	} catch (InterruptedException e) {
		throw new RuntimeException("Interrupted", e);
	}
	getLogger().debug("Mutation returned %s", rv);
	return rv.get();
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:26,代码来源:MemcachedClient.java


示例17: asyncMutate

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
private Future<Long> asyncMutate(Mutator m, String key, int by, long def,
		int exp) {
	final CountDownLatch latch = new CountDownLatch(1);
	final OperationFuture<Long> rv = new OperationFuture<Long>(
			latch, operationTimeout);
	Operation op = addOp(key, opFact.mutate(m, key, by, def, exp,
			new OperationCallback() {
		public void receivedStatus(OperationStatus s) {
			rv.set(new Long(s.isSuccess() ? s.getMessage() : "-1"));
		}
		public void complete() {
			latch.countDown();
		}
	}));
	rv.setOperation(op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:18,代码来源:MemcachedClient.java


示例18: delete

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * Delete the given key from the cache.
 *
 * @param key the key to delete
 * @return whether or not the operation was performed
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public Future<Boolean> delete(String key) {
	final CountDownLatch latch=new CountDownLatch(1);
	final OperationFuture<Boolean> rv=new OperationFuture<Boolean>(latch,
		operationTimeout);
	DeleteOperation op=opFact.delete(key,
			new OperationCallback() {
				public void receivedStatus(OperationStatus s) {
					rv.set(s.isSuccess());
				}
				public void complete() {
					latch.countDown();
				}});
	rv.setOperation(op);
	addOp(key, op);
	return rv;
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:25,代码来源:MemcachedClient.java


示例19: waitForQueues

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
/**
 * Wait for the queues to die down.
 *
 * @param timeout the amount of time time for shutdown
 * @param unit the TimeUnit for the timeout
 * @return result of the request for the wait
 * @throws IllegalStateException in the rare circumstance where queue
 *         is too full to accept any more requests
 */
public boolean waitForQueues(long timeout, TimeUnit unit) {
	CountDownLatch blatch = broadcastOp(new BroadcastOpFactory(){
		public Operation newOp(final MemcachedNode n,
				final CountDownLatch latch) {
			return opFact.noop(
					new OperationCallback() {
						public void complete() {
							latch.countDown();
						}
						public void receivedStatus(OperationStatus s) {
							// Nothing special when receiving status, only
							// necessary to complete the interface
						}
					});
		}}, conn.getLocator().getAll(), false);
	try {
		// XXX:  Perhaps IllegalStateException should be caught here
		// and the check retried.
		return blatch.await(timeout, unit);
	} catch (InterruptedException e) {
		throw new RuntimeException("Interrupted waiting for queues", e);
	}
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:33,代码来源:MemcachedClient.java


示例20: setUp

import net.spy.memcached.ops.OperationStatus; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
	super.setUp();
	ofact = getOperationFactory();
	genericCallback = new OperationCallback() {
		public void complete() {
			fail("Unexpected invocation");
		}
		public void receivedStatus(OperationStatus status) {
			fail("Unexpected status:  " + status);
		}
	};

	testData = new byte[64];
	new Random().nextBytes(testData);
}
 
开发者ID:naver,项目名称:arcus-java-client,代码行数:17,代码来源:OperationFactoryTestBase.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultInternalAction类代码示例发布时间:2022-05-23
下一篇:
Java StAXDocumentParser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap