public RetryPolicy getRetryPolicy() { if (this.retryPolicyName.equals(DowngradingConsistencyRetryPolicy.class.getSimpleName())) { return new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); } if (this.retryPolicyName.equals(FallthroughRetryPolicy.class.getSimpleName())) { return FallthroughRetryPolicy.INSTANCE; } if (this.retryPolicyName.equals(DefaultRetryPolicy.class.getSimpleName())) { return DefaultRetryPolicy.INSTANCE; } throw new IllegalArgumentException("Unknown cassandra retry policy " + this.retryPolicyName); }
retryPolicy = new LoggingRetryPolicy(retryPolicy);
@Test(groups = "short") public void should_call_init_method_on_inner_policy() { RetryPolicy innerPolicyMock = Mockito.mock(RetryPolicy.class); new LoggingRetryPolicy(innerPolicyMock).init(cluster); Mockito.verify(innerPolicyMock).init(cluster); }
@Test(groups = "unit") public void should_call_close_method_on_inner_policy() { RetryPolicy innerPolicyMock = Mockito.mock(RetryPolicy.class); new LoggingRetryPolicy(innerPolicyMock).close(); Mockito.verify(innerPolicyMock).close(); }
@BeforeClass(groups = {"short", "unit"}) public void setUpRetryPolicy() { setRetryPolicy(new LoggingRetryPolicy(new CustomRetryPolicy())); }
public RetryPolicy getRetryPolicy() { if(this.retryPolicyName.equals(DowngradingConsistencyRetryPolicy.class.getSimpleName())) return new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); if(this.retryPolicyName.equals(FallthroughRetryPolicy.class.getSimpleName())) return FallthroughRetryPolicy.INSTANCE; if(this.retryPolicyName.equals(DefaultRetryPolicy.class.getSimpleName())) return DefaultRetryPolicy.INSTANCE; throw new IllegalArgumentException("Unknown cassandra retry policy " + this.retryPolicyName); }
@Override public RetryPolicy build() { return new LoggingRetryPolicy(subPolicy.build()); } }
@Override public RetryPolicy build() { return new LoggingRetryPolicy(subPolicy.build()); } }
private Builder populateRetrytPolicy(Map<String, String> properties, Builder builder) throws DataServiceFault { String retryPolicy = properties.get(DBConstants.Cassandra.RETRY_POLICY); if (retryPolicy != null) { if ("DefaultRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE); } else if ("DowngradingConsistencyRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); } else if ("FallthroughRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(FallthroughRetryPolicy.INSTANCE); } else if ("LoggingDefaultRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)); } else if ("LoggingDowngradingConsistencyRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)); } else if ("LoggingFallthroughRetryPolicy".equals(retryPolicy)) { builder = builder.withRetryPolicy(new LoggingRetryPolicy(FallthroughRetryPolicy.INSTANCE)); } else { throw new DataServiceFault("Invalid Cassandra retry policy: " + retryPolicy); } } return builder; }
private Cluster.Builder populateRetrytPolicy(Properties properties, Cluster.Builder builder) { String retryPolicy = properties.getProperty(CassandraStoreParameters.RETRY_POLICY); if (retryPolicy != null) { switch (retryPolicy) { case "DefaultRetryPolicy": builder = builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE); break; case "DowngradingConsistencyRetryPolicy": builder = builder.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); break; case "FallthroughRetryPolicy": builder = builder.withRetryPolicy(FallthroughRetryPolicy.INSTANCE); break; case "LoggingDefaultRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)); break; case "LoggingDowngradingConsistencyRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)); break; case "LoggingFallthroughRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(FallthroughRetryPolicy.INSTANCE)); break; default: LOG.error("Unsupported retry policy : {} ", retryPolicy); break; } } return builder; }
private Cluster.Builder populateRetrytPolicy(Properties properties, Cluster.Builder builder) { String retryPolicy = properties.getProperty(CassandraStoreParameters.RETRY_POLICY); if (retryPolicy != null) { switch (retryPolicy) { case "DefaultRetryPolicy": builder = builder.withRetryPolicy(DefaultRetryPolicy.INSTANCE); break; case "DowngradingConsistencyRetryPolicy": builder = builder.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE); break; case "FallthroughRetryPolicy": builder = builder.withRetryPolicy(FallthroughRetryPolicy.INSTANCE); break; case "LoggingDefaultRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)); break; case "LoggingDowngradingConsistencyRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)); break; case "LoggingFallthroughRetryPolicy": builder = builder.withRetryPolicy(new LoggingRetryPolicy(FallthroughRetryPolicy.INSTANCE)); break; default: LOG.error("Unsupported retry policy : {} ", retryPolicy); break; } } return builder; }
@Test(groups = "short") public void should_call_init_method_on_inner_policy() { RetryPolicy innerPolicyMock = Mockito.mock(RetryPolicy.class); new LoggingRetryPolicy(innerPolicyMock).init(cluster); Mockito.verify(innerPolicyMock).init(cluster); }
@Test(groups = "unit") public void should_call_close_method_on_inner_policy() { RetryPolicy innerPolicyMock = Mockito.mock(RetryPolicy.class); new LoggingRetryPolicy(innerPolicyMock).close(); Mockito.verify(innerPolicyMock).close(); }
/** * Creates a {@link SessionManager} instance. Sub-class my override this * method to customized its own {@link SessionManager}. * * @return */ protected SessionManager createSessionManager() { SessionManager sm = new SessionManager(); // sm.setRetryPolicy(new // LoggingRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)); sm.setRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)); sm.setSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(10000, 3)); sm.init(); return sm; }
@BeforeClass(groups = {"short", "unit"}) public void setUpRetryPolicy() { setRetryPolicy(new LoggingRetryPolicy(new CustomRetryPolicy())); }
.withCredentialsObfuscated(this.cachedStorageUsername, this.cachedStoragePassword).withPort(port) .withLoadBalancingPolicy(getLoadBalancingPolicy()) .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)).withCompression( ProtocolOptions.Compression.NONE).build();
.withLoadBalancingPolicy(loadBalancingPolicy) .withSocketOptions(socketOptions) .withRetryPolicy(new LoggingRetryPolicy(retryPolicy)) .withCompression(ProtocolOptions.Compression.valueOf(cassandra.getCompression())) .withPort(cassandra.getPort())