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

  • Field Details

    • SUFFIX

      protected static final String SUFFIX
      See Also:
    • regexp

      protected static final Pattern regexp
    • location

      protected 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 File root_dir
    • filter

      protected static final FilenameFilter filter
    • info_writer

      protected Future<?> info_writer
  • Constructor Details

    • FILE_PING

      public FILE_PING()
  • Method Details

    • isDynamic

      public boolean isDynamic()
      Specified by:
      isDynamic in class Discovery
    • getLocation

      public String getLocation()
    • setLocation

      public FILE_PING setLocation(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 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:
      Exception - Thrown if protocol cannot be initialized successfully. This will cause the ProtocolStack to fail, so the the channel constructor will throw an exception
    • stop

      public void stop()
      Description copied from class: Protocol
      Called on a JChannel.disconnect(); stops work (e.g. by closing multicast socket). Will be called from top to bottom.
      Specified by:
      stop in interface Lifecycle
      Overrides:
      stop in class Discovery
    • resetStats

      public void resetStats()
      Overrides:
      resetStats in class Discovery
    • down

      public 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(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 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(String clustername, Address addr)
    • removeAll

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

      protected void readAll(List<Address> members, String clustername, Responses responses)
    • read

      protected List<PingData> read(File file) throws Exception
      Throws:
      Exception
    • read

      protected List<PingData> read(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(List<PingData> list, String clustername)
    • write

      protected void write(List<PingData> list, OutputStream out) throws Exception
      Overrides:
      write in class Discovery
      Throws:
      Exception
    • deleteFile

      protected boolean deleteFile(File file)
    • startInfoWriter

      protected void startInfoWriter()
    • stopInfoWriter

      protected void stopInfoWriter()