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;
}
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;
}
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;
}
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;
}
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();
}
Aggregations