Search in sources :

Example 6 with OzoneManagerProtocol

use of org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol in project ozone by apache.

the class FinalizeUpgradeSubCommand method call.

@Override
public Void call() throws Exception {
    boolean forceHA = false;
    OzoneManagerProtocol client = parent.createOmClient(omServiceId, omHost, forceHA);
    String upgradeClientID = "Upgrade-Client-" + UUID.randomUUID().toString();
    try {
        UpgradeFinalizer.StatusAndMessages finalizationResponse = client.finalizeUpgrade(upgradeClientID);
        if (isFinalized(finalizationResponse.status())) {
            System.out.println("Upgrade has already been finalized.");
            emitExitMsg();
            return null;
        } else if (!isStarting(finalizationResponse.status())) {
            System.err.println("Invalid response from Ozone Manager.");
            System.err.println("Current finalization status is: " + finalizationResponse.status());
            throw new IOException("Exiting...");
        }
    } catch (UpgradeException e) {
        handleInvalidRequestAfterInitiatingFinalization(force, e);
    }
    monitorAndWaitFinalization(client, upgradeClientID);
    return null;
}
Also used : UpgradeException(org.apache.hadoop.ozone.upgrade.UpgradeException) UpgradeFinalizer(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) IOException(java.io.IOException)

Example 7 with OzoneManagerProtocol

use of org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol in project ozone by apache.

the class PrepareSubCommand method call.

@Override
public Void call() throws Exception {
    OzoneManagerProtocol client = parent.createOmClient(omServiceId);
    long prepareTxnId = client.prepareOzoneManager(txnApplyWaitTimeSeconds, txnApplyCheckIntervalSeconds);
    System.out.println("Ozone Manager Prepare Request successfully returned " + "with Transaction Id : [" + prepareTxnId + "].");
    Map<String, Boolean> omPreparedStatusMap = new HashMap<>();
    Set<String> omHosts = getOmHostsFromConfig(parent.getParent().getOzoneConf(), omServiceId);
    omHosts.forEach(h -> omPreparedStatusMap.put(h, false));
    Duration pTimeout = Duration.of(prepareTimeOut, ChronoUnit.SECONDS);
    Duration pInterval = Duration.of(prepareCheckInterval, ChronoUnit.SECONDS);
    System.out.println();
    System.out.println("Checking individual OM instances for prepare request " + "completion...");
    long endTime = System.currentTimeMillis() + pTimeout.toMillis();
    int expectedNumPreparedOms = omPreparedStatusMap.size();
    int currentNumPreparedOms = 0;
    while (System.currentTimeMillis() < endTime && currentNumPreparedOms < expectedNumPreparedOms) {
        for (Map.Entry<String, Boolean> e : omPreparedStatusMap.entrySet()) {
            if (!e.getValue()) {
                String omHost = e.getKey();
                try (OzoneManagerProtocol singleOmClient = parent.createOmClient(omServiceId, omHost, false)) {
                    PrepareStatusResponse response = singleOmClient.getOzoneManagerPrepareStatus(prepareTxnId);
                    PrepareStatus status = response.getStatus();
                    System.out.println("OM : [" + omHost + "], Prepare " + "Status : [" + status.name() + "], Current Transaction Id : [" + response.getCurrentTxnIndex() + "]");
                    if (status.equals(PREPARE_COMPLETED)) {
                        e.setValue(true);
                        currentNumPreparedOms++;
                    }
                } catch (IOException ioEx) {
                    System.out.println("Exception while checking preparation " + "completeness for [" + omHost + "], Error : [" + ioEx.getMessage() + "]");
                }
            }
        }
        if (currentNumPreparedOms < expectedNumPreparedOms) {
            System.out.println("Waiting for " + prepareCheckInterval + " seconds before retrying...");
            Thread.sleep(pInterval.toMillis());
        }
    }
    if (currentNumPreparedOms < (expectedNumPreparedOms + 1) / 2) {
        throw new Exception("OM Preparation failed since a majority OMs are not" + " prepared yet.");
    } else {
        System.out.println();
        System.out.println("OM Preparation successful! ");
        if (currentNumPreparedOms == expectedNumPreparedOms) {
            System.out.println("All OMs are prepared");
        } else {
            System.out.println("A majority of OMs are prepared. OMs that are not " + "prepared : " + omPreparedStatusMap.entrySet().stream().filter(e -> !e.getValue()).map(e -> e.getKey()).collect(Collectors.joining()));
        }
        System.out.println("No new write requests will be allowed until " + "preparation is cancelled or upgrade/downgrade is done.");
    }
    return null;
}
Also used : HddsVersionProvider(org.apache.hadoop.hdds.cli.HddsVersionProvider) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) Set(java.util.Set) OmUtils.getOmHostsFromConfig(org.apache.hadoop.ozone.OmUtils.getOmHostsFromConfig) IOException(java.io.IOException) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) Collectors(java.util.stream.Collectors) ChronoUnit(java.time.temporal.ChronoUnit) PREPARE_COMPLETED(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus.PREPARE_COMPLETED) Duration(java.time.Duration) Map(java.util.Map) PrepareStatusResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse) PrepareStatus(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus) CommandLine(picocli.CommandLine) OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) HashMap(java.util.HashMap) Duration(java.time.Duration) IOException(java.io.IOException) IOException(java.io.IOException) PrepareStatus(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus) HashMap(java.util.HashMap) Map(java.util.Map) PrepareStatusResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse)

Example 8 with OzoneManagerProtocol

use of org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol in project ozone by apache.

the class MockOzoneServiceProvider method getMockOzoneManagerClientWith4Updates.

private OzoneManagerProtocol getMockOzoneManagerClientWith4Updates(DBUpdates updates1, DBUpdates updates2, DBUpdates updates3, DBUpdates updates4) throws IOException {
    OzoneManagerProtocol ozoneManagerProtocolMock = mock(OzoneManagerProtocol.class);
    when(ozoneManagerProtocolMock.getDBUpdates(any(OzoneManagerProtocolProtos.DBUpdatesRequest.class))).thenReturn(updates1, updates2, updates3, updates4);
    return ozoneManagerProtocolMock;
}
Also used : OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol)

Example 9 with OzoneManagerProtocol

use of org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol in project ozone by apache.

the class MockOzoneServiceProvider method getMockOzoneManagerClient.

private OzoneManagerProtocol getMockOzoneManagerClient(DBUpdates dbUpdatesWrapper) throws IOException {
    OzoneManagerProtocol ozoneManagerProtocolMock = mock(OzoneManagerProtocol.class);
    when(ozoneManagerProtocolMock.getDBUpdates(any(OzoneManagerProtocolProtos.DBUpdatesRequest.class))).thenReturn(dbUpdatesWrapper);
    return ozoneManagerProtocolMock;
}
Also used : OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol)

Example 10 with OzoneManagerProtocol

use of org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol in project ozone by apache.

the class BaseFileChecksumHelper method fetchBlocks.

/**
 * Request the blocks created in the most recent version from Ozone Manager.
 *
 * @throws IOException
 */
private void fetchBlocks() throws IOException {
    OzoneManagerProtocol ozoneManagerClient = getRpcClient().getOzoneManagerClient();
    OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volume.getName()).setBucketName(bucket.getName()).setKeyName(keyName).setRefreshPipeline(true).setSortDatanodesInPipeline(true).setLatestVersionLocation(true).build();
    OmKeyInfo keyInfo = ozoneManagerClient.lookupKey(keyArgs);
    if (keyInfo.getFileChecksum() != null && isFullLength(keyInfo.getDataSize())) {
        // if the checksum is cached in OM, and we request the checksum of
        // the full length.
        fileChecksum = keyInfo.getFileChecksum();
    }
    // use OmKeyArgs to call Om.lookup() and get OmKeyInfo
    keyLocationInfos = keyInfo.getLatestVersionLocations().getBlocksLatestVersionOnly();
}
Also used : OzoneManagerProtocol(org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol) OmKeyInfo(org.apache.hadoop.ozone.om.helpers.OmKeyInfo) OmKeyArgs(org.apache.hadoop.ozone.om.helpers.OmKeyArgs)

Aggregations

OzoneManagerProtocol (org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol)14 IOException (java.io.IOException)5 Test (org.junit.Test)5 UpgradeFinalizer (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer)3 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 FileChecksum (org.apache.hadoop.fs.FileChecksum)2 MD5MD5CRC32GzipFileChecksum (org.apache.hadoop.fs.MD5MD5CRC32GzipFileChecksum)2 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)2 OzoneClientConfig (org.apache.hadoop.hdds.scm.OzoneClientConfig)2 OmKeyInfo (org.apache.hadoop.ozone.om.helpers.OmKeyInfo)2 Optional (com.google.common.base.Optional)1 Provides (com.google.inject.Provides)1 File (java.io.File)1 Duration (java.time.Duration)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1