use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse in project ozone by apache.
the class OMFinalizeUpgradeRequest method validateAndUpdateCache.
@Override
public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, long transactionLogIndex, OzoneManagerDoubleBufferHelper ozoneManagerDoubleBufferHelper) {
LOG.trace("Request: {}", getOmRequest());
OMResponse.Builder responseBuilder = OmResponseUtil.getOMResponseBuilder(getOmRequest());
responseBuilder.setCmdType(FinalizeUpgrade);
OMClientResponse response = null;
try {
String username = getOmRequest().getUserInfo().getUserName();
if (ozoneManager.getAclsEnabled() && !ozoneManager.isAdmin(username)) {
throw new OMException("Access denied for user " + username + ". " + "Superuser privilege is required to finalize upgrade.", OMException.ResultCodes.ACCESS_DENIED);
}
FinalizeUpgradeRequest request = getOmRequest().getFinalizeUpgradeRequest();
String upgradeClientID = request.getUpgradeClientId();
StatusAndMessages omStatus = ozoneManager.finalizeUpgrade(upgradeClientID);
UpgradeFinalizationStatus.Status protoStatus = UpgradeFinalizationStatus.Status.valueOf(omStatus.status().name());
UpgradeFinalizationStatus responseStatus = UpgradeFinalizationStatus.newBuilder().setStatus(protoStatus).build();
OMMetadataManager omMetadataManager = ozoneManager.getMetadataManager();
int lV = ozoneManager.getVersionManager().getMetadataLayoutVersion();
omMetadataManager.getMetaTable().addCacheEntry(new CacheKey<>(LAYOUT_VERSION_KEY), new CacheValue<>(Optional.of(String.valueOf(lV)), transactionLogIndex));
FinalizeUpgradeResponse omResponse = FinalizeUpgradeResponse.newBuilder().setStatus(responseStatus).build();
responseBuilder.setFinalizeUpgradeResponse(omResponse);
response = new OMFinalizeUpgradeResponse(responseBuilder.build(), ozoneManager.getVersionManager().getMetadataLayoutVersion());
LOG.trace("Returning response: {}", response);
} catch (IOException e) {
response = new OMFinalizeUpgradeResponse(createErrorOMResponse(responseBuilder, e), -1);
} finally {
addResponseToDoubleBuffer(transactionLogIndex, response, ozoneManagerDoubleBufferHelper);
}
return response;
}
use of org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse in project ozone by apache.
the class OzoneManagerProtocolClientSideTranslatorPB method finalizeUpgrade.
@Override
public StatusAndMessages finalizeUpgrade(String upgradeClientID) throws IOException {
FinalizeUpgradeRequest req = FinalizeUpgradeRequest.newBuilder().setUpgradeClientId(upgradeClientID).build();
OMRequest omRequest = createOMRequest(Type.FinalizeUpgrade).setFinalizeUpgradeRequest(req).build();
FinalizeUpgradeResponse response = handleError(submitRequest(omRequest)).getFinalizeUpgradeResponse();
UpgradeFinalizationStatus status = response.getStatus();
return new StatusAndMessages(UpgradeFinalizer.Status.valueOf(status.getStatus().name()), status.getMessagesList());
}
Aggregations