Search in sources :

Example 26 with OzoneManager

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);
    }
}
Also used : OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) BindException(java.net.BindException) IOException(java.io.IOException)

Example 27 with OzoneManager

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);
}
Also used : OzoneManager(org.apache.hadoop.ozone.om.OzoneManager) OzoneManagerRatisServer(org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer)

Example 28 with OzoneManager

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();
    }
}
Also used : OzoneManager(org.apache.hadoop.ozone.om.OzoneManager)

Example 29 with OzoneManager

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();
}
Also used : StorageContainerManager(org.apache.hadoop.hdds.scm.server.StorageContainerManager) OzoneManager(org.apache.hadoop.ozone.om.OzoneManager)

Example 30 with OzoneManager

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);
}
Also used : OzoneManager(org.apache.hadoop.ozone.om.OzoneManager)

Aggregations

OzoneManager (org.apache.hadoop.ozone.om.OzoneManager)39 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)15 OmMetadataManagerImpl (org.apache.hadoop.ozone.om.OmMetadataManagerImpl)15 Before (org.junit.Before)14 Test (org.junit.Test)12 AuditLogger (org.apache.hadoop.ozone.audit.AuditLogger)9 AuditMessage (org.apache.hadoop.ozone.audit.AuditMessage)9 OMClientRequest (org.apache.hadoop.ozone.om.request.OMClientRequest)5 IOException (java.io.IOException)4 ResolvedBucket (org.apache.hadoop.ozone.om.ResolvedBucket)4 OMLayoutVersionManager (org.apache.hadoop.ozone.om.upgrade.OMLayoutVersionManager)4 KeyArgs (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.KeyArgs)4 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 StorageContainerManager (org.apache.hadoop.hdds.scm.server.StorageContainerManager)2 RatisSnapshotInfo (org.apache.hadoop.ozone.common.ha.ratis.RatisSnapshotInfo)2 OMMultiTenantManager (org.apache.hadoop.ozone.om.OMMultiTenantManager)2 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)2 BucketLayout (org.apache.hadoop.ozone.om.helpers.BucketLayout)2