Class PathNameUtility
java.lang.Object
edu.stanford.slac.archiverappliance.plain.PathNameUtility
A utility class with a bunch of methods that operate on the path names used by the PlainPB storage plugin.
- Author:
- mshankar
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe PlainPBStorage plugin has a naming scheme that provides much information. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetermineTimesFromFileName(String pvName, String finalNameComponent, PartitionGranularity partitionGranularity, PVNameToKeyMapping pv2key) Determines the times for a chunk simply from the file name.static Path[]getAllPathsForPV(ArchPaths archPaths, String rootFolder, String pvName, String extension, PathResolver pathResolver, PVNameToKeyMapping pv2key) 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).static PathgetFileName(String rootFolder, String pvName, Instant ts, String extension, PartitionGranularity partitionGranularity, boolean createParentFolder, ArchPaths paths, PathResolver pathResolver, PVNameToKeyMapping pv2key) This method returns the path for a given pv for a given time based on the partitionGranularitystatic PathgetMostRecentPathBeforeTime(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) If a PV changes infrequently, we often will not have a sample in the given time frame.static PathgetPathNameForTime(PlainStoragePlugin plugin, String pvName, Instant ts, ArchPaths paths, PVNameToKeyMapping pv2key) static PathgetPathNameForTime(String rootFolder, String pvName, Instant ts, PartitionGranularity partitionGranularity, ArchPaths paths, PathResolver pathResolver, PVNameToKeyMapping pv2key, String fileExtension) static Path[]getPathsBeforeCurrentPartition(ArchPaths archPaths, String rootFolder, String pvName, Instant currentTime, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) The PlainPB storage plugin partitions files according to time and partition granularity.static Path[]getPathsWithData(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, Instant endts, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) Given a parent folder, this method returns a list of all the paths with data that falls within the specified timeframe.static PathgetPreviousPartitionBeforeTime(ArchPaths archPaths, String rootFolder, String pvName, Instant startts, String extension, PartitionGranularity granularity, PathResolver pathResolver, PVNameToKeyMapping pv2key) If a PV changes infrequently, we often will not have a sample in the given time frame.
-
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, PathResolver pathResolver, 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 thePlainStoragePlugin. 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 PathsrootFolder- The root folder for the plugin.pvName- Name of the PV.startts- Instant startendts- Instant endextension- 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 PathsrootFolder- The root folder for the pluginpvName- The name of the PVcurrentTime- 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- PathResolverpv2key- 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 PathsrootFolder- The root folder for the pluginpvName- The name of the PVextension- 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 PathsrootFolder- The root folder for the pluginpvName- Name of the PV.startts- Instant startextension- The file extension.granularity- Partition granularity of the file.pathResolver- Path Resolverpv2key- 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 PathsrootFolder- The root folder for the pluginpvName- Name of the PV.startts- Instant startextension- The file extension.granularity- Partition granularity of the file.pathResolver- PathResolverpv2key- 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 pluginpvName- Name of the PV.ts- Seconds after linux epochextension- 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 componentpartitionGranularity- Partition granularity of the file.pv2key- PVNameToKeyMapping- Returns:
- fileNameTimes Start and End Time from name
- Throws:
IOException-
-