Package com.datastax.driver.core

Examples of com.datastax.driver.core.Cluster$ConnectionReaper


    @Override
    public Persistence getPersistence(String host, String keySpace,
            ReplicaStrategy replicaStrategy, int factor) {

        if (!persistenceMap.containsKey(keySpace)) {
            Cluster cluter = Cluster.builder().addContactPoints(host).build();
            Session session = cluter.connect();
            if (!keySpace.contains(keySpace)) {
                verifyKeySpace(keySpace, cluter.connect(), replicaStrategy, factor);
                keySpaces.add(keySpace);
            }
            persistenceMap.put(keySpace, new PersistenceSimpleImpl(session,
                    keySpace));
        }
View Full Code Here


            {
                clusterName = args[1];
            }
        }

        Cluster cluster = Cluster.builder().
            addContactPoint(contact).
            withClusterName(clusterName).
            build();
        try
        {
            new Demo().runDemo(cluster);
        }
        finally
        {
            cluster.close();
        }
    }
View Full Code Here

            withClusterName(CLUSTER_NAME);

        VersionNumber expect = VersionNumber.parse(configuredCassandraVersion);
        boolean remove = true;
        boolean create = false;
        Cluster c = builder.build();
        try {
            VersionNumber ver = clusterVersion(c);
            if (ver.getMajor() == expect.getMajor() && ver.getMinor() == expect.getMinor()
                && c.getMetadata().getAllHosts().size() == Integer.parseInt(configuredNodeCount)) {
                System.out.println("Reusing previous Apache Cassandra cluster ...");
                remove = false;
            } else {
                create = true;
            }
        } catch (Throwable ignore) {
            create = true;
        } finally { c.close(); }

        if (remove) {
            System.out.println("Removing previous Apache Cassandra cluster test...");
            exec("ccm", "remove", "test");
        }
View Full Code Here

  protected abstract String getKeyspaceName();

  @Bean
  public CassandraCqlSessionFactoryBean session() throws Exception {

    Cluster cluster = cluster().getObject();

    CassandraCqlSessionFactoryBean bean = new CassandraCqlSessionFactoryBean();
    bean.setCluster(cluster);
    bean.setKeyspaceName(getKeyspaceName());
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);
View Full Code Here

        }
    }

    @Override
    public void start() {
        Cluster cluster = Cluster.builder().addContactPoint(address).build();
        Metadata metadata = cluster.getMetadata();
        LOGGER.debug("Connected to cluster: {0}", metadata.getClusterName());
        for (Host host : metadata.getAllHosts()) {
            LOGGER.debug("Datacenter: {0}; Host: {1}; Rack: {2}", host.getDatacenter(), host.getAddress(), host.getRack());
        }

        session = cluster.connect();
        try {
            session.execute("CREATE KEYSPACE modeshape WITH replication "
                            + "= {'class':'SimpleStrategy', 'replication_factor':3};");
        } catch (AlreadyExistsException e) {
        }
View Full Code Here

        QueryOptions options = new QueryOptions();
        options.setFetchSize(fetchSize);
        options.setConsistencyLevel(consistencyLevel);
        clusterBuilder.withQueryOptions(options);

        Cluster cluster = clusterBuilder.build();
        Session session = cluster.connect();
        return new CassandraSession(connectorId.toString(), session, fetchSizeForPartitionKeySelect, limitForPartitionKeySelect);
    }
View Full Code Here

          "to be able to connect to Cassandra. See ICassandraSettings#getContactPoints.");
    }

    String[] contactPointsAsArray = contactPoints.toArray(new String[contactPoints.size()]);

    Cluster cluster = Cluster.builder()
        .addContactPoints(contactPointsAsArray).build();

    return cluster;
  }
View Full Code Here

        } else {
            hostname = DEFAULT_CASSANDRA_HOST;
            cqlPort = parameters.getTyped(CASSANDRA_CQL_PORT);
        }

        final Cluster cluster = createCluster(hostname, cqlPort, parameters);

        createKeyspaceIfNeeded(cluster, keyspaceName, keyspaceDurableWrite);

        if (nativeSessionOnly) {
            REPOSITORY.addNewSessionToKeyspace(keyspaceName, cluster.connect(keyspaceName));
        } else {
            Session nativeSession = cluster.connect(keyspaceName);
            achillesParameters.put(ConfigurationParameters.NATIVE_SESSION, nativeSession);
            achillesParameters.put(ConfigurationParameters.KEYSPACE_NAME, keyspaceName);
            if (!achillesParameters.containsKey(ConfigurationParameters.FORCE_TABLE_CREATION)) {
                achillesParameters.put(ConfigurationParameters.FORCE_TABLE_CREATION, true);
            }
View Full Code Here

        // 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

TOP

Related Classes of com.datastax.driver.core.Cluster$ConnectionReaper

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.