sumitagrawl commented on code in PR #12139:
URL: https://github.com/apache/ozone/pull/12139#discussion_r4692321529
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/ContainerSet.java:
##########
@@ -226,14 +259,30 @@ private boolean addContainer(Container<?> container,
boolean overwrite) throws
}
}
- private void updateContainerIdTable(long containerId, ContainerData
containerData) throws StorageContainerException {
+ /**
+ * Records the replica that is being added in the witnessed container DB.
The entry is written when:
+ * <ul>
+ * <li>there is none: this is the first replica of the container on this
datanode;</li>
+ * <li>it is DELETED: this datanode deleted its replica, and now loads one
from disk at startup or gets one through
+ * repair. An ordinary create does not get here for a DELETED entry,
KeyValueHandler refuses it;</li>
+ * <li>it has no replica index: it was written in the older table
format;</li>
+ * <li>{@code replaceReplicaIndex} is set and the replica has another
index than the entry: a repair replaces the
+ * replica that this datanode held.</li>
+ * </ul>
+ * In all other cases the entry is kept as it is.
+ */
+ private void updateContainerIdTable(long containerId, ContainerData
containerData, boolean replaceReplicaIndex)
+ throws StorageContainerException {
if (null != containerMetadataStore) {
try {
ContainerID containerIdObj = ContainerID.valueOf(containerId);
Table<ContainerID, ContainerCreateInfo> containerCreateInfoTable =
containerMetadataStore.getContainerCreateInfoTable();
ContainerCreateInfo containerCreateInfo =
containerCreateInfoTable.get(containerIdObj);
- if (containerCreateInfo == null ||
containerCreateInfo.getReplicaIndex() == INVALID_REPLICA_INDEX) {
+ if (containerCreateInfo == null
+ || containerCreateInfo.getState() == State.DELETED
Review Comment:
Earlier, purpose was to avoid creation of container is already exist, so
first it try to get and then update if not present.
But since the check is done outside, getter is no more required here and we
can update with value directly and avoid double check.
--
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]