本文整理汇总了Java中org.apache.cassandra.dht.AbstractByteOrderedPartitioner类的典型用法代码示例。如果您正苦于以下问题:Java AbstractByteOrderedPartitioner类的具体用法?Java AbstractByteOrderedPartitioner怎么用?Java AbstractByteOrderedPartitioner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractByteOrderedPartitioner类属于org.apache.cassandra.dht包,在下文中一共展示了AbstractByteOrderedPartitioner类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalKeyPartition
import org.apache.cassandra.dht.AbstractByteOrderedPartitioner; //导入依赖的package包/类
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
CTConnection conn = null;
IPartitioner partitioner = getCassandraPartitioner();
if (!(partitioner instanceof AbstractByteOrderedPartitioner))
throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");
Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
try {
// Resist the temptation to describe SYSTEM_KS. It has no ring.
// Instead, we'll create our own keyspace (or check that it exists), then describe it.
ensureKeyspaceExists(keySpaceName);
conn = pool.borrowObject(keySpaceName);
List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (TokenRange range : ranges) {
if (!NetworkUtil.hasLocalAddress(range.endpoints))
continue;
keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
}
return keyRanges;
} catch (Exception e) {
throw CassandraThriftKeyColumnValueStore.convertException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}
示例2: getLocalKeyPartition
import org.apache.cassandra.dht.AbstractByteOrderedPartitioner; //导入依赖的package包/类
@Override
public List<KeyRange> getLocalKeyPartition() throws BackendException {
CTConnection conn = null;
IPartitioner<?> partitioner = getCassandraPartitioner();
if (!(partitioner instanceof AbstractByteOrderedPartitioner))
throw new UnsupportedOperationException("getLocalKeyPartition() only supported by byte ordered partitioner.");
Token.TokenFactory tokenFactory = partitioner.getTokenFactory();
try {
conn = pool.borrowObject(keySpaceName);
List<TokenRange> ranges = conn.getClient().describe_ring(keySpaceName);
List<KeyRange> keyRanges = new ArrayList<KeyRange>(ranges.size());
for (TokenRange range : ranges) {
if (!NetworkUtil.hasLocalAddress(range.endpoints))
continue;
keyRanges.add(CassandraHelper.transformRange(tokenFactory.fromString(range.start_token), tokenFactory.fromString(range.end_token)));
}
return keyRanges;
} catch (Exception e) {
throw CassandraThriftKeyColumnValueStore.convertException(e);
} finally {
pool.returnObjectUnsafe(keySpaceName, conn);
}
}