Class ReplicationStorageListener

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ARCHIVE_FLAG_PROPERTY
      Name of the property specifying whether to use archive flag on the replication.
      static java.lang.String REPL_CMD_PROPERTY
      Name of the property specifying the replication command on the host system.
      static java.lang.String REPL_HOSTS_PROPERTY
      Name of property specifying to which hosts the storage should be replicated.
      static java.lang.String REPL_MAX_TRIES_PROPERTY
      Name of property indicating how many times the replication should be attempted before considering it a failure.
      static java.lang.String REPL_TIMEOUT_PROPERTY
      Name of the property specifying how long to wait for the replication to complete successfully.
    • Constructor Summary

      Constructors 
      Constructor Description
      ReplicationStorageListener()
      Default constructor used when this object is instantiated via configuration.
      ReplicationStorageListener​(boolean archiveFlag, java.lang.String replCmd, long replTimeout, java.util.List<java.lang.String> replHosts)
      Customer initialization of the constructor
    • Field Detail

      • ARCHIVE_FLAG_PROPERTY

        public static final java.lang.String ARCHIVE_FLAG_PROPERTY
        Name of the property specifying whether to use archive flag on the replication.
        See Also:
        Constant Field Values
      • REPL_CMD_PROPERTY

        public static final java.lang.String REPL_CMD_PROPERTY
        Name of the property specifying the replication command on the host system.
        See Also:
        Constant Field Values
      • REPL_MAX_TRIES_PROPERTY

        public static final java.lang.String REPL_MAX_TRIES_PROPERTY
        Name of property indicating how many times the replication should be attempted before considering it a failure.
        See Also:
        Constant Field Values
      • REPL_TIMEOUT_PROPERTY

        public static final java.lang.String REPL_TIMEOUT_PROPERTY
        Name of the property specifying how long to wait for the replication to complete successfully.
        See Also:
        Constant Field Values
      • REPL_HOSTS_PROPERTY

        public static final java.lang.String REPL_HOSTS_PROPERTY
        Name of property specifying to which hosts the storage should be replicated.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ReplicationStorageListener

        public ReplicationStorageListener()
        Default constructor used when this object is instantiated via configuration.
      • ReplicationStorageListener

        public ReplicationStorageListener​(boolean archiveFlag,
                                          java.lang.String replCmd,
                                          long replTimeout,
                                          java.util.List<java.lang.String> replHosts)
        Customer initialization of the constructor
        Parameters:
        archiveFlag - Bool flag of what to do on archive
        replCmd - Replication command on host system
        replTimeout - Replication in ms
        replHosts - List of Replication hosts
    • Method Detail

      • setReplHosts

        protected void setReplHosts​(java.util.List<java.lang.String> replHosts)
        Set new Replication hosts
        Parameters:
        replHosts - string list of new hosts
      • onProductStored

        public void onProductStored​(StorageEvent event)
                             throws java.lang.Exception
        Description copied from class: DefaultStorageListener
        Dispatched method called when the type of event is StorageEvent.StorageEventType.PRODUCT_STORED.
        Overrides:
        onProductStored in class DefaultStorageListener
        Parameters:
        event - The event that triggered the call
        Throws:
        java.lang.Exception - if error occurs
      • onProductRemoved

        public void onProductRemoved​(StorageEvent event)
                              throws java.lang.Exception
        Description copied from class: DefaultStorageListener
        Dispatched method called when the type of event is StorageEvent.StorageEventType.PRODUCT_REMOVED.
        Overrides:
        onProductRemoved in class DefaultStorageListener
        Parameters:
        event - The event that triggered the call
        Throws:
        java.lang.Exception - if error occurs
      • syncProductContents

        protected void syncProductContents​(FileProductStorage storage,
                                           ProductId id,
                                           boolean deleting)
                                    throws java.io.IOException
        Parameters:
        storage - FileProductStorage to use as the base directory
        id - ID of product in storage
        deleting - Bool flag for deleting
        Throws:
        java.io.IOException - if IO error occurs
      • createReplicationCommand

        protected java.util.List<java.lang.String> createReplicationCommand​(java.io.File baseDir,
                                                                            java.lang.String path,
                                                                            java.lang.String host,
                                                                            boolean deleting)
                                                                     throws java.io.IOException
        Create the replication command.
        Parameters:
        baseDir - The directory from which replication will be executed.
        path - The path of the content to replicate
        host - The host string to which content should be replicated. Format = user@host:path
        deleting - Flag whether this should be a deleting replication or not
        Returns:
        The command and arguments as a list suitable for a ProcessBuilder.
        Throws:
        java.io.IOException - if IO error occurs