本文整理了Java中com.datastax.driver.core.Cluster.getConfiguration()
方法的一些代码示例,展示了Cluster.getConfiguration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cluster.getConfiguration()
方法的具体详情如下:
包路径:com.datastax.driver.core.Cluster
类名称:Cluster
方法名:getConfiguration
[英]The cluster configuration.
[中]群集配置。
代码示例来源:origin: apache/storm
private MappingManager getMappingManager(Session session) {
synchronized (mappingManagers) {
MappingManager mappingManager = mappingManagers.get(session);
if (mappingManager == null) {
mappingManager = new MappingManager(session);
mappingManagers.put(session, mappingManager);
CodecRegistry codecRegistry = session.getCluster().getConfiguration().getCodecRegistry();
for (TypeCodec<?> codec : codecs) {
codecRegistry.register(codec);
}
for (Class<?> udtClass : udtClasses) {
mappingManager.udtCodec(udtClass);
}
}
return mappingManager;
}
}
}
代码示例来源:origin: prestodb/presto
private <T> T executeWithSession(SessionCallable<T> sessionCallable)
{
ReconnectionPolicy reconnectionPolicy = cluster.getConfiguration().getPolicies().getReconnectionPolicy();
ReconnectionSchedule schedule = reconnectionPolicy.newSchedule();
long deadline = System.currentTimeMillis() + noHostAvailableRetryTimeout.toMillis();
while (true) {
try {
return sessionCallable.executeWithSession(session.get());
}
catch (NoHostAvailableException e) {
long timeLeft = deadline - System.currentTimeMillis();
if (timeLeft <= 0) {
throw e;
}
else {
long delay = Math.min(schedule.nextDelayMs(), timeLeft);
log.warn(e.getCustomMessage(10, true, true));
log.warn("Reconnecting in %dms", delay);
try {
Thread.sleep(delay);
}
catch (InterruptedException interrupted) {
Thread.currentThread().interrupt();
throw new RuntimeException("interrupted", interrupted);
}
}
}
}
}
代码示例来源:origin: apache/storm
public void prepare() {
LOG.info("Preparing state for {}", options.toString());
Preconditions.checkNotNull(options.getMapper, "CassandraBackingMap.Options should have getMapper");
Preconditions.checkNotNull(options.putMapper, "CassandraBackingMap.Options should have putMapper");
client = options.clientProvider.getClient(conf);
session = client.connect();
if (options.maxParallelism == null || options.maxParallelism <= 0) {
PoolingOptions po = session.getCluster().getConfiguration().getPoolingOptions();
Integer maxRequestsPerHost = Math.min(
po.getMaxConnectionsPerHost(HostDistance.LOCAL) * po.getMaxRequestsPerConnection(HostDistance.LOCAL),
po.getMaxConnectionsPerHost(HostDistance.REMOTE) * po.getMaxRequestsPerConnection(HostDistance.REMOTE)
);
options.maxParallelism = maxRequestsPerHost / 2;
LOG.info("Parallelism default set to {}", options.maxParallelism);
}
throttle = new Semaphore(options.maxParallelism, false);
this.getResultMapper = new TridentAyncCQLResultSetValuesMapper(options.stateMapper.getStateFields(), throttle);
this.putResultMapper = new TridentAyncCQLResultSetValuesMapper(null, throttle);
}
代码示例来源:origin: apache/nifi
@OnScheduled
public void onScheduled(final ProcessContext context) {
super.onScheduled(context);
final int fetchSize = context.getProperty(FETCH_SIZE).evaluateAttributeExpressions().asInteger();
if (fetchSize > 0) {
synchronized (cluster.get()) {
cluster.get().getConfiguration().getQueryOptions().setFetchSize(fetchSize);
}
}
}
代码示例来源:origin: apache/usergrid
@Inject
public DataStaxClusterImpl(final CassandraConfig cassandraFig ) throws Exception {
this.cassandraConfig = cassandraFig;
this.cluster = getCluster();
logger.info("Initialized datastax cluster client. Hosts={}, Idle Timeout={}s, Pool Timeout={}s",
getCluster().getMetadata().getAllHosts().toString(),
getCluster().getConfiguration().getPoolingOptions().getIdleTimeoutSeconds(),
getCluster().getConfiguration().getPoolingOptions().getPoolTimeoutMillis() / 1000);
// always initialize the keyspaces
this.createApplicationKeyspace(false);
this.createApplicationLocalKeyspace(false);
}
代码示例来源:origin: kaaproject/kaa
.getConfiguration()
.getCodecRegistry()
.register(instance);
代码示例来源:origin: brianfrankcooper/YCSB
MAX_CONNECTIONS_PROPERTY);
if (maxConnections != null) {
cluster.getConfiguration().getPoolingOptions()
.setMaxConnectionsPerHost(HostDistance.LOCAL,
Integer.valueOf(maxConnections));
CORE_CONNECTIONS_PROPERTY);
if (coreConnections != null) {
cluster.getConfiguration().getPoolingOptions()
.setCoreConnectionsPerHost(HostDistance.LOCAL,
Integer.valueOf(coreConnections));
CONNECT_TIMEOUT_MILLIS_PROPERTY);
if (connectTimoutMillis != null) {
cluster.getConfiguration().getSocketOptions()
.setConnectTimeoutMillis(Integer.valueOf(connectTimoutMillis));
READ_TIMEOUT_MILLIS_PROPERTY);
if (readTimoutMillis != null) {
cluster.getConfiguration().getSocketOptions()
.setReadTimeoutMillis(Integer.valueOf(readTimoutMillis));
代码示例来源:origin: jooby-project/jooby
Configuration configuration = cluster.getConfiguration();
CodecRegistry codecRegistry = configuration.getCodecRegistry();
代码示例来源:origin: apache/nifi
newCluster.getConfiguration().getQueryOptions().setConsistencyLevel(ConsistencyLevel.valueOf(consistencyLevel));
Metadata metadata = newCluster.getMetadata();
代码示例来源:origin: apache/nifi
newSession = newCluster.connect();
newCluster.getConfiguration().getQueryOptions().setConsistencyLevel(ConsistencyLevel.valueOf(consistencyLevel));
Metadata metadata = newCluster.getMetadata();
log.info("Connected to Cassandra cluster: {}", new Object[]{metadata.getClusterName()});
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private ProtocolVersion protocolVersion() {
// Since the QueryLogger can be registered before the Cluster was initialized, we can't retrieve
// it at construction time. Cache it field at first use (a volatile field is good enough since
// we
// don't need mutual exclusion).
if (protocolVersion == null) {
protocolVersion = cluster.getConfiguration().getProtocolOptions().getProtocolVersion();
// At least one connection was established when QueryLogger is invoked
assert protocolVersion != null : "protocol version should be defined";
}
return protocolVersion;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Override
public void init(Cluster cluster) {
childPolicy.init(cluster);
queryOptions = cluster.getConfiguration().getQueryOptions();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@BeforeMethod(groups = "unit")
public void setUpQueryBuilder() throws Exception {
CodecRegistry codecRegistry = new CodecRegistry();
cluster = mock(Cluster.class);
Configuration configuration = mock(Configuration.class);
ProtocolOptions protocolOptions = mock(ProtocolOptions.class);
when(cluster.getConfiguration()).thenReturn(configuration);
when(configuration.getCodecRegistry()).thenReturn(codecRegistry);
when(configuration.getProtocolOptions()).thenReturn(protocolOptions);
when(protocolOptions.getProtocolVersion()).thenReturn(ProtocolVersion.NEWEST_SUPPORTED);
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_set_flag_on_successful_agreement() {
ProtocolOptions protocolOptions = cluster().getConfiguration().getProtocolOptions();
protocolOptions.maxSchemaAgreementWaitSeconds = 10;
ResultSet rs = session().execute(String.format(CREATE_TABLE, COUNTER.getAndIncrement()));
assertThat(rs.getExecutionInfo().isSchemaInAgreement()).isTrue();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short", priority = 1)
public void should_unset_flag_on_failed_agreement() {
// Setting to 0 results in no query being set, so agreement fails
ProtocolOptions protocolOptions = cluster().getConfiguration().getProtocolOptions();
protocolOptions.maxSchemaAgreementWaitSeconds = 0;
ResultSet rs = session().execute(String.format(CREATE_TABLE, COUNTER.getAndIncrement()));
assertThat(rs.getExecutionInfo().isSchemaInAgreement()).isFalse();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@Test(groups = "short")
public void should_set_flag_on_non_schema_altering_statement() {
ProtocolOptions protocolOptions = cluster().getConfiguration().getProtocolOptions();
protocolOptions.maxSchemaAgreementWaitSeconds = 10;
ResultSet rs = session().execute("select release_version from system.local");
assertThat(rs.getExecutionInfo().isSchemaInAgreement()).isTrue();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public void checkGetValuesReturnsSerializedValue(
ProtocolVersion protocolVersion, SimpleStatement statement, TestTable table) {
CodecRegistry codecRegistry = cluster().getConfiguration().getCodecRegistry();
ByteBuffer[] values = statement.getValues(protocolVersion, codecRegistry);
assertThat(values.length).isEqualTo(1);
assertThat(values[0])
.as("Value not serialized as expected for " + table.sampleValue)
.isEqualTo(
codecRegistry
.codecFor(table.testColumnType)
.serialize(table.sampleValue, protocolVersion));
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/** @jira_ticket JAVA-1209 */
@Test(groups = "short")
public void getProtocolVersion_should_return_version() throws InterruptedException {
ProtocolVersion version =
cluster().getConfiguration().getProtocolOptions().getProtocolVersion();
assertThat(version).isNotNull();
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/** @jira_ticket JAVA-1209 */
@Test(groups = "unit")
public void getProtocolVersion_should_return_null_if_not_connected() {
Cluster cluster = Cluster.builder().addContactPoint("127.0.0.1").build();
assertThat(cluster.getConfiguration().getProtocolOptions().getProtocolVersion()).isNull();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
@BeforeMethod(groups = "short")
public void setup() {
primingClient.prime(
queryBuilder().withQuery(query).withThen(then().withFixedDelay(100L)).build());
// Set default timeout too low
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(10);
}
内容来源于网络,如有侵权,请联系作者删除!