public class InstanceObservable
extends java.lang.Object
Instance information from the specified InstanceDiscovery
object. The InstanceDiscovery must be registered with the PluginsFactory at startup, else Turbine uses a default
FileBasedInstanceDiscovery mechanism.
Note that the InstanceObservable runs in continuous loop at a periodic interval specified by the config property turbine.discovery.pollDelayMillis
with a default of 60 seconds
It checks the Instance.isUp() state to understand whether to notify observers downstream about hosts that are up and down.
It also keeps state from the previous poll and it uses this to determine whether some older hosts have disappeared.
One can register a InstanceObservable.InstanceObserver by using the register(InstanceObserver) to receive periodic updates of hosts that are up
and down via the InstanceObservable.InstanceObserver.hostsUp(Collection) and the InstanceObservable.InstanceObserver.hostsDown(Collection) callbacks.
| Modifier and Type | Class and Description |
|---|---|
static interface |
InstanceObservable.InstanceObserver
Interface for representing an observer to the
InstanceObservable |
static class |
InstanceObservable.UnitTest |
| Modifier and Type | Method and Description |
|---|---|
void |
deregister(InstanceObservable.InstanceObserver watcher)
Deregister from the observable
|
int |
getCurrentHostDownCount() |
java.util.HashSet<Instance> |
getCurrentHostsDown() |
java.util.HashSet<Instance> |
getCurrentHostsUp() |
int |
getCurrentHostUpCount() |
int |
getHeartbeat() |
static InstanceObservable |
getInstance() |
int |
getNumHostsUpForCluster(java.lang.String cluster)
Helper method to give us the hosts up for a specified cluster
|
java.util.Set<java.lang.String> |
getObservers() |
InstanceObservable.InstanceObserver |
register(InstanceObservable.InstanceObserver watcher)
Register with the observable to get callbacks on fleet status updates
|
void |
start(InstanceDiscovery iDiscovery)
Idempotent call to start the Observable.
|
void |
stop()
Stop the
InstanceObservable |
public static InstanceObservable getInstance()
InstanceObservable@Monitor(name="HostUp",
type=GAUGE)
public int getCurrentHostUpCount()
@Monitor(name="HostDown",
type=GAUGE)
public int getCurrentHostDownCount()
@Monitor(name="Heartbeat",
type=COUNTER)
public int getHeartbeat()
public java.util.HashSet<Instance> getCurrentHostsDown()
Instance>public java.util.Set<java.lang.String> getObservers()
public void start(InstanceDiscovery iDiscovery)
InstanceDiscovery implementationiDiscovery - public void stop()
InstanceObservablepublic InstanceObservable.InstanceObserver register(InstanceObservable.InstanceObserver watcher)
watcher - InstanceObservable.InstanceObserverInstanceObservable.InstanceObserver if it already existspublic void deregister(InstanceObservable.InstanceObserver watcher)
watcher - InstanceObservable.InstanceObserverpublic int getNumHostsUpForCluster(java.lang.String cluster)
cluster -