Class FILE_PING

  • All Implemented Interfaces:
    Lifecycle
    Direct Known Subclasses:
    JDBC_PING, JDBC_PING2, RACKSPACE_PING, SWIFT_PING

    public class FILE_PING
    extends Discovery
    Simple discovery protocol which uses a file on shared storage such as an SMB share, NFS mount or S3. The local address information, e.g. UUID and physical addresses mappings are written to the file and the content is read and added to our transport's UUID-PhysicalAddress cache.

    The design is at doc/design/FILE_PING.txt

    Author:
    Bela Ban
    • Field Detail

      • regexp

        protected static final java.util.regex.Pattern regexp
      • location

        protected java.lang.String location
      • remove_old_coords_on_view_change

        protected boolean remove_old_coords_on_view_change
      • remove_all_data_on_view_change

        protected boolean remove_all_data_on_view_change
      • info_writer_max_writes_after_view

        protected int info_writer_max_writes_after_view
      • info_writer_sleep_time

        protected long info_writer_sleep_time
      • write_data_on_find

        protected boolean write_data_on_find
      • register_shutdown_hook

        protected boolean register_shutdown_hook
      • update_store_on_view_change

        protected boolean update_store_on_view_change
      • writes

        protected int writes
      • reads

        protected int reads
      • root_dir

        protected java.io.File root_dir
      • filter

        protected static final java.io.FilenameFilter filter
      • info_writer

        protected java.util.concurrent.Future<?> info_writer
    • Constructor Detail

      • FILE_PING

        public FILE_PING()
    • Method Detail

      • getLocation

        public java.lang.String getLocation()
      • setLocation

        public FILE_PING setLocation​(java.lang.String l)
      • removeAllDataOnViewChange

        public boolean removeAllDataOnViewChange()
      • removeAllDataOnViewChange

        public FILE_PING removeAllDataOnViewChange​(boolean r)
      • removeOldCoordsOnViewChange

        public boolean removeOldCoordsOnViewChange()
      • removeOldCoordsOnViewChange

        public FILE_PING removeOldCoordsOnViewChange​(boolean r)
      • getInfoWriterMaxWritesAfterView

        public int getInfoWriterMaxWritesAfterView()
      • setInfoWriterMaxWritesAfterView

        public FILE_PING setInfoWriterMaxWritesAfterView​(int i)
      • getInfoWriterSleepTime

        public long getInfoWriterSleepTime()
      • setInfoWriterSleepTime

        public FILE_PING setInfoWriterSleepTime​(long i)
      • writeDataOnFind

        public boolean writeDataOnFind()
      • writeDataOnFind

        public FILE_PING writeDataOnFind​(boolean w)
      • registerShutdownHook

        public boolean registerShutdownHook()
      • registerShutdownHook

        public FILE_PING registerShutdownHook​(boolean r)
      • updateStoreOnViewChange

        public boolean updateStoreOnViewChange()
      • updateStoreOnViewChange

        public FILE_PING updateStoreOnViewChange​(boolean u)
      • isInfoWriterRunning

        public boolean isInfoWriterRunning()
      • writeInfo

        public void writeInfo()
      • init

        public void init()
                  throws java.lang.Exception
        Description copied from class: Protocol
        Called after a protocol has been created and before the protocol is started. Attributes are already set. Other protocols are not yet connected and events cannot yet be sent.
        Specified by:
        init in interface Lifecycle
        Overrides:
        init in class Discovery
        Throws:
        java.lang.Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
      • down

        public java.lang.Object down​(Event evt)
        Description copied from class: Protocol
        An event is to be sent down the stack. A protocol may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the protocol may need to add a header to it (or do nothing at all) before sending it down the stack using down_prot.down().
        Overrides:
        down in class Discovery
      • findMembers

        public void findMembers​(java.util.List<Address> members,
                                boolean initial_discovery,
                                Responses responses)
        Description copied from class: Discovery
        Fetches information (e.g. physical address, logical name) for the given member addresses. Needs to add responses to the Responses object. If Discovery.async_discovery is true, this method will be called in a separate thread, otherwise the caller's thread will be used.
        Specified by:
        findMembers in class Discovery
        Parameters:
        members - A list of logical addresses (typically UUIDs). If null, then information for all members is fetched
        initial_discovery - Set to true if this is for the initial membership discovery. Some protocols (e.g. file based ones) may return only the information for the coordinator(s).
        responses - The list to which responses should be added
      • addressToFilename

        protected static java.lang.String addressToFilename​(Address mbr)
      • createRootDir

        protected void createRootDir()
      • handleView

        protected void handleView​(View new_view,
                                  View old_view,
                                  boolean coord_changed)
      • remove

        protected void remove​(java.lang.String clustername,
                              Address addr)
      • removeAll

        protected void removeAll​(java.lang.String clustername)
        Removes all files for the given cluster name
      • readAll

        protected void readAll​(java.util.List<Address> members,
                               java.lang.String clustername,
                               Responses responses)
      • read

        protected java.util.List<PingData> read​(java.io.File file)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • read

        protected java.util.List<PingData> read​(java.io.InputStream in)
        Overrides:
        read in class Discovery
      • writeAll

        protected void writeAll()
        Write information about all of the member to file (only if I'm the coord)
      • writeAll

        protected void writeAll​(Address[] excluded_mbrs)
      • write

        protected void write​(java.util.List<PingData> list,
                             java.lang.String clustername)
      • write

        protected void write​(java.util.List<PingData> list,
                             java.io.OutputStream out)
                      throws java.lang.Exception
        Overrides:
        write in class Discovery
        Throws:
        java.lang.Exception
      • deleteFile

        protected boolean deleteFile​(java.io.File file)
      • startInfoWriter

        protected void startInfoWriter()
      • stopInfoWriter

        protected void stopInfoWriter()