me.prettyprint.cassandra.service
Class CassandraHostConfigurator

java.lang.Object
  extended by me.prettyprint.cassandra.service.CassandraHostConfigurator
All Implemented Interfaces:
Serializable

public final class CassandraHostConfigurator
extends Object
implements Serializable

See Also:
Serialized Form

Field Summary
static ClockResolution DEF_CLOCK_RESOLUTION
           
 
Constructor Summary
CassandraHostConfigurator()
           
CassandraHostConfigurator(String hosts)
          Creates a new CassandraHostConfigurator from the specified hosts String, formatted as host[:port][,host[:port]...].
 
Method Summary
 void applyConfig(CassandraHost cassandraHost)
           
 CassandraHost[] buildCassandraHosts()
           
 boolean getAutoDiscoverHosts()
           
 List<String> getAutoDiscoveryDataCenters()
          Retrieves the 'local' datacenter names that the DiscoveryService recognizes as valid in order to discover new hosts.
 int getAutoDiscoveryDelayInSeconds()
           
 Class<? extends HClientFactory> getClientFactoryClass()
           
static ClockResolution getClockResolution()
           
 int getHostTimeoutCounter()
           
 int getHostTimeoutSuspensionDurationInSeconds()
           
 int getHostTimeoutUnsuspendCheckDelay()
           
 int getHostTimeoutWindow()
           
 boolean getLifo()
           
 LoadBalancingPolicy getLoadBalancingPolicy()
           
 long getMaxConnectTimeMillis()
          The maximum time in milliseconds that we'll allow a connection to stay open to a host.
 long getMaxLastSuccessTimeMillis()
          The maximum time in milliseconds that we'll allow a connection to stay idle to a host.
 HOpTimer getOpTimer()
           
 int getPort()
           
 boolean getRetryDownedHosts()
           
 int getRetryDownedHostsDelayInSeconds()
           
 int getRetryDownedHostsQueueSize()
           
 boolean getRunAutoDiscoveryAtStartup()
           
 boolean getUseHostTimeoutTracker()
           
 boolean getUseSocketKeepalive()
           
 void setAutoDiscoverHosts(boolean autoDiscoverHosts)
           
 void setAutoDiscoveryDataCenter(List<String> dataCenters)
          Sets the datacenters for the DiscoveryService.
 void setAutoDiscoveryDataCenter(String dataCenter)
          Sets the local datacenter for the DiscoveryService.
 void setAutoDiscoveryDelayInSeconds(int autoDiscoveryDelayInSeconds)
           
 void setCassandraThriftSocketTimeout(int cassandraThriftSocketTimeout)
          The value (in milliseconds) which gets passed down to Socket.setSoTimeout(int) used by the underlying Thrift transport.
 void setClientFactoryClass(String cls)
           
static void setClockResolution(ClockResolution clockResolution)
          Sets this Clock for all clusters administered by Hector.
static void setClockResolution(String resolutionString)
          Sets this Clock for all clusters administered by Hector.
 void setHosts(String hosts)
          Specifies the hosts String, formatted as host[:port][,host[:port]...].
 void setHostTimeoutCounter(int hostTimeoutCounter)
           
 void setHostTimeoutSuspensionDurationInSeconds(int hostTimeoutSuspensionDurationInSeconds)
           
 void setHostTimeoutUnsuspendCheckDelay(int hostTimeoutUnsuspendCheckDelay)
           
 void setHostTimeoutWindow(int hostTimeoutWindow)
           
 void setLifo(boolean lifo)
           
 void setLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy)
           
 void setMaxActive(int maxActive)
           
 void setMaxConnectTimeMillis(long maxConnectTimeMillis)
          Set the maximum time in milliseconds that we'll allow a connection to stay open to a host.
 void setMaxFrameSize(int maxFrameSize)
           
 void setMaxLastSuccessTimeMillis(long maxLastSuccessTimeMillis)
          Set the maximum time in milliseconds that we'll allow a connection to stay idle to a host.
 void setMaxWaitTimeWhenExhausted(long maxWaitTimeWhenExhausted)
           
 void setOpTimer(HOpTimer opTimer)
           
 void setPort(int port)
           
 void setRetryDownedHosts(boolean retryDownedHosts)
           
 void setRetryDownedHostsDelayInSeconds(int retryDownedHostsDelayInSeconds)
           
 void setRetryDownedHostsQueueSize(int retryDownedHostsQueueSize)
           
 void setRunAutoDiscoveryAtStartup(boolean runAutoDiscoveryAtStartup)
          Set to true to run NodeAutoDiscoverService at startup.
 void setUseHostTimeoutTracker(boolean useHostTimeoutTracker)
           
 void setUseSocketKeepalive(boolean useSocketKeepalive)
          Enable SO_KEEPALIVE on the underlying socket.
 void setUseThriftFramedTransport(boolean useThriftFramedTransport)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEF_CLOCK_RESOLUTION

public static final ClockResolution DEF_CLOCK_RESOLUTION
Constructor Detail

CassandraHostConfigurator

public CassandraHostConfigurator()

CassandraHostConfigurator

public CassandraHostConfigurator(String hosts)
Creates a new CassandraHostConfigurator from the specified hosts String, formatted as host[:port][,host[:port]...].

Parameters:
hosts - The hosts to create CassandraHosts from.
Method Detail

buildCassandraHosts

public CassandraHost[] buildCassandraHosts()

applyConfig

public void applyConfig(CassandraHost cassandraHost)

setHosts

public void setHosts(String hosts)
Specifies the hosts String, formatted as host[:port][,host[:port]...].

Parameters:
hosts - The hosts to create CassandraHosts from.

setMaxActive

public void setMaxActive(int maxActive)

setMaxWaitTimeWhenExhausted

public void setMaxWaitTimeWhenExhausted(long maxWaitTimeWhenExhausted)

setCassandraThriftSocketTimeout

public void setCassandraThriftSocketTimeout(int cassandraThriftSocketTimeout)
The value (in milliseconds) which gets passed down to Socket.setSoTimeout(int) used by the underlying Thrift transport.


getRetryDownedHosts

public boolean getRetryDownedHosts()

setRetryDownedHosts

public void setRetryDownedHosts(boolean retryDownedHosts)

setRetryDownedHostsQueueSize

public void setRetryDownedHostsQueueSize(int retryDownedHostsQueueSize)

getRetryDownedHostsQueueSize

public int getRetryDownedHostsQueueSize()

setRetryDownedHostsDelayInSeconds

public void setRetryDownedHostsDelayInSeconds(int retryDownedHostsDelayInSeconds)

getRetryDownedHostsDelayInSeconds

public int getRetryDownedHostsDelayInSeconds()

setClockResolution

public static void setClockResolution(String resolutionString)
Sets this Clock for all clusters administered by Hector. Notice this is a class method and ideally should be called from the CHC class just once.

Parameters:
resolutionString - one of "SECONDS", "MILLISECONDS", "MICROSECONDS" or "MICROSECONDS_SYNC"

getOpTimer

public HOpTimer getOpTimer()

setOpTimer

public void setOpTimer(HOpTimer opTimer)

toString

public String toString()
Overrides:
toString in class Object

getLifo

public boolean getLifo()

setLifo

public void setLifo(boolean lifo)

getPort

public int getPort()

setPort

public void setPort(int port)

setUseThriftFramedTransport

public void setUseThriftFramedTransport(boolean useThriftFramedTransport)

setMaxFrameSize

public void setMaxFrameSize(int maxFrameSize)

getClockResolution

public static ClockResolution getClockResolution()

setClockResolution

public static void setClockResolution(ClockResolution clockResolution)
Sets this Clock for all clusters administered by Hector. Notice this is a class method and ideally should be called from the CHC class just once.

Parameters:
clockResolution - a specific ClockResolution

getAutoDiscoverHosts

public boolean getAutoDiscoverHosts()

setAutoDiscoverHosts

public void setAutoDiscoverHosts(boolean autoDiscoverHosts)

getAutoDiscoveryDelayInSeconds

public int getAutoDiscoveryDelayInSeconds()

setAutoDiscoveryDelayInSeconds

public void setAutoDiscoveryDelayInSeconds(int autoDiscoveryDelayInSeconds)

setAutoDiscoveryDataCenter

public void setAutoDiscoveryDataCenter(String dataCenter)
Sets the local datacenter for the DiscoveryService. Nodes out of this datacenter will be discarded. For configuration simplicity, you can provide an empty or null string with the effect being the same as if you had not set this property.

Parameters:
dataCenter - DataCenter name

setAutoDiscoveryDataCenter

public void setAutoDiscoveryDataCenter(List<String> dataCenters)
Sets the datacenters for the DiscoveryService. Nodes out of these datacenters will be discarded.


getAutoDiscoveryDataCenters

public List<String> getAutoDiscoveryDataCenters()
Retrieves the 'local' datacenter names that the DiscoveryService recognizes as valid in order to discover new hosts.

Returns:
a list of 'local' datacenter names

getLoadBalancingPolicy

public LoadBalancingPolicy getLoadBalancingPolicy()

setLoadBalancingPolicy

public void setLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy)

getHostTimeoutCounter

public int getHostTimeoutCounter()

setHostTimeoutCounter

public void setHostTimeoutCounter(int hostTimeoutCounter)

getHostTimeoutWindow

public int getHostTimeoutWindow()

setHostTimeoutWindow

public void setHostTimeoutWindow(int hostTimeoutWindow)

getHostTimeoutSuspensionDurationInSeconds

public int getHostTimeoutSuspensionDurationInSeconds()

setHostTimeoutSuspensionDurationInSeconds

public void setHostTimeoutSuspensionDurationInSeconds(int hostTimeoutSuspensionDurationInSeconds)

getHostTimeoutUnsuspendCheckDelay

public int getHostTimeoutUnsuspendCheckDelay()

setHostTimeoutUnsuspendCheckDelay

public void setHostTimeoutUnsuspendCheckDelay(int hostTimeoutUnsuspendCheckDelay)

getUseHostTimeoutTracker

public boolean getUseHostTimeoutTracker()

setUseHostTimeoutTracker

public void setUseHostTimeoutTracker(boolean useHostTimeoutTracker)

getRunAutoDiscoveryAtStartup

public boolean getRunAutoDiscoveryAtStartup()

setRunAutoDiscoveryAtStartup

public void setRunAutoDiscoveryAtStartup(boolean runAutoDiscoveryAtStartup)
Set to true to run NodeAutoDiscoverService at startup. You must also call setAutoDiscoverHosts(boolean) to true for this to have an effect.

Parameters:
runAutoDiscoveryAtStartup -

getUseSocketKeepalive

public boolean getUseSocketKeepalive()

setUseSocketKeepalive

public void setUseSocketKeepalive(boolean useSocketKeepalive)
Enable SO_KEEPALIVE on the underlying socket. OFF by default (per java.net.Socket).
Enabling the socket keepalive is the usual way to work around a firewall problem (that is, a firewall that cuts idle connections between the Hector's host and the Cassandra nodes, Hector being unaware of these cuts). To do so, this method must be used in accordance with the appropriate "tcp_keepalive" settings of the machine that runs Hector, to deal with the firewall own settings (that is, how long a connection should be detected idle before the firewall cuts it).


setClientFactoryClass

public void setClientFactoryClass(String cls)

getClientFactoryClass

public Class<? extends HClientFactory> getClientFactoryClass()

getMaxConnectTimeMillis

public long getMaxConnectTimeMillis()
The maximum time in milliseconds that we'll allow a connection to stay open to a host. A negative value indicates indefinitely (and is the default).

Returns:
the number of milliseconds

setMaxConnectTimeMillis

public void setMaxConnectTimeMillis(long maxConnectTimeMillis)
Set the maximum time in milliseconds that we'll allow a connection to stay open to a host. A negative value indicates indefinitely. This setting is useful if you you need to work around a firewall that forcefully closes connections after a fixed amount of time regardless of activity.

Parameters:
maxConnectTimeMillis - the maximum time to use a connection

getMaxLastSuccessTimeMillis

public long getMaxLastSuccessTimeMillis()
The maximum time in milliseconds that we'll allow a connection to stay idle to a host. A negative value indicates indefinitely (and is the default).

Returns:
the number of milliseconds

setMaxLastSuccessTimeMillis

public void setMaxLastSuccessTimeMillis(long maxLastSuccessTimeMillis)
Set the maximum time in milliseconds that we'll allow a connection to stay idle to a host. A negative value indicates indefinitely.
This setting is useful if you you need to work around a firewall that forcefully closes connections after a fixed amount of idle time. Example: if your firewall cuts connections after an idle time of 30 mn, one could set this property with the duration 29 mn 30s to have a margin.
But before using setMaxLastSuccessTimeMillis, the first way, that is, the most used way, to try to work around a firewall problem should be to use the socket "keepalive" mechanism, see setUseSocketKeepalive method. The current method setMaxLastSuccessTimeMillis is generally used for dealing with firewalls when the "keepalive" mechanism could not be used.

Parameters:
maxLastSuccessTimeMillis - the maximum idle time for a connection


Copyright © 2013. All Rights Reserved.