kerneltime commented on code in PR #7402:
URL: https://github.com/apache/ozone/pull/7402#discussion_r1847754135
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/impl/HddsDispatcher.java:
##########
@@ -276,7 +277,8 @@ private ContainerCommandResponseProto dispatchRequest(
getMissingContainerSet().remove(containerID);
}
}
- if (getMissingContainerSet().contains(containerID)) {
+ if (cmdType != Type.CreateContainer && !HddsUtils.isReadOnly(msg)
Review Comment:
Why do we need to expand this check?
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -378,7 +387,11 @@ ContainerCommandResponseProto handleCreateContainer(
try {
if (containerSet.getContainer(containerID) == null) {
newContainer.create(volumeSet, volumeChoosingPolicy, clusterId);
- created = containerSet.addContainer(newContainer);
+ if (RECOVERING == newContainer.getContainerState()) {
+ created =
containerSet.addContainerByOverwriteMissingContainer(newContainer);
+ } else {
+ created = containerSet.addContainer(newContainer);
+ }
Review Comment:
```suggestion
if (RECOVERING == newContainer.getContainerState()) {
created = containerSet.addContainer(newContainer);
} else {
created = containerSet.addContainerIfNotPresent(newContainer);
}
```
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -354,6 +354,15 @@ ContainerCommandResponseProto handleCreateContainer(
}
long containerID = request.getContainerID();
+ State containerState = request.getCreateContainer().getState();
+
+ if (containerState != RECOVERING) {
+ try {
+ containerSet.validateContainerIsMissing(containerID, containerState);
+ } catch (StorageContainerException ex) {
+ return ContainerUtils.logAndReturnError(LOG, ex, request);
+ }
+ }
Review Comment:
This code reads poorly and complicates a straighforward logic. The witnessed
container list should NOT care about the state.
```suggestion
if (containerSet.wasContainerWitnessed(containerID) && containerState
!= RECOVERING) {
LOG.warn("Trying to create a container already witnessed on this
node which is not in recovering state);
return ContainerUtils.logAndReturnError(LOG, null, request);
}
```
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/MasterVolumeDBDefinition.java:
##########
@@ -0,0 +1,72 @@
+package org.apache.hadoop.ozone.container.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto.State;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.utils.db.DBColumnFamilyDefinition;
+import org.apache.hadoop.hdds.utils.db.DBDefinition;
+import org.apache.hadoop.hdds.utils.db.LongCodec;
+import org.apache.hadoop.hdds.utils.db.Proto2EnumCodec;
+import org.apache.hadoop.ozone.OzoneConsts;
+
+import java.util.Map;
+
+/**
+ * Class for defining the schema for master volume in a datanode.
+ */
+public final class MasterVolumeDBDefinition extends DBDefinition.WithMap {
Review Comment:
This new vocabulary introduced in this PR will complicate the code and
design literature for a long time.
We don't have a `MasterVolume` in the design. We have locations (paths)
where we store Ratis logs, or Datanode ID. These could all be one volume or any
volume. Looking at the code, I do not like this terminology introduced.
```suggestion
public final class WitnessedVolumeStore extends DBDefinition.WithMap {
```
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/MasterVolumeMetadataStore.java:
##########
@@ -0,0 +1,88 @@
+package org.apache.hadoop.ozone.container.metadata;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.utils.db.DBStore;
+import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
+import org.apache.hadoop.hdds.utils.db.Table;
+import org.apache.hadoop.hdds.utils.db.managed.ManagedDBOptions;
+import org.apache.hadoop.ozone.container.common.utils.BaseReferenceCountedDB;
+import org.apache.hadoop.ozone.container.common.utils.ReferenceCountedHandle;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * Class for interacting with database in the master volume of a datanode.
+ */
+public final class MasterVolumeMetadataStore extends
AbstractRDBStore<MasterVolumeDBDefinition>
Review Comment:
```suggestion
public final class WitnessedContainerMetadataStore extends
AbstractRDBStore<MasterVolumeDBDefinition>
```
--
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]