Class FileSystemHelper
- java.lang.Object
-
- org.openstreetmap.atlas.generator.tools.filesystem.FileSystemHelper
-
public final class FileSystemHelper extends java.lang.ObjectUtility class that helps generatingResourceandWritableResourcefrom a Hadoop Path.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFILE_NOT_FOUND
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleandelete(java.lang.String path, boolean recursive, java.util.Map<java.lang.String,java.lang.String> configuration)Deletes given path using given configuration settings.static booleanexists(java.lang.String path)Check if the given path exists.static booleanexists(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)Check if the given path exists.static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource>listResourcesRecursively(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)static booleanmkdir(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)Creates a new directory for given path using given configuration settings.static booleanrename(java.lang.String sourcePath, java.lang.String destinationPath, java.util.Map<java.lang.String,java.lang.String> configuration)Renames a source path to a destination path using the given configuration settings.static org.openstreetmap.atlas.streaming.resource.Resourceresource(java.lang.String path)static org.openstreetmap.atlas.streaming.resource.Resourceresource(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource>resources(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration)List resources, but omit the hadoop "_SUCCESS" file.static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource>resources(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)static java.util.stream.Stream<org.apache.hadoop.fs.Path>streamPathsRecursively(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)static org.openstreetmap.atlas.streaming.resource.WritableResourcewritableResource(java.lang.String path)static org.openstreetmap.atlas.streaming.resource.WritableResourcewritableResource(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)
-
-
-
Field Detail
-
FILE_NOT_FOUND
public static final java.lang.String FILE_NOT_FOUND
- See Also:
- Constant Field Values
-
-
Method Detail
-
delete
public static boolean delete(java.lang.String path, boolean recursive, java.util.Map<java.lang.String,java.lang.String> configuration)Deletes given path using given configuration settings.- Parameters:
path- Path to deleterecursive- If given path is a directory and this is set, then directory and all child items will be deleted, otherwise throws Exception.configuration- Configuration settings to use as context- Returns:
- true if deletion succeeded
-
exists
public static boolean exists(java.lang.String path)
Check if the given path exists.- Parameters:
path- The path to check- Returns:
- If the given path exists
-
exists
public static boolean exists(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)Check if the given path exists.- Parameters:
path- The path to checkconfiguration- The configuration map- Returns:
- If the given path exists
-
listResourcesRecursively
public static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource> listResourcesRecursively(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)- Parameters:
directory- The directory from which to recursively load filesconfiguration- The configuration (containing the filesystem definition)filter- The path filter. If null, all the files will be returned.- Returns:
- a list of
Resources
-
mkdir
public static boolean mkdir(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)Creates a new directory for given path using given configuration settings.- Parameters:
path- Path to use for directory creation operationconfiguration- Configuration settings to use as context- Returns:
- true if create operation succeeded
-
rename
public static boolean rename(java.lang.String sourcePath, java.lang.String destinationPath, java.util.Map<java.lang.String,java.lang.String> configuration)Renames a source path to a destination path using the given configuration settings. This assumes that the source and destination path file systems are the same. Hence, the source path is used as a reference while initializing file system.- Parameters:
sourcePath- Path to rename fromdestinationPath- Path to rename toconfiguration- Configuration settings to use as context- Returns:
- true if rename operation succeeded
-
resource
public static org.openstreetmap.atlas.streaming.resource.Resource resource(java.lang.String path)
- Parameters:
path- The path to create the resource from- Returns:
- A
Resourcecoming from the defaultRawLocalFileSystem
-
resource
public static org.openstreetmap.atlas.streaming.resource.Resource resource(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)- Parameters:
path- The path to create the resource fromconfiguration- The configuration defining theFileSystem- Returns:
- A
Resourcecoming from the appropriateFileSystem
-
resources
public static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource> resources(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration)List resources, but omit the hadoop "_SUCCESS" file.- Parameters:
directory- The directory from which to load filesconfiguration- The configuration defining theFileSystem- Returns:
- a list of
Resources which contains all the files but the _SUCCESS file
-
resources
public static java.util.List<org.openstreetmap.atlas.streaming.resource.Resource> resources(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)- Parameters:
directory- The directory from which to load filesconfiguration- The configuration defining theFileSystemfilter- The path filter. If null, all the files will be returned.- Returns:
- a list of
Resources
-
streamPathsRecursively
public static java.util.stream.Stream<org.apache.hadoop.fs.Path> streamPathsRecursively(java.lang.String directory, java.util.Map<java.lang.String,java.lang.String> configuration, org.apache.hadoop.fs.PathFilter filter)- Parameters:
directory- The directory from which to recursively stream pathsconfiguration- The configuration (containing the filesystem definition)filter- The path filter. If null, all the paths will be returned.- Returns:
- a stream of
Paths
-
writableResource
public static org.openstreetmap.atlas.streaming.resource.WritableResource writableResource(java.lang.String path)
- Parameters:
path- The path to create the resource from- Returns:
- A
WritableResourcecoming from the defaultRawLocalFileSystem
-
writableResource
public static org.openstreetmap.atlas.streaming.resource.WritableResource writableResource(java.lang.String path, java.util.Map<java.lang.String,java.lang.String> configuration)- Parameters:
path- The path to create the resource fromconfiguration- The configuration defining theFileSystem- Returns:
- A
WritableResourcecoming from the appropriateFileSystem
-
-