use of org.apache.hadoop.ozone.container.common.DatanodeLayoutStorage in project ozone by apache.
the class TestDatanodeUpgradeToScmHA method startPreFinalizedDatanode.
// / CLUSTER OPERATIONS ///
/**
* Starts the datanode with the first layout version, and calls the version
* endpoint task to get cluster ID and SCM ID.
*
* The daemon for the datanode state machine is not started in this test.
* This greatly speeds up execution time.
* It means we do not have heartbeat functionality or pre-finalize
* upgrade actions, but neither of those things are needed for these tests.
*/
public void startPreFinalizedDatanode() throws Exception {
// Set layout version.
conf.set(HddsConfigKeys.OZONE_METADATA_DIRS, tempFolder.getRoot().getAbsolutePath());
DatanodeLayoutStorage layoutStorage = new DatanodeLayoutStorage(conf, UUID.randomUUID().toString(), HDDSLayoutFeature.INITIAL_VERSION.layoutVersion());
layoutStorage.initialize();
// Build and start the datanode.
DatanodeDetails dd = ContainerTestUtils.createDatanodeDetails();
DatanodeStateMachine newDsm = new DatanodeStateMachine(dd, conf, null, null, null);
int actualMlv = newDsm.getLayoutVersionManager().getMetadataLayoutVersion();
Assert.assertEquals(HDDSLayoutFeature.INITIAL_VERSION.layoutVersion(), actualMlv);
dsm = newDsm;
callVersionEndpointTask();
}
use of org.apache.hadoop.ozone.container.common.DatanodeLayoutStorage in project ozone by apache.
the class HddsDatanodeService method start.
public void start() {
serviceRuntimeInfo.setStartTime();
RatisDropwizardExports.registerRatisMetricReporters(ratisMetricsMap);
OzoneConfiguration.activate();
HddsServerUtil.initializeMetrics(conf, "HddsDatanode");
try {
String hostname = HddsUtils.getHostName(conf);
String ip = InetAddress.getByName(hostname).getHostAddress();
datanodeDetails = initializeDatanodeDetails();
datanodeDetails.setHostName(hostname);
datanodeDetails.setIpAddress(ip);
datanodeDetails.setVersion(HddsVersionInfo.HDDS_VERSION_INFO.getVersion());
datanodeDetails.setSetupTime(Time.now());
datanodeDetails.setRevision(HddsVersionInfo.HDDS_VERSION_INFO.getRevision());
datanodeDetails.setBuildDate(HddsVersionInfo.HDDS_VERSION_INFO.getDate());
datanodeDetails.setCurrentVersion(DatanodeVersions.CURRENT_VERSION);
TracingUtil.initTracing("HddsDatanodeService." + datanodeDetails.getUuidString().substring(0, 8), conf);
LOG.info("HddsDatanodeService host:{} ip:{}", hostname, ip);
// Authenticate Hdds Datanode service if security is enabled
if (OzoneSecurityUtil.isSecurityEnabled(conf)) {
component = "dn-" + datanodeDetails.getUuidString();
dnCertClient = new DNCertificateClient(new SecurityConfig(conf), datanodeDetails.getCertSerialId());
if (SecurityUtil.getAuthenticationMethod(conf).equals(UserGroupInformation.AuthenticationMethod.KERBEROS)) {
LOG.info("Ozone security is enabled. Attempting login for Hdds " + "Datanode user. Principal: {},keytab: {}", conf.get(DFSConfigKeysLegacy.DFS_DATANODE_KERBEROS_PRINCIPAL_KEY), conf.get(DFSConfigKeysLegacy.DFS_DATANODE_KERBEROS_KEYTAB_FILE_KEY));
UserGroupInformation.setConfiguration(conf);
SecurityUtil.login(conf, DFSConfigKeysLegacy.DFS_DATANODE_KERBEROS_KEYTAB_FILE_KEY, DFSConfigKeysLegacy.DFS_DATANODE_KERBEROS_PRINCIPAL_KEY, hostname);
} else {
throw new AuthenticationException(SecurityUtil.getAuthenticationMethod(conf) + " authentication method not " + "supported. Datanode user" + " login " + "failed.");
}
LOG.info("Hdds Datanode login successful.");
}
DatanodeLayoutStorage layoutStorage = new DatanodeLayoutStorage(conf, datanodeDetails.getUuidString());
if (layoutStorage.getState() != INITIALIZED) {
layoutStorage.initialize();
}
// initialize datanode CRL store
dnCRLStore = new DatanodeCRLStoreImpl(conf);
if (OzoneSecurityUtil.isSecurityEnabled(conf)) {
initializeCertificateClient(conf);
}
datanodeStateMachine = new DatanodeStateMachine(datanodeDetails, conf, dnCertClient, this::terminateDatanode, dnCRLStore);
try {
httpServer = new HddsDatanodeHttpServer(conf);
httpServer.start();
} catch (Exception ex) {
LOG.error("HttpServer failed to start.", ex);
}
startPlugins();
// Starting HDDS Daemons
datanodeStateMachine.startDaemon();
if ("follower".equalsIgnoreCase(System.getenv("OZONE_DATANODE_STANDALONE_TEST"))) {
startRatisForTest();
}
registerMXBean();
} catch (IOException e) {
throw new RuntimeException("Can't start the HDDS datanode plugin", e);
} catch (AuthenticationException ex) {
throw new RuntimeException("Fail to authentication when starting" + " HDDS datanode plugin", ex);
}
}
Aggregations