本文整理汇总了Java中org.apache.cassandra.db.SliceByNamesReadCommand类的典型用法代码示例。如果您正苦于以下问题:Java SliceByNamesReadCommand类的具体用法?Java SliceByNamesReadCommand怎么用?Java SliceByNamesReadCommand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SliceByNamesReadCommand类属于org.apache.cassandra.db包,在下文中一共展示了SliceByNamesReadCommand类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retryDummyRead
import org.apache.cassandra.db.SliceByNamesReadCommand; //导入依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<ByteBuffer> ss = new TreeSet<ByteBuffer>();
ss.add(ByteBufferUtil.zeroByteBuffer(1));
NamesQueryFilter nqf = new NamesQueryFilter(ss);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}
示例2: retryDummyRead
import org.apache.cassandra.db.SliceByNamesReadCommand; //导入依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() {
// This is a singleton set. We need to define a comparator because SimpleDenseCellName is not
// comparable, but it doesn't have to be a useful comparator
@Override
public int compare(CellName o1, CellName o2)
{
return 0;
}
});
names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1)));
NamesQueryFilter nqf = new NamesQueryFilter(names);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}