Class StoragePolicy

java.lang.Object
ecmwf.ecpds.master.storage.StoragePolicy

public final class StoragePolicy extends Object
A Storage Lifecycle Policy. A policy can only shorten the physical retention of a data file, never extend it beyond the lifetime (expiry) of the related transfers.
  • Field Details

    • DEFAULT_NAME

      public static final String DEFAULT_NAME
      The name of the built-in policy applied when no other policy matches.
      See Also:
    • DEFAULT_REQUEUE_WINDOW_MS

      public static final long DEFAULT_REQUEUE_WINDOW_MS
      The default requeue window (7 days).
      See Also:
    • DEFAULT_DROP_REPLICAS_AFTER_MS

      public static final long DEFAULT_DROP_REPLICAS_AFTER_MS
      The default delay before dropping replicas (1 hour).
      See Also:
    • REGEX_PREFIX

      public static final String REGEX_PREFIX
      Prefix marking a file pattern as a regular expression.
      See Also:
  • Constructor Details

    • StoragePolicy

      public StoragePolicy(Map<String,String> row)
      Instantiates a new storage policy.
      Parameters:
      row - the row (keys as returned by the database interface)
      Throws:
      IllegalArgumentException - if a value is invalid
  • Method Details

    • defaultPolicy

      public static StoragePolicy defaultPolicy()
      Gets the built-in default policy (the current behaviour with a 7 days requeue window).
      Returns:
      the default policy
    • isDefault

      public boolean isDefault()
      Checks if this is the built-in default policy.
      Returns:
      true, if it is the default policy
    • fromRows

      public static List<StoragePolicy> fromRows(List<Map<String,String>> rows)
      Parses a list of rows.
      Parameters:
      rows - the rows
      Returns:
      the policies
    • select

      public static StoragePolicy.Match select(List<StoragePolicy> policies, StoragePolicy.Subject subject)
      Selects the policy for the subject. A policy explicitly named by the destination option always wins. Otherwise the active, non-disabled policies are examined in order and the first one whose criteria all match is selected. If none matches the built-in default policy is returned.
      Parameters:
      policies - the policies (any order)
      subject - the subject
      Returns:
      the match
    • matches

      public boolean matches(StoragePolicy.Subject subject)
      Checks that all the criteria of this policy match the subject (a policy without any criteria matches everything).
      Parameters:
      subject - the subject
      Returns:
      true, if all the criteria match
    • guaranteedUntil

      public long guaranteedUntil(long windowStart, long expiry)
      Gets the time until which the original file is guaranteed to be kept for a requeue. A policy can only shorten the retention, never extend it beyond the lifetime.
      Parameters:
      windowStart - the start of the window (time of the last activity)
      expiry - the expiry time of the transfer (the lifetime)
      Returns:
      the time until which the requeue is guaranteed
    • addDuration

      public static long addDuration(long start, long duration)
    • getMinRetentionMs

      public long getMinRetentionMs()
    • getGraceMs

      public long getGraceMs()
    • getLazyReplicationMs

      public long getLazyReplicationMs()
    • getHighWatermark

      public int getHighWatermark()
    • getLowWatermark

      public int getLowWatermark()
    • splitList

      public static List<String> splitList(String value)
      Splits a list separated by commas, semicolons or whitespace.
      Parameters:
      value - the value
      Returns:
      the items
    • getName

      public String getName()
      Gets the name.
      Returns:
      the name
    • getComment

      public String getComment()
      Gets the comment.
      Returns:
      the comment
    • isActive

      public boolean isActive()
      Checks if is active.
      Returns:
      true, if active
    • getMode

      public StoragePolicy.Mode getMode()
      Gets the mode.
      Returns:
      the mode
    • getOrder

      public int getOrder()
      Gets the order.
      Returns:
      the order
    • getRequeueWindowMs

      public long getRequeueWindowMs()
      Gets the requeue window in milliseconds.
      Returns:
      the requeue window
    • isRestartOnRequeue

      public boolean isRestartOnRequeue()
      Checks if the window restarts on requeue.
      Returns:
      true, if it restarts
    • isDropReplicas

      public boolean isDropReplicas()
      Checks if the replicas are dropped.
      Returns:
      true, if they are dropped
    • getDropReplicasAfterMs

      public long getDropReplicasAfterMs()
      Gets the delay before dropping replicas in milliseconds.
      Returns:
      the delay
    • getFilePattern

      public String getFilePattern()
      Gets the file pattern.
      Returns:
      the file pattern