Codota Logo
Cluster$Builder.addContactPoints
Code IndexAdd Codota to your IDE (free)

How to use
addContactPoints
method
in
com.datastax.driver.core.Cluster$Builder

Best Java code snippets using com.datastax.driver.core.Cluster$Builder.addContactPoints (Showing top 20 results out of 639)

Refine searchRefine arrow

  • Cluster.Builder.withPort
  • Cluster.Builder.build
  • Cluster.builder
  • Common ways to obtain Cluster$Builder
private void myMethod () {
Cluster$Builder c =
  • Codota IconCluster.builder()
  • Smart code suggestions by Codota
}
origin: brianfrankcooper/YCSB

 cluster = Cluster.builder().withCredentials(username, password)
   .withPort(Integer.valueOf(port)).addContactPoints(hosts).build();
} else {
 cluster = Cluster.builder().withPort(Integer.valueOf(port))
   .addContactPoints(hosts).build();
origin: jooby-project/jooby

  .addContactPoints(cstr.contactPoints())
  .withPort(cstr.port());
Cluster cluster = builder.build();
origin: pulsarIO/realtime-analytics

private void startUp() {
  int port = 9042;
  String[] seeds;
  if (configuration.containsKey(CONTACT_POINTS)) {
    seeds = configuration.get(CONTACT_POINTS).split(",");
  } else {
    seeds = new String[] {LOCALHOST};
  }
  Cluster cluster = new Cluster.Builder()
    .addContactPoints(seeds)
    .withPort(port)
    .build();
  String keySpace = configuration.get(KEY_SPACE);
  if (keySpace == null || keySpace.isEmpty()) {
    keySpace=DEFAULT_KEYSPACE;
  }
  session = Optional.of(cluster.connect(keySpace));
  dataAccess = new DataAccess(session.get());
}
origin: kaaproject/kaa

@Override
protected void load() {
 String hostIp = EmbeddedCassandraServerHelper.getHost();
 int port = EmbeddedCassandraServerHelper.getNativeTransportPort();
 cluster = new Cluster.Builder().addContactPoints(hostIp).withPort(port).withSocketOptions(getSocketOptions())
   .build();
 session = cluster.connect();
 CQLDataLoader dataLoader = new CQLDataLoader(session);
 dataLoader.load(dataSet);
 session = dataLoader.getSession();
}
origin: com.datastax.cassandra/cassandra-driver-core

protected void initTestCluster(Object testInstance) throws Exception {
 if (ccmTestConfig.createCcm() && ccmTestConfig.createCluster()) {
  Cluster.Builder builder = ccmTestConfig.clusterProvider(testInstance);
  // add contact points only if the provided builder didn't do so
  if (builder.getContactPoints().isEmpty()) builder.addContactPoints(getContactPoints());
  builder.withPort(ccm.getBinaryPort());
  cluster = register(builder.build());
  cluster.init();
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

protected void resetTestSession() throws Exception {
 session.close();
 Cluster.Builder builder = ccmTestConfig.clusterProvider(this);
 // add contact points only if the provided builder didn't do so
 if (builder.getContactPoints().isEmpty()) builder.addContactPoints(getContactPoints());
 builder.withPort(ccm.getBinaryPort());
 cluster = register(builder.build());
 cluster.init();
 session.close();
 session = register(cluster.connect());
 useKeyspace(session, keyspace);
}
origin: com.datastax.cassandra/cassandra-driver-core

public void useNamedValuesWithProtocol(ProtocolVersion version) {
 Cluster vCluster =
   createClusterBuilder()
     .addContactPoints(getContactPoints())
     .withPort(ccm().getBinaryPort())
     .withProtocolVersion(version)
     .build();
 try {
  Session vSession = vCluster.connect(this.keyspace);
  // Given - A simple statement with named parameters.
  SimpleStatement statement =
    new SimpleStatement(
      "SELECT * FROM users WHERE id = :id", ImmutableMap.<String, Object>of("id", 1));
  // When - Executing that statement against a Cluster instance using Protocol Version V2.
  vSession.execute(statement).one();
  // Then - Should throw an UnsupportedFeatureException
 } finally {
  vCluster.close();
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

Cluster cluster =
  builder()
    .addContactPoints(sCluster.address(1, 1).getAddress())
    .withPort(sCluster.getBinaryPort())
    .withLoadBalancingPolicy(
      DCAwareRoundRobinPolicy.builder().withLocalDc(datacenter(1)).build())
    .build();
try {
 sCluster.init();
origin: com.datastax.cassandra/cassandra-driver-core

Cluster cluster =
  builder()
    .addContactPoints(sCluster.address(1, 1).getAddress())
    .withPort(sCluster.getBinaryPort())
    .withLoadBalancingPolicy(policy)
    .build();
origin: prestodb/presto

  public TestHost(InetSocketAddress address)
  {
    super(address, new ConvictionPolicy.DefaultConvictionPolicy.Factory(), Cluster.builder().addContactPoints("localhost").build().manager);
  }
}
origin: apache/usergrid

  .setMetadataEnabled(true); // choose whether to have the driver store metadata such as schema info
Cluster.Builder datastaxCluster = Cluster.builder()
  .withClusterName(cassandraConfig.getClusterName())
  .addContactPoints(cassandraConfig.getHosts().split(","))
  .withMaxSchemaAgreementWaitSeconds(45)
  .withCompression(ProtocolOptions.Compression.LZ4)
return datastaxCluster.build();
origin: apache/ignite

  return ses;
Cluster.Builder builder = Cluster.builder();
  builder = builder.withPort(port);
  builder = builder.addContactPoints(contactPoints);
origin: apache/storm

CassandraConf cassandraConf = new CassandraConf(topoConf);
Cluster.Builder cluster = Cluster.builder()
                 .withoutJMXReporting()
                 .withoutMetrics()
                 .addContactPoints(cassandraConf.getNodes())
                 .withPort(cassandraConf.getPort())
                 .withRetryPolicy(cassandraConf.getRetryPolicy())
                 .withReconnectionPolicy(new ExponentialReconnectionPolicy(
cluster.withPoolingOptions(poolOps);
return cluster.build();
origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Tests the NoHostAvailableException. by attempting to build a cluster using the IP address
 * "255.255.255.255" and test all available exception methods.
 */
@Test(groups = "short")
public void noHostAvailableException() throws Exception {
 try {
  Cluster.builder().addContactPoints("255.255.255.255").build();
 } catch (NoHostAvailableException e) {
  assertEquals(e.getErrors().size(), 1);
  assertTrue(
    e.getErrors()
      .values()
      .iterator()
      .next()
      .toString()
      .contains("[/255.255.255.255] Cannot connect"));
  NoHostAvailableException copy = (NoHostAvailableException) e.copy();
  assertEquals(copy.getMessage(), e.getMessage());
  assertEquals(copy.getErrors(), e.getErrors());
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Validates that when a Cluster is initialized that {@link
 * SpeculativeExecutionPolicy#init(Cluster)} is called and that when a Cluster is closed {@link
 * SpeculativeExecutionPolicy#close()} is called.
 *
 * @test_category queries:speculative_execution
 * @expected_result init and close are called on cluster init and close.
 * @jira_ticket JAVA-796
 * @since 2.0.11, 2.1.7, 2.2.1
 */
@Test(groups = "short")
public void should_init_and_close_policy_on_cluster() {
 SpeculativeExecutionPolicy mockPolicy = mock(SpeculativeExecutionPolicy.class);
 Cluster cluster =
   Cluster.builder()
     .addContactPoints(scassandras.address(2).getAddress())
     .withPort(scassandras.getBinaryPort())
     .withSpeculativeExecutionPolicy(mockPolicy)
     .build();
 verify(mockPolicy, times(0)).init(cluster);
 verify(mockPolicy, times(0)).close();
 try {
  cluster.init();
  verify(mockPolicy, times(1)).init(cluster);
 } finally {
  cluster.close();
  verify(mockPolicy, times(1)).close();
 }
}
origin: com.datastax.cassandra/cassandra-driver-core

Cluster cluster =
  register(
    Cluster.builder()
      .addContactPoints(getContactPoints())
      .withPort(ccm().getBinaryPort())
      .withCodecRegistry(codecRegistry)
      .build());
Session session = cluster.connect(keyspace);
setUpTupleTypes(cluster);
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void testMissingRpcAddressAtStartup() throws Exception {
 deleteNode2RpcAddressFromNode1();
 // Use only one contact point to make sure that the control connection is on node1
 Cluster cluster =
   register(
     Cluster.builder()
       .addContactPoints(getContactPoints().get(0))
       .withPort(ccm().getBinaryPort())
       .build());
 cluster.connect();
 // Since node2's RPC address is unknown on our control host, it should have been ignored
 assertEquals(cluster.getMetrics().getConnectedToHosts().getValue().intValue(), 1);
 assertNull(cluster.getMetadata().getHost(getContactPointsWithPorts().get(1)));
}
origin: com.datastax.cassandra/cassandra-driver-core

Cluster cluster =
  register(
    Cluster.builder()
      .addContactPoints(getContactPoints())
      .withPort(ccm().getBinaryPort())
      .withCodecRegistry(codecRegistry)
      .build());
Session session = cluster.connect(keyspace);
setUpTupleTypes(cluster);
origin: com.datastax.cassandra/cassandra-driver-core

Cluster cluster =
  register(
    Cluster.builder()
      .addContactPoints(getContactPoints())
      .withPort(ccm().getBinaryPort())
      .withCodecRegistry(codecRegistry)
      .build());
Session session = cluster.connect(keyspace);
setUpUserTypes(cluster);
origin: com.datastax.cassandra/cassandra-driver-core

@Test(groups = "short")
public void should_connect_with_credentials() {
 PlainTextAuthProvider authProvider = spy(new PlainTextAuthProvider("cassandra", "cassandra"));
 Cluster cluster =
   Cluster.builder()
     .addContactPoints(getContactPoints())
     .withPort(ccm().getBinaryPort())
     .withAuthProvider(authProvider)
     .build();
 cluster.connect();
 verify(authProvider, atLeastOnce())
   .newAuthenticator(
     findHost(cluster, 1).getSocketAddress(),
     "org.apache.cassandra.auth.PasswordAuthenticator");
 assertThat(cluster.getMetrics().getErrorMetrics().getAuthenticationErrors().getCount())
   .isEqualTo(0);
}
com.datastax.driver.coreCluster$BuilderaddContactPoints

Javadoc

Adds contact points.

See Builder#addContactPoint for more details on contact points.

Popular methods of Cluster$Builder

  • build
    Builds the cluster with the configured set of initial contact points and policies. This is a conveni
  • withPort
    The port to use to connect to the Cassandra host. If not set through this method, the default port (
  • addContactPoint
    Adds a contact point - or many if the given address resolves to multiple InetAddresss (A records). C
  • withCredentials
    Uses the provided credentials when connecting to Cassandra hosts. This should be used if the Cassand
  • withLoadBalancingPolicy
    Configures the load balancing policy to use for the new cluster. If no load balancing policy is set
  • withSocketOptions
    Sets the SocketOptions to use for the newly created Cluster. If no socket options are set through th
  • withPoolingOptions
    Sets the PoolingOptions to use for the newly created Cluster. If no pooling options are set through
  • withQueryOptions
    Sets the QueryOptions to use for the newly created Cluster. If no query options are set through this
  • withReconnectionPolicy
    Configures the reconnection policy to use for the new cluster. If no reconnection policy is set thro
  • withSSL
    Enable the use of SSL for the created Cluster using the provided options.
  • withRetryPolicy
    Configures the retry policy to use for the new cluster. If no retry policy is set through this metho
  • withCompression
    Sets the compression to use for the transport.
  • withRetryPolicy,
  • withCompression,
  • withClusterName,
  • withoutJMXReporting,
  • withProtocolVersion,
  • addContactPointsWithPorts,
  • <init>,
  • withAuthProvider,
  • withoutMetrics

Popular in Java

  • Start an intent from android
  • getContentResolver (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • findViewById (Activity)
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JFileChooser (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now