Package com.datastax.driver.core

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


public class CloseableLoadBalancingPolicyTest {
    @Test(groups = "short")
    public void should_be_invoked_at_shutdown() {
        CloseMonitoringPolicy policy = new CloseMonitoringPolicy(Policies.defaultLoadBalancingPolicy());
        CCMBridge ccm = null;
        Cluster cluster = null;
        try {
            ccm = CCMBridge.create("test", 1);
            cluster = Cluster.builder()
                             .addContactPoint(CCMBridge.ipOfNode(1))
                             .withLoadBalancingPolicy(policy)
                             .build();
            cluster.connect();
        } finally {
            if (cluster != null)
                cluster.close();
            if (ccm != null)
                ccm.remove();
        }
        assertThat(policy.wasClosed).isTrue();
    }
View Full Code Here


     *
     * @return Cassandra session
     * @throws Exception
     */
    private Session createCassandraSession() throws Exception {
        Cluster cluster = Cluster
            .builder()
            .addContactPoints((String[]) configuration.get(cassandraHostsOption))
            .withPort((Integer) configuration.get(cassandraPortOption))
            .withCompression(Compression.NONE)
            .withoutMetrics()
            .withCredentials((String) configuration.get(cassandraUserOption),
                (String) configuration.get(cassandraPasswordOption))
            .build();

        try {
            return cluster.connect("rhq");
        } catch (Exception e) {
            log.debug("Failed to connect to the storage cluster.", e);
            cluster.shutdown();
            throw e;
        }
    }
View Full Code Here

    @BeforeSuite
    @DeployCluster(numNodes = 1, username = RHQADMIN, password = RHQADMIN_PASSWORD, waitForSchemaAgreement = true)
    public void deployCluster() throws Exception {
        dateTimeService = new DateTimeService();

        Cluster cluster = new ClusterBuilder()
            .addContactPoints("127.0.0.1")
            .withCredentialsObfuscated(RHQADMIN, RHQADMIN_PASSWORD)
            .build();

        PoolingOptions poolingOptions = cluster.getConfiguration().getPoolingOptions();
        poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, 24);
        poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, 24);
        poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, 32);
        poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, 32);

        cluster.register(new Host.StateListener() {
            @Override
            public void onAdd(Host host) {
                log.info("host " + host + " added");
            }

            @Override
            public void onUp(Host host) {
                log.info("host " + host + " up");
            }

            @Override
            public void onDown(Host host) {
                log.info("host " + host + " down");
            }

            @Override
            public void onRemove(Host host) {
                log.info("host " + host + " removed");
            }
        });

        session = cluster.connect("rhq");
        storageSession = new StorageSession(session);
    }
View Full Code Here

    private final Log log = LogFactory.getLog(ClusterMonitorTest.class);

//    @Test
    public void monitorCluster() {
        Cluster cluster = new ClusterBuilder()
            .addContactPoints("127.0.0.1")
//            .withCredentials("cassandra", "cassandra")
            .withCredentials("rhqadmin", "rhqadmin")
            .build();

        cluster.register(new Host.StateListener() {
            @Override
            public void onAdd(Host host) {
                log.info("host " + host + " ADDED");
            }

            @Override
            public void onUp(Host host) {
                log.info("host " + host + " UP");
            }

            @Override
            public void onDown(Host host) {
                log.info("host " + host + " DOWN");
            }

            @Override
            public void onRemove(Host host) {
                log.info("host " + host + " REMOVED");
            }
        });

        Session session = cluster.connect("rhq");
        StorageSession storageSession = new StorageSession(session);

        MetricsDAO dao = new MetricsDAO(storageSession, new MetricsConfiguration());

        while (true) {
View Full Code Here

        }
    }

    private Session createSession(String[] nodes, int cqlPort) throws NoHostAvailableException {
        try {
            Cluster cluster = new ClusterBuilder().addContactPoints(nodes).withPort(cqlPort)
                .withCredentials("rhqadmin", "rhqadmin")
                .build();
            PoolingOptions poolingOptions = cluster.getConfiguration().getPoolingOptions();
            poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, 24);
            poolingOptions.setCoreConnectionsPerHost(HostDistance.REMOTE, 24);
            poolingOptions.setMaxConnectionsPerHost(HostDistance.LOCAL, 32);
            poolingOptions.setMaxConnectionsPerHost(HostDistance.REMOTE, 32);

            log.debug("Created cluster object with " + cluster.getConfiguration().getProtocolOptions().getCompression()
                + " compression.");

            return initSession(cluster);
        } catch (Exception e) {
            log.error("Failed to start simulator. Unable to create " + Session.class, e);
View Full Code Here

        schemaManager.drop();
        schemaManager.shutdown();
        schemaManager.install(new Properties());
        schemaManager.shutdown();

        Cluster cluster = new Cluster.Builder()
            .addContactPoint("127.0.0.1")
            .withCredentials("rhqadmin", "rhqadmin")
            .build();
        session = cluster.connect("rhq");

        DateTime endTime =  DateTime.now().hourOfDay().roundFloorCopy();
        DateTime startTime = endTime.minusDays(3);
        DateTime today = endTime.hourOfDay().roundFloorCopy().minusHours(endTime.hourOfDay().roundFloorCopy()
            .hourOfDay().get());
View Full Code Here

        populateRaw412Index(endTime.minusHours(1), endTime, scheduleIds(105, 123));
        populate1Hour412Index(today, today.plusHours(6), scheduleIds(105, 123));
        populate6Hour412Index(today, today.plusDays(1), scheduleIds(100, 125));


        Cluster cluster = new Cluster.Builder()
            .addContactPoint("127.0.0.1")
            .withCredentials("rhqadmin", "rhqadmin")
            .build();
        session = cluster.connect("rhq");

        schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc",
            new String[] {"127.0.0.1"}, 9042);
        schemaManager.install(new Properties());
        schemaManager.shutdown();
View Full Code Here

        schemaManager.drop();
        schemaManager.shutdown();
        schemaManager.install(properties);
        schemaManager.shutdown();

        Cluster cluster = new Cluster.Builder()
            .addContactPoint("127.0.0.1")
            .withCredentials("rhqadmin", "rhqadmin")
            .withPoolingOptions(new PoolingOptions()
                .setCoreConnectionsPerHost(HostDistance.LOCAL, 30)
                .setMaxConnectionsPerHost(HostDistance.LOCAL, 50))
            .build();
        session = cluster.connect("rhq");
        initPreparedStatements();

        DateTime endTime = DateTime.now();
        insert1HourData(numSchedules, endTime);
        insert6HourData(numSchedules, endTime);
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

  public void should_work_twice() {
    test();
  }

  private void test() {
    Cluster cluster = Cluster.builder()
        .addContactPoints("127.0.0.1")
        .withPort(9142)
        .build();
    Session session = cluster.connect("cassandra_unit_keyspace");

    ResultSet result = session.execute("select * from testCQLTable1 WHERE id=1690e8da-5bf8-49e8-9583-4dff8a570717");
    String val = result.iterator().next().getString("value");
    assertEquals("1- Cql loaded string", val);

View Full Code Here

TOP

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

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.