Class PDC

java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.PDC
All Implemented Interfaces:
Lifecycle

public class PDC extends Protocol
Persistent Discovery Cache. Caches mapping between logical and physical addresses on disk, merges them with the results of the get physical address(es) events. This is done by intercepting the get and set physical address(es) event. Needs to be placed between the transport and the discovery protocol. The disk cache stores each mapping in a separate file, named by the logical address.
Since:
3.3
  • Field Details

  • Constructor Details

    • PDC

      public PDC()
  • Method Details

    • printCache

      public String printCache()
    • 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 Protocol
      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
    • 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 Protocol
    • createDiskCacheFile

      protected void createDiskCacheFile() throws IOException
      Throws:
      IOException
    • readCacheFromDisk

      protected void readCacheFromDisk()
      Reads all mappings from disk
    • readAddressMapping

      private PDC.Mapping readAddressMapping(File file)
    • writeNodeToDisk

      protected void writeNodeToDisk(Address logical_addr, PhysicalAddress physical_addr)
    • writeToTempFile

      protected File writeToTempFile(File dir, Address logical_addr, Address physical_addr, String logical_name) throws Exception
      Writes the data to a temporary file.
      The file is stored in the same directory as the other cluster files but is given the tmp suffix
      Parameters:
      dir - The disk cache root dir
      logical_addr - The logical address
      physical_addr - The physical address
      Returns:
      Throws:
      Exception
    • removeNodeFromDisk

      protected void removeNodeFromDisk(Address logical_addr)
    • addressAsString

      protected static String addressAsString(Address address)
    • deleteFile

      protected boolean deleteFile(File file)
      Attempts to delete the provided file.
      Logging is performed on the result
      Parameters:
      file -
      Returns: