Class ChunkUtils
java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.helpers.ChunkUtils
Utility methods for chunk operations for KeyValue container.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final FileAttribute<?>[]static final Set<? extends OpenOption> -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisOverWriteRequested(File chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo) Checks if we are getting a request to overwrite an existing range of chunk.static booleanisOverWriteRequested(FileChannel channel, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo) Checks if a request to overwrite an existing range of a chunk has been received.static voidlimitReadSize(long len) static org.apache.hadoop.ozone.common.ChunkBufferreadData(long len, int bufferCapacity, File file, long off, HddsVolume volume, int readMappedBufferThreshold, boolean mmapEnabled, MappedBufferManager mappedBufferManager) static org.apache.hadoop.ozone.common.ChunkBufferToByteStringreadData(File file, long chunkSize, long offset, long length, HddsVolume volume, DispatcherContext context) static voidsetStripedLock(com.google.common.util.concurrent.Striped<ReadWriteLock> stripedLock) static voidvalidateBufferSize(long expected, long actual) static booleanvalidateChunkForOverwrite(File chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo info) Validates chunk data and returns a file object to Chunk File that we are expected to write data to.static booleanvalidateChunkForOverwrite(FileChannel chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo info) Validates chunk data and returns a boolean value that indicates if the chunk data should be overwritten.static voidvalidateChunkSize(FileChannel fileChannel, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo, String fileName) Checks if the block file length is equal to the chunk offset.static voidverifyChunkFileExists(File file) static org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionstatic voidwriteData(File file, org.apache.hadoop.ozone.common.ChunkBuffer data, long offset, long len, HddsVolume volume, boolean sync) Writes the data in chunk Info to the specified location in the chunkfile.static voidwriteData(FileChannel file, String filename, org.apache.hadoop.ozone.common.ChunkBuffer data, long offset, long len, HddsVolume volume)
-
Field Details
-
READ_OPTIONS
-
NO_ATTRIBUTES
-
DEFAULT_FILE_LOCK_STRIPED_SIZE
public static final int DEFAULT_FILE_LOCK_STRIPED_SIZE- See Also:
-
-
Method Details
-
setStripedLock
public static void setStripedLock(com.google.common.util.concurrent.Striped<ReadWriteLock> stripedLock) -
writeData
public static void writeData(File file, org.apache.hadoop.ozone.common.ChunkBuffer data, long offset, long len, HddsVolume volume, boolean sync) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Writes the data in chunk Info to the specified location in the chunkfile.- Parameters:
file- - File to write data to.data- - The data buffer.offset-len-volume- for statistics and checkersync- whether to do fsync or not- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
writeData
public static void writeData(FileChannel file, String filename, org.apache.hadoop.ozone.common.ChunkBuffer data, long offset, long len, HddsVolume volume) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
readData
public static org.apache.hadoop.ozone.common.ChunkBuffer readData(long len, int bufferCapacity, File file, long off, HddsVolume volume, int readMappedBufferThreshold, boolean mmapEnabled, MappedBufferManager mappedBufferManager) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
readData
public static org.apache.hadoop.ozone.common.ChunkBufferToByteString readData(File file, long chunkSize, long offset, long length, HddsVolume volume, DispatcherContext context) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
validateChunkForOverwrite
public static boolean validateChunkForOverwrite(File chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo info) Validates chunk data and returns a file object to Chunk File that we are expected to write data to.- Parameters:
chunkFile- - chunkFile to write data into.info- - chunk info.- Returns:
- true if the chunkFile exists and chunkOffset < chunkFile length, false otherwise.
-
validateChunkForOverwrite
public static boolean validateChunkForOverwrite(FileChannel chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo info) Validates chunk data and returns a boolean value that indicates if the chunk data should be overwritten.- Parameters:
chunkFile- - FileChannel of the chunkFile to write data into.info- - chunk info.- Returns:
- true if the chunkOffset is less than the chunkFile length, false otherwise.
-
isOverWriteRequested
public static boolean isOverWriteRequested(File chunkFile, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo) Checks if we are getting a request to overwrite an existing range of chunk.- Parameters:
chunkFile- - FilechunkInfo- - Buffer to write- Returns:
- bool
-
isOverWriteRequested
public static boolean isOverWriteRequested(FileChannel channel, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo) Checks if a request to overwrite an existing range of a chunk has been received.- Parameters:
channel- - FileChannel of the file to checkchunkInfo- - Chunk information containing the offset- Returns:
- true if the offset is less than the file length, indicating a request to overwrite an existing range; false otherwise
-
verifyChunkFileExists
public static void verifyChunkFileExists(File file) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
validateBufferSize
public static void validateBufferSize(long expected, long actual) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
limitReadSize
public static void limitReadSize(long len) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
wrapInStorageContainerException
public static org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException wrapInStorageContainerException(Exception e) -
validateChunkSize
public static void validateChunkSize(FileChannel fileChannel, org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo, String fileName) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Checks if the block file length is equal to the chunk offset.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-