Class PathNameUtility

java.lang.Object
edu.stanford.slac.archiverappliance.plain.PathNameUtility

public class PathNameUtility extends Object
A utility class with a bunch of methods that operate on the path names used by the PlainPB storage plugin.
Author:
mshankar
  • Constructor Details

    • PathNameUtility

      public PathNameUtility()
  • Method Details

    • getPathNameForTime

      public static Path getPathNameForTime(PlainStoragePlugin plugin, String pvName, Instant ts, ArchPaths paths, PVNameToKeyMapping pv2key) throws IOException
      Throws:
      IOException
    • getPathNameForTime

      public static Path getPathNameForTime(String rootFolder, String pvName, Instant ts, PartitionGranularity partitionGranularity, ArchPaths paths, PathResolver pathResolver, PVNameToKeyMapping pv2key, String fileExtension) throws IOException
      Throws:
      IOException
    • getPathsWithData

      public static Path[] getPathsWithData(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, Instant endts, String extension, PartitionGranularity granularity, PVNameToKeyMapping pv2key) throws IOException
      Given a parent folder, this method returns a list of all the paths with data that falls within the specified timeframe. We assume the pathnames follow the syntax used by the PlainStoragePlugin. The alg for matching is based on this
             --------
        [ ] [|] [ ] [|] [ ]
        
      For the chunks that are eliminated, either the end time of the chunk is less than the start time or the start time of the chunk is greater than the end time.
      Parameters:
      archPaths - The replacement for NIO Paths
      rootFolder - The root folder for the plugin.
      pvName - Name of the PV.
      startts - Instant start
      endts - Instant end
      extension - The file extension.
      granularity - Partition granularity of the file.
      pv2key - PVNameToKeyMapping
      Returns:
      Path A list of all the paths
      Throws:
      IOException -  
    • getPathsBeforeCurrentPartition

      public static Path[] getPathsBeforeCurrentPartition(ArchPaths archPaths, String rootFolder, String pvName, Instant currentTime, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) throws IOException
      The PlainPB storage plugin partitions files according to time and partition granularity. At any particular point in time, we are only writing to one partition, the "current" partition. For ETL, we need to know the partitions that are not being written into; that is, all the previous partitions. This is typically everything except the file for the current partition
      Parameters:
      archPaths - The replacement for NIO Paths
      rootFolder - The root folder for the plugin
      pvName - The name of the PV
      currentTime - The time that we are running ETL for. To prevent border conditions, caller can add a buffer if needed.
      extension - The file extension.
      granularity - The granularity of this store.
      pathResolver - PathResolver
      pv2key - PVNameToKeyMapping
      Returns:
      Path A list of all the paths
      Throws:
      IOException -  
    • getAllPathsForPV

      public static Path[] getAllPathsForPV(ArchPaths archPaths, String rootFolder, String pvName, String extension, PathResolver pathResolver, PVNameToKeyMapping pv2key) throws IOException
      This method returns all the paths that could contain data for a PV sorted according to the name (which in our case should translate to time).
      Parameters:
      archPaths - The replacement for NIO Paths
      rootFolder - The root folder for the plugin
      pvName - The name of the PV
      extension - The file extension.
      pv2key - PVNameToKeyMapping
      Returns:
      Path A list of all the paths
      Throws:
      IOException -  
    • getMostRecentPathBeforeTime

      public static Path getMostRecentPathBeforeTime(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) throws Exception
      If a PV changes infrequently, we often will not have a sample in the given time frame. The getData contract asks that we return the most recent known sample; even if this sample's timestamp is before the requested start/end time. The way we do this is to ask for the file that potentially has most recent data before the start time. We take advantage of the sorting nature of getAllPathsForPV and work our way from the back
      Parameters:
      archPaths - The replacement for NIO Paths
      rootFolder - The root folder for the plugin
      pvName - Name of the PV.
      startts - Instant start
      extension - The file extension.
      granularity - Partition granularity of the file.
      pathResolver - Path Resolver
      pv2key - PVNameToKeyMapping
      Returns:
      Path A list of all the paths
      Throws:
      Exception -  
    • getPreviousPartitionBeforeTime

      public static Path getPreviousPartitionBeforeTime(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) throws Exception
      If a PV changes infrequently, we often will not have a sample in the given time frame. The getData contract asks that we return the most recent known sample; even if this sample's timestamp is before the requested start/end time. Another way we do this is to return the last event in the partition which ends before the start time. We take advantage of the sorting nature of getAllPathsForPV and work our way from the back
      Parameters:
      archPaths - The replacement for NIO Paths
      rootFolder - The root folder for the plugin
      pvName - Name of the PV.
      startts - Instant start
      extension - The file extension.
      granularity - Partition granularity of the file.
      pathResolver - PathResolver
      pv2key - PVNameToKeyMapping
      Returns:
      Path A list of all the paths
      Throws:
      Exception -  
    • getFileName

      public static Path getFileName(String rootFolder, String pvName, Instant ts, String extension, PartitionGranularity partitionGranularity, boolean createParentFolder, ArchPaths paths, PathResolver pathResolver, PVNameToKeyMapping pv2key) throws IOException
      This method returns the path for a given pv for a given time based on the partitionGranularity
      Parameters:
      rootFolder - The root folder for the plugin
      pvName - Name of the PV.
      ts - Seconds after linux epoch
      extension - The file extension.
      partitionGranularity - Partition granularity of the file.
      Returns:
      Path A list of all the paths
      Throws:
      IOException -  
    • determineTimesFromFileName

      public static PathNameUtility.StartEndTimeFromName determineTimesFromFileName(String pvName, String finalNameComponent, PartitionGranularity partitionGranularity, PVNameToKeyMapping pv2key) throws IOException
      Determines the times for a chunk simply from the file name. Bear in mind there is no guarantee that the file has data in this range. For that, @see PBFileInfo.
      Parameters:
      pvName - Name of the PV.
      finalNameComponent - The final name component
      partitionGranularity - Partition granularity of the file.
      pv2key - PVNameToKeyMapping
      Returns:
      fileNameTimes Start and End Time from name
      Throws:
      IOException -