HDFS-12842. Ozone: SCM: During startup SCM should check if the cluster is INITIALIZED. Contributed by Nanda kumar.
This commit is contained in:
parent
73ca8608da
commit
ea86945754
|
@ -238,9 +238,8 @@ public class StorageContainerManager extends ServiceRuntimeInfoImpl
|
|||
initContainerReportCache(conf);
|
||||
|
||||
scmStorage = new SCMStorage(conf);
|
||||
String clusterId = scmStorage.getClusterID();
|
||||
if (clusterId == null) {
|
||||
throw new SCMException("clusterId not found",
|
||||
if (scmStorage.getState() != StorageState.INITIALIZED) {
|
||||
throw new SCMException("SCM not initialized.",
|
||||
ResultCodes.SCM_NOT_INITIALIZED);
|
||||
}
|
||||
scmNodeManager = new SCMNodeManager(conf, scmStorage.getClusterID(), this);
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.hadoop.ozone.scm.StorageContainerManager;
|
|||
import org.apache.hadoop.ozone.scm.StorageContainerManager.StartupOption;
|
||||
import org.apache.hadoop.ozone.scm.block.DeletedBlockLog;
|
||||
import org.apache.hadoop.ozone.scm.block.SCMBlockDeletingService;
|
||||
import org.apache.hadoop.ozone.scm.exceptions.SCMException;
|
||||
import org.apache.hadoop.ozone.scm.node.NodeManager;
|
||||
import org.apache.hadoop.scm.XceiverClientManager;
|
||||
import org.apache.hadoop.scm.container.common.helpers.Pipeline;
|
||||
|
@ -398,6 +399,19 @@ public class TestStorageContainerManager {
|
|||
Assert.assertNotEquals("testClusterId", scmStore.getClusterID());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSCMInitializationFailure() throws IOException {
|
||||
OzoneConfiguration conf = new OzoneConfiguration();
|
||||
final String path =
|
||||
GenericTestUtils.getTempPath(UUID.randomUUID().toString());
|
||||
Path scmPath = Paths.get(path, "scm-meta");
|
||||
conf.set(OzoneConfigKeys.OZONE_METADATA_DIRS, scmPath.toString());
|
||||
conf.setBoolean(OzoneConfigKeys.OZONE_ENABLED, true);
|
||||
exception.expect(SCMException.class);
|
||||
exception.expectMessage("SCM not initialized.");
|
||||
StorageContainerManager.createSCM(null, conf);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScmInfo() throws Exception {
|
||||
OzoneConfiguration conf = new OzoneConfiguration();
|
||||
|
|
Loading…
Reference in New Issue