Package com.yahoo.jrt.slobrok.api
Class Mirror
java.lang.Object
com.yahoo.jrt.slobrok.api.Mirror
- All Implemented Interfaces:
IMirror
A Mirror object is used to keep track of the services registered
with a slobrok cluster.
Updates to the service repository are fetched in the
background. Lookups against this object is done using an internal
mirror of the service repository.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
An Entry contains the name and connection spec for a single service. -
Constructor Summary
ConstructorDescriptionMirror
(Supervisor orb, SlobrokList slobroks) Create a new MirrorAPI using the given Supervisor and slobrok connect specs.Mirror
(Supervisor orb, SlobrokList slobroks, BackOffPolicy bop) Create a new MirrorAPI using the given Supervisor and slobrok connect specs. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this mirror is connected to the slobrok server at this time or not.void
long
Obtain all the services matching a given pattern.boolean
ready()
Ask if the MirrorAPI has got any useful information from the Slobrok.void
shutdown()
Shut down the Mirror.int
updates()
Obtain the number of updates seen by this mirror.
-
Constructor Details
-
Mirror
Create a new MirrorAPI using the given Supervisor and slobrok connect specs.- Parameters:
orb
- the Supervisor to useslobroks
- slobrok connect spec listbop
- custom backoff policy, mostly useful for testing
-
Mirror
Create a new MirrorAPI using the given Supervisor and slobrok connect specs.- Parameters:
orb
- the Supervisor to useslobroks
- slobrok connect spec list
-
-
Method Details
-
shutdown
public void shutdown()Shut down the Mirror. This will close any open connections, stop the regular mirror updates, and discard all entries. -
lookup
Description copied from interface:IMirror
Obtain all the services matching a given pattern. The pattern is matched against all service names in the local mirror repository. A service name may contain '/' as a separator token. A pattern may contain '*' to match anything up to the next '/' (or the end of the name). This means that the pattern 'foo/*/baz' would match the service names 'foo/bar/baz' and 'foo/xyz/baz'. The pattern 'foo/b*' would match 'foo/bar', but neither 'foo/xyz' nor 'foo/bar/baz'. The pattern 'a*b' will never match anything. As a special case, a pattern can end in '**' to match the rest of a name including '/' separators. -
updates
public int updates()Description copied from interface:IMirror
Obtain the number of updates seen by this mirror. The value may wrap, but will never become 0 again. This can be used for name lookup optimization, because the results returned by lookup() will never change unless this number also changes. -
ready
public boolean ready()Ask if the MirrorAPI has got any useful information from the Slobrok. On application startup it is often useful to run the event loop for some time until this functions returns true (or if it never does, time out and tell the user there was no answer from any Service Location Broker).- Returns:
- true if the MirrorAPI object has asked for updates from a Slobrok and got any answer back
-
connected
public boolean connected()Returns whether this mirror is connected to the slobrok server at this time or not. -
dumpState
public void dumpState() -
getIterations
public long getIterations()
-