use of org.apache.hadoop.ozone.om.OzoneManager in project ozone by apache.
the class MiniOzoneHAClusterImpl method bootstrapOzoneManager.
/**
* Bootstrap new OM and add to existing OM HA service ring.
* @param omNodeId nodeId of new OM
* @param updateConfigs if true, update the old OM configs with new node
* information
* @param force if true, start new OM with FORCE_BOOTSTRAP option.
* Otherwise, start new OM with BOOTSTRAP option.
*/
public void bootstrapOzoneManager(String omNodeId, boolean updateConfigs, boolean force) throws Exception {
// Set testReloadConfigFlag to true so that
// OzoneManager#reloadConfiguration does not reload config as it will
// return the default configurations.
OzoneManager.setTestReloadConfigFlag(true);
int retryCount = 0;
OzoneManager om = null;
OzoneManager omLeader = getOMLeader(true);
long leaderSnapshotIndex = omLeader.getRatisSnapshotIndex();
while (true) {
try {
OzoneConfiguration newConf = addNewOMToConfig(getOMServiceId(), omNodeId);
if (updateConfigs) {
updateOMConfigs(newConf);
}
om = bootstrapNewOM(omNodeId, newConf, force);
LOG.info("Bootstrapped OzoneManager {} RPC server at {}", omNodeId, om.getOmRpcServerAddr());
// Add new OMs to cluster's in memory map and update existing OMs conf.
setConf(newConf);
break;
} catch (IOException e) {
// Existing OM config could have been updated with new conf. Reset it.
for (OzoneManager existingOM : omhaService.getServices()) {
existingOM.setConfiguration(getConf());
}
if (e instanceof BindException || e.getCause() instanceof BindException) {
++retryCount;
LOG.info("MiniOzoneHACluster port conflicts, retried {} times", retryCount, e);
} else {
throw e;
}
}
}
waitForBootstrappedNodeToBeReady(om, leaderSnapshotIndex);
if (updateConfigs) {
waitForConfigUpdateOnActiveOMs(omNodeId);
}
}
use of org.apache.hadoop.ozone.om.OzoneManager in project ozone by apache.
the class MiniOzoneHAClusterImpl method waitForConfigUpdateOnActiveOMs.
private void waitForConfigUpdateOnActiveOMs(String newOMNodeId) throws Exception {
OzoneManager newOMNode = omhaService.getServiceById(newOMNodeId);
OzoneManagerRatisServer newOMRatisServer = newOMNode.getOmRatisServer();
GenericTestUtils.waitFor(() -> {
// peer list and RatisServer peerList.
for (OzoneManager om : omhaService.getActiveServices()) {
if (!om.doesPeerExist(newOMNodeId)) {
return false;
}
if (!newOMNode.doesPeerExist(om.getOMNodeId())) {
return false;
}
if (!newOMRatisServer.doesPeerExist(om.getOMNodeId())) {
return false;
}
}
return true;
}, 1000, waitForClusterToBeReadyTimeout);
}
use of org.apache.hadoop.ozone.om.OzoneManager in project ozone by apache.
the class MiniOzoneHAClusterImpl method restartOzoneManager.
@Override
public void restartOzoneManager() throws IOException {
for (OzoneManager ozoneManager : this.omhaService.getServices()) {
ozoneManager.stop();
ozoneManager.restart();
}
}
use of org.apache.hadoop.ozone.om.OzoneManager in project ozone by apache.
the class MiniOzoneHAClusterImpl method stop.
@Override
public void stop() {
for (OzoneManager ozoneManager : this.omhaService.getServices()) {
if (ozoneManager != null) {
LOG.info("Stopping the OzoneManager {}", ozoneManager.getOMNodeId());
ozoneManager.stop();
ozoneManager.join();
}
}
for (StorageContainerManager scm : this.scmhaService.getServices()) {
if (scm != null) {
LOG.info("Stopping the StorageContainerManager {}", scm.getScmId());
scm.stop();
scm.join();
}
}
super.stop();
}
use of org.apache.hadoop.ozone.om.OzoneManager in project ozone by apache.
the class MiniOzoneChaosCluster method waitForClusterToBeReady.
/**
* Check if cluster is ready for a restart or shutdown of an OM node. If
* yes, then set isClusterReady to false so that another thread cannot
* restart/ shutdown OM till all OMs are up again.
*/
@Override
public void waitForClusterToBeReady() throws TimeoutException, InterruptedException {
super.waitForClusterToBeReady();
GenericTestUtils.waitFor(() -> {
for (OzoneManager om : getOzoneManagersList()) {
if (!om.isRunning()) {
return false;
}
}
return true;
}, 1000, waitForClusterToBeReadyTimeout);
}
Aggregations