CassandraHostConfigurator implements Serializable { public CassandraHost[] buildCassandraHosts() { if (this.hosts == null) { throw new IllegalArgumentException("Need to define at least one host in order to apply configuration."); } String[] hostVals = hosts.split(","); CassandraHost[] cassandraHosts = new CassandraHost[hostVals.length]; for (int x=0; x<hostVals.length; x++) { CassandraHost cassandraHost = this.port == CassandraHost.DEFAULT_PORT ? new CassandraHost(hostVals[x].trim()) : new CassandraHost(hostVals[x], this.port); applyConfig(cassandraHost); cassandraHosts[x] = cassandraHost; } return cassandraHosts; } 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 public void testSimpleCassandraHostSetup() { CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9170"); CassandraHost[] cassandraHosts = cassandraHostConfigurator.buildCassandraHosts(); assertEquals(1, cassandraHosts.length); }