public class StorageLocation extends Object
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 and Description |
|---|
StorageLocation(File path,
long maxSizeBytes,
Double freeSpacePercent) |
| Modifier and Type | Method and Description |
|---|---|
long |
availableSizeBytes() |
long |
currSizeBytes() |
File |
getPath() |
boolean |
isReserved(String segmentDir) |
void |
maybeReserve(String segmentFilePathToAdd,
DataSegment segment)
Reserves space to store the given segment, only if it has not been done already.
|
boolean |
release(String segmentFilePath,
long segmentSize) |
void |
removeFile(File file)
Remove a segment file from this location.
|
void |
removeSegmentDir(File segmentDir,
DataSegment segment)
Remove a segment dir from this location.
|
File |
reserve(String segmentDir,
DataSegment segment)
Reserves space to store the given segment.
|
File |
reserve(String segmentFilePathToAdd,
String segmentId,
long segmentSize)
Reserves space to store the given segment.
|
File |
segmentDirectoryAsFile(String segmentDir) |
public File getPath()
public void removeFile(File file)
public void removeSegmentDir(File segmentDir, DataSegment segment)
@Nullable public File reserve(String segmentDir, DataSegment segment)
public boolean isReserved(String segmentDir)
public void maybeReserve(String segmentFilePathToAdd, DataSegment segment)
reserve(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.@Nullable public File reserve(String segmentFilePathToAdd, String segmentId, long segmentSize)
public boolean release(String segmentFilePath, long segmentSize)
public long availableSizeBytes()
public long currSizeBytes()
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.