com.netflix.astyanax.connectionpool.impl
Class NodeDiscoveryImpl

java.lang.Object
  extended by com.netflix.astyanax.connectionpool.impl.NodeDiscoveryImpl
Type Parameters:
CL -
All Implemented Interfaces:
NodeDiscovery

public class NodeDiscoveryImpl
extends java.lang.Object
implements NodeDiscovery

Re-discover the ring on a fixed interval to identify new nodes or changes to the ring tokens.

The class is started by the AstyanaxContext and uses a thread within an executor to repeatedly update the list of hosts required by a ConnectionPool using ConnectionPool.setHosts(java.util.Collection). Note that the host source / supplier is passed in as an argument.


Constructor Summary
NodeDiscoveryImpl(java.lang.String name, int interval, com.google.common.base.Supplier<java.util.List<Host>> hostSupplier, ConnectionPool<?> connectionPool)
           
NodeDiscoveryImpl(java.lang.String name, int interval, com.google.common.base.Supplier<java.util.List<Host>> hostSupplier, ConnectionPool<?> connectionPool, java.util.concurrent.ScheduledExecutorService executor)
           
 
Method Summary
 long getErrorCount()
           
 java.lang.Exception getLastException()
           
 org.joda.time.DateTime getLastRefreshTime()
           
 java.lang.String getRawHostList()
           
 long getRefreshCount()
           
 void shutdown()
          Stop the node discovery thread
 void start()
          Start the node discovery thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeDiscoveryImpl

public NodeDiscoveryImpl(java.lang.String name,
                         int interval,
                         com.google.common.base.Supplier<java.util.List<Host>> hostSupplier,
                         ConnectionPool<?> connectionPool)

NodeDiscoveryImpl

public NodeDiscoveryImpl(java.lang.String name,
                         int interval,
                         com.google.common.base.Supplier<java.util.List<Host>> hostSupplier,
                         ConnectionPool<?> connectionPool,
                         java.util.concurrent.ScheduledExecutorService executor)
Method Detail

start

public void start()
Description copied from interface: NodeDiscovery
Start the node discovery thread

Specified by:
start in interface NodeDiscovery

shutdown

public void shutdown()
Description copied from interface: NodeDiscovery
Stop the node discovery thread

Specified by:
shutdown in interface NodeDiscovery

getLastRefreshTime

public org.joda.time.DateTime getLastRefreshTime()
Specified by:
getLastRefreshTime in interface NodeDiscovery
Returns:
Get the last refresh time in the discovery thread

getRefreshCount

public long getRefreshCount()
Specified by:
getRefreshCount in interface NodeDiscovery
Returns:
Get the number of refreshes

getLastException

public java.lang.Exception getLastException()
Specified by:
getLastException in interface NodeDiscovery
Returns:
Get the last exception that was encountered

getErrorCount

public long getErrorCount()
Specified by:
getErrorCount in interface NodeDiscovery
Returns:
Get total number of errors encountered during a refresh

getRawHostList

public java.lang.String getRawHostList()
Specified by:
getRawHostList in interface NodeDiscovery
Returns:
Get the raw list of nodes from the underlying refresh mechanism