Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.exceptions.OMLeaderNotReadyException;
import org.apache.hadoop.ozone.om.exceptions.OMNotLeaderException;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.SecretManager;
import org.apache.ratis.protocol.exceptions.ReadException;
import org.apache.ratis.protocol.exceptions.ReadIndexException;
import org.apache.ratis.protocol.exceptions.StateMachineException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -159,16 +157,6 @@ protected synchronized boolean shouldFailover(Exception ex) {
}
} else if (HddsUtils.shouldNotFailoverOnRpcException(unwrappedException)) {
return false;
} else if (ex instanceof StateMachineException) {
StateMachineException smEx = (StateMachineException) ex;
Throwable cause = smEx.getCause();
if (cause instanceof OMException) {
OMException omEx = (OMException) cause;
// Do not failover if the operation was blocked because the OM was
// prepared.
return omEx.getResult() !=
OMException.ResultCodes.NOT_SUPPORTED_OPERATION_WHEN_PREPARED;
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.ozone.ha.ConfUtils;
import org.apache.hadoop.ozone.om.exceptions.OMException;
import org.apache.hadoop.ozone.om.protocolPB.OzoneManagerProtocolPB;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.ratis.protocol.exceptions.StateMachineException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -254,4 +256,16 @@ public void testCanonicalTokenServiceName() throws IOException {
}
}

/**
* If OM is in prepare mode it should still retry.
*/
@Test
public void testShouldFailoverOnPreparedStateMachineException() {
OMException omEx = new OMException("prepared",
OMException.ResultCodes.NOT_SUPPORTED_OPERATION_WHEN_PREPARED);
StateMachineException smEx = new StateMachineException("sme", omEx);

assertTrue(provider.shouldFailover(smEx));
}

}