Package org.apache.druid.segment.loading
Class StorageLocation
java.lang.Object
org.apache.druid.segment.loading.StorageLocation
This class is a very simple logical representation of a local path. It keeps track of files stored under the
path via reserve(java.lang.String, org.apache.druid.timeline.DataSegment), so that the total size of stored files doesn't exceed the maxSizeBytes
and available space is always kept smaller than freeSpaceToKeep.
This class is thread-safe, so that multiple threads can update its state at the same time.
One example usage is that a historical can use multiple threads to load different segments in parallel
from deep storage.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlonglonggetPath()booleanisReserved(String segmentDir) voidmaybeReserve(String segmentFilePathToAdd, DataSegment segment) Reserves space to store the given segment, only if it has not been done already.booleanvoidremoveFile(File file) Remove a segment file from this location.voidremoveSegmentDir(File segmentDir, DataSegment segment) Remove a segment dir from this location.Reserves space to store the given segment.reserve(String segmentDir, DataSegment segment) Reserves space to store the given segment.segmentDirectoryAsFile(String segmentDir)
-
Constructor Details
-
StorageLocation
-
-
Method Details
-
getPath
-
removeFile
Remove a segment file from this location. The given file argument must be a file rather than directory. -
removeSegmentDir
Remove a segment dir from this location. The segment size is subtracted from currSizeBytes. -
reserve
Reserves space to store the given segment. The segment size is added to currSizeBytes. If it succeeds, it returns a file for the given segmentDir in this storage location. Returns null otherwise. -
isReserved
-
segmentDirectoryAsFile
-
maybeReserve
Reserves space to store the given segment, only if it has not been done already. This can be used when segment is already downloaded on the disk. Unlikereserve(String, DataSegment), this function skips the check on disk availability. We also account for segment usage even if available size dips below 0. Such a situation indicates a configuration problem or a bug and we don't let segment loading fail because of this. -
reserve
Reserves space to store the given segment. If it succeeds, it returns a file for the given segmentFilePathToAdd in this storage location. Returns null otherwise. -
release
-
availableSizeBytes
public long availableSizeBytes() -
currSizeBytes
public long currSizeBytes()
-