You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/08/23 18:03:00 UTC

[GitHub] [ozone] umamaheswararao commented on a diff in pull request #3634: HDDS-7058. EC: ReplicationManager - Implement Ratis Container healthCheck

umamaheswararao commented on code in PR #3634:
URL: https://github.com/apache/ozone/pull/3634#discussion_r952814919


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerHealthCheck.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+package org.apache.hadoop.hdds.scm.container.replication;
+
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.scm.ContainerPlacementStatus;
+import org.apache.hadoop.hdds.scm.PlacementPolicy;
+import org.apache.hadoop.hdds.scm.container.ContainerInfo;
+import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Class to determine the health state of a Ratis Container. Given the container
+ * and current replica details, along with replicas pending add and delete,
+ * this class will return a ContainerHealthResult indicating if the container
+ * is healthy, or under / over replicated etc.
+ */
+public class RatisContainerHealthCheck implements ContainerHealthCheck {
+  public static final Logger LOG =
+      LoggerFactory.getLogger(RatisContainerHealthCheck.class);
+
+  /**
+   * PlacementPolicy which is used to identify where a container
+   * should be replicated.
+   */
+  private final PlacementPolicy ratisContainerPlacement;
+
+  public RatisContainerHealthCheck(final PlacementPolicy containerPlacement) {
+    this.ratisContainerPlacement = containerPlacement;
+  }
+
+  @Override
+  public ContainerHealthResult checkHealth(ContainerInfo container,
+      Set<ContainerReplica> replicas,
+      List<ContainerReplicaOp> replicaPendingOps,
+      int remainingRedundancyForMaintenance) {
+    int pendingAdd = 0;
+    int pendingDelete = 0;
+    for (ContainerReplicaOp op : replicaPendingOps) {
+      if (op.getOpType() == ContainerReplicaOp.PendingOpType.ADD) {
+        pendingAdd++;
+      } else if (op.getOpType() == ContainerReplicaOp.PendingOpType.DELETE) {
+        pendingDelete++;
+      } else {
+        LOG.warn("unknown opType of op : {}", op);
+        //TODO: return an appropriate state
+        return new ContainerHealthResult.UnHealthyResult(container);
+      }
+    }
+    int requiredNodes = container.getReplicationConfig().getRequiredNodes();
+
+    RatisContainerReplicaCount replicaCount =
+        new RatisContainerReplicaCount(container, replicas, pendingAdd,
+            pendingDelete, requiredNodes, remainingRedundancyForMaintenance);
+
+    ContainerPlacementStatus placementStatus =
+        getPlacementStatus(replicas, requiredNodes);
+
+    boolean sufficientlyReplicated = replicaCount.isSufficientlyReplicated();
+    boolean isPolicySatisfied = placementStatus.isPolicySatisfied();
+    if (!sufficientlyReplicated || !isPolicySatisfied) {

Review Comment:
   Probably misreplicated state should be given low priority compared to Underplicated state. So, is it make sense to have misreplicated status once under/overreplicated status checks done?



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/RatisContainerHealthCheck.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.
+ */
+package org.apache.hadoop.hdds.scm.container.replication;
+
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.scm.ContainerPlacementStatus;
+import org.apache.hadoop.hdds.scm.PlacementPolicy;
+import org.apache.hadoop.hdds.scm.container.ContainerInfo;
+import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Class to determine the health state of a Ratis Container. Given the container
+ * and current replica details, along with replicas pending add and delete,
+ * this class will return a ContainerHealthResult indicating if the container
+ * is healthy, or under / over replicated etc.
+ */
+public class RatisContainerHealthCheck implements ContainerHealthCheck {
+  public static final Logger LOG =
+      LoggerFactory.getLogger(RatisContainerHealthCheck.class);
+
+  /**
+   * PlacementPolicy which is used to identify where a container
+   * should be replicated.
+   */
+  private final PlacementPolicy ratisContainerPlacement;
+
+  public RatisContainerHealthCheck(final PlacementPolicy containerPlacement) {
+    this.ratisContainerPlacement = containerPlacement;
+  }
+
+  @Override
+  public ContainerHealthResult checkHealth(ContainerInfo container,
+      Set<ContainerReplica> replicas,
+      List<ContainerReplicaOp> replicaPendingOps,
+      int remainingRedundancyForMaintenance) {
+    int pendingAdd = 0;
+    int pendingDelete = 0;
+    for (ContainerReplicaOp op : replicaPendingOps) {
+      if (op.getOpType() == ContainerReplicaOp.PendingOpType.ADD) {
+        pendingAdd++;
+      } else if (op.getOpType() == ContainerReplicaOp.PendingOpType.DELETE) {
+        pendingDelete++;
+      } else {
+        LOG.warn("unknown opType of op : {}", op);
+        //TODO: return an appropriate state
+        return new ContainerHealthResult.UnHealthyResult(container);
+      }
+    }
+    int requiredNodes = container.getReplicationConfig().getRequiredNodes();
+
+    RatisContainerReplicaCount replicaCount =
+        new RatisContainerReplicaCount(container, replicas, pendingAdd,
+            pendingDelete, requiredNodes, remainingRedundancyForMaintenance);
+
+    ContainerPlacementStatus placementStatus =
+        getPlacementStatus(replicas, requiredNodes);
+
+    boolean sufficientlyReplicated = replicaCount.isSufficientlyReplicated();
+    boolean isPolicySatisfied = placementStatus.isPolicySatisfied();
+    if (!sufficientlyReplicated || !isPolicySatisfied) {

Review Comment:
   Even if HDDS-6892 implemented to provide Mis replicated status, we need to revisit here to use that. So, I would suggest to file a followup.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org