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 voiddeleteFile(String path)Delete file present at the input path.voiddeleteFiles(Iterable<String> paths)Delete files present at the input paths.voiddeleteRecursively(String path)Delete a directory pointed to by the path and also recursively deletes all files/directories in said directory.static NilStorageConnectorgetInstance()Iterator<String>listDir(String dirName)Returns a lazy iterator containing all the files present in the path.booleanpathExists(String path)Check if the path exists in the underlying storage layer.InputStreamread(String path)Reads the data present at the path in the underlying storage system.InputStreamreadRange(String path, long from, long size)Reads the data present for a given range at the path in the underlying storage system.OutputStreamwrite(String path)Open anOutputStreamfor 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:StorageConnectorCheck if the path exists in the underlying storage layer. Most implementations prepend the input path with a basePath.- Specified by:
pathExistsin interfaceStorageConnector- Returns:
- true if path exists else false.
-
read
public InputStream read(String path)
Description copied from interface:StorageConnectorReads 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:
readin interfaceStorageConnector- Returns:
- InputStream
-
readRange
public InputStream readRange(String path, long from, long size)
Description copied from interface:StorageConnectorReads 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:
readRangein 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:StorageConnectorOpen anOutputStreamfor 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:
writein interfaceStorageConnector- Parameters:
path- to write- Returns:
- OutputStream to the path
-
deleteFile
public void deleteFile(String path)
Description copied from interface:StorageConnectorDelete 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:
deleteFilein interfaceStorageConnector- Parameters:
path- to delete
-
deleteFiles
public void deleteFiles(Iterable<String> paths)
Description copied from interface:StorageConnectorDelete 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:
deleteFilesin interfaceStorageConnector- Parameters:
paths- Iterable of the paths to delete.
-
deleteRecursively
public void deleteRecursively(String path)
Description copied from interface:StorageConnectorDelete 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:
deleteRecursivelyin interfaceStorageConnector- Parameters:
path- path
-
listDir
public Iterator<String> listDir(String dirName)
Description copied from interface:StorageConnectorReturns 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:
listDirin interfaceStorageConnector
-
-