Class StoreProcessHelper

java.lang.Object
i5.las2peer.persistency.helper.StoreProcessHelper
All Implemented Interfaces:
StorageCollisionHandler, StorageExceptionHandler, StorageStoreResultHandler

public class StoreProcessHelper extends Object implements StorageStoreResultHandler, StorageCollisionHandler, StorageExceptionHandler
  • Constructor Details

    • StoreProcessHelper

      public StoreProcessHelper()
  • Method Details

    • onResult

      public void onResult(Serializable serializable, int successfulOperations)
      Description copied from interface: StorageStoreResultHandler
      This method is called in its own thread to handle the result of a store operation.
      Specified by:
      onResult in interface StorageStoreResultHandler
      Parameters:
      serializable - The serializable that was stored in the network.
      successfulOperations - The number of successful insert operations (replications).
    • onCollision

      public Serializable onCollision(EnvelopeVersion toStore, EnvelopeVersion inNetwork, long numberOfCollisions) throws StopMergingException
      Description copied from interface: StorageCollisionHandler
      This method is called if an envelope is already known for the given identifier and version.
      Specified by:
      onCollision in interface StorageCollisionHandler
      Parameters:
      toStore - This is the envelope that was requested to be stored in the network.
      inNetwork - This is the colliding envelope that was fetched from the network.
      numberOfCollisions - This is an increasing counter on how often this method was called. It should be a hint to the developer to reconsider his storage structure if this value reaches often high values.
      Returns:
      Returns the merged content from both envelopes, which is automatically wrapped in a new store operation.
      Throws:
      StopMergingException - If there should be made no further merging attempt.
    • mergeReaders

      public Set<PublicKey> mergeReaders(Set<PublicKey> toStoreReaders, Set<PublicKey> inNetworkReaders)
      Specified by:
      mergeReaders in interface StorageCollisionHandler
    • mergeGroups

      public Set<String> mergeGroups(Set<String> toStoreGroups, Set<String> inNetworkGroups)
      Specified by:
      mergeGroups in interface StorageCollisionHandler
    • onException

      public void onException(Exception e)
      Description copied from interface: StorageExceptionHandler
      This method is called in its own thread to handle the given exception.
      Specified by:
      onException in interface StorageExceptionHandler
      Parameters:
      e - An execption that occurred during a network operation. Usually the reason or metadata should be known from the surrounding context and should be provided to this handler, too.
    • getResult

      public int getResult() throws Exception
      Throws:
      Exception