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 2021/04/13 08:25:40 UTC

[GitHub] [ozone] elek commented on a change in pull request #2068: HDDS-5011. Introduce ECReplicationConfig and Java based ReplicationConfig implementation

elek commented on a change in pull request #2068:
URL: https://github.com/apache/ozone/pull/2068#discussion_r612236927



##########
File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/RatisReplicationConfig.java
##########
@@ -0,0 +1,82 @@
+/**
+ * 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.
+ */
+
+package org.apache.hadoop.hdds.client;
+
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
+
+import java.util.Objects;
+
+/**
+ * Replication configuration for EC replication.
+ */
+public class RatisReplicationConfig
+    implements ReplicationConfig {
+
+  private final ReplicationFactor replicationFactor;
+
+  public RatisReplicationConfig(ReplicationFactor replicationFactor) {
+    this.replicationFactor = replicationFactor;
+  }
+
+  public static boolean hasFactor(ReplicationConfig replicationConfig,
+      ReplicationFactor factor) {
+    if (replicationConfig instanceof RatisReplicationConfig) {
+      return ((RatisReplicationConfig) replicationConfig).getReplicationFactor()
+          .equals(factor);
+    }
+    return false;
+  }
+
+  @Override
+  public ReplicationType getReplicationType() {
+    return ReplicationType.RATIS;
+  }
+
+  @Override
+  public int getRequiredNodes() {
+    return replicationFactor.getNumber();
+  }
+
+  public ReplicationFactor getReplicationFactor() {
+    return replicationFactor;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
+    RatisReplicationConfig that = (RatisReplicationConfig) o;
+    return replicationFactor == that.replicationFactor;
+  }
+
+  @Override
+  public String toString() {
+    return "RATIS/" + replicationFactor;
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(replicationFactor);
+  }
+}

Review comment:
       `RatisReplictionConfig` is not serialized anymore to any `***ReplicationConfig` proto structure. Only the replication factor is required which can be retrieved with either casting or using the `getLegacyFactor` helper method.   




-- 
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.

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