本文整理了Java中com.datastax.driver.core.Metadata.newTokenRange()
方法的一些代码示例,展示了Metadata.newTokenRange()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Metadata.newTokenRange()
方法的具体详情如下:
包路径:com.datastax.driver.core.Metadata
类名称:Metadata
方法名:newTokenRange
[英]Builds a new TokenRange.
[中]建立一个新的代币范围。
代码示例来源:origin: hugegraph/hugegraph
private TokenRange rangeToTokenRange(Range<Token> range) {
TokenFactory tokenFactory = this.partitioner.getTokenFactory();
Metadata metadata = this.session.metadata();
return metadata.newTokenRange(
metadata.newToken(tokenFactory.toString(range.left)),
metadata.newToken(tokenFactory.toString(range.right)));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_expose_token_and_range_creation_methods() {
Metadata metadata = cluster().getMetadata();
// Pick a random range
TokenRange range = metadata.getTokenRanges().iterator().next();
Token start = metadata.newToken(range.getStart().toString());
Token end = metadata.newToken(range.getEnd().toString());
assertThat(metadata.newTokenRange(start, end)).isEqualTo(range);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Ensures that calling {@link Metadata#newTokenRange(Token, Token)} on a Cluster that has schema
* metadata disabled will throw a {@link IllegalStateException}.
*
* @jira_ticket JAVA-858
* @since 2.0.11
*/
@Test(groups = "short", expectedExceptions = IllegalStateException.class)
public void should_throw_illegal_state_exception_on_newTokenRange_with_metadata_disabled() {
Cluster cluster =
Cluster.builder()
.addContactPoints(getContactPoints())
.withPort(ccm().getBinaryPort())
.withQueryOptions(nonDebouncingQueryOptions().setMetadataEnabled(false))
.build();
try {
cluster.init();
Token.Factory factory = Token.getFactory("Murmur3Partitioner");
Token token = factory.fromString(Long.toString(1));
cluster.getMetadata().newTokenRange(token, token);
} finally {
cluster.close();
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
assertThat(token1).isNotNull();
assertThat(token2).isNotNull();
assertThat(schemaDisabledCluster.getMetadata().newTokenRange(token1, token2)).isNotNull();
代码示例来源:origin: jsevellec/cassandra-unit
private TokenRange rangeToTokenRange(Metadata metadata, Range<Token> range)
{
return metadata.newTokenRange(metadata.newToken(partitioner.getTokenFactory().toString(range.left)),
metadata.newToken(partitioner.getTokenFactory().toString(range.right)));
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
private TokenRange rangeToTokenRange(Metadata metadata, Range<Token> range)
{
return metadata.newTokenRange(metadata.newToken(partitioner.getTokenFactory().toString(range.left)),
metadata.newToken(partitioner.getTokenFactory().toString(range.right)));
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
private TokenRange rangeToTokenRange(Metadata metadata, Range<Token> range)
{
return metadata.newTokenRange(metadata.newToken(partitioner.getTokenFactory().toString(range.left)),
metadata.newToken(partitioner.getTokenFactory().toString(range.right)));
}
代码示例来源:origin: com.baidu.hugegraph/hugegraph-cassandra
private TokenRange rangeToTokenRange(Range<Token> range) {
TokenFactory tokenFactory = this.partitioner.getTokenFactory();
Metadata metadata = this.session.metadata();
return metadata.newTokenRange(
metadata.newToken(tokenFactory.toString(range.left)),
metadata.newToken(tokenFactory.toString(range.right)));
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
@Test(groups = "short")
public void should_expose_token_and_range_creation_methods() {
Metadata metadata = cluster().getMetadata();
// Pick a random range
TokenRange range = metadata.getTokenRanges().iterator().next();
Token start = metadata.newToken(range.getStart().toString());
Token end = metadata.newToken(range.getEnd().toString());
assertThat(metadata.newTokenRange(start, end)).isEqualTo(range);
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
/**
* Ensures that calling {@link Metadata#newTokenRange(Token, Token)} on a Cluster that has schema
* metadata disabled will throw a {@link IllegalStateException}.
*
* @jira_ticket JAVA-858
* @since 2.0.11
*/
@Test(groups = "short", expectedExceptions = IllegalStateException.class)
public void should_throw_illegal_state_exception_on_newTokenRange_with_metadata_disabled() {
Cluster cluster =
Cluster.builder()
.addContactPoints(getContactPoints())
.withPort(ccm().getBinaryPort())
.withQueryOptions(nonDebouncingQueryOptions().setMetadataEnabled(false))
.build();
try {
cluster.init();
Token.Factory factory = Token.getFactory("Murmur3Partitioner");
Token token = factory.fromString(Long.toString(1));
cluster.getMetadata().newTokenRange(token, token);
} finally {
cluster.close();
}
}
代码示例来源:origin: com.datastax.dse/dse-java-driver-core
assertThat(token1).isNotNull();
assertThat(token2).isNotNull();
assertThat(schemaDisabledCluster.getMetadata().newTokenRange(token1, token2)).isNotNull();
内容来源于网络,如有侵权,请联系作者删除!