This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 197553eb7a HDDS-11113. Remove unused ScmUtils#preCheck and related 
code (#6907)
197553eb7a is described below

commit 197553eb7ac66d83d33e62c255313d679583de56
Author: Maksim Myskov <[email protected]>
AuthorDate: Tue Jul 9 06:17:01 2024 +0300

    HDDS-11113. Remove unused ScmUtils#preCheck and related code (#6907)
---
 .../java/org/apache/hadoop/hdds/scm/ScmUtils.java  | 27 ---------
 .../apache/hadoop/hdds/scm/safemode/Precheck.java  | 29 ---------
 .../hadoop/hdds/scm/safemode/SafeModePrecheck.java | 69 ----------------------
 .../hdds/scm/safemode/SafeModeRestrictedOps.java   | 41 -------------
 4 files changed, 166 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ScmUtils.java 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ScmUtils.java
index cc6147c7a6..3f6b90b05e 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ScmUtils.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ScmUtils.java
@@ -23,10 +23,8 @@ import java.util.List;
 import java.util.concurrent.BlockingQueue;
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ScmOps;
 import org.apache.hadoop.hdds.scm.events.SCMEvents;
 import org.apache.hadoop.hdds.scm.exceptions.SCMException;
-import org.apache.hadoop.hdds.scm.safemode.Precheck;
 
 import org.apache.hadoop.hdds.scm.security.RootCARotationManager;
 import org.apache.hadoop.hdds.scm.server.ContainerReportQueue;
@@ -39,7 +37,6 @@ import jakarta.annotation.Nonnull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.File;
 import java.net.InetSocketAddress;
 import java.util.Optional;
 import java.util.OptionalInt;
@@ -75,30 +72,6 @@ public final class ScmUtils {
   private ScmUtils() {
   }
 
-  /**
-   * Perform all prechecks for given scm operation.
-   *
-   * @param operation
-   * @param preChecks prechecks to be performed
-   */
-  public static void preCheck(ScmOps operation, Precheck... preChecks)
-      throws SCMException {
-    for (Precheck preCheck : preChecks) {
-      preCheck.check(operation);
-    }
-  }
-
-  /**
-   * Create SCM directory file based on given path.
-   */
-  public static File createSCMDir(String dirPath) {
-    File dirFile = new File(dirPath);
-    if (!dirFile.mkdirs() && !dirFile.exists()) {
-      throw new IllegalArgumentException("Unable to create path: " + dirFile);
-    }
-    return dirFile;
-  }
-
   public static InetSocketAddress getScmBlockProtocolServerAddress(
       OzoneConfiguration conf, String localScmServiceId, String nodeId) {
     String bindHostKey = ConfUtils.addKeySuffixes(
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/Precheck.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/Precheck.java
deleted file mode 100644
index 12c6c31754..0000000000
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/Precheck.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.scm.safemode;
-
-import org.apache.hadoop.hdds.scm.exceptions.SCMException;
-
-/**
- * Precheck for SCM operations.
- * */
-public interface Precheck<T> {
-  boolean check(T t) throws SCMException;
-  String type();
-}
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModePrecheck.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModePrecheck.java
deleted file mode 100644
index 6a0001c673..0000000000
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModePrecheck.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.scm.safemode;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.hadoop.hdds.conf.ConfigurationSource;
-import org.apache.hadoop.hdds.HddsConfigKeys;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ScmOps;
-import org.apache.hadoop.hdds.scm.exceptions.SCMException;
-import org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes;
-
-/**
- * Safe mode pre-check for SCM operations.
- * */
-public class SafeModePrecheck implements Precheck<ScmOps> {
-
-  private AtomicBoolean inSafeMode;
-  public static final String PRECHECK_TYPE = "SafeModePrecheck";
-
-  public SafeModePrecheck(ConfigurationSource conf) {
-    boolean safeModeEnabled = conf.getBoolean(
-        HddsConfigKeys.HDDS_SCM_SAFEMODE_ENABLED,
-        HddsConfigKeys.HDDS_SCM_SAFEMODE_ENABLED_DEFAULT);
-    if (safeModeEnabled) {
-      inSafeMode = new AtomicBoolean(true);
-    } else {
-      inSafeMode = new AtomicBoolean(false);
-    }
-  }
-
-  @Override
-  public boolean check(ScmOps op) throws SCMException {
-    if (inSafeMode.get() && SafeModeRestrictedOps
-        .isRestrictedInSafeMode(op)) {
-      throw new SCMException("SafeModePrecheck failed for " + op,
-          ResultCodes.SAFE_MODE_EXCEPTION);
-    }
-    return inSafeMode.get();
-  }
-
-  @Override
-  public String type() {
-    return PRECHECK_TYPE;
-  }
-
-  public boolean isInSafeMode() {
-    return inSafeMode.get();
-  }
-
-  public void setInSafeMode(boolean inSafeMode) {
-    this.inSafeMode.set(inSafeMode);
-  }
-}
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModeRestrictedOps.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModeRestrictedOps.java
deleted file mode 100644
index b46611f6ee..0000000000
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/SafeModeRestrictedOps.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.scm.safemode;
-
-import java.util.EnumSet;
-
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ScmOps;
-
-/**
- * Operations restricted in SCM safe mode.
- */
-public final class SafeModeRestrictedOps {
-  private static EnumSet restrictedOps = EnumSet.noneOf(ScmOps.class);
-
-  private SafeModeRestrictedOps() {
-  }
-
-  static {
-    restrictedOps.add(ScmOps.allocateBlock);
-    restrictedOps.add(ScmOps.allocateContainer);
-  }
-
-  public static boolean isRestrictedInSafeMode(ScmOps opName) {
-    return restrictedOps.contains(opName);
-  }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to