本文整理汇总了Java中com.datastax.driver.core.Cluster.Builder.withProtocolVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.withProtocolVersion方法的具体用法?Java Builder.withProtocolVersion怎么用?Java Builder.withProtocolVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.Cluster.Builder
的用法示例。
在下文中一共展示了Builder.withProtocolVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.datastax.driver.core.Cluster.Builder; //导入方法依赖的package包/类
@Override
public Cluster create(CassandraServiceInfo serviceInfo,
ServiceConnectorConfig serviceConnectorConfig) {
Builder builder = Cluster.builder()
.addContactPoints(serviceInfo.getContactPoints().toArray(new String[0]))
.withPort(serviceInfo.getPort());
if (StringUtils.hasText(serviceInfo.getUsername())) {
builder.withCredentials(serviceInfo.getUsername(), serviceInfo.getPassword());
}
if (serviceConnectorConfig instanceof CassandraClusterConfig) {
CassandraClusterConfig config = (CassandraClusterConfig) serviceConnectorConfig;
if (config.getCompression() != null) {
builder.withCompression(config.getCompression());
}
builder.withPoolingOptions(config.getPoolingOptions());
builder.withSocketOptions(config.getSocketOptions());
builder.withQueryOptions(config.getQueryOptions());
builder.withNettyOptions(config.getNettyOptions());
builder.withLoadBalancingPolicy(config.getLoadBalancingPolicy());
builder.withReconnectionPolicy(config.getReconnectionPolicy());
builder.withRetryPolicy(config.getRetryPolicy());
builder.withProtocolVersion(config.getProtocolVersion());
if (!config.isMetricsEnabled()) {
builder.withoutMetrics();
}
if (!config.isJmxReportingEnabled()) {
builder.withoutJMXReporting();
}
}
return builder.build();
}
示例2: populateSettings
import com.datastax.driver.core.Cluster.Builder; //导入方法依赖的package包/类
private Builder populateSettings(Builder builder, Map<String, String> properties) throws DataServiceFault {
String serversParam = properties.get(DBConstants.Cassandra.CASSANDRA_SERVERS);
String[] servers = serversParam.split(",");
for (String server : servers) {
builder = builder.addContactPoint(server);
}
String portProp = properties.get(DBConstants.Cassandra.PORT);
if (portProp != null) {
builder = builder.withPort(Integer.parseInt(portProp));
}
String clusterNameProp = properties.get(DBConstants.Cassandra.CLUSTER_NAME);
if (clusterNameProp != null) {
builder = builder.withClusterName(clusterNameProp);
}
String compressionProp = properties.get(DBConstants.Cassandra.COMPRESSION);
if (compressionProp != null) {
builder = builder.withCompression(Compression.valueOf(compressionProp));
}
builder = this.populateCredentials(properties, builder);
builder = this.populateLoadBalancingProp(properties, builder);
String enableJMXProp = properties.get(DBConstants.Cassandra.ENABLE_JMX_REPORTING);
if (enableJMXProp != null) {
if (!Boolean.parseBoolean(enableJMXProp)) {
builder = builder.withoutJMXReporting();
}
}
String enableMetricsProp = properties.get(DBConstants.Cassandra.ENABLE_METRICS);
if (enableMetricsProp != null) {
if (!Boolean.parseBoolean(enableMetricsProp)) {
builder = builder.withoutMetrics();
}
}
builder = this.populatePoolingSettings(properties, builder);
String versionProp = properties.get(DBConstants.Cassandra.PROTOCOL_VERSION);
if (versionProp != null) {
builder = builder.withProtocolVersion(ProtocolVersion.fromInt(Integer.parseInt(versionProp)));
}
builder = this.populateQueryOptions(properties, builder);
builder = this.populateReconnectPolicy(properties, builder);
builder = this.populateRetrytPolicy(properties, builder);
builder = this.populateSocketOptions(properties, builder);
String enableSSLProp = properties.get(DBConstants.Cassandra.ENABLE_SSL);
if (enableSSLProp != null) {
if (Boolean.parseBoolean(enableSSLProp)) {
builder = builder.withSSL();
}
}
return builder;
}