Class Mirror

java.lang.Object
com.yahoo.jrt.slobrok.api.Mirror
All Implemented Interfaces:
IMirror

public class Mirror extends Object implements 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.
  • Constructor Details

    • Mirror

      public Mirror(Supervisor orb, SlobrokList slobroks, BackOffPolicy bop)
      Create a new MirrorAPI using the given Supervisor and slobrok connect specs.
      Parameters:
      orb - the Supervisor to use
      slobroks - slobrok connect spec list
      bop - custom backoff policy, mostly useful for testing
    • Mirror

      public Mirror(Supervisor orb, SlobrokList slobroks)
      Create a new MirrorAPI using the given Supervisor and slobrok connect specs.
      Parameters:
      orb - the Supervisor to use
      slobroks - 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

      public List<Mirror.Entry> lookup(String pattern)
      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.
      Specified by:
      lookup in interface IMirror
      Parameters:
      pattern - The pattern used for matching
      Returns:
      a list of all matching services, with corresponding connect specs
    • 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.
      Specified by:
      updates in interface IMirror
      Returns:
      number of slobrok updates seen
    • 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()