Package org.apache.druid.storage
Class NilStorageConnector
- java.lang.Object
-
- org.apache.druid.storage.NilStorageConnector
-
- All Implemented Interfaces:
StorageConnector
public class NilStorageConnector extends Object implements StorageConnector
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteFile(String path)
Delete file present at the input path.void
deleteFiles(Iterable<String> paths)
Delete files present at the input paths.void
deleteRecursively(String path)
Delete a directory pointed to by the path and also recursively deletes all files/directories in said directory.static NilStorageConnector
getInstance()
Iterator<String>
listDir(String dirName)
Returns a lazy iterator containing all the files present in the path.boolean
pathExists(String path)
Check if the path exists in the underlying storage layer.InputStream
read(String path)
Reads the data present at the path in the underlying storage system.InputStream
readRange(String path, long from, long size)
Reads the data present for a given range at the path in the underlying storage system.OutputStream
write(String path)
Open anOutputStream
for writing data to the path in the underlying storage system.
-
-
-
Method Detail
-
getInstance
public static NilStorageConnector getInstance()
-
pathExists
public boolean pathExists(String path)
Description copied from interface:StorageConnector
Check if the path exists in the underlying storage layer. Most implementations prepend the input path with a basePath.- Specified by:
pathExists
in interfaceStorageConnector
- Returns:
- true if path exists else false.
-
read
public InputStream read(String path)
Description copied from interface:StorageConnector
Reads the data present at the path in the underlying storage system. Most implementations prepend the input path with a basePath. The caller should take care of closing the stream when done or in case of error.- Specified by:
read
in interfaceStorageConnector
- Returns:
- InputStream
-
readRange
public InputStream readRange(String path, long from, long size)
Description copied from interface:StorageConnector
Reads the data present for a given range at the path in the underlying storage system. Most implementations prepend the input path with a basePath. The caller should take care of closing the stream when done or in case of error. Further, the caller must ensure that the start offset and the size of the read are valid parameters for the given path for correct behavior.- Specified by:
readRange
in interfaceStorageConnector
- Parameters:
path
- The path to read data fromfrom
- Start offset of the read in the pathsize
- Length of the read to be done- Returns:
- InputStream starting from the given offset limited by the given size
-
write
public OutputStream write(String path)
Description copied from interface:StorageConnector
Open anOutputStream
for writing data to the path in the underlying storage system. Most implementations prepend the input path with a basePath. If an object exists at the path, the existing object will be overwritten by the write operation. Callers are adivised to namespace there files as there might be race conditions. The caller should take care of closing the stream when done or in case of error.- Specified by:
write
in interfaceStorageConnector
- Parameters:
path
- to write- Returns:
- OutputStream to the path
-
deleteFile
public void deleteFile(String path)
Description copied from interface:StorageConnector
Delete file present at the input path. Most implementations prepend the input path with a basePath. If the path is a directory, this method throws an exception.- Specified by:
deleteFile
in interfaceStorageConnector
- Parameters:
path
- to delete
-
deleteFiles
public void deleteFiles(Iterable<String> paths)
Description copied from interface:StorageConnector
Delete files present at the input paths. Most implementations prepend all the input paths with the basePath.
This method is recommended in case we need to delete a batch of files. If the path is a directory, this method throws an exception.- Specified by:
deleteFiles
in interfaceStorageConnector
- Parameters:
paths
- Iterable of the paths to delete.
-
deleteRecursively
public void deleteRecursively(String path)
Description copied from interface:StorageConnector
Delete a directory pointed to by the path and also recursively deletes all files/directories in said directory. Most implementations prepend the input path with a basePath.- Specified by:
deleteRecursively
in interfaceStorageConnector
- Parameters:
path
- path
-
listDir
public Iterator<String> listDir(String dirName)
Description copied from interface:StorageConnector
Returns a lazy iterator containing all the files present in the path. The returned filenames should be such that joining the dirName and the file name form the full path that can be used as the arguments for other methods of the storage connector. For example, for a S3 path such as s3://bucket/parent1/parent2/child, the filename returned for the input path "parent1/parent2" should be "child" and for input "parent1" should be "parent2/child"- Specified by:
listDir
in interfaceStorageConnector
-
-