hanishakoneru commented on a change in pull request #3034:
URL: https://github.com/apache/ozone/pull/3034#discussion_r812333779
##########
File path:
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueContainer.java
##########
@@ -89,15 +90,30 @@
private final KeyValueContainerData containerData;
private ConfigurationSource config;
+ // Cache of Blocks (LocalIDs) awaiting final PutBlock call after the stream
+ // is closed. When a block is added to the DB as part of putBlock, it is
+ // added to the cache here. It is cleared from the Cache when the putBlock
+ // is called on the block as part of stream.close() (with endOfBlock = true
+ // in BlockManagerImpl#putBlock). Or when the container is marked for
+ // close, the whole cache is cleared as there can be no more writes to this
+ // container.
+ // We do not need to explicitly synchronize this cache as the writes to
+ // container are synchronous.
+ private ArrayList<Long> pendingPutBlockCache;
+
public KeyValueContainer(KeyValueContainerData containerData,
- ConfigurationSource
- ozoneConfig) {
+ ConfigurationSource ozoneConfig) {
Preconditions.checkNotNull(containerData,
"KeyValueContainerData cannot be null");
Preconditions.checkNotNull(ozoneConfig,
"Ozone configuration cannot be null");
this.config = ozoneConfig;
this.containerData = containerData;
+ if (this.containerData.isOpen() || this.containerData.isClosing()) {
+ // If container is not in OPEN or CLOSING state, there cannot be block
+ // writes to the container. So pendingPutBlockCache is not needed.
+ this.pendingPutBlockCache = new ArrayList<>();
+ }
Review comment:
The null check is a safety net I added just in case there is a scenario
(not that I can think of right now) where we try to call add/ remove on an
uninitialized object.
How about I add a TODO to remove the null check (and replace with empty
collection)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]