本文整理汇总了Java中com.datastax.driver.core.Cluster.Builder.addContactPoints方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.addContactPoints方法的具体用法?Java Builder.addContactPoints怎么用?Java Builder.addContactPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.Cluster.Builder
的用法示例。
在下文中一共展示了Builder.addContactPoints方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCluster
import com.datastax.driver.core.Cluster.Builder; //导入方法依赖的package包/类
protected Cluster getCluster()
{
Builder cb = Cluster.builder();
cb.addContactPoints(contactPoints);
cb.withPort(getPort());
if (getDataCenter() != null)
{
cb.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getDataCenter()));
}
enrichCluster(cb);
return cb.build();
}
示例2: open
import com.datastax.driver.core.Cluster.Builder; //导入方法依赖的package包/类
public void open() {
if ( cluster == null || session == null ) {
Builder builder = Cluster.builder();
builder.addContactPoints( hosts );
if ( user != null && pass != null && !user.isEmpty() && !pass.isEmpty() ) {
builder = builder.withCredentials( user, pass );
}
cluster = builder.build();
session = cluster.connect( keyspace );
}
}
示例3: create
import com.datastax.driver.core.Cluster.Builder; //导入方法依赖的package包/类
@Override
public DataContext create(DataContextProperties properties, ResourceFactoryRegistry resourceFactoryRegistry)
throws UnsupportedDataContextPropertiesException, ConnectionException {
final Map<String, Object> map = properties.toMap();
final Builder clusterBuilder = Cluster.builder();
final String hostname = properties.getHostname();
if (!Strings.isNullOrEmpty(hostname)) {
clusterBuilder.addContactPoints(hostname.split(","));
}
if (properties.getPort() != null) {
clusterBuilder.withPort(properties.getPort());
}
if (map.containsKey("cluster-name")) {
clusterBuilder.withClusterName((String) map.get("cluster-name"));
}
if (properties.getUsername() != null && properties.getPassword() != null) {
clusterBuilder.withCredentials(properties.getUsername(), properties.getPassword());
}
final Cluster cluster = clusterBuilder.build();
final String keySpace = getString(map.get("keyspace"), properties.getDatabaseName());
return new CassandraDataContext(cluster, keySpace, properties.getTableDefs());
}