Class Topology


  • public class Topology
    extends java.lang.Object
    Provides a cache of all sites and their members (addresses, IP addresses, site masters etc) in a network of autonomous sites. The cache is an approximation, and is refreshed on reception of RelayHeader.SITES_UP or RelayHeader.SITES_DOWN notifications. A refresh can also be triggered programmatically.
    Used as a component in RELAY2 and RELAY3.
    Since:
    5.2.15
    Author:
    Bela Ban
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<java.lang.String,​View> cache  
      protected boolean global_views  
      protected RELAY relay  
      protected java.util.function.BiConsumer<java.lang.String,​View> view_handler  
    • Constructor Summary

      Constructors 
      Constructor Description
      Topology​(RELAY relay)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​View> cache()  
      protected java.lang.String dumpSite​(java.lang.String site)  
      boolean globalViews()  
      Topology globalViews​(boolean b)  
      java.lang.String print()  
      java.lang.String print​(java.lang.String site)
      Dumps the members for a given site, or all sites
      protected void put​(java.lang.String site, View v)
      Called when a response has been received.
      Topology refresh()  
      Topology refresh​(java.lang.String site)
      Refreshes the topology for a given site.
      Topology refresh​(java.lang.String site, boolean return_entire_cache)  
      Topology removeAll​(java.util.Collection<java.lang.String> sites)  
      Topology setViewHandler​(java.util.function.BiConsumer<java.lang.String,​View> c)
      Sets a view handler
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • relay

        protected final RELAY relay
      • cache

        protected final java.util.Map<java.lang.String,​View> cache
      • view_handler

        protected java.util.function.BiConsumer<java.lang.String,​View> view_handler
      • global_views

        protected boolean global_views
    • Constructor Detail

      • Topology

        public Topology​(RELAY relay)
    • Method Detail

      • cache

        public java.util.Map<java.lang.String,​View> cache()
      • globalViews

        public boolean globalViews()
      • globalViews

        public Topology globalViews​(boolean b)
      • setViewHandler

        public Topology setViewHandler​(java.util.function.BiConsumer<java.lang.String,​View> c)
        Sets a view handler
        Parameters:
        c - The view handler. Arguments are the site and the View of that site)
      • refresh

        public Topology refresh​(java.lang.String site)
        Refreshes the topology for a given site.
        Parameters:
        site - The site. If null, all sites will be refreshed.
      • refresh

        public Topology refresh​(java.lang.String site,
                                boolean return_entire_cache)
      • print

        public java.lang.String print()
      • print

        public java.lang.String print​(java.lang.String site)
        Dumps the members for a given site, or all sites
        Parameters:
        site - The site name. Dumps all sites if null
        Returns:
        A string of all sites and their members
      • removeAll

        public Topology removeAll​(java.util.Collection<java.lang.String> sites)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • dumpSite

        protected java.lang.String dumpSite​(java.lang.String site)
      • put

        protected void put​(java.lang.String site,
                           View v)
        Called when a response has been received. Updates the internal cache