Class KeyValueContainer
java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.KeyValueContainer
- All Implemented Interfaces:
Container<KeyValueContainerData>
Class to perform KeyValue Container operations. Any modifications to
KeyValueContainer object should ideally be done via api exposed in
KeyValueHandler class.
-
Constructor Summary
ConstructorsConstructorDescriptionKeyValueContainer(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource ozoneConfig) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToPendingPutBlockCache(long localID) Add the given localID of a block to the pendingPutBlockCache.voidclose()Closes a open/quasi closed container, if it is already closed or does not exist a StorageContainerException is thrown.voidcreate(VolumeSet volumeSet, VolumeChoosingPolicy volumeChoosingPolicy, String clusterId) Creates a container.protected voidcreateContainerMetaData(File containerMetaDataPath, File chunksPath, File dbFile, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource configuration) The Static method call is wrapped in a protected instance method so it can be overridden in tests.voiddelete()Deletes the container.voidexportContainerData(OutputStream destination, ContainerPacker<KeyValueContainerData> packer) Export all the data of the container to one output archive with the help of the packer.longReturns the blockCommitSequenceId.Get metadata about the container.Returns container DB file.Returns containerFile.static FilegetContainerFile(String metadataPath, long containerId) org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProtoReturns KeyValueContainerReport for the KeyValueContainer.org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.StateGet the Container Lifecycle state.org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerTypeReturn the ContainerType for the container.booleanReturns true if container has some block.booleanCheck if the current thread holds read lock.booleanCheck if the current thread holds write lock.voidimportContainerData(InputStream input, ContainerPacker<KeyValueContainerData> packer) Import the container from an external archive.voidimportContainerData(KeyValueContainerData originalContainerData) booleanisBlockInPendingPutBlockCache(long localID) Return whether the given localID of a block is present in the pendingPutBlockCache or not.voidMarks the container for closing.voidMarks the container replica as deleted.voidMarks the container replica as unhealthy.voidpopulatePathFields(String clusterId, HddsVolume containerVolume) Set all of the path realted container data fields based on the name conventions.voidQuasi Closes a open container, if it is already closed or does not exist a StorageContainerException is thrown.voidreadLock()Acquire read lock.voidAcquire read lock, unless interrupted while waiting.voidRelease read lock.voidremoveFromPendingPutBlockCache(long localID) Remove the given localID of a block from the pendingPutBlockCache.scanData(org.apache.hadoop.hdfs.util.DataTransferThrottler throttler, org.apache.hadoop.hdfs.util.Canceler canceler) Perform checksum verification for the container data.check and report the structural integrity of the container.voidsetCheckChunksFilePath(boolean bCheckChunksDirFilePath) booleanReturn if the container data should be checksum verified to detect corruption.voidUpdate the container.voidvoidupdateBlockCommitSequenceId(long blockCommitSequenceId) updates the blockCommitSequenceId.voidvoidupdateDeleteTransactionId(long deleteTransactionId) updates the DeleteTransactionId.voidAcquire write lock.voidAcquire write lock, unless interrupted while waiting.booleanwriteLockTryLock(long time, TimeUnit unit) voidRelease write lock.
-
Constructor Details
-
KeyValueContainer
public KeyValueContainer(KeyValueContainerData containerData, org.apache.hadoop.hdds.conf.ConfigurationSource ozoneConfig)
-
-
Method Details
-
setCheckChunksFilePath
public void setCheckChunksFilePath(boolean bCheckChunksDirFilePath) -
create
public void create(VolumeSet volumeSet, VolumeChoosingPolicy volumeChoosingPolicy, String clusterId) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Description copied from interface:ContainerCreates a container.- Specified by:
createin interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
createContainerMetaData
protected void createContainerMetaData(File containerMetaDataPath, File chunksPath, File dbFile, String schemaVersion, org.apache.hadoop.hdds.conf.ConfigurationSource configuration) throws IOException The Static method call is wrapped in a protected instance method so it can be overridden in tests.- Throws:
IOException
-
populatePathFields
Set all of the path realted container data fields based on the name conventions.- Parameters:
clusterId-containerVolume-
-
delete
public void delete() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerDeletes the container.- Specified by:
deletein interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
hasBlocks
Description copied from interface:ContainerReturns true if container has some block.- Specified by:
hasBlocksin interfaceContainer<KeyValueContainerData>- Returns:
- true if container has some block.
- Throws:
IOException- if was unable to check container status.
-
markContainerForClose
public void markContainerForClose() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerMarks the container for closing. Moves the container to CLOSING state.- Specified by:
markContainerForClosein interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
markContainerUnhealthy
public void markContainerUnhealthy() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerMarks the container replica as unhealthy.- Specified by:
markContainerUnhealthyin interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
markContainerForDelete
public void markContainerForDelete()Description copied from interface:ContainerMarks the container replica as deleted.- Specified by:
markContainerForDeletein interfaceContainer<KeyValueContainerData>
-
quasiClose
public void quasiClose() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerQuasi Closes a open container, if it is already closed or does not exist a StorageContainerException is thrown.- Specified by:
quasiClosein interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
close
public void close() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerCloses a open/quasi closed container, if it is already closed or does not exist a StorageContainerException is thrown.- Specified by:
closein interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
updateDataScanTimestamp
public void updateDataScanTimestamp(Instant time) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Specified by:
updateDataScanTimestampin interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
getContainerData
Description copied from interface:ContainerGet metadata about the container.- Specified by:
getContainerDatain interfaceContainer<KeyValueContainerData>- Returns:
- ContainerData - Container Data.
-
getContainerState
public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State getContainerState()Description copied from interface:ContainerGet the Container Lifecycle state.- Specified by:
getContainerStatein interfaceContainer<KeyValueContainerData>- Returns:
- ContainerLifeCycleState - Container State.
-
getContainerType
public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType getContainerType()Description copied from interface:ContainerReturn the ContainerType for the container.- Specified by:
getContainerTypein interfaceContainer<KeyValueContainerData>
-
update
public void update(Map<String, String> metadata, boolean forceUpdate) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDescription copied from interface:ContainerUpdate the container.- Specified by:
updatein interfaceContainer<KeyValueContainerData>- Parameters:
metadata-forceUpdate- if true, update container forcibly.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
update
public void update(Map<String, String> metadata, boolean forceUpdate, String containerMetadataPath) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException- Specified by:
updatein interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
updateDeleteTransactionId
public void updateDeleteTransactionId(long deleteTransactionId) Description copied from interface:Containerupdates the DeleteTransactionId.- Specified by:
updateDeleteTransactionIdin interfaceContainer<KeyValueContainerData>- Parameters:
deleteTransactionId-
-
importContainerData
public void importContainerData(InputStream input, ContainerPacker<KeyValueContainerData> packer) throws IOException Description copied from interface:ContainerImport the container from an external archive.- Specified by:
importContainerDatain interfaceContainer<KeyValueContainerData>- Throws:
IOException
-
importContainerData
- Throws:
IOException
-
exportContainerData
public void exportContainerData(OutputStream destination, ContainerPacker<KeyValueContainerData> packer) throws IOException Description copied from interface:ContainerExport all the data of the container to one output archive with the help of the packer.- Specified by:
exportContainerDatain interfaceContainer<KeyValueContainerData>- Throws:
IOException
-
readLock
public void readLock()Acquire read lock.- Specified by:
readLockin interfaceContainer<KeyValueContainerData>
-
readUnlock
public void readUnlock()Release read lock.- Specified by:
readUnlockin interfaceContainer<KeyValueContainerData>
-
hasReadLock
public boolean hasReadLock()Check if the current thread holds read lock.- Specified by:
hasReadLockin interfaceContainer<KeyValueContainerData>
-
writeLock
public void writeLock()Acquire write lock.- Specified by:
writeLockin interfaceContainer<KeyValueContainerData>
-
writeUnlock
public void writeUnlock()Release write lock.- Specified by:
writeUnlockin interfaceContainer<KeyValueContainerData>
-
hasWriteLock
public boolean hasWriteLock()Check if the current thread holds write lock.- Specified by:
hasWriteLockin interfaceContainer<KeyValueContainerData>
-
readLockInterruptibly
Acquire read lock, unless interrupted while waiting.- Specified by:
readLockInterruptiblyin interfaceContainer<KeyValueContainerData>- Throws:
InterruptedException
-
writeLockInterruptibly
Acquire write lock, unless interrupted while waiting.- Specified by:
writeLockInterruptiblyin interfaceContainer<KeyValueContainerData>- Throws:
InterruptedException
-
writeLockTryLock
- Throws:
InterruptedException
-
getContainerFile
Returns containerFile.- Specified by:
getContainerFilein interfaceContainer<KeyValueContainerData>- Returns:
- .container File name
-
getContainerFile
-
updateBlockCommitSequenceId
public void updateBlockCommitSequenceId(long blockCommitSequenceId) Description copied from interface:Containerupdates the blockCommitSequenceId.- Specified by:
updateBlockCommitSequenceIdin interfaceContainer<KeyValueContainerData>
-
getBlockCommitSequenceId
public long getBlockCommitSequenceId()Description copied from interface:ContainerReturns the blockCommitSequenceId.- Specified by:
getBlockCommitSequenceIdin interfaceContainer<KeyValueContainerData>
-
isBlockInPendingPutBlockCache
public boolean isBlockInPendingPutBlockCache(long localID) Return whether the given localID of a block is present in the pendingPutBlockCache or not. -
addToPendingPutBlockCache
public void addToPendingPutBlockCache(long localID) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Add the given localID of a block to the pendingPutBlockCache.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
removeFromPendingPutBlockCache
public void removeFromPendingPutBlockCache(long localID) Remove the given localID of a block from the pendingPutBlockCache. -
getContainerReport
public org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto getContainerReport() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionReturns KeyValueContainerReport for the KeyValueContainer.- Specified by:
getContainerReportin interfaceContainer<KeyValueContainerData>- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
getContainerDBFile
Returns container DB file. -
scanMetaData
Description copied from interface:Containercheck and report the structural integrity of the container.- Specified by:
scanMetaDatain interfaceContainer<KeyValueContainerData>- Returns:
- A
MetadataScanResultencapsulating the result of the scan. - Throws:
InterruptedException- if the scanning thread is interrupted before it completes.
-
shouldScanData
public boolean shouldScanData()Description copied from interface:ContainerReturn if the container data should be checksum verified to detect corruption. The result depends upon the current state of the container (e.g. if a container is accepting writes, it may not be a good idea to perform checksum verification to avoid concurrency issues).- Specified by:
shouldScanDatain interfaceContainer<KeyValueContainerData>
-
scanData
public DataScanResult scanData(org.apache.hadoop.hdfs.util.DataTransferThrottler throttler, org.apache.hadoop.hdfs.util.Canceler canceler) throws InterruptedException Description copied from interface:ContainerPerform checksum verification for the container data.- Specified by:
scanDatain interfaceContainer<KeyValueContainerData>- Parameters:
throttler- A reference ofDataTransferThrottlerused to perform I/O bandwidth throttlingcanceler- A reference ofCancelerused to cancel the I/O bandwidth throttling (e.g. for shutdown purpose).- Returns:
- A
DataScanResultencapsulating the result of the scan. - Throws:
InterruptedException- if the scanning thread is interrupted before it completes.
-