Interface Container<CONTAINERDATA extends ContainerData>
- All Known Implementing Classes:
KeyValueContainer
public interface Container<CONTAINERDATA extends ContainerData>
Interface for Container Operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()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 scmId) Creates a container.voiddelete()Deletes the container.voidexportContainerData(OutputStream stream, ContainerPacker<CONTAINERDATA> 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 containerFile.org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProtoReturns containerReport for the container.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 stream, ContainerPacker<CONTAINERDATA> packer) Import the container from an external archive.voidMarks the container for closing.voidMarks the container replica as deleted.voidMarks the container replica as unhealthy.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.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.booleanReturn if the container data should be checksum verified to detect corruption.voidUpdate the container.voidvoidupdateBlockCommitSequenceId(long blockCommitSequenceId) updates the blockCommitSequenceId.voidupdateDataScanTimestamp(Instant timestamp) voidupdateDeleteTransactionId(long deleteTransactionId) updates the DeleteTransactionId.voidAcquire write lock.voidAcquire write lock, unless interrupted while waiting.voidRelease write lock.
-
Method Details
-
create
void create(VolumeSet volumeSet, VolumeChoosingPolicy volumeChoosingPolicy, String scmId) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException Creates a container.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
delete
void delete() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionDeletes the container.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
hasBlocks
Returns true if container has some block.- Returns:
- true if container has some block.
- Throws:
IOException- if was unable to check container status.
-
update
void update(Map<String, String> metaData, boolean forceUpdate) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionUpdate the container.- Parameters:
metaData-forceUpdate- if true, update container forcibly.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
update
void update(Map<String, String> metaData, boolean forceUpdate, String containerMetadataPath) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
updateDataScanTimestamp
void updateDataScanTimestamp(Instant timestamp) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
getContainerData
CONTAINERDATA getContainerData()Get metadata about the container.- Returns:
- ContainerData - Container Data.
-
getContainerState
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State getContainerState()Get the Container Lifecycle state.- Returns:
- ContainerLifeCycleState - Container State.
-
markContainerForClose
void markContainerForClose() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionMarks the container for closing. Moves the container to CLOSING state.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
markContainerUnhealthy
void markContainerUnhealthy() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionMarks the container replica as unhealthy.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
markContainerForDelete
void markContainerForDelete()Marks the container replica as deleted. -
quasiClose
void quasiClose() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionQuasi Closes a open container, if it is already closed or does not exist a StorageContainerException is thrown.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
close
void close() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionCloses a open/quasi closed container, if it is already closed or does not exist a StorageContainerException is thrown.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
getContainerType
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType getContainerType()Return the ContainerType for the container. -
getContainerFile
File getContainerFile()Returns containerFile. -
updateDeleteTransactionId
void updateDeleteTransactionId(long deleteTransactionId) updates the DeleteTransactionId.- Parameters:
deleteTransactionId-
-
importContainerData
void importContainerData(InputStream stream, ContainerPacker<CONTAINERDATA> packer) throws IOException Import the container from an external archive.- Throws:
IOException
-
exportContainerData
void exportContainerData(OutputStream stream, ContainerPacker<CONTAINERDATA> packer) throws IOException Export all the data of the container to one output archive with the help of the packer.- Throws:
IOException
-
getContainerReport
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReplicaProto getContainerReport() throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerExceptionReturns containerReport for the container.- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
updateBlockCommitSequenceId
void updateBlockCommitSequenceId(long blockCommitSequenceId) updates the blockCommitSequenceId. -
getBlockCommitSequenceId
long getBlockCommitSequenceId()Returns the blockCommitSequenceId. -
scanMetaData
check and report the structural integrity of the container.- Returns:
- A
MetadataScanResultencapsulating the result of the scan. - Throws:
InterruptedException- if the scanning thread is interrupted before it completes.
-
shouldScanData
boolean shouldScanData()Return 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). -
scanData
DataScanResult scanData(org.apache.hadoop.hdfs.util.DataTransferThrottler throttler, org.apache.hadoop.hdfs.util.Canceler canceler) throws InterruptedException Perform checksum verification for the container data.- 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.
-
readLock
void readLock()Acquire read lock. -
readLockInterruptibly
Acquire read lock, unless interrupted while waiting.- Throws:
InterruptedException
-
readUnlock
void readUnlock()Release read lock. -
hasReadLock
boolean hasReadLock()Check if the current thread holds read lock. -
writeLock
void writeLock()Acquire write lock. -
writeLockInterruptibly
Acquire write lock, unless interrupted while waiting.- Throws:
InterruptedException
-
writeUnlock
void writeUnlock()Release write lock. -
hasWriteLock
boolean hasWriteLock()Check if the current thread holds write lock.
-