Package com.datastax.driver.core.Cluster

Examples of com.datastax.driver.core.Cluster.Builder


        public void createCluster() {
            erroredOut = false;
            schemaCreated = false;
            cassandraCluster = CCMBridge.create("test", 1);
            try {
                Builder builder = Cluster.builder();
                builder = configure(builder);
                cluster = builder.addContactPoints(IP_PREFIX + '1').build();
                session = cluster.connect();
            } catch (NoHostAvailableException e) {
                erroredOut = true;
                for (Map.Entry<InetSocketAddress, Throwable> entry : e.getErrors().entrySet())
                    logger.info("Error connecting to " + entry.getKey() + ": " + entry.getValue());
View Full Code Here


    _log.info("Finished parsing Cassandra configuration.");

    final String node = _configuration.getHost();
    final String username = System.getProperty(CASSANDRA_USERNAME, null);
    final String password = System.getProperty(CASSANDRA_PASSWORD, null);
    Builder clusterBuilder = Cluster.builder();

    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster...");
      _cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster: {} !", node);
View Full Code Here

  //
  //

  private Cluster connectToCluster(String node, String username,
      String password) throws Exception {
    Builder clusterBuilder = Cluster.builder().withoutMetrics();

    Cluster cluster = null;
    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster user...");
      cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster user: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster user: {} !", node);
View Full Code Here

    _log.info("Finished parsing Cassandra configuration.");

    final String node = _configuration.getHost();
    final String username = System.getProperty(CASSANDRA_USERNAME, null);
    final String password = System.getProperty(CASSANDRA_PASSWORD, null);
    Builder clusterBuilder = Cluster.builder();

    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster...");
      _cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster: {} !", node);
View Full Code Here

    _log.info("Finished parsing Cassandra configuration.");

    final String node = _configuration.getHost();
    final String username = System.getProperty(CASSANDRA_USERNAME, null);
    final String password = System.getProperty(CASSANDRA_PASSWORD, null);
    Builder clusterBuilder = Cluster.builder();

    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster...");
      _cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster: {} !", node);
View Full Code Here

        this.dataCenter.put(dataCenterName, factor);
        return this;
    }
    Cluster build() {

        Builder buildCluster = Cluster.builder().withPort(port)
                .addContactPoints(hosts.toArray(new String[0]));

        if (!user.isEmpty() && !password.isEmpty()) {
            buildCluster.withCredentials(user, password);
        }
        return buildCluster.build();
    }
View Full Code Here

  //
  //

  private Cluster connectToCluster(String node, String username,
      String password) throws Exception {
    Builder clusterBuilder = Cluster.builder().withoutMetrics();

    Cluster cluster = null;
    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster user...");
      cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster user: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster user: {} !", node);
View Full Code Here

    _log.info("Finished parsing Cassandra configuration.");

    final String node = _configuration.getHost();
    final String username = System.getProperty(CASSANDRA_USERNAME, null);
    final String password = System.getProperty(CASSANDRA_PASSWORD, null);
    Builder clusterBuilder = Cluster.builder();

    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);

      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }

      _log.debug("Building cluster...");
      _cluster = clusterBuilder.build();

      _log.info("Finished connecting to cluster: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster: {} !", node);
View Full Code Here

        {
            logger.debug("Intiatilzing connection");
        }

        Properties connectionProperties = CassandraPropertyReader.csmd.getConnectionProperties();
        Builder connectionBuilder = Cluster.builder();

        // add host/port and AuthInfoProvider
        for (Host host : configuration.getCassandraHosts())
        {
            connectionBuilder.addContactPoint(host.getHost()).withPort(host.getPort());
            if (host.getUser() != null)
            {
                connectionBuilder.withCredentials(host.getUser(), host.getPassword());
            }
        }

        // add policy configuration
        String loadBalancingPolicy = connectionProperties.getProperty(Constants.LOADBALANCING_POLICY);
        if (!StringUtils.isBlank(loadBalancingPolicy))
        {
            LoadBalancingPolicy policy = getPolicyInstance(BalancingPolicy.getPolicy(loadBalancingPolicy),
                    connectionProperties);
            if (policy != null)
            {
                connectionBuilder.withLoadBalancingPolicy(policy);
            }
        }

        // compression
        String compression = connectionProperties.getProperty("compression");

        if (!StringUtils.isBlank(compression))
        {
            connectionBuilder.withCompression(Compression.valueOf(compression));
        }

        // ReconnectionPolicy

        String reconnectionPolicy = connectionProperties.getProperty("reconnection.policy");
        if (!StringUtils.isBlank(reconnectionPolicy))
        {
            com.datastax.driver.core.policies.ReconnectionPolicy policy = getPolicy(
                    ReconnectionPolicy.getPolicy(reconnectionPolicy), connectionProperties);

            if (policy != null)
            {
                connectionBuilder.withReconnectionPolicy(policy);
            }

        }

        // , RetryPolicy
        String retryPolicy = connectionProperties.getProperty("retry.policy");

        if (!StringUtils.isBlank(retryPolicy))
        {
            com.datastax.driver.core.policies.RetryPolicy policy = getPolicy(RetryPolicy.getPolicy(retryPolicy),
                    connectionProperties);

            if (policy != null)
            {
                connectionBuilder.withRetryPolicy(policy);
            }

        }

        // TODO::: SSLOptions? Not sure how to add it.

        // SocketOptions
        connectionBuilder.withSocketOptions(getSocketOptions(connectionProperties));

        // PoolingOptions,
        connectionBuilder.withPoolingOptions(getPoolingOptions(connectionProperties));

        // finally build cluster.
        Cluster cluster = connectionBuilder.build();

        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());
        Properties props = persistenceUnitMetadata.getProperties();
View Full Code Here

    _log.info("Finished parsing Cassandra configuration.");

    final String node = _configuration.getHost();
    final String username = System.getProperty(CASSANDRA_USERNAME, null);
    final String password = System.getProperty(CASSANDRA_PASSWORD, null);
    Builder clusterBuilder = Cluster.builder();

    try {
      _log.info("Started connecting to cluster: {} ...", node);
      _log.debug("Adding contact point...");
      clusterBuilder = clusterBuilder.addContactPoint(node);
      if (username != null && password != null) {
        _log.debug("Adding credentials...");
        clusterBuilder = clusterBuilder.withCredentials(username,
            password);
      }
      _log.debug("Building cluster...");
      _cluster = clusterBuilder.build();
      _log.info("Finished connecting to cluster: {} .", node);

    } catch (Exception e) {
      _log.error("Error connecting to cluster: {} !", node);
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.Cluster.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.