use of org.apache.hadoop.hdds.scm.ScmInfo in project ozone by apache.
the class OzoneManager method omInit.
/**
* Initializes the OM instance.
*
* @param conf OzoneConfiguration
* @return true if OM initialization succeeds, false otherwise
* @throws IOException in case ozone metadata directory path is not
* accessible
*/
@VisibleForTesting
public static boolean omInit(OzoneConfiguration conf) throws IOException, AuthenticationException {
OMHANodeDetails.loadOMHAConfig(conf);
loginOMUserIfSecurityEnabled(conf);
OMStorage omStorage = new OMStorage(conf);
StorageState state = omStorage.getState();
if (state != StorageState.INITIALIZED) {
try {
ScmInfo scmInfo = getScmInfo(conf);
String clusterId = scmInfo.getClusterId();
String scmId = scmInfo.getScmId();
if (clusterId == null || clusterId.isEmpty()) {
throw new IOException("Invalid Cluster ID");
}
if (scmId == null || scmId.isEmpty()) {
throw new IOException("Invalid SCM ID");
}
omStorage.setClusterId(clusterId);
if (OzoneSecurityUtil.isSecurityEnabled(conf)) {
initializeSecurity(conf, omStorage, scmId);
}
omStorage.initialize();
System.out.println("OM initialization succeeded.Current cluster id for sd=" + omStorage.getStorageDir() + ";cid=" + omStorage.getClusterID() + ";layoutVersion=" + omStorage.getLayoutVersion());
return true;
} catch (IOException ioe) {
LOG.error("Could not initialize OM version file", ioe);
return false;
}
} else {
if (OzoneSecurityUtil.isSecurityEnabled(conf) && omStorage.getOmCertSerialId() == null) {
ScmInfo scmInfo = HAUtils.getScmInfo(conf);
String scmId = scmInfo.getScmId();
if (scmId == null || scmId.isEmpty()) {
throw new IOException("Invalid SCM ID");
}
LOG.info("OM storage is already initialized. Initializing security");
initializeSecurity(conf, omStorage, scmId);
omStorage.persistCurrentState();
}
System.out.println("OM already initialized.Reusing existing cluster id for sd=" + omStorage.getStorageDir() + ";cid=" + omStorage.getClusterID() + ";layoutVersion=" + omStorage.getLayoutVersion());
return true;
}
}
Aggregations