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

szetszwo 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 b8b1263283 HDDS-8934. SCMHAInvocationHandler throws undeclared 
exceptions, causes SCM to exit (#4990)
b8b1263283 is described below

commit b8b1263283ce8a84cc27c7e96022f94e3d190833
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Thu Jun 29 17:31:29 2023 +0200

    HDDS-8934. SCMHAInvocationHandler throws undeclared exceptions, causes SCM 
to exit (#4990)
---
 hadoop-hdds/annotations/pom.xml                    |   1 -
 .../annotations/ReplicateAnnotationProcessor.java  |  35 ++-
 .../hadoop/hdds/scm/exceptions/SCMException.java   |   3 +-
 .../hdds/security/symmetric/SecretKeyManager.java  |   6 +-
 .../hdds/security/symmetric/SecretKeyState.java    |   4 +-
 .../certificate/authority/CertificateStore.java    |   5 +-
 .../certificate/authority/DefaultCAServer.java     |   8 +-
 .../security/symmetric/SecretKeyManagerTest.java   |   3 +-
 .../src/main/proto/ScmServerProtocol.proto         |   1 +
 .../hadoop/hdds/scm/block/BlockManagerImpl.java    |   8 +-
 .../hadoop/hdds/scm/block/DeletedBlockLog.java     |   9 +-
 .../hadoop/hdds/scm/block/DeletedBlockLogImpl.java |  11 +-
 .../scm/block/DeletedBlockLogStateManager.java     |   9 +-
 .../scm/container/CloseContainerEventHandler.java  |   4 +-
 .../hdds/scm/container/ContainerManager.java       |   7 +-
 .../hdds/scm/container/ContainerManagerImpl.java   |  11 +-
 .../hdds/scm/container/ContainerStateManager.java  |   7 +-
 .../scm/container/balancer/ContainerBalancer.java  |   9 +-
 .../replication/LegacyReplicationManager.java      |  30 +-
 .../container/replication/ReplicationManager.java  |   3 +-
 .../hadoop/hdds/scm/ha/SCMHAInvocationHandler.java |  74 ++++-
 .../hadoop/hdds/scm/ha/SequenceIdGenerator.java    |   6 +-
 .../apache/hadoop/hdds/scm/ha/StatefulService.java |   3 +-
 .../hdds/scm/ha/StatefulServiceStateManager.java   |   3 +-
 .../hadoop/hdds/scm/node/DeadNodeHandler.java      |   3 +-
 .../hdds/scm/node/HealthyReadOnlyNodeHandler.java  |   3 +-
 .../hadoop/hdds/scm/node/StaleNodeHandler.java     |   3 +-
 .../hdds/scm/node/StartDatanodeAdminHandler.java   |   3 +-
 .../hdds/scm/pipeline/PipelineActionHandler.java   |   3 +-
 .../hadoop/hdds/scm/pipeline/PipelineManager.java  |  19 +-
 .../hdds/scm/pipeline/PipelineManagerImpl.java     |  30 +-
 .../hdds/scm/pipeline/PipelineStateManager.java    |   7 +-
 .../scm/pipeline/WritableContainerFactory.java     |   3 +-
 .../scm/pipeline/WritableContainerProvider.java    |   3 +-
 .../scm/pipeline/WritableECContainerProvider.java  |   5 +-
 .../pipeline/WritableRatisContainerProvider.java   |   3 +-
 .../hdds/scm/security/SecretKeyManagerService.java |   7 +-
 .../hdds/scm/server/SCMClientProtocolServer.java   |  54 ++--
 .../server/upgrade/FinalizationStateManager.java   |   7 +-
 .../scm/server/upgrade/SCMUpgradeFinalizer.java    |  37 +--
 .../hadoop/hdds/scm/block/TestBlockManager.java    |  18 +-
 .../container/balancer/TestContainerBalancer.java  |   3 +-
 .../hdds/scm/ha/TestBackgroundSCMService.java      |   4 +-
 .../hdds/scm/ha/TestReplicationAnnotation.java     |  14 +-
 .../hdds/scm/pipeline/MockPipelineManager.java     |  17 +-
 .../TestPipelineDatanodesIntersection.java         |   3 +-
 .../hdds/scm/pipeline/TestPipelineManagerImpl.java | 317 +++++++++------------
 .../scm/pipeline/TestPipelineStateManagerImpl.java |  46 ++-
 .../pipeline/TestWritableECContainerProvider.java  |  33 ++-
 .../container/TestScmApplyTransactionFailure.java  |  22 +-
 .../hdds/scm/storage/TestContainerCommandsEC.java  |   5 +-
 .../apache/hadoop/ozone/om/TestScmSafeMode.java    |   4 +-
 .../ozone/recon/fsck/ContainerHealthTask.java      |   3 +-
 .../ozone/recon/scm/ReconContainerManager.java     |  12 +-
 .../ozone/recon/scm/ReconPipelineManager.java      |   9 +-
 .../scm/ReconStorageContainerManagerFacade.java    |   6 +-
 56 files changed, 440 insertions(+), 526 deletions(-)

diff --git a/hadoop-hdds/annotations/pom.xml b/hadoop-hdds/annotations/pom.xml
index 582e232889..27d5f43894 100644
--- a/hadoop-hdds/annotations/pom.xml
+++ b/hadoop-hdds/annotations/pom.xml
@@ -30,5 +30,4 @@ https://maven.apache.org/xsd/maven-4.0.0.xsd";>
   </description>
   <name>Apache Ozone Annotation Processing</name>
   <packaging>jar</packaging>
-
 </project>
diff --git 
a/hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/ReplicateAnnotationProcessor.java
 
b/hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/ReplicateAnnotationProcessor.java
index 9f184ec49c..e580293772 100644
--- 
a/hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/ReplicateAnnotationProcessor.java
+++ 
b/hadoop-hdds/annotations/src/main/java/org/apache/ozone/annotations/ReplicateAnnotationProcessor.java
@@ -18,6 +18,7 @@
 package org.apache.ozone.annotations;
 
 import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
 import javax.annotation.processing.SupportedSourceVersion;
@@ -27,30 +28,38 @@ import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeMirror;
 import javax.tools.Diagnostic.Kind;
-import java.util.List;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Annotation Processor that verifies if the methods that are marked with
  * Replicate annotation have proper method signature which throws
  * TimeoutException.
  */
-@SupportedAnnotationTypes("org.apache.hadoop.hdds.scm.metadata.Replicate")
+@SupportedAnnotationTypes(ReplicateAnnotationProcessor.ANNOTATION_NAME)
 @SupportedSourceVersion(SourceVersion.RELEASE_8)
 public class ReplicateAnnotationProcessor extends AbstractProcessor {
 
-  private static final String ANNOTATION_SIMPLE_NAME = "Replicate";
+  static final String ANNOTATION_NAME =
+      "org.apache.hadoop.hdds.scm.metadata.Replicate";
+  private static final String REQUIRED_EXCEPTION =
+      "org.apache.hadoop.hdds.scm.exceptions.SCMException";
+  private TypeMirror requiredException;
+
+  @Override
+  public synchronized void init(ProcessingEnvironment processingEnv) {
+    super.init(processingEnv);
+    requiredException = processingEnv.getElementUtils()
+        .getTypeElement(REQUIRED_EXCEPTION).asType();
+  }
 
   @Override
   public boolean process(Set<? extends TypeElement> annotations,
                          RoundEnvironment roundEnv) {
     for (TypeElement annotation : annotations) {
-      if (!annotation.getSimpleName().contentEquals(ANNOTATION_SIMPLE_NAME)) {
-        continue;
+      if (ANNOTATION_NAME.contentEquals(annotation.getQualifiedName())) {
+        roundEnv.getElementsAnnotatedWith(annotation)
+            .forEach(this::checkMethodSignature);
       }
-      roundEnv.getElementsAnnotatedWith(annotation)
-          .forEach(this::checkMethodSignature);
     }
     return false;
   }
@@ -67,14 +76,12 @@ public class ReplicateAnnotationProcessor extends 
AbstractProcessor {
       return;
     }
     final ExecutableElement executableElement = (ExecutableElement) element;
-    final List<? extends TypeMirror> exceptions =
-        executableElement.getThrownTypes();
 
-    if (exceptions.stream().map(TypeMirror::toString)
-        .noneMatch(TimeoutException.class.getName()::equals)) {
+    if (executableElement.getThrownTypes().stream().noneMatch(
+        m -> processingEnv.getTypeUtils().isAssignable(requiredException, m))) 
{
       processingEnv.getMessager().printMessage(Kind.ERROR,
-          "Method with Replicate annotation should declare " +
-              "TimeoutException in its signature.");
+          "Method with Replicate annotation should declare throwing " +
+              REQUIRED_EXCEPTION + " or one of its parents", 
executableElement);
     }
   }
 }
diff --git 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java
 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java
index 7ded5f869a..40b484988d 100644
--- 
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java
+++ 
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java
@@ -134,6 +134,7 @@ public class SCMException extends IOException {
     FAILED_TO_CONNECT_TO_CRL_SERVICE,
     FAILED_TO_ADD_CRL_CLIENT,
     INVALID_PIPELINE_STATE,
-    DUPLICATED_PIPELINE_ID
+    DUPLICATED_PIPELINE_ID,
+    TIMEOUT,
   }
 }
diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManager.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManager.java
index 8685a7fb52..227317f913 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManager.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManager.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hdds.security.symmetric;
 
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,7 +28,6 @@ import java.time.Duration;
 import java.time.Instant;
 import java.util.List;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 import static java.time.Duration.between;
 import static java.util.Objects.requireNonNull;
@@ -72,7 +72,7 @@ public class SecretKeyManager implements SecretKeyClient {
    * SecretKeys from local file, or generate new keys if the file doesn't
    * exist.
    */
-  public synchronized void checkAndInitialize() throws TimeoutException {
+  public synchronized void checkAndInitialize() throws SCMException {
     if (isInitialized()) {
       return;
     }
@@ -109,7 +109,7 @@ public class SecretKeyManager implements SecretKeyClient {
    *
    * @return true if rotation actually happens, false if it doesn't.
    */
-  public synchronized boolean checkAndRotate() throws TimeoutException {
+  public synchronized boolean checkAndRotate() throws SCMException {
     // Initialize the state if it's not initialized already.
     checkAndInitialize();
 
diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyState.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyState.java
index 43518b901a..11d8f031b3 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyState.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyState.java
@@ -18,11 +18,11 @@
 
 package org.apache.hadoop.hdds.security.symmetric;
 
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.metadata.Replicate;
 
 import java.util.List;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 /**
  * This component holds the state of managed SecretKeys, including the
@@ -51,7 +51,7 @@ public interface SecretKeyState {
    * This method replicates SecretKeys across all SCM instances.
    */
   @Replicate
-  void updateKeys(List<ManagedSecretKey> newKeys) throws TimeoutException;
+  void updateKeys(List<ManagedSecretKey> newKeys) throws SCMException;
 
   /**
    * Update SecretKeys from a snapshot from SCM leader.
diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateStore.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateStore.java
index fef65fb367..18b572e7ab 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateStore.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/CertificateStore.java
@@ -35,7 +35,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.Optional;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 /**
  * This interface allows the DefaultCA to be portable and use different DB
@@ -63,7 +62,7 @@ public interface CertificateStore {
   @Replicate
   void storeValidCertificate(BigInteger serialID,
       X509Certificate certificate, NodeType role)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   void storeValidScmCertificate(BigInteger serialID,
       X509Certificate certificate) throws IOException;
@@ -97,7 +96,7 @@ public interface CertificateStore {
                                     CRLReason reason,
                                     Date revocationTime,
                                     CRLApprover approver)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Deletes an expired certificate from the store. Please note: We don't
diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
index be5755f0b4..c94408f08e 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/authority/DefaultCAServer.java
@@ -60,7 +60,6 @@ import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import java.util.function.Consumer;
@@ -269,8 +268,7 @@ public class DefaultCAServer implements CertificateServer {
       default:
         return null; // cannot happen, keeping checkstyle happy.
       }
-    } catch (CertificateException | IOException | OperatorCreationException |
-             TimeoutException e) {
+    } catch (CertificateException | IOException | OperatorCreationException e) 
{
       LOG.error("Unable to issue a certificate.", e);
       xCertHolders.completeExceptionally(
           new SCMSecurityException(e, UNABLE_TO_ISSUE_CERTIFICATE));
@@ -281,7 +279,7 @@ public class DefaultCAServer implements CertificateServer {
   private X509CertificateHolder signAndStoreCertificate(LocalDateTime 
beginDate,
       LocalDateTime endDate, PKCS10CertificationRequest csr, NodeType role)
       throws IOException,
-      OperatorCreationException, CertificateException, TimeoutException {
+      OperatorCreationException, CertificateException {
 
     lock.lock();
     X509CertificateHolder xcert;
@@ -328,7 +326,7 @@ public class DefaultCAServer implements CertificateServer {
           store.revokeCertificates(certificates,
               getCACertificate(), reason, revocationTime, crlApprover)
       );
-    } catch (IOException | TimeoutException ex) {
+    } catch (IOException ex) {
       LOG.error("Revoking the certificate failed.", ex.getCause());
       revoked.completeExceptionally(new SCMSecurityException(ex));
     }
diff --git 
a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManagerTest.java
 
b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManagerTest.java
index e7fd24082c..675488f5e6 100644
--- 
a/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManagerTest.java
+++ 
b/hadoop-hdds/framework/src/test/java/org/apache/hadoop/hdds/security/symmetric/SecretKeyManagerTest.java
@@ -30,7 +30,6 @@ import java.time.Duration;
 import java.time.Instant;
 import java.util.Collection;
 import java.util.List;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Stream;
 
 import static com.google.common.collect.Lists.newArrayList;
@@ -150,7 +149,7 @@ public class SecretKeyManagerTest {
   public void testRotate(List<ManagedSecretKey> initialKeys,
                          boolean expectRotate,
                          List<ManagedSecretKey> expectedRetainedKeys)
-      throws TimeoutException {
+      throws Exception {
 
     SecretKeyState state = new SecretKeyStateImpl(mockedKeyStore);
 
diff --git 
a/hadoop-hdds/interface-server/src/main/proto/ScmServerProtocol.proto 
b/hadoop-hdds/interface-server/src/main/proto/ScmServerProtocol.proto
index 6df2db8569..0987006421 100644
--- a/hadoop-hdds/interface-server/src/main/proto/ScmServerProtocol.proto
+++ b/hadoop-hdds/interface-server/src/main/proto/ScmServerProtocol.proto
@@ -132,6 +132,7 @@ enum Status {
   FAILED_TO_ADD_CRL_CLIENT = 39;
   INVALID_PIPELINE_STATE = 40;
   DUPLICATED_PIPELINE_ID = 41;
+  TIMEOUT = 42;
 }
 
 /**
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java
index 70c98b5ac7..58cc85166c 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java
@@ -23,7 +23,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.client.BlockID;
 import org.apache.hadoop.hdds.client.ContainerBlockID;
@@ -48,7 +47,6 @@ import org.apache.hadoop.util.StringUtils;
 import static 
org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes.INVALID_BLOCK_SIZE;
 import static org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator.LOCAL_ID;
 
-import org.apache.ratis.protocol.exceptions.NotLeaderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -149,7 +147,7 @@ public class BlockManagerImpl implements BlockManager, 
BlockmanagerMXBean {
   public AllocatedBlock allocateBlock(final long size,
       ReplicationConfig replicationConfig,
       String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException {
+      throws IOException {
     if (LOG.isTraceEnabled()) {
       LOG.trace("Size : {} , replicationConfig: {}", size, replicationConfig);
     }
@@ -184,7 +182,7 @@ public class BlockManagerImpl implements BlockManager, 
BlockmanagerMXBean {
    * @return AllocatedBlock
    */
   private AllocatedBlock newBlock(ContainerInfo containerInfo)
-      throws NotLeaderException, TimeoutException {
+      throws SCMException {
     try {
       final Pipeline pipeline = pipelineManager
           .getPipeline(containerInfo.getPipelineID());
@@ -245,7 +243,7 @@ public class BlockManagerImpl implements BlockManager, 
BlockmanagerMXBean {
 
     try {
       deletedBlockLog.addTransactions(containerBlocks);
-    } catch (IOException | TimeoutException e) {
+    } catch (IOException e) {
       throw new IOException("Skip writing the deleted blocks info to"
           + " the delLog because addTransaction fails. " + keyBlocksInfoList
           .size() + "Keys skipped", e);
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
index 20a68e5010..cb9cf603b1 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java
@@ -31,7 +31,6 @@ import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 /**
  * The DeletedBlockLog is a persisted log in SCM to keep tracking
@@ -53,7 +52,7 @@ public interface DeletedBlockLog extends Closeable {
    */
   DatanodeDeletedBlockTransactions getTransactions(
       int blockDeletionLimit, Set<DatanodeDetails> dnList)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Return the failed transactions in the log. A transaction is
@@ -77,7 +76,7 @@ public interface DeletedBlockLog extends Closeable {
    * @param txIDs - transaction ID.
    */
   void incrementCount(List<Long> txIDs)
-      throws IOException, TimeoutException;
+      throws IOException;
 
 
   /**
@@ -86,7 +85,7 @@ public interface DeletedBlockLog extends Closeable {
    * @param txIDs transactionId list to be reset
    * @return num of successful reset
    */
-  int resetCount(List<Long> txIDs) throws IOException, TimeoutException;
+  int resetCount(List<Long> txIDs) throws IOException;
 
   /**
    * Commits a transaction means to delete all footprints of a transaction
@@ -112,7 +111,7 @@ public interface DeletedBlockLog extends Closeable {
    * @throws IOException
    */
   void addTransactions(Map<Long, List<Long>> containerBlocksMap)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Returns the total number of valid transactions. A transaction is
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
index 52b8be9d64..99075acee6 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.LinkedHashSet;
 import java.util.ArrayList;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -166,7 +165,7 @@ public class DeletedBlockLogImpl
    */
   @Override
   public void incrementCount(List<Long> txIDs)
-      throws IOException, TimeoutException {
+      throws IOException {
     lock.lock();
     try {
       ArrayList<Long> txIDsToUpdate = new ArrayList<>();
@@ -198,7 +197,7 @@ public class DeletedBlockLogImpl
    *
    */
   @Override
-  public int resetCount(List<Long> txIDs) throws IOException, TimeoutException 
{
+  public int resetCount(List<Long> txIDs) throws IOException {
     lock.lock();
     try {
       if (txIDs == null || txIDs.isEmpty()) {
@@ -300,7 +299,7 @@ public class DeletedBlockLogImpl
       try {
         deletedBlockLogStateManager.removeTransactionsFromDB(txIDsToBeDeleted);
         metrics.incrBlockDeletionTransactionCompleted(txIDsToBeDeleted.size());
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
         LOG.warn("Could not commit delete block transactions: "
             + txIDsToBeDeleted, e);
       }
@@ -378,7 +377,7 @@ public class DeletedBlockLogImpl
    */
   @Override
   public void addTransactions(Map<Long, List<Long>> containerBlocksMap)
-      throws IOException, TimeoutException {
+      throws IOException {
     lock.lock();
     try {
       ArrayList<DeletedBlocksTransaction> txsToBeAdded = new ArrayList<>();
@@ -435,7 +434,7 @@ public class DeletedBlockLogImpl
   @Override
   public DatanodeDeletedBlockTransactions getTransactions(
       int blockDeletionLimit, Set<DatanodeDetails> dnList)
-      throws IOException, TimeoutException {
+      throws IOException {
     lock.lock();
     try {
       DatanodeDeletedBlockTransactions transactions =
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManager.java
index 0c03152f9d..ce74b8ea92 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManager.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.hdds.utils.db.Table.KeyValue;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.concurrent.TimeoutException;
 
 /**
  * DeletedBlockLogStateManager interface to
@@ -34,19 +33,19 @@ import java.util.concurrent.TimeoutException;
 public interface DeletedBlockLogStateManager {
   @Replicate
   void addTransactionsToDB(ArrayList<DeletedBlocksTransaction> txs)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   @Replicate
   void removeTransactionsFromDB(ArrayList<Long> txIDs)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   @Replicate
   void increaseRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   @Replicate
   int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   TableIterator<Long,
       KeyValue<Long, DeletedBlocksTransaction>> getReadOnlyIterator()
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/CloseContainerEventHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/CloseContainerEventHandler.java
index c1b1db7827..39181d8f0d 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/CloseContainerEventHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/CloseContainerEventHandler.java
@@ -18,7 +18,6 @@ package org.apache.hadoop.hdds.scm.container;
 
 import java.io.IOException;
 import java.util.List;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import javax.annotation.Nullable;
@@ -136,8 +135,7 @@ public class CloseContainerEventHandler implements 
EventHandler<ContainerID> {
     } catch (NotLeaderException nle) {
       LOG.warn("Skip sending close container command,"
           + " since current SCM is not leader.", nle);
-    } catch (IOException | InvalidStateTransitionException |
-             TimeoutException ex) {
+    } catch (IOException | InvalidStateTransitionException ex) {
       LOG.error("Failed to close the container {}.", containerID, ex);
     }
   }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
index a093775067..2a60e268ff 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManager.java
@@ -22,7 +22,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.client.ReplicationConfig;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState;
@@ -119,7 +118,7 @@ public interface ContainerManager extends Closeable {
    */
   ContainerInfo allocateContainer(ReplicationConfig replicationConfig,
                                   String owner)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Update container state.
@@ -130,7 +129,7 @@ public interface ContainerManager extends Closeable {
    */
   void updateContainerState(ContainerID containerID,
                             LifeCycleEvent event)
-      throws IOException, InvalidStateTransitionException, TimeoutException;
+      throws IOException, InvalidStateTransitionException;
 
   /**
    * Returns the latest list of replicas for given containerId.
@@ -203,7 +202,7 @@ public interface ContainerManager extends Closeable {
    * @throws IOException
    */
   void deleteContainer(ContainerID containerID)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Returns containerStateManger.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
index 2a62e1c71d..34604edb3b 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerManagerImpl.java
@@ -28,7 +28,6 @@ import java.util.NavigableSet;
 import java.util.Optional;
 import java.util.Random;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -172,7 +171,7 @@ public class ContainerManagerImpl implements 
ContainerManager {
   @Override
   public ContainerInfo allocateContainer(
       final ReplicationConfig replicationConfig, final String owner)
-      throws IOException, TimeoutException {
+      throws IOException {
     // Acquire pipeline manager lock, to avoid any updates to pipeline
     // while allocate container happens. This is to avoid scenario like
     // mentioned in HDDS-5655.
@@ -225,7 +224,7 @@ public class ContainerManagerImpl implements 
ContainerManager {
   }
 
   private ContainerInfo createContainer(Pipeline pipeline, String owner)
-      throws IOException, TimeoutException {
+      throws IOException {
     final ContainerInfo containerInfo = allocateContainer(pipeline, owner);
     if (LOG.isTraceEnabled()) {
       LOG.trace("New container allocated: {}", containerInfo);
@@ -235,7 +234,7 @@ public class ContainerManagerImpl implements 
ContainerManager {
 
   private ContainerInfo allocateContainer(final Pipeline pipeline,
                                           final String owner)
-      throws IOException, TimeoutException {
+      throws IOException {
     final long uniqueId = sequenceIdGen.getNextId(CONTAINER_ID);
     Preconditions.checkState(uniqueId > 0,
         "Cannot allocate container, negative container id" +
@@ -269,7 +268,7 @@ public class ContainerManagerImpl implements 
ContainerManager {
   @Override
   public void updateContainerState(final ContainerID cid,
                                    final LifeCycleEvent event)
-      throws IOException, InvalidStateTransitionException, TimeoutException {
+      throws IOException, InvalidStateTransitionException {
     HddsProtos.ContainerID protoId = cid.getProtobuf();
     lock.lock();
     try {
@@ -398,7 +397,7 @@ public class ContainerManagerImpl implements 
ContainerManager {
 
   @Override
   public void deleteContainer(final ContainerID cid)
-      throws IOException, TimeoutException {
+      throws IOException {
     HddsProtos.ContainerID protoId = cid.getProtobuf();
 
     final boolean found;
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
index 1a544ce0b1..9f741068a8 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerStateManager.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.util.Map;
 import java.util.NavigableSet;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ContainerInfoProto;
@@ -142,7 +141,7 @@ public interface ContainerStateManager {
    */
   @Replicate
   void addContainer(ContainerInfoProto containerInfo)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    *
@@ -150,7 +149,7 @@ public interface ContainerStateManager {
   @Replicate
   void updateContainerState(HddsProtos.ContainerID id,
                             HddsProtos.LifeCycleEvent event)
-      throws IOException, InvalidStateTransitionException, TimeoutException;
+      throws IOException, InvalidStateTransitionException;
 
   /**
    *
@@ -171,7 +170,7 @@ public interface ContainerStateManager {
    */
   @Replicate
   void removeContainer(HddsProtos.ContainerID containerInfo)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Reinitialize the ContainerStateManager with container store.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
index 54109153b7..1030c0eab0 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
@@ -31,7 +31,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -251,8 +250,7 @@ public class ContainerBalancer extends StatefulService {
    */
   public void startBalancer(ContainerBalancerConfiguration configuration)
       throws IllegalContainerBalancerStateException,
-      InvalidContainerBalancerConfigurationException, IOException,
-      TimeoutException {
+      InvalidContainerBalancerConfigurationException, IOException {
     lock.lock();
     try {
       // validates state, config, and then saves config
@@ -359,8 +357,7 @@ public class ContainerBalancer extends StatefulService {
    * "stop" command.
    */
   public void stopBalancer()
-      throws IOException, IllegalContainerBalancerStateException,
-      TimeoutException {
+      throws IOException, IllegalContainerBalancerStateException {
     Thread balancingThread;
     lock.lock();
     try {
@@ -377,7 +374,7 @@ public class ContainerBalancer extends StatefulService {
 
   public void saveConfiguration(ContainerBalancerConfiguration configuration,
                                 boolean shouldRun, int index)
-      throws IOException, TimeoutException {
+      throws IOException {
     config = configuration;
     saveConfiguration(configuration.toProtobufBuilder()
         .setShouldRun(shouldRun)
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java
index fb982dd063..63fdc95bdf 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java
@@ -44,6 +44,7 @@ import 
org.apache.hadoop.hdds.scm.container.balancer.MoveManager;
 import org.apache.hadoop.hdds.scm.container.common.helpers.MoveDataNodePair;
 import 
org.apache.hadoop.hdds.scm.container.replication.ReplicationManager.ReplicationManagerConfiguration;
 import org.apache.hadoop.hdds.scm.events.SCMEvents;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.ha.SCMContext;
 import org.apache.hadoop.hdds.scm.ha.SCMHAInvocationHandler;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManager;
@@ -88,7 +89,6 @@ import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Consumer;
 import java.util.function.Predicate;
@@ -569,7 +569,7 @@ public class LegacyReplicationManager {
       final InflightMap inflightActions,
       final Predicate<InflightAction> filter,
       final Runnable timeoutCounter,
-      final Consumer<InflightAction> completedCounter) throws TimeoutException 
{
+      final Consumer<InflightAction> completedCounter) {
     final ContainerID id = container.containerID();
     final long deadline = clock.millis() - rmConf.getEventTimeout();
     inflightActions.iterate(id, a -> updateInflightAction(
@@ -607,7 +607,7 @@ public class LegacyReplicationManager {
       // Should not happen, but if it does, just remove the action as the
       // node somehow does not exist;
       remove = true;
-    } catch (TimeoutException e) {
+    } catch (Exception e) {
       LOG.error("Got exception while updating.", e);
     }
     return remove;
@@ -628,7 +628,7 @@ public class LegacyReplicationManager {
                    final boolean isNotInService,
                    final ContainerInfo container, final DatanodeDetails dn,
                    final boolean isInflightReplication)
-      throws ContainerNotFoundException, TimeoutException {
+      throws SCMException {
     // make sure inflightMove contains the container
     ContainerID id = container.containerID();
 
@@ -722,8 +722,7 @@ public class LegacyReplicationManager {
    */
   public CompletableFuture<MoveManager.MoveResult> move(ContainerID cid,
              DatanodeDetails src, DatanodeDetails tgt)
-      throws ContainerNotFoundException, NodeNotFoundException,
-      TimeoutException {
+      throws ContainerNotFoundException, NodeNotFoundException {
     return move(cid, new MoveDataNodePair(src, tgt));
   }
 
@@ -735,7 +734,7 @@ public class LegacyReplicationManager {
    */
   private CompletableFuture<MoveManager.MoveResult> move(ContainerID cid,
       MoveDataNodePair mp) throws ContainerNotFoundException,
-      NodeNotFoundException, TimeoutException {
+      NodeNotFoundException {
     CompletableFuture<MoveManager.MoveResult> ret = new CompletableFuture<>();
 
     if (!scmContext.isLeader()) {
@@ -1022,7 +1021,7 @@ public class LegacyReplicationManager {
    */
   private void deleteContainerReplicas(final ContainerInfo container,
       final Set<ContainerReplica> replicas) throws IOException,
-      InvalidStateTransitionException, TimeoutException {
+      InvalidStateTransitionException {
     Preconditions.assertTrue(container.getState() ==
         LifeCycleState.CLOSED);
 
@@ -1044,7 +1043,7 @@ public class LegacyReplicationManager {
    */
   private void handleContainerUnderDelete(final ContainerInfo container,
       final Set<ContainerReplica> replicas) throws IOException,
-      InvalidStateTransitionException, TimeoutException {
+      InvalidStateTransitionException {
     if (replicas.size() == 0) {
       containerManager.updateContainerState(container.containerID(),
           HddsProtos.LifeCycleEvent.CLEANUP);
@@ -1325,7 +1324,7 @@ public class LegacyReplicationManager {
    */
   private void deleteSrcDnForMove(final ContainerInfo cif,
                    final Set<ContainerReplica> replicaSet)
-      throws TimeoutException {
+      throws SCMException {
     final ContainerID cid = cif.containerID();
     MoveDataNodePair movePair = moveScheduler.getMoveDataNodePair(cid);
     if (movePair == null) {
@@ -1688,7 +1687,7 @@ public class LegacyReplicationManager {
      */
     @Replicate
     void completeMove(HddsProtos.ContainerID contianerIDProto)
-        throws TimeoutException;
+        throws SCMException;
 
     /**
      * start a move action for a given container.
@@ -1699,7 +1698,7 @@ public class LegacyReplicationManager {
     @Replicate
     void startMove(HddsProtos.ContainerID contianerIDProto,
               HddsProtos.MoveDataNodePairProto mp)
-        throws IOException, TimeoutException;
+        throws IOException;
 
     /**
      * get the MoveDataNodePair of the giver container.
@@ -1889,7 +1888,7 @@ public class LegacyReplicationManager {
           //before reelection.here, we just try to send the command again.
           try {
             deleteSrcDnForMove(cif, replicas);
-          } catch (TimeoutException ex) {
+          } catch (Exception ex) {
             LOG.error("Exception while cleaning up excess replicas.", ex);
           }
         } else {
@@ -1909,7 +1908,7 @@ public class LegacyReplicationManager {
     for (HddsProtos.ContainerID containerID : needToRemove) {
       try {
         moveScheduler.completeMove(containerID);
-      } catch (TimeoutException ex) {
+      } catch (Exception ex) {
         LOG.error("Exception while moving container.", ex);
       }
     }
@@ -2269,8 +2268,7 @@ public class LegacyReplicationManager {
         containerManager.updateContainerState(containerInfo.containerID(),
             HddsProtos.LifeCycleEvent.CLOSE);
       }
-    } catch (IOException | InvalidStateTransitionException |
-             TimeoutException e) {
+    } catch (IOException | InvalidStateTransitionException e) {
       LOG.error("Failed to CLOSE the container {}",
           containerInfo.containerID(), e);
     }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java
index 72f5b9eb47..d1d8a3782b 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationManager.java
@@ -741,8 +741,7 @@ public class ReplicationManager implements SCMService {
                                    HddsProtos.LifeCycleEvent event) {
     try {
       containerManager.updateContainerState(containerID, event);
-    } catch (IOException | InvalidStateTransitionException |
-             TimeoutException e) {
+    } catch (IOException | InvalidStateTransitionException e) {
       LOG.error("Failed to update the state of container {}, update Event {}",
           containerID, event, e);
     }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java
index 8dd4182383..f87758676d 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHAInvocationHandler.java
@@ -17,15 +17,21 @@
 
 package org.apache.hadoop.hdds.scm.ha;
 
+import java.io.IOException;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
 
 import com.google.common.base.Preconditions;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes;
 import org.apache.hadoop.hdds.scm.metadata.Replicate;
 import org.apache.hadoop.util.Time;
+import org.apache.ratis.protocol.exceptions.NotLeaderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,40 +65,55 @@ public class SCMHAInvocationHandler implements 
InvocationHandler {
 
   @Override
   public Object invoke(final Object proxy, final Method method,
-                       final Object[] args) throws Throwable {
+                       final Object[] args) throws SCMException {
     // Javadoc for InvocationHandler#invoke specifies that args will be null
     // if the method takes no arguments. Convert this to an empty array for
     // easier handling.
     Object[] convertedArgs = (args == null) ? new Object[]{} : args;
-    try {
-      long startTime = Time.monotonicNow();
-      final Object result =
-          ratisHandler != null && method.isAnnotationPresent(Replicate.class) ?
-              invokeRatis(method, convertedArgs) :
-              invokeLocal(method, convertedArgs);
+    long startTime = Time.monotonicNow();
+    final Object result =
+        ratisHandler != null && method.isAnnotationPresent(Replicate.class) ?
+            invokeRatis(method, convertedArgs) :
+            invokeLocal(method, convertedArgs);
+    if (LOG.isDebugEnabled()) {
       LOG.debug("Call: {} took {} ms", method, Time.monotonicNow() - 
startTime);
-      return result;
-    } catch (InvocationTargetException iEx) {
-      throw iEx.getCause();
     }
+    return result;
   }
 
   /**
    * TODO.
    */
   private Object invokeLocal(Method method, Object[] args)
-      throws InvocationTargetException, IllegalAccessException {
-    LOG.trace("Invoking method {} on target {} with arguments {}",
-        method, localHandler, args);
-    return method.invoke(localHandler, args);
+      throws SCMException {
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("Invoking method {} on target {} with arguments {}",
+          method, localHandler, args);
+    }
+    try {
+      return method.invoke(localHandler, args);
+    } catch (Exception e) {
+      throw translateException(e);
+    }
   }
 
   /**
    * TODO.
    */
   private Object invokeRatis(Method method, Object[] args)
+      throws SCMException {
+    try {
+      return invokeRatisImpl(method, args);
+    } catch (Exception e) {
+      throw translateException(e);
+    }
+  }
+
+  private Object invokeRatisImpl(Method method, Object[] args)
       throws Exception {
-    LOG.trace("Invoking method {} on target {}", method, ratisHandler);
+    if (LOG.isTraceEnabled()) {
+      LOG.trace("Invoking method {} on target {}", method, ratisHandler);
+    }
     // TODO: Add metric here to track time taken by Ratis
     Preconditions.checkNotNull(ratisHandler);
     SCMRatisRequest scmRatisRequest = SCMRatisRequest.of(requestType,
@@ -123,4 +144,27 @@ public class SCMHAInvocationHandler implements 
InvocationHandler {
     throw response.getException();
   }
 
+  private static SCMException translateException(Throwable t) {
+    if (t instanceof SCMException) {
+      return (SCMException) t;
+    }
+    if (t instanceof ExecutionException
+        || t instanceof InvocationTargetException) {
+      return translateException(t.getCause());
+    }
+
+    ResultCodes result;
+    if (t instanceof TimeoutException) {
+      result = ResultCodes.TIMEOUT;
+    } else if (t instanceof NotLeaderException) {
+      result = ResultCodes.SCM_NOT_LEADER;
+    } else if (t instanceof IOException) {
+      result = ResultCodes.IO_EXCEPTION;
+    } else {
+      result = ResultCodes.INTERNAL_ERROR;
+    }
+
+    return new SCMException(t, result);
+  }
+
 }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
index 0f799044df..fba776471a 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hdds.scm.ha;
 import com.google.common.base.Preconditions;
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.metadata.DBTransactionBuffer;
 import org.apache.hadoop.hdds.scm.container.ContainerID;
 import org.apache.hadoop.hdds.scm.container.ContainerInfo;
@@ -38,7 +39,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -105,7 +105,7 @@ public class SequenceIdGenerator {
    * @param sequenceIdName : name of the sequenceId
    * @return : next id of this sequenceId.
    */
-  public long getNextId(String sequenceIdName) throws TimeoutException {
+  public long getNextId(String sequenceIdName) throws SCMException {
     lock.lock();
     try {
       Batch batch = sequenceIdToBatchMap.computeIfAbsent(
@@ -188,7 +188,7 @@ public class SequenceIdGenerator {
     @Replicate
     Boolean allocateBatch(String sequenceIdName,
                           Long expectedLastId, Long newLastId)
-        throws TimeoutException;
+        throws SCMException;
 
     /**
      * @param sequenceIdName : name of the sequence id.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulService.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulService.java
index ef496d9964..12f285e6bc 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulService.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulService.java
@@ -23,7 +23,6 @@ import com.google.protobuf.Message;
 
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
-import java.util.concurrent.TimeoutException;
 
 /**
  * A StatefulService is an SCMService that persists configuration to RocksDB.
@@ -49,7 +48,7 @@ public abstract class StatefulService implements SCMService {
    * @throws IOException on failure to persist configuration
    */
   protected final void saveConfiguration(Message configurationMessage)
-      throws IOException, TimeoutException {
+      throws IOException {
     stateManager.saveConfiguration(getServiceName(),
         configurationMessage.toByteString());
   }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulServiceStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulServiceStateManager.java
index dbb0f5d6cb..a6a8a50ae5 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulServiceStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/StatefulServiceStateManager.java
@@ -23,7 +23,6 @@ import org.apache.hadoop.hdds.scm.metadata.Replicate;
 import org.apache.hadoop.hdds.utils.db.Table;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 /**
  * This interface defines an API for saving and reading configurations of a
@@ -42,7 +41,7 @@ public interface StatefulServiceStateManager {
    */
   @Replicate
   void saveConfiguration(String serviceName, ByteString bytes)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Reads the persisted configuration mapped to the specified serviceName.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/DeadNodeHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/DeadNodeHandler.java
index 917e48097f..b95998c1da 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/DeadNodeHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/DeadNodeHandler.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hdds.scm.node;
 import java.io.IOException;
 import java.util.List;
 import java.util.Optional;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
@@ -128,7 +127,7 @@ public class DeadNodeHandler implements 
EventHandler<DatanodeDetails> {
               } catch (PipelineNotFoundException ignore) {
                 // Pipeline is not there in pipeline manager,
                 // should we care?
-              } catch (IOException | TimeoutException ex) {
+              } catch (IOException ex) {
                 LOG.warn("Exception while finalizing pipeline {}",
                     id, ex);
               }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/HealthyReadOnlyNodeHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/HealthyReadOnlyNodeHandler.java
index 98de77f80e..3286133009 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/HealthyReadOnlyNodeHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/HealthyReadOnlyNodeHandler.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.hdds.scm.node;
 
 import java.io.IOException;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
@@ -92,7 +91,7 @@ public class HealthyReadOnlyNodeHandler
             HddsProtos.NodeState.HEALTHY_READONLY,
             datanodeDetails.getUuidString());
         pipelineManager.closePipeline(pipeline, true);
-      } catch (IOException | TimeoutException ex) {
+      } catch (IOException ex) {
         LOG.error("Failed to close pipeline {} which uses HEALTHY READONLY " +
             "datanode {}: ", pipelineID, datanodeDetails, ex);
       }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java
index e01949973a..dd8cea3669 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StaleNodeHandler.java
@@ -31,7 +31,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Handles Stale node event.
@@ -62,7 +61,7 @@ public class StaleNodeHandler implements 
EventHandler<DatanodeDetails> {
       try {
         Pipeline pipeline = pipelineManager.getPipeline(pipelineID);
         pipelineManager.closePipeline(pipeline, true);
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
         LOG.info("Could not finalize pipeline={} for dn={}", pipelineID,
             datanodeDetails);
       }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StartDatanodeAdminHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StartDatanodeAdminHandler.java
index 48dbbe8b61..783eb1358e 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StartDatanodeAdminHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/StartDatanodeAdminHandler.java
@@ -29,7 +29,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Handler which is fired when a datanode starts admin (decommission or
@@ -60,7 +59,7 @@ public class StartDatanodeAdminHandler
       try {
         Pipeline pipeline = pipelineManager.getPipeline(pipelineID);
         pipelineManager.closePipeline(pipeline, false);
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
         LOG.info("Could not finalize pipeline={} for dn={}", pipelineID,
             datanodeDetails);
       }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineActionHandler.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineActionHandler.java
index 7b76cf8d22..e33f256a44 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineActionHandler.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineActionHandler.java
@@ -36,7 +36,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Handles pipeline actions from datanode.
@@ -103,7 +102,7 @@ public class PipelineActionHandler
       }
       publisher.fireEvent(SCMEvents.DATANODE_COMMAND,
           new CommandForDatanode<>(datanode.getUuid(), command));
-    } catch (IOException | TimeoutException ioe) {
+    } catch (IOException ioe) {
       LOG.error("Could not execute pipeline action={} pipeline={}",
           action, pid, ioe);
     }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManager.java
index 4f224285e6..2df7e6db5f 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManager.java
@@ -24,7 +24,6 @@ import java.util.Collection;
 import java.util.List;
 import java.util.NavigableSet;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.client.ReplicationConfig;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
@@ -38,19 +37,19 @@ import org.apache.hadoop.hdds.utils.db.Table;
 public interface PipelineManager extends Closeable, PipelineManagerMXBean {
 
   Pipeline createPipeline(ReplicationConfig replicationConfig)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   Pipeline createPipeline(ReplicationConfig replicationConfig,
                           List<DatanodeDetails> excludedNodes,
                           List<DatanodeDetails> favoredNodes)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   Pipeline buildECPipeline(ReplicationConfig replicationConfig,
                            List<DatanodeDetails> excludedNodes,
                            List<DatanodeDetails> favoredNodes)
-      throws IOException, TimeoutException;
+      throws IOException;
 
-  void addEcPipeline(Pipeline pipeline) throws IOException, TimeoutException;
+  void addEcPipeline(Pipeline pipeline) throws IOException;
 
 
   Pipeline createPipeline(
@@ -114,14 +113,14 @@ public interface PipelineManager extends Closeable, 
PipelineManagerMXBean {
 
   int getNumberOfContainers(PipelineID pipelineID) throws IOException;
 
-  void openPipeline(PipelineID pipelineId) throws IOException, 
TimeoutException;
+  void openPipeline(PipelineID pipelineId) throws IOException;
 
   void closePipeline(Pipeline pipeline, boolean onTimeout)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   void closeStalePipelines(DatanodeDetails datanodeDetails);
 
-  void scrubPipelines() throws IOException, TimeoutException;
+  void scrubPipelines() throws IOException;
 
   void startPipelineCreator();
 
@@ -140,7 +139,7 @@ public interface PipelineManager extends Closeable, 
PipelineManagerMXBean {
    * @throws IOException in case of any Exception
    */
   void activatePipeline(PipelineID pipelineID)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Deactivates an active pipeline.
@@ -149,7 +148,7 @@ public interface PipelineManager extends Closeable, 
PipelineManagerMXBean {
    * @throws IOException in case of any Exception
    */
   void deactivatePipeline(PipelineID pipelineID)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Wait a pipeline to be OPEN.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java
index e234eb4115..b1186ef332 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java
@@ -62,7 +62,6 @@ import java.util.Map;
 import java.util.NavigableSet;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.stream.Collectors;
@@ -184,7 +183,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
             .setPeriodicalTask(() -> {
               try {
                 pipelineManager.scrubPipelines();
-              } catch (IOException | TimeoutException e) {
+              } catch (IOException e) {
                 LOG.error("Unexpected error during pipeline scrubbing", e);
               }
             }).build();
@@ -223,11 +222,10 @@ public class PipelineManagerImpl implements 
PipelineManager {
    * the pipline to be used by clients in the system.
    * @param pipeline
    * @throws IOException
-   * @throws TimeoutException
    */
   @Override
   public void addEcPipeline(Pipeline pipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     if (pipeline.getReplicationConfig().getReplicationType()
         != ReplicationType.EC) {
       throw new IllegalArgumentException(
@@ -239,7 +237,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
 
   @Override
   public Pipeline createPipeline(ReplicationConfig replicationConfig)
-      throws IOException, TimeoutException {
+      throws IOException {
     return createPipeline(replicationConfig, Collections.emptyList(),
         Collections.emptyList());
   }
@@ -247,7 +245,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
   @Override
   public Pipeline createPipeline(ReplicationConfig replicationConfig,
       List<DatanodeDetails> excludedNodes, List<DatanodeDetails> favoredNodes)
-      throws IOException, TimeoutException {
+      throws IOException {
     checkIfPipelineCreationIsAllowed(replicationConfig);
 
     acquireWriteLock();
@@ -285,13 +283,13 @@ public class PipelineManagerImpl implements 
PipelineManager {
   }
 
   private void addPipelineToManager(Pipeline pipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     HddsProtos.Pipeline pipelineProto = pipeline.getProtobufMessage(
         ClientVersion.CURRENT_VERSION);
     acquireWriteLock();
     try {
       stateManager.addPipeline(pipelineProto);
-    } catch (IOException | TimeoutException ex) {
+    } catch (IOException ex) {
       LOG.debug("Failed to add pipeline {}.", pipeline, ex);
       metrics.incNumPipelineCreationFailed();
       throw ex;
@@ -420,7 +418,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
 
   @Override
   public void openPipeline(PipelineID pipelineId)
-      throws IOException, TimeoutException {
+      throws IOException {
     HddsProtos.PipelineID pipelineIdProtobuf = pipelineId.getProtobuf();
     acquireWriteLock();
     final Pipeline pipeline;
@@ -453,7 +451,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    * @throws IOException
    */
   protected void removePipeline(Pipeline pipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     pipelineFactory.close(pipeline.getType(), pipeline);
     HddsProtos.PipelineID pipelineID = pipeline.getId().getProtobuf();
     acquireWriteLock();
@@ -475,7 +473,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    * @throws IOException
    */
   private void closeContainersForPipeline(final PipelineID pipelineId)
-      throws IOException, TimeoutException {
+      throws IOException {
     Set<ContainerID> containerIDs = stateManager.getContainers(pipelineId);
     ContainerManager containerManager = scmContext.getScm()
         .getContainerManager();
@@ -502,7 +500,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    */
   @Override
   public void closePipeline(Pipeline pipeline, boolean onTimeout)
-      throws IOException, TimeoutException {
+      throws IOException {
     PipelineID pipelineID = pipeline.getId();
     HddsProtos.PipelineID pipelineIDProtobuf = pipelineID.getProtobuf();
     // close containers.
@@ -547,7 +545,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
         LOG.info("Closing the stale pipeline: {}", p.getId());
         closePipeline(p, false);
         LOG.info("Closed the stale pipeline: {}", p.getId());
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
         LOG.error("Closing the stale pipeline failed: {}", p, e);
       }
     });
@@ -571,7 +569,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    * Scrub pipelines.
    */
   @Override
-  public void scrubPipelines() throws IOException, TimeoutException {
+  public void scrubPipelines() throws IOException {
     Instant currentTime = clock.instant();
     long pipelineScrubTimeoutInMills = conf.getTimeDuration(
         ScmConfigKeys.OZONE_SCM_PIPELINE_ALLOCATED_TIMEOUT,
@@ -670,7 +668,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    */
   @Override
   public void activatePipeline(PipelineID pipelineID)
-      throws IOException, TimeoutException {
+      throws IOException {
     HddsProtos.PipelineID pipelineIDProtobuf = pipelineID.getProtobuf();
     acquireWriteLock();
     try {
@@ -689,7 +687,7 @@ public class PipelineManagerImpl implements PipelineManager 
{
    */
   @Override
   public void deactivatePipeline(PipelineID pipelineID)
-      throws IOException, TimeoutException {
+      throws IOException {
     HddsProtos.PipelineID pipelineIDProtobuf = pipelineID.getProtobuf();
     acquireWriteLock();
     try {
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateManager.java
index 53d12aa9d7..ab0a448e6a 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateManager.java
@@ -28,7 +28,6 @@ import java.io.IOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.NavigableSet;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Manages the state of pipelines in SCM.
@@ -42,7 +41,7 @@ public interface PipelineStateManager {
    */
   @Replicate
   void addPipeline(HddsProtos.Pipeline pipelineProto)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Removing pipeline would be replicated to Ratis.
@@ -52,7 +51,7 @@ public interface PipelineStateManager {
    */
   @Replicate
   void removePipeline(HddsProtos.PipelineID pipelineIDProto)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * Updating pipeline state would be replicated to Ratis.
@@ -62,7 +61,7 @@ public interface PipelineStateManager {
    */
   @Replicate
   void updatePipelineState(HddsProtos.PipelineID pipelineIDProto,
-      HddsProtos.PipelineState newState) throws IOException, TimeoutException;
+      HddsProtos.PipelineState newState) throws IOException;
 
   void addContainerToPipeline(
       PipelineID pipelineID,
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerFactory.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerFactory.java
index 8c8c9c29bb..000f2d296b 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerFactory.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerFactory.java
@@ -27,7 +27,6 @@ import 
org.apache.hadoop.hdds.scm.pipeline.WritableECContainerProvider.WritableE
 import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 import static org.apache.hadoop.hdds.conf.StorageUnit.BYTES;
 import static 
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE;
@@ -62,7 +61,7 @@ public class WritableContainerFactory {
 
   public ContainerInfo getContainer(final long size,
       ReplicationConfig repConfig, String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException {
+      throws IOException {
     switch (repConfig.getReplicationType()) {
     case STAND_ALONE:
       return standaloneProvider
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerProvider.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerProvider.java
index 6a37610129..628aba629a 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableContainerProvider.java
@@ -23,7 +23,6 @@ import org.apache.hadoop.hdds.scm.container.ContainerInfo;
 import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Interface used by the WritableContainerFactory to obtain a writable 
container
@@ -54,6 +53,6 @@ public interface WritableContainerProvider<T extends 
ReplicationConfig> {
    */
   ContainerInfo getContainer(long size, T repConfig,
       String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException;
+      throws IOException;
 
 }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
index be20a6f7b5..d95e539c10 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableECContainerProvider.java
@@ -42,7 +42,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.NavigableSet;
-import java.util.concurrent.TimeoutException;
 
 import static org.apache.hadoop.hdds.conf.ConfigTag.SCM;
 
@@ -93,7 +92,7 @@ public class WritableECContainerProvider
   @Override
   public ContainerInfo getContainer(final long size,
       ECReplicationConfig repConfig, String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException {
+      throws IOException {
     int maximumPipelines = getMaximumPipelines(repConfig);
     int openPipelineCount = 0;
     synchronized (this) {
@@ -180,7 +179,7 @@ public class WritableECContainerProvider
 
   private ContainerInfo allocateContainer(ReplicationConfig repConfig,
       long size, String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException {
+      throws IOException {
 
     List<DatanodeDetails> excludedNodes = Collections.emptyList();
     if (excludeList.getDatanodes().size() > 0) {
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java
index c423177e84..a113a0cd14 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java
@@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.List;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 /**
@@ -65,7 +64,7 @@ public class WritableRatisContainerProvider
   @Override
   public ContainerInfo getContainer(final long size,
       ReplicationConfig repConfig, String owner, ExcludeList excludeList)
-      throws IOException, TimeoutException {
+      throws IOException {
     /*
       Here is the high level logic.
 
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java
index 0d4fbad2c6..b81b4eab13 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/security/SecretKeyManagerService.java
@@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
@@ -94,9 +93,9 @@ public class SecretKeyManagerService implements SCMService, 
Runnable {
           scheduler.schedule(() -> {
             try {
               secretKeyManager.checkAndInitialize();
-            } catch (TimeoutException e) {
+            } catch (Exception e) {
               throw new RuntimeException(
-                  "Timeout replicating initialized state.", e);
+                  "Error replicating initialized state.", e);
             }
           }, 0, TimeUnit.SECONDS);
         }
@@ -128,7 +127,7 @@ public class SecretKeyManagerService implements SCMService, 
Runnable {
 
     try {
       secretKeyManager.checkAndRotate();
-    } catch (TimeoutException e) {
+    } catch (Exception e) {
       LOG.error("Error occurred when updating SecretKeys.", e);
     }
   }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
index bf766a12e0..2c12656b1e 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
@@ -107,7 +107,6 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -229,18 +228,13 @@ public class SCMClientProtocolServer implements
           ResultCodes.SAFE_MODE_EXCEPTION);
     }
     getScm().checkAdminAccess(getRemoteUser(), false);
-    try {
-      final ContainerInfo container = scm.getContainerManager()
-          .allocateContainer(
-              ReplicationConfig.fromProtoTypeAndFactor(replicationType, 
factor),
-              owner);
-      final Pipeline pipeline = scm.getPipelineManager()
-          .getPipeline(container.getPipelineID());
-      return new ContainerWithPipeline(container, pipeline);
-    } catch (TimeoutException e) {
-      throw new SCMException("Allocate Container TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
-    }
+    final ContainerInfo container = scm.getContainerManager()
+        .allocateContainer(
+            ReplicationConfig.fromProtoTypeAndFactor(replicationType, factor),
+            owner);
+    final Pipeline pipeline = scm.getPipelineManager()
+        .getPipeline(container.getPipelineID());
+    return new ContainerWithPipeline(container, pipeline);
   }
 
   @Override
@@ -588,11 +582,6 @@ public class SCMClientProtocolServer implements
           ContainerID.valueOf(containerID));
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.DELETE_CONTAINER, auditMap));
-    } catch (TimeoutException ex) {
-      AUDIT.logWriteFailure(buildAuditMessageForFailure(
-          SCMAction.DELETE_CONTAINER, auditMap, ex));
-      throw new SCMException("Delete Container TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
     } catch (Exception ex) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.DELETE_CONTAINER, auditMap, ex));
@@ -700,11 +689,10 @@ public class SCMClientProtocolServer implements
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.CREATE_PIPELINE, null));
       return result;
-    } catch (TimeoutException ex) {
+    } catch (SCMException e) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
-          SCMAction.CREATE_PIPELINE, null, ex));
-      throw new SCMException("Create Pipeline TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
+          SCMAction.CREATE_PIPELINE, null, e));
+      throw e;
     }
   }
 
@@ -730,11 +718,10 @@ public class SCMClientProtocolServer implements
           PipelineID.getFromProtobuf(pipelineID));
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.ACTIVATE_PIPELINE, null));
-    } catch (TimeoutException ex) {
+    } catch (Exception ex) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.ACTIVATE_PIPELINE, null, ex));
-      throw new SCMException("Activate Pipeline TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
+      throw ex;
     }
   }
 
@@ -747,11 +734,10 @@ public class SCMClientProtocolServer implements
           PipelineID.getFromProtobuf(pipelineID));
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.DEACTIVATE_PIPELINE, null));
-    } catch (TimeoutException ex) {
+    } catch (Exception ex) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.DEACTIVATE_PIPELINE, null, ex));
-      throw new SCMException("DeActivate Pipeline TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
+      throw ex;
     }
   }
 
@@ -768,11 +754,9 @@ public class SCMClientProtocolServer implements
       pipelineManager.closePipeline(pipeline, true);
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.CLOSE_PIPELINE, auditMap));
-    } catch (TimeoutException ex) {
+    } catch (Exception ex) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.CLOSE_PIPELINE, auditMap, ex));
-      throw new SCMException("Close Pipeline TimeoutException",
-          ResultCodes.INTERNAL_ERROR);
     }
   }
 
@@ -887,10 +871,10 @@ public class SCMClientProtocolServer implements
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.RESET_DELETED_BLOCK_RETRY_COUNT, auditMap));
       return count;
-    } catch (TimeoutException | IOException ex) {
+    } catch (Exception ex) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.RESET_DELETED_BLOCK_RETRY_COUNT, auditMap, ex));
-      throw new IOException(ex);
+      throw ex;
     }
   }
 
@@ -1055,7 +1039,7 @@ public class SCMClientProtocolServer implements
     try {
       containerBalancer.startBalancer(cbc);
     } catch (IllegalContainerBalancerStateException | IOException |
-        InvalidContainerBalancerConfigurationException | TimeoutException e) {
+        InvalidContainerBalancerConfigurationException e) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.START_CONTAINER_BALANCER, null, e));
       return StartContainerBalancerResponseProto.newBuilder()
@@ -1077,7 +1061,7 @@ public class SCMClientProtocolServer implements
       scm.getContainerBalancer().stopBalancer();
       AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
           SCMAction.STOP_CONTAINER_BALANCER, null));
-    } catch (IllegalContainerBalancerStateException | TimeoutException e) {
+    } catch (IllegalContainerBalancerStateException e) {
       AUDIT.logWriteFailure(buildAuditMessageForFailure(
           SCMAction.STOP_CONTAINER_BALANCER, null, e));
     }
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/FinalizationStateManager.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/FinalizationStateManager.java
index fe1a8e91dd..694e013db2 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/FinalizationStateManager.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/FinalizationStateManager.java
@@ -20,7 +20,6 @@ import org.apache.hadoop.hdds.scm.metadata.Replicate;
 import org.apache.hadoop.hdds.utils.db.Table;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 /**
  * Manages the state of finalization in SCM.
@@ -28,14 +27,14 @@ import java.util.concurrent.TimeoutException;
 public interface FinalizationStateManager {
 
   @Replicate
-  void addFinalizingMark() throws IOException, TimeoutException;
+  void addFinalizingMark() throws IOException;
 
   @Replicate
-  void removeFinalizingMark() throws IOException, TimeoutException;
+  void removeFinalizingMark() throws IOException;
 
   @Replicate
   void finalizeLayoutFeature(Integer layoutVersion)
-      throws IOException, TimeoutException;
+      throws IOException;
 
   /**
    * @param query The checkpoint to check for being crossed.
diff --git 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java
 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java
index b65cc00706..3a838a1b39 100644
--- 
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java
+++ 
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java
@@ -21,7 +21,6 @@ package org.apache.hadoop.hdds.scm.server.upgrade;
 import static 
org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.CLOSED;
 
 import java.io.IOException;
-import java.util.concurrent.TimeoutException;
 
 import org.apache.hadoop.hdds.client.ReplicationConfig;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
@@ -64,22 +63,17 @@ public class SCMUpgradeFinalizer extends
   @Override
   public void preFinalizeUpgrade(SCMUpgradeFinalizationContext context)
       throws IOException {
-    try {
-      FinalizationStateManager stateManager =
-          context.getFinalizationStateManager();
-      if (!stateManager.crossedCheckpoint(
-          FinalizationCheckpoint.FINALIZATION_STARTED)) {
-        context.getFinalizationStateManager().addFinalizingMark();
-      }
-      logCheckpointCrossed(FinalizationCheckpoint.FINALIZATION_STARTED);
+    FinalizationStateManager stateManager =
+        context.getFinalizationStateManager();
+    if (!stateManager.crossedCheckpoint(
+        FinalizationCheckpoint.FINALIZATION_STARTED)) {
+      context.getFinalizationStateManager().addFinalizingMark();
+    }
+    logCheckpointCrossed(FinalizationCheckpoint.FINALIZATION_STARTED);
 
-      if (!stateManager.crossedCheckpoint(
-          FinalizationCheckpoint.MLV_EQUALS_SLV)) {
-        closePipelinesBeforeFinalization(context.getPipelineManager());
-      }
-    } catch (TimeoutException ex) {
-      LOG.error("TimeoutException during preFinalizeUpgrade", ex);
-      throw new IOException(ex);
+    if (!stateManager.crossedCheckpoint(
+        FinalizationCheckpoint.MLV_EQUALS_SLV)) {
+      closePipelinesBeforeFinalization(context.getPipelineManager());
     }
   }
 
@@ -91,7 +85,7 @@ public class SCMUpgradeFinalizer extends
     try {
       context.getFinalizationStateManager()
           .finalizeLayoutFeature(lf.layoutVersion());
-    } catch (IOException | TimeoutException ex) {
+    } catch (IOException ex) {
       throw new UpgradeException(ex,
           UpgradeException.ResultCodes.LAYOUT_FEATURE_FINALIZATION_FAILED);
     }
@@ -124,12 +118,7 @@ public class SCMUpgradeFinalizer extends
     if (!stateManager.crossedCheckpoint(
         FinalizationCheckpoint.FINALIZATION_COMPLETE)) {
       createPipelinesAfterFinalization(context);
-      // @Replicate methods are required to throw TimeoutException.
-      try {
-        stateManager.removeFinalizingMark();
-      } catch (TimeoutException ex) {
-        throw new IOException(ex);
-      }
+      stateManager.removeFinalizingMark();
     }
   }
 
@@ -141,7 +130,7 @@ public class SCMUpgradeFinalizer extends
   }
 
   private void closePipelinesBeforeFinalization(PipelineManager 
pipelineManager)
-      throws IOException, TimeoutException {
+      throws IOException {
     /*
      * Before we can call finalize the feature, we need to make sure that
      * all existing pipelines are closed and pipeline Manger would freeze
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/TestBlockManager.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/TestBlockManager.java
index 15b5e1f737..d9760efc47 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/TestBlockManager.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/block/TestBlockManager.java
@@ -261,7 +261,7 @@ public class TestBlockManager {
               .allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig,
                   OzoneConsts.OZONE,
                   new ExcludeList()));
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
           future.completeExceptionally(e);
         }
         return future;
@@ -311,7 +311,7 @@ public class TestBlockManager {
           blockList.add(block);
           allocatedBlockMap.put(containerId, blockList);
           future.complete(block);
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
           future.completeExceptionally(e);
         }
         return future;
@@ -372,7 +372,7 @@ public class TestBlockManager {
           blockList.add(block);
           allocatedBlockMap.put(containerId, blockList);
           future.complete(block);
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
           future.completeExceptionally(e);
         }
         return future;
@@ -440,7 +440,7 @@ public class TestBlockManager {
           blockList.add(block);
           allocatedBlockMap.put(containerId, blockList);
           future.complete(block);
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
           future.completeExceptionally(e);
         }
         return future;
@@ -519,7 +519,7 @@ public class TestBlockManager {
                 new ExcludeList());
         return !block.getPipeline().getId()
             .equals(allocatedBlock.getPipeline().getId());
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
       }
       return false;
     }, 100, 1000);
@@ -564,7 +564,7 @@ public class TestBlockManager {
             .allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig,
                 OzoneConsts.OZONE,
                 new ExcludeList());
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
       }
       return verifyNumberOfContainersInPipelines(
           numContainerPerOwnerInPipeline);
@@ -589,7 +589,7 @@ public class TestBlockManager {
             .allocateBlock(DEFAULT_BLOCK_SIZE, replicationConfig,
                 OzoneConsts.OZONE,
                 new ExcludeList());
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
       }
       return verifyNumberOfContainersInPipelines(
           numContainerPerOwnerInPipeline);
@@ -599,7 +599,7 @@ public class TestBlockManager {
   @Test
   @Timeout(100)
   public void testBlockAllocationWithNoAvailablePipelines()
-      throws IOException, TimeoutException {
+      throws IOException {
     for (Pipeline pipeline : pipelineManager.getPipelines()) {
       pipelineManager.closePipeline(pipeline, false);
     }
@@ -622,7 +622,7 @@ public class TestBlockManager {
             (CreatePipelineCommand) command.getCommand();
         try {
           pipelineManager.openPipeline(createCommand.getPipelineID());
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
         }
       }
     }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java
index f67ac49bdb..d5ae7457db 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java
@@ -285,8 +285,7 @@ public class TestContainerBalancer {
       if (containerBalancer.isBalancerRunning()) {
         containerBalancer.stopBalancer();
       }
-    } catch (IOException | IllegalContainerBalancerStateException |
-             TimeoutException e) {
+    } catch (IOException | IllegalContainerBalancerStateException e) {
       LOG.warn("Failed to stop balancer", e);
     }
   }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestBackgroundSCMService.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestBackgroundSCMService.java
index 3810f01915..ebddcc3ede 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestBackgroundSCMService.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestBackgroundSCMService.java
@@ -60,7 +60,7 @@ public class TestBackgroundSCMService {
         .setPeriodicalTask(() -> {
           try {
             pipelineManager.scrubPipelines();
-          } catch (IOException | TimeoutException e) {
+          } catch (IOException e) {
             throw new RuntimeException(e);
           }
         }).build();
@@ -99,7 +99,7 @@ public class TestBackgroundSCMService {
   }
 
   @Test
-  public void testRun() throws IOException, TimeoutException {
+  public void testRun() throws IOException {
     assertFalse(backgroundSCMService.shouldRun());
     // kick a run
     synchronized (backgroundSCMService) {
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
index 24a09bdac2..3049e88662 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
@@ -130,10 +130,9 @@ public class TestReplicationAnnotation {
     try {
       proxy.addContainer(HddsProtos.ContainerInfoProto.getDefaultInstance());
       Assertions.fail("Cannot reach here: should have seen a IOException");
-    } catch (IOException ignore) {
-      Assertions.assertNotNull(ignore.getMessage() != null);
-      Assertions.assertEquals("submitRequest is called.",
-          ignore.getMessage());
+    } catch (IOException e) {
+      Assertions.assertNotNull(e.getMessage());
+      Assertions.assertTrue(e.getMessage().contains("submitRequest is 
called"));
     }
 
     scmhaInvocationHandler = new SCMHAInvocationHandler(
@@ -151,10 +150,9 @@ public class TestReplicationAnnotation {
           KeyStoreTestUtil.generateCertificate("CN=Test", keyPair, 30,
           "SHA256withRSA"), HddsProtos.NodeType.DATANODE);
       Assertions.fail("Cannot reach here: should have seen a IOException");
-    } catch (IOException ignore) {
-      Assertions.assertNotNull(ignore.getMessage() != null);
-      Assertions.assertEquals("submitRequest is called.",
-          ignore.getMessage());
+    } catch (IOException e) {
+      Assertions.assertNotNull(e.getMessage());
+      Assertions.assertTrue(e.getMessage().contains("submitRequest is 
called"));
     }
 
   }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/MockPipelineManager.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/MockPipelineManager.java
index 5303f44c26..3fedeff9c6 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/MockPipelineManager.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/MockPipelineManager.java
@@ -39,7 +39,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.NavigableSet;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -48,7 +47,7 @@ import java.util.stream.Stream;
  */
 public class MockPipelineManager implements PipelineManager {
 
-  private PipelineStateManager stateManager;
+  private final PipelineStateManager stateManager;
 
   public MockPipelineManager(DBStore dbStore, SCMHAManager scmhaManager,
                              NodeManager nodeManager) throws IOException {
@@ -62,7 +61,7 @@ public class MockPipelineManager implements PipelineManager {
 
   @Override
   public Pipeline createPipeline(ReplicationConfig replicationConfig)
-      throws IOException, TimeoutException {
+      throws IOException {
     return createPipeline(replicationConfig, Collections.emptyList(),
         Collections.emptyList());
   }
@@ -70,7 +69,7 @@ public class MockPipelineManager implements PipelineManager {
   @Override
   public Pipeline createPipeline(ReplicationConfig replicationConfig,
       List<DatanodeDetails> excludedNodes, List<DatanodeDetails> favoredNodes)
-      throws IOException, TimeoutException {
+      throws IOException {
     Pipeline pipeline = buildECPipeline(replicationConfig, excludedNodes,
         favoredNodes);
 
@@ -82,7 +81,7 @@ public class MockPipelineManager implements PipelineManager {
   @Override
   public Pipeline buildECPipeline(ReplicationConfig replicationConfig,
       List<DatanodeDetails> excludedNodes, List<DatanodeDetails> favoredNodes)
-      throws IOException, TimeoutException {
+      throws IOException {
     final List<DatanodeDetails> nodes = Stream.generate(
             MockDatanodeDetails::randomDatanodeDetails)
         .limit(replicationConfig.getRequiredNodes())
@@ -98,7 +97,7 @@ public class MockPipelineManager implements PipelineManager {
 
   @Override
   public void addEcPipeline(Pipeline pipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     stateManager.addPipeline(pipeline.getProtobufMessage(
         ClientVersion.CURRENT_VERSION));
   }
@@ -222,14 +221,14 @@ public class MockPipelineManager implements 
PipelineManager {
 
   @Override
   public void openPipeline(final PipelineID pipelineId)
-      throws IOException, TimeoutException {
+      throws IOException {
     stateManager.updatePipelineState(
         pipelineId.getProtobuf(), HddsProtos.PipelineState.PIPELINE_OPEN);
   }
 
   @Override
   public void closePipeline(final Pipeline pipeline, final boolean onTimeout)
-      throws IOException, TimeoutException {
+      throws IOException {
     stateManager.updatePipelineState(pipeline.getId().getProtobuf(),
         HddsProtos.PipelineState.PIPELINE_CLOSED);
   }
@@ -276,7 +275,7 @@ public class MockPipelineManager implements PipelineManager 
{
 
   @Override
   public void deactivatePipeline(final PipelineID pipelineID)
-      throws IOException, TimeoutException {
+      throws IOException {
     stateManager.updatePipelineState(pipelineID.getProtobuf(),
         HddsProtos.PipelineState.PIPELINE_DORMANT);
   }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineDatanodesIntersection.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineDatanodesIntersection.java
index ae4411cdf0..dcc3829cce 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineDatanodesIntersection.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineDatanodesIntersection.java
@@ -49,7 +49,6 @@ import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 import static 
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_DATANODE_PIPELINE_LIMIT;
 import static 
org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_PIPELINE_AUTO_CREATE_FACTOR_ONE;
@@ -146,7 +145,7 @@ public class TestPipelineDatanodesIntersection {
         createdPipelineCount++;
       } catch (SCMException e) {
         end = true;
-      } catch (IOException | TimeoutException e) {
+      } catch (IOException e) {
         end = true;
         // Should not throw regular IOException.
         Assertions.fail();
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
index 95ccf87f0b..23b71f278f 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineManagerImpl.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hdds.scm.container.MockNodeManager;
 import org.apache.hadoop.hdds.scm.container.common.helpers.ExcludeList;
 import 
org.apache.hadoop.hdds.scm.container.placement.algorithms.SCMContainerPlacementRandom;
 import org.apache.hadoop.hdds.scm.exceptions.SCMException;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes;
 import org.apache.hadoop.hdds.scm.ha.SCMHADBTransactionBuffer;
 import org.apache.hadoop.hdds.scm.ha.SCMHADBTransactionBufferStub;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManagerStub;
@@ -58,6 +59,7 @@ import org.apache.hadoop.ozone.container.common.SCMTestUtils;
 import org.apache.ozone.test.GenericTestUtils;
 import org.apache.ozone.test.TestClock;
 import org.apache.ratis.protocol.exceptions.NotLeaderException;
+import org.apache.ratis.util.function.CheckedRunnable;
 import org.assertj.core.util.Lists;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
@@ -88,6 +90,7 @@ import static 
org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.ALLOCAT
 import static org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.OPEN;
 import static org.apache.hadoop.test.MetricsAsserts.getLongCounter;
 import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
+import static org.apache.ratis.util.Preconditions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
@@ -226,18 +229,11 @@ public class TestPipelineManagerImpl {
 
   @Test
   public void testCreatePipelineShouldFailOnFollower() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(false);
-    Assertions.assertTrue(pipelineManager.getPipelines().isEmpty());
-    try {
-      pipelineManager
-          .createPipeline(RatisReplicationConfig
-              .getInstance(ReplicationFactor.THREE));
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManager pipelineManager = createPipelineManager(false)) {
+      Assertions.assertTrue(pipelineManager.getPipelines().isEmpty());
+      assertFailsNotLeader(() -> pipelineManager.createPipeline(
+              RatisReplicationConfig.getInstance(ReplicationFactor.THREE)));
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
@@ -247,11 +243,7 @@ public class TestPipelineManagerImpl {
         createPipelineManager(true, buffer);
     Table<PipelineID, Pipeline> pipelineStore =
         SCMDBDefinition.PIPELINES.getTable(dbStore);
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
+    Pipeline pipeline = assertAllocate(pipelineManager);
     buffer.flush();
     Assertions.assertEquals(ALLOCATED,
         pipelineStore.get(pipeline.getId()).getPipelineState());
@@ -295,185 +287,129 @@ public class TestPipelineManagerImpl {
 
   @Test
   public void testOpenPipelineShouldFailOnFollower() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
-    // Change to follower
-    assert pipelineManager.getScmhaManager() instanceof SCMHAManagerStub;
-    ((SCMHAManagerStub) pipelineManager.getScmhaManager()).setIsLeader(false);
-    try {
-      pipelineManager.openPipeline(pipeline.getId());
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      Pipeline pipeline = assertAllocate(pipelineManager);
+      changeToFollower(pipelineManager);
+      assertFailsNotLeader(
+          () -> pipelineManager.openPipeline(pipeline.getId()));
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
   public void testActivatePipelineShouldFailOnFollower() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
-    // Change to follower
-    assert pipelineManager.getScmhaManager() instanceof SCMHAManagerStub;
-    ((SCMHAManagerStub) pipelineManager.getScmhaManager()).setIsLeader(false);
-    try {
-      pipelineManager.activatePipeline(pipeline.getId());
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      Pipeline pipeline = assertAllocate(pipelineManager);
+      changeToFollower(pipelineManager);
+      assertFailsNotLeader(
+          () -> pipelineManager.activatePipeline(pipeline.getId()));
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
   public void testDeactivatePipelineShouldFailOnFollower() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
-    // Change to follower
-    assert pipelineManager.getScmhaManager() instanceof SCMHAManagerStub;
-    ((SCMHAManagerStub) pipelineManager.getScmhaManager()).setIsLeader(false);
-    try {
-      pipelineManager.deactivatePipeline(pipeline.getId());
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      Pipeline pipeline = assertAllocate(pipelineManager);
+      changeToFollower(pipelineManager);
+      Assertions.assertThrows(SCMException.class,
+          () -> pipelineManager.deactivatePipeline(pipeline.getId()));
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
   public void testRemovePipeline() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    // Create a pipeline
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      Pipeline pipeline = assertAllocate(pipelineManager);
 
-    // Open the pipeline
-    pipelineManager.openPipeline(pipeline.getId());
-    ContainerManager containerManager = scm.getContainerManager();
-    ContainerInfo containerInfo = HddsTestUtils.
-            getContainer(HddsProtos.LifeCycleState.CLOSED, pipeline.getId());
-    ContainerID containerID = containerInfo.containerID();
-    //Add Container to ContainerMap
-    containerManager.getContainerStateManager().
-            addContainer(containerInfo.getProtobuf());
-    //Add Container to PipelineStateMap
-    pipelineManager.addContainerToPipeline(pipeline.getId(), containerID);
-    Assertions.assertTrue(pipelineManager
-        .getPipelines(RatisReplicationConfig
-            .getInstance(ReplicationFactor.THREE),
-            Pipeline.PipelineState.OPEN).contains(pipeline));
+      // Open the pipeline
+      pipelineManager.openPipeline(pipeline.getId());
+      ContainerManager containerManager = scm.getContainerManager();
+      ContainerInfo containerInfo = HddsTestUtils.
+          getContainer(HddsProtos.LifeCycleState.CLOSED, pipeline.getId());
+      ContainerID containerID = containerInfo.containerID();
+      //Add Container to ContainerMap
+      containerManager.getContainerStateManager().
+          addContainer(containerInfo.getProtobuf());
+      //Add Container to PipelineStateMap
+      pipelineManager.addContainerToPipeline(pipeline.getId(), containerID);
+      Assertions.assertTrue(pipelineManager
+          .getPipelines(RatisReplicationConfig
+                  .getInstance(ReplicationFactor.THREE),
+              Pipeline.PipelineState.OPEN).contains(pipeline));
 
-    try {
-      pipelineManager.removePipeline(pipeline);
-      fail();
-    } catch (IOException ioe) {
-      // Should not be able to remove the OPEN pipeline.
-      Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    } catch (Exception e) {
-      Assertions.fail("Should not reach here.");
-    }
+      try {
+        pipelineManager.removePipeline(pipeline);
+        fail();
+      } catch (IOException ioe) {
+        // Should not be able to remove the OPEN pipeline.
+        Assertions.assertEquals(1, pipelineManager.getPipelines().size());
+      } catch (Exception e) {
+        Assertions.fail("Should not reach here.");
+      }
 
-    // Destroy pipeline
-    pipelineManager.closePipeline(pipeline, false);
-    try {
-      pipelineManager.getPipeline(pipeline.getId());
-      fail("Pipeline should not have been retrieved");
-    } catch (PipelineNotFoundException e) {
-      // There may be pipelines created by BackgroundPipelineCreator
-      // exist in pipelineManager, just ignore them.
+      // Destroy pipeline
+      pipelineManager.closePipeline(pipeline, false);
+      try {
+        pipelineManager.getPipeline(pipeline.getId());
+        fail("Pipeline should not have been retrieved");
+      } catch (PipelineNotFoundException e) {
+        // There may be pipelines created by BackgroundPipelineCreator
+        // exist in pipelineManager, just ignore them.
+      }
     }
-
-    pipelineManager.close();
   }
 
   @Test
   public void testClosePipelineShouldFailOnFollower() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    Pipeline pipeline = pipelineManager.createPipeline(
-        RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
-    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
-    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
-    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
-    // Change to follower
-    assert pipelineManager.getScmhaManager() instanceof SCMHAManagerStub;
-    ((SCMHAManagerStub) pipelineManager.getScmhaManager()).setIsLeader(false);
-    try {
-      pipelineManager.closePipeline(pipeline, false);
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      Pipeline pipeline = assertAllocate(pipelineManager);
+      changeToFollower(pipelineManager);
+      assertFailsNotLeader(
+          () -> pipelineManager.closePipeline(pipeline, false));
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
   public void testPipelineReport() throws Exception {
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    SCMSafeModeManager scmSafeModeManager =
-        new SCMSafeModeManager(conf, new ArrayList<>(), null, pipelineManager,
-            new EventQueue(), serviceManager, scmContext);
-    Pipeline pipeline = pipelineManager
-        .createPipeline(RatisReplicationConfig
-            .getInstance(ReplicationFactor.THREE));
-
-    // pipeline is not healthy until all dns report
-    List<DatanodeDetails> nodes = pipeline.getNodes();
-    Assertions.assertFalse(
-        pipelineManager.getPipeline(pipeline.getId()).isHealthy());
-    // get pipeline report from each dn in the pipeline
-    PipelineReportHandler pipelineReportHandler =
-        new PipelineReportHandler(scmSafeModeManager, pipelineManager,
-            SCMContext.emptyContext(), conf);
-    nodes.subList(0, 2).forEach(dn -> sendPipelineReport(dn, pipeline,
-        pipelineReportHandler, false));
-    sendPipelineReport(nodes.get(nodes.size() - 1), pipeline,
-        pipelineReportHandler, true);
-
-    // pipeline is healthy when all dns report
-    Assertions.assertTrue(
-        pipelineManager.getPipeline(pipeline.getId()).isHealthy());
-    // pipeline should now move to open state
-    Assertions.assertTrue(
-        pipelineManager.getPipeline(pipeline.getId()).isOpen());
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      SCMSafeModeManager scmSafeModeManager =
+          new SCMSafeModeManager(conf, new ArrayList<>(), null, 
pipelineManager,
+              new EventQueue(), serviceManager, scmContext);
+      Pipeline pipeline = pipelineManager
+          .createPipeline(RatisReplicationConfig
+              .getInstance(ReplicationFactor.THREE));
 
-    // close the pipeline
-    pipelineManager.closePipeline(pipeline, false);
+      // pipeline is not healthy until all dns report
+      List<DatanodeDetails> nodes = pipeline.getNodes();
+      Assertions.assertFalse(
+          pipelineManager.getPipeline(pipeline.getId()).isHealthy());
+      // get pipeline report from each dn in the pipeline
+      PipelineReportHandler pipelineReportHandler =
+          new PipelineReportHandler(scmSafeModeManager, pipelineManager,
+              SCMContext.emptyContext(), conf);
+      nodes.subList(0, 2).forEach(dn -> sendPipelineReport(dn, pipeline,
+          pipelineReportHandler, false));
+      sendPipelineReport(nodes.get(nodes.size() - 1), pipeline,
+          pipelineReportHandler, true);
+
+      // pipeline is healthy when all dns report
+      Assertions.assertTrue(
+          pipelineManager.getPipeline(pipeline.getId()).isHealthy());
+      // pipeline should now move to open state
+      Assertions.assertTrue(
+          pipelineManager.getPipeline(pipeline.getId()).isOpen());
+
+      // close the pipeline
+      pipelineManager.closePipeline(pipeline, false);
 
-    // pipeline report for destroyed pipeline should be ignored
-    nodes.subList(0, 2).forEach(dn -> sendPipelineReport(dn, pipeline,
-        pipelineReportHandler, false));
-    sendPipelineReport(nodes.get(nodes.size() - 1), pipeline,
-        pipelineReportHandler, true);
+      // pipeline report for destroyed pipeline should be ignored
+      nodes.subList(0, 2).forEach(dn -> sendPipelineReport(dn, pipeline,
+          pipelineReportHandler, false));
+      sendPipelineReport(nodes.get(nodes.size() - 1), pipeline,
+          pipelineReportHandler, true);
 
-    try {
-      pipelineManager.getPipeline(pipeline.getId());
-      fail("Pipeline should not have been retrieved");
-    } catch (PipelineNotFoundException e) {
-      // should reach here
+      assertThrows(PipelineNotFoundException.class,
+          () -> pipelineManager.getPipeline(pipeline.getId()));
     }
-
-    // clean up
-    pipelineManager.close();
   }
 
   @Test
@@ -515,7 +451,7 @@ public class TestPipelineManagerImpl {
     } catch (SCMException ioe) {
       // pipeline creation failed this time.
       Assertions.assertEquals(
-          SCMException.ResultCodes.FAILED_TO_FIND_SUITABLE_NODE,
+          ResultCodes.FAILED_TO_FIND_SUITABLE_NODE,
           ioe.getResult());
     }
 
@@ -671,33 +607,13 @@ public class TestPipelineManagerImpl {
     conf.setTimeDuration(
         OZONE_SCM_PIPELINE_ALLOCATED_TIMEOUT, 10, TimeUnit.SECONDS);
 
-    PipelineManagerImpl pipelineManager = createPipelineManager(true);
-    Pipeline pipeline = pipelineManager
-        .createPipeline(RatisReplicationConfig
-            .getInstance(ReplicationFactor.THREE));
-    // At this point, pipeline is not at OPEN stage.
-    Assertions.assertEquals(Pipeline.PipelineState.ALLOCATED,
-        pipeline.getPipelineState());
-
-    // pipeline should be seen in pipelineManager as ALLOCATED.
-    Assertions.assertTrue(pipelineManager
-        .getPipelines(RatisReplicationConfig
-                .getInstance(ReplicationFactor.THREE),
-            Pipeline.PipelineState.ALLOCATED).contains(pipeline));
-
-    // Change to follower
-    assert pipelineManager.getScmhaManager() instanceof SCMHAManagerStub;
-    ((SCMHAManagerStub) pipelineManager.getScmhaManager()).setIsLeader(false);
-
-    testClock.fastForward(20000);
-    try {
-      pipelineManager.scrubPipelines();
-    } catch (NotLeaderException ex) {
-      pipelineManager.close();
-      return;
+    try (PipelineManagerImpl pipelineManager = createPipelineManager(true)) {
+      assertAllocate(pipelineManager);
+      changeToFollower(pipelineManager);
+      testClock.fastForward(20000);
+      Assertions.assertThrows(SCMException.class,
+          pipelineManager::scrubPipelines);
     }
-    // Should not reach here.
-    Assertions.fail();
   }
 
   @Test
@@ -1066,4 +982,25 @@ public class TestPipelineManagerImpl {
             isLeader);
     pipelineReportHandler.onMessage(report, new EventQueue());
   }
+
+  private static Pipeline assertAllocate(PipelineManagerImpl pipelineManager) {
+    Pipeline pipeline = Assertions.assertDoesNotThrow(
+        () -> pipelineManager.createPipeline(
+            RatisReplicationConfig.getInstance(ReplicationFactor.THREE)));
+    Assertions.assertEquals(1, pipelineManager.getPipelines().size());
+    Assertions.assertTrue(pipelineManager.containsPipeline(pipeline.getId()));
+    Assertions.assertEquals(ALLOCATED, pipeline.getPipelineState());
+    return pipeline;
+  }
+
+  private static void changeToFollower(PipelineManagerImpl pipelineManager) {
+    assertInstanceOf(pipelineManager.getScmhaManager(), SCMHAManagerStub.class)
+        .setIsLeader(false);
+  }
+
+  private static void assertFailsNotLeader(CheckedRunnable<?> block) {
+    SCMException e = Assertions.assertThrows(SCMException.class, block::run);
+    Assertions.assertEquals(ResultCodes.SCM_NOT_LEADER, e.getResult());
+    Assertions.assertTrue(e.getCause() instanceof NotLeaderException);
+  }
 }
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineStateManagerImpl.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineStateManagerImpl.java
index 91a12b216b..93a51ce1df 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineStateManagerImpl.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestPipelineStateManagerImpl.java
@@ -31,6 +31,7 @@ import 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import org.apache.hadoop.hdds.scm.container.ContainerID;
 import org.apache.hadoop.hdds.scm.container.MockNodeManager;
 import org.apache.hadoop.hdds.scm.container.TestContainerManagerImpl;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManagerStub;
 import org.apache.hadoop.hdds.scm.ha.SCMHAManager;
 import org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition;
@@ -40,7 +41,6 @@ import org.apache.hadoop.hdds.utils.db.DBStoreBuilder;
 import org.apache.hadoop.ozone.ClientVersion;
 import org.apache.hadoop.ozone.container.common.SCMTestUtils;
 import org.apache.ozone.test.GenericTestUtils;
-import org.apache.ratis.protocol.exceptions.StateMachineException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -115,37 +115,33 @@ public class TestPipelineStateManagerImpl {
 
   @Test
   public void testAddAndGetPipeline() throws IOException, TimeoutException {
-    Pipeline pipeline = createDummyPipeline(0);
-    HddsProtos.Pipeline pipelineProto = pipeline.getProtobufMessage(
-        ClientVersion.CURRENT_VERSION);
-    try {
-      stateManager.addPipeline(pipelineProto);
-      Assertions.fail("Pipeline should not have been added");
-    } catch (StateMachineException e) {
-      // replication factor and number of nodes in the pipeline do not match
-      Assertions.assertTrue(e.getMessage().contains("do not match"));
-    }
+    Exception e = Assertions.assertThrows(SCMException.class,
+        () -> stateManager.addPipeline(createDummyPipeline(0)
+            .getProtobufMessage(ClientVersion.CURRENT_VERSION)));
+    // replication factor and number of nodes in the pipeline do not match
+    Assertions.assertTrue(e.getMessage().contains("do not match"));
 
     // add a pipeline
-    pipeline = createDummyPipeline(1);
-    pipelineProto = pipeline.getProtobufMessage(ClientVersion.CURRENT_VERSION);
-    stateManager.addPipeline(pipelineProto);
+    Pipeline pipeline = createDummyPipeline(1);
+    HddsProtos.Pipeline pipelineProto = pipeline
+        .getProtobufMessage(ClientVersion.CURRENT_VERSION);
 
     try {
       stateManager.addPipeline(pipelineProto);
-      Assertions.fail("Pipeline should not have been added");
-    } catch (IOException e) {
-      // Can not add a pipeline twice
-      Assertions.assertTrue(e.getMessage().contains("Duplicate pipeline ID"));
-    }
 
-    // verify pipeline returned is same
-    Pipeline pipeline1 = stateManager.getPipeline(pipeline.getId());
-    Assertions.assertTrue(pipeline.getId().equals(pipeline1.getId()));
+      // Cannot add a pipeline twice
+      e = Assertions.assertThrows(SCMException.class,
+          () -> stateManager.addPipeline(pipelineProto));
+      Assertions.assertTrue(e.getMessage().contains("Duplicate pipeline ID"));
 
-    // clean up
-    finalizePipeline(pipelineProto);
-    removePipeline(pipelineProto);
+      // verify pipeline returned is same
+      Assertions.assertEquals(pipeline.getId(),
+          stateManager.getPipeline(pipeline.getId()).getId());
+    } finally {
+      // clean up
+      finalizePipeline(pipelineProto);
+      removePipeline(pipelineProto);
+    }
   }
 
   @Test
diff --git 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
index 76225d07fd..9d2626591f 100644
--- 
a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
+++ 
b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/pipeline/TestWritableECContainerProvider.java
@@ -60,7 +60,6 @@ import java.util.Map;
 import java.util.NavigableSet;
 import java.util.Set;
 import java.util.UUID;
-import java.util.concurrent.TimeoutException;
 
 import static org.apache.hadoop.hdds.conf.StorageUnit.BYTES;
 import static 
org.apache.hadoop.hdds.scm.pipeline.Pipeline.PipelineState.CLOSED;
@@ -150,7 +149,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   void testPipelinesCreatedBasedOnTotalDiskCount(PipelineChoosePolicy policy)
-      throws IOException, TimeoutException {
+      throws IOException {
     provider = createSubject(policy);
     providerConf.setMinimumPipelines(1);
     nodeManager.setNumHealthyVolumes(20);
@@ -164,7 +163,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   void testPipelinesCreatedBasedOnTotalDiskCountWithFactor(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     int factor = 10;
     providerConf.setMinimumPipelines(1);
@@ -180,7 +179,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   void testPipelinesCreatedUpToMinLimitAndRandomPipelineReturned(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     int minimumPipelines = providerConf.getMinimumPipelines();
     Set<ContainerInfo> allocated = assertDistinctContainers(minimumPipelines);
@@ -188,7 +187,7 @@ public class TestWritableECContainerProvider {
   }
 
   private Set<ContainerInfo> assertDistinctContainers(int n)
-      throws IOException, TimeoutException {
+      throws IOException {
     Set<ContainerInfo> allocatedContainers = new HashSet<>();
     for (int i = 0; i < n; i++) {
       ContainerInfo container =
@@ -201,7 +200,7 @@ public class TestWritableECContainerProvider {
   }
 
   private void assertReusesExisting(Set<ContainerInfo> existing, int n)
-      throws IOException, TimeoutException {
+      throws IOException {
     for (int i = 0; i < 3 * n; i++) {
       ContainerInfo container =
           provider.getContainer(1, repConfig, OWNER, new ExcludeList());
@@ -213,7 +212,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testPiplineLimitIgnoresExcludedPipelines(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     Set<ContainerInfo> allocatedContainers = new HashSet<>();
     for (int i = 0; i < providerConf.getMinimumPipelines(); i++) {
@@ -237,7 +236,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testNewPipelineNotCreatedIfAllPipelinesExcluded(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     Set<ContainerInfo> allocatedContainers = new HashSet<>();
     for (int i = 0; i < providerConf.getMinimumPipelines(); i++) {
@@ -258,7 +257,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testNewPipelineNotCreatedIfAllContainersExcluded(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     Set<ContainerInfo> allocatedContainers = new HashSet<>();
     for (int i = 0; i < providerConf.getMinimumPipelines(); i++) {
@@ -293,7 +292,7 @@ public class TestWritableECContainerProvider {
     try {
       provider.getContainer(1, repConfig, OWNER, new ExcludeList());
       Assert.fail();
-    } catch (IOException | TimeoutException ex) {
+    } catch (IOException ex) {
       GenericTestUtils.assertExceptionContains("Cannot create pipelines", ex);
     }
   }
@@ -301,7 +300,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testExistingPipelineReturnedWhenNewCannotBeCreated(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     pipelineManager = new MockPipelineManager(
         dbStore, scmhaManager, nodeManager) {
 
@@ -311,7 +310,7 @@ public class TestWritableECContainerProvider {
       public Pipeline createPipeline(ReplicationConfig repConf,
           List<DatanodeDetails> excludedNodes,
           List<DatanodeDetails> favoredNodes)
-          throws IOException, TimeoutException {
+          throws IOException {
         if (throwError) {
           throw new IOException("Cannot create pipelines");
         }
@@ -341,7 +340,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testNewContainerAllocatedAndPipelinesClosedIfNoSpaceInExisting(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     Set<ContainerInfo> allocatedContainers =
         assertDistinctContainers(providerConf.getMinimumPipelines());
@@ -375,7 +374,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testPipelineNotFoundWhenAttemptingToUseExisting(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     // Ensure PM throws PNF exception when we ask for the containers in the
     // pipeline
     pipelineManager = new MockPipelineManager(
@@ -403,7 +402,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testContainerNotFoundWhenAttemptingToUseExisting(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     provider = createSubject(policy);
     Set<ContainerInfo> allocatedContainers =
         assertDistinctContainers(providerConf.getMinimumPipelines());
@@ -429,7 +428,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testPipelineOpenButContainerRemovedFromIt(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     // This can happen if the container close process is triggered from the DN.
     // When tha happens, CM will change the container state to CLOSING and
     // remove it from the container list in pipeline Manager.
@@ -456,7 +455,7 @@ public class TestWritableECContainerProvider {
   @ParameterizedTest
   @MethodSource("policies")
   public void testExcludedNodesPassedToCreatePipelineIfProvided(
-      PipelineChoosePolicy policy) throws IOException, TimeoutException {
+      PipelineChoosePolicy policy) throws IOException {
     PipelineManager pipelineManagerSpy = Mockito.spy(pipelineManager);
     provider = createSubject(pipelineManagerSpy, policy);
     ExcludeList excludeList = new ExcludeList();
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestScmApplyTransactionFailure.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestScmApplyTransactionFailure.java
index 6486307697..9bf46092fa 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestScmApplyTransactionFailure.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/container/TestScmApplyTransactionFailure.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ContainerInfoProto;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor;
 import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.exceptions.SCMException;
 import org.apache.hadoop.hdds.scm.pipeline.DuplicatedPipelineIdException;
 import org.apache.hadoop.hdds.scm.pipeline.InvalidPipelineStateException;
 import org.apache.hadoop.hdds.scm.pipeline.Pipeline;
@@ -43,9 +44,9 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import static org.apache.hadoop.ozone.ClientVersion.CURRENT_VERSION;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Test-cases to verify SCMStateMachine.applyTransaction failure scenarios.
@@ -98,10 +99,11 @@ public class TestScmApplyTransactionFailure {
 
     // adding container to a closed pipeline should yield an error.
     ContainerInfoProto containerInfo = createContainer(pipeline);
-    StateMachineException ex = assertThrows(StateMachineException.class,
+    Throwable ex = assertThrows(SCMException.class,
         () -> containerManager.getContainerStateManager()
             .addContainer(containerInfo));
-    assertTrue(ex.getCause() instanceof InvalidPipelineStateException);
+    assertCause(ex, StateMachineException.class,
+        InvalidPipelineStateException.class);
     assertThrows(ContainerNotFoundException.class,
         () -> containerManager.getContainer(
             new ContainerID(containerInfo.getContainerID())));
@@ -121,10 +123,11 @@ public class TestScmApplyTransactionFailure {
 
     HddsProtos.Pipeline pipelineToCreate =
         existing.getProtobufMessage(CURRENT_VERSION);
-    StateMachineException ex = assertThrows(StateMachineException.class,
+    Throwable ex = assertThrows(SCMException.class,
         () -> pipelineManager.getStateManager().addPipeline(
             pipelineToCreate));
-    assertTrue(ex.getCause() instanceof DuplicatedPipelineIdException);
+    assertCause(ex, StateMachineException.class,
+        DuplicatedPipelineIdException.class);
   }
 
   private ContainerInfoProto createContainer(Pipeline pipeline) {
@@ -144,4 +147,13 @@ public class TestScmApplyTransactionFailure {
         ReplicationConfig.getLegacyFactor(pipeline.getReplicationConfig()));
     return containerInfoBuilder.build();
   }
+
+  @SafeVarargs
+  private static void assertCause(Throwable ex,
+      Class<? extends Throwable>... causes) {
+    for (Class<? extends Throwable> cause : causes) {
+      assertInstanceOf(cause, ex.getCause());
+      ex = ex.getCause();
+    }
+  }
 }
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestContainerCommandsEC.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestContainerCommandsEC.java
index a9cf2c1086..fa3e440259 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestContainerCommandsEC.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestContainerCommandsEC.java
@@ -102,7 +102,6 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
@@ -235,8 +234,6 @@ public class TestContainerCommandsEC {
             scm.getPipelineManager().closePipeline(p, false);
           } catch (IOException e) {
             throw new RuntimeException(e);
-          } catch (TimeoutException e) {
-            throw new RuntimeException(e);
           }
         });
   }
@@ -799,7 +796,7 @@ public class TestContainerCommandsEC {
   }
 
   private void closeContainer(long conID)
-      throws IOException, InvalidStateTransitionException, TimeoutException {
+      throws IOException, InvalidStateTransitionException {
     //Close the container first.
     scm.getContainerManager().getContainerStateManager().updateContainerState(
         HddsProtos.ContainerID.newBuilder().setId(conID).build(),
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
index 5802972e87..7d21a9fecd 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestScmSafeMode.java
@@ -58,7 +58,6 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.TimeoutException;
 
 import static org.apache.hadoop.hdds.client.ReplicationType.RATIS;
 import static org.apache.hadoop.hdds.client.ReplicationFactor.ONE;
@@ -252,8 +251,7 @@ public class TestScmSafeMode {
             HddsProtos.LifeCycleEvent.FINALIZE);
         mapping.updateContainerState(c.containerID(),
             LifeCycleEvent.CLOSE);
-      } catch (IOException | InvalidStateTransitionException |
-               TimeoutException e) {
+      } catch (IOException | InvalidStateTransitionException e) {
         LOG.info("Failed to change state of open containers.", e);
       }
     });
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java
index 606eb0a062..c5fc6ab625 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/fsck/ContainerHealthTask.java
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -245,7 +244,7 @@ public class ContainerHealthTask extends ReconScmTask {
     } catch (InvalidStateTransitionException e) {
       LOG.error("Failed to transition Container state while processing " +
           "container in Container Health task", e);
-    } catch (IOException | TimeoutException e) {
+    } catch (IOException e) {
       LOG.error("Got exception while processing container in" +
           " Container Health task", e);
     }
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconContainerManager.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconContainerManager.java
index 4bc9ebeb69..d1d8373a29 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconContainerManager.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconContainerManager.java
@@ -28,7 +28,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import org.apache.hadoop.conf.Configuration;
@@ -110,7 +109,7 @@ public class ReconContainerManager extends 
ContainerManagerImpl {
   public void checkAndAddNewContainer(ContainerID containerID,
       ContainerReplicaProto.State replicaState,
       DatanodeDetails datanodeDetails)
-      throws IOException, TimeoutException, InvalidStateTransitionException {
+      throws IOException, InvalidStateTransitionException {
     if (!containerExist(containerID)) {
       LOG.info("New container {} got from {}.", containerID,
           datanodeDetails.getHostName());
@@ -160,7 +159,7 @@ public class ReconContainerManager extends 
ContainerManagerImpl {
       for (ContainerWithPipeline cwp : verifiedContainerPipeline) {
         try {
           addNewContainer(cwp);
-        } catch (IOException | TimeoutException ioe) {
+        } catch (IOException ioe) {
           LOG.error("Exception while checking and adding new container.", ioe);
         }
       }
@@ -192,8 +191,7 @@ public class ReconContainerManager extends 
ContainerManagerImpl {
 
   private void checkContainerStateAndUpdate(ContainerID containerID,
                                             ContainerReplicaProto.State state)
-          throws IOException, InvalidStateTransitionException,
-          TimeoutException {
+          throws IOException, InvalidStateTransitionException {
     ContainerInfo containerInfo = getContainer(containerID);
     if (containerInfo.getState().equals(HddsProtos.LifeCycleState.OPEN)
         && !state.equals(ContainerReplicaProto.State.OPEN)
@@ -224,7 +222,7 @@ public class ReconContainerManager extends 
ContainerManagerImpl {
    * @throws IOException on Error.
    */
   public void addNewContainer(ContainerWithPipeline containerWithPipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     ContainerInfo containerInfo = containerWithPipeline.getContainerInfo();
     try {
       if (containerInfo.getState().equals(HddsProtos.LifeCycleState.OPEN)) {
@@ -250,7 +248,7 @@ public class ReconContainerManager extends 
ContainerManagerImpl {
         LOG.info("Successfully added no open container {} to Recon.",
             containerInfo.containerID());
       }
-    } catch (IOException | TimeoutException ex) {
+    } catch (IOException ex) {
       LOG.info("Exception while adding container {} .",
           containerInfo.containerID(), ex);
       pipelineManager.removeContainerFromPipeline(
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconPipelineManager.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconPipelineManager.java
index 37ee6580e8..77dd5486ec 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconPipelineManager.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconPipelineManager.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.time.Clock;
 import java.time.ZoneOffset;
 import java.util.List;
-import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
@@ -97,7 +96,7 @@ public final class ReconPipelineManager extends 
PipelineManagerImpl {
    * @throws IOException on exception.
    */
   void initializePipelines(List<Pipeline> pipelinesFromScm)
-      throws IOException, TimeoutException {
+      throws IOException {
 
     acquireWriteLock();
     try {
@@ -143,7 +142,7 @@ public final class ReconPipelineManager extends 
PipelineManagerImpl {
             getStateManager().updatePipelineState(
                 pipelineID.getProtobuf(),
                 HddsProtos.PipelineState.PIPELINE_CLOSED);
-          } catch (IOException | TimeoutException e) {
+          } catch (IOException e) {
             LOG.warn("Pipeline {} not found while updating state. ",
                 p.getId(), e);
           }
@@ -151,7 +150,7 @@ public final class ReconPipelineManager extends 
PipelineManagerImpl {
         try {
           LOG.info("Removing invalid pipeline {} from Recon.", pipelineID);
           closePipeline(p, false);
-        } catch (IOException | TimeoutException e) {
+        } catch (IOException e) {
           LOG.warn("Unable to remove pipeline {}", pipelineID, e);
         }
       });
@@ -166,7 +165,7 @@ public final class ReconPipelineManager extends 
PipelineManagerImpl {
    */
   @VisibleForTesting
   public void addPipeline(Pipeline pipeline)
-      throws IOException, TimeoutException {
+      throws IOException {
     acquireWriteLock();
     try {
       getStateManager().addPipeline(
diff --git 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
index 941bc52658..be40e60880 100644
--- 
a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
+++ 
b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/scm/ReconStorageContainerManagerFacade.java
@@ -34,7 +34,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -461,7 +460,7 @@ public class ReconStorageContainerManagerFacade
       List<Pipeline> pipelinesFromScm = scmServiceProvider.getPipelines();
       LOG.info("Obtained {} pipelines from SCM.", pipelinesFromScm.size());
       pipelineManager.initializePipelines(pipelinesFromScm);
-    } catch (IOException | TimeoutException ioEx) {
+    } catch (IOException ioEx) {
       LOG.error("Exception encountered while getting pipelines from SCM.",
           ioEx);
     }
@@ -543,9 +542,6 @@ public class ReconStorageContainerManagerFacade
                   } catch (IOException e) {
                     LOG.error("Could not get container with pipeline " +
                         "for container : {}", containerID);
-                  } catch (TimeoutException e) {
-                    LOG.error("Could not add new container {} in Recon " +
-                        "container manager cache.", containerID);
                   }
                 }
               });


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


Reply via email to