CassandraHostConfigurator implements Serializable { public void setClientFactoryClass(String cls) { String className = cls.contains(".") ? cls : "me.prettyprint.cassandra.connection.factory." + cls; Class<? extends HClientFactory> temp; try { temp = Class.forName(className).asSubclass(HClientFactory.class); } catch (ClassNotFoundException e) { throw new IllegalArgumentException(String.format("Unable to find '%s' class.", className), e); } catch (ClassCastException e) { throw new IllegalArgumentException("ClientFactoryClass should be extended from HClientFactory.", e); } clientFactoryClass = temp; } CassandraHostConfigurator();  CassandraHostConfigurator(String hosts); CassandraHost[] buildCassandraHosts(); void applyConfig(CassandraHost cassandraHost); void setHosts(String hosts); void setMaxActive(int maxActive); void setMaxWaitTimeWhenExhausted(long maxWaitTimeWhenExhausted); void setMaxExhaustedTimeBeforeMarkingAsDown(long maxExhaustedTimeBeforeMarkingAsDown); void setCassandraThriftSocketTimeout(int cassandraThriftSocketTimeout); boolean getRetryDownedHosts(); void setRetryDownedHosts(boolean retryDownedHosts); void setRetryDownedHostsQueueSize(int retryDownedHostsQueueSize); int getRetryDownedHostsQueueSize(); void setRetryDownedHostsDelayInSeconds(int retryDownedHostsDelayInSeconds); int getRetryDownedHostsDelayInSeconds(); static void setClockResolution(String resolutionString); HOpTimer getOpTimer(); void setOpTimer(HOpTimer opTimer); @Override String toString(); boolean getLifo(); void setLifo(boolean lifo); int getPort(); void setPort(int port); void setUseThriftFramedTransport(boolean useThriftFramedTransport); void setMaxFrameSize(int maxFrameSize); static ClockResolution getClockResolution(); static void setClockResolution(ClockResolution clockResolution); boolean getAutoDiscoverHosts(); void setAutoDiscoverHosts(boolean autoDiscoverHosts); int getAutoDiscoveryDelayInSeconds(); void setAutoDiscoveryDelayInSeconds(int autoDiscoveryDelayInSeconds); void setAutoDiscoveryDataCenter(String dataCenter); void setAutoDiscoveryDataCenter(List<String> dataCenters); List<String> getAutoDiscoveryDataCenters(); LoadBalancingPolicy getLoadBalancingPolicy(); void setLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy); int getHostTimeoutCounter(); void setHostTimeoutCounter(int hostTimeoutCounter); int getHostTimeoutWindow(); void setHostTimeoutWindow(int hostTimeoutWindow); int getHostTimeoutSuspensionDurationInSeconds(); void setHostTimeoutSuspensionDurationInSeconds(int hostTimeoutSuspensionDurationInSeconds); int getHostTimeoutUnsuspendCheckDelay(); void setHostTimeoutUnsuspendCheckDelay(int hostTimeoutUnsuspendCheckDelay); boolean getUseHostTimeoutTracker(); void setUseHostTimeoutTracker(boolean useHostTimeoutTracker); boolean getRunAutoDiscoveryAtStartup(); void setRunAutoDiscoveryAtStartup(boolean runAutoDiscoveryAtStartup); boolean getUseSocketKeepalive(); void setUseSocketKeepalive(boolean useSocketKeepalive); void setClientFactoryClass(String cls); Class<? extends HClientFactory> getClientFactoryClass(); long getMaxConnectTimeMillis(); void setMaxConnectTimeMillis(long maxConnectTimeMillis); long getMaxLastSuccessTimeMillis(); void setMaxLastSuccessTimeMillis(long maxLastSuccessTimeMillis); static final ClockResolution DEF_CLOCK_RESOLUTION; }
@Test(expected = IllegalArgumentException.class) public void testSettingNotFoundClientFactory() { CassandraHostConfigurator chc = new CassandraHostConfigurator("localhost"); chc.setClientFactoryClass("NotARealClass"); }
@Test(expected = IllegalArgumentException.class) public void testSettingInvalidExistingClassClientFactory() { CassandraHostConfigurator chc = new CassandraHostConfigurator("localhost"); chc.setClientFactoryClass(CassandraHostConfigurator.class.getCanonicalName()); }