Package com.datastax.driver.core.policies

Examples of com.datastax.driver.core.policies.ConstantReconnectionPolicy


            PoolingOptions poolingOptions = Mockito.spy(new PoolingOptions());
            cluster = Cluster.builder()
                             .addContactPoint(CCMBridge.ipOfNode(1))
                             .withPoolingOptions(poolingOptions)
                             .withLoadBalancingPolicy(loadBalancingPolicy)
                             .withReconnectionPolicy(new ConstantReconnectionPolicy(1000))
                             .build();

            Session session = cluster.connect();

            assertThat(cluster).usesControlHost(1);
View Full Code Here


    /*
     * Test the ConstantReconnectionPolicy.
     */
    @Test(groups = "long")
    public void constantReconnectionPolicyTest() throws Throwable {
        Cluster.Builder builder = Cluster.builder().withReconnectionPolicy(new ConstantReconnectionPolicy(10 * 1000));

        // Ensure that ConstantReconnectionPolicy is what we should be testing
        if (!(builder.getConfiguration().getPolicies().getReconnectionPolicy() instanceof ConstantReconnectionPolicy)) {
            fail("Set policy does not match retrieved policy.");
        }

        // Test basic getters
        ConstantReconnectionPolicy reconnectionPolicy = (ConstantReconnectionPolicy) builder.getConfiguration().getPolicies().getReconnectionPolicy();
        assertTrue(reconnectionPolicy.getConstantDelayMs() == 10 * 1000);

        // Test erroneous instantiations
        try {
            new ConstantReconnectionPolicy(-1);
            fail();
        } catch (IllegalArgumentException e) {}

        // Test nextDelays()
        ReconnectionPolicy.ReconnectionSchedule schedule = new ConstantReconnectionPolicy(10 * 1000).newSchedule();
        assertTrue(schedule.nextDelayMs() == 10000);
        assertTrue(schedule.nextDelayMs() == 10000);
        assertTrue(schedule.nextDelayMs() == 10000);
        assertTrue(schedule.nextDelayMs() == 10000);
        assertTrue(schedule.nextDelayMs() == 10000);
View Full Code Here

        if (propFile.exists()) {
          config.load(new FileReader(propFile));
        }

        cluster = Cluster.builder().addContactPoints(endpoints.toArray(new String[0]))
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE).withReconnectionPolicy(new ConstantReconnectionPolicy(2000L))
            .build();
        session = cluster.connect();
        session.execute("USE " + getKeyspaceName() + ";");
        return session;
      }
View Full Code Here

        switch (policy)
        {
        case ConstantReconnectionPolicy:
            String property = props.getProperty("constantDelayMs");
            long constantDelayMs = property != null ? new Long(property) : 0l;
            reconnectionPolicy = new ConstantReconnectionPolicy(constantDelayMs);
            break;

        case ExponentialReconnectionPolicy:
            String baseDelayMsAsStr = props.getProperty("baseDelayMs");
            String maxDelayMsAsStr = props.getProperty("maxDelayMs");
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.policies.ConstantReconnectionPolicy

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.