Search in sources :

Example 1 with OMFinalizeUpgradeResponse

use of org.apache.hadoop.ozone.om.response.upgrade.OMFinalizeUpgradeResponse 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;
}
Also used : OMClientResponse(org.apache.hadoop.ozone.om.response.OMClientResponse) UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) OMFinalizeUpgradeResponse(org.apache.hadoop.ozone.om.response.upgrade.OMFinalizeUpgradeResponse) IOException(java.io.IOException) OMResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse) OMFinalizeUpgradeResponse(org.apache.hadoop.ozone.om.response.upgrade.OMFinalizeUpgradeResponse) FinalizeUpgradeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse) OMMetadataManager(org.apache.hadoop.ozone.om.OMMetadataManager) FinalizeUpgradeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeRequest) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages) OMException(org.apache.hadoop.ozone.om.exceptions.OMException)

Aggregations

IOException (java.io.IOException)1 UpgradeFinalizationStatus (org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus)1 OMMetadataManager (org.apache.hadoop.ozone.om.OMMetadataManager)1 OMException (org.apache.hadoop.ozone.om.exceptions.OMException)1 OMClientResponse (org.apache.hadoop.ozone.om.response.OMClientResponse)1 OMFinalizeUpgradeResponse (org.apache.hadoop.ozone.om.response.upgrade.OMFinalizeUpgradeResponse)1 FinalizeUpgradeRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeRequest)1 FinalizeUpgradeResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse)1 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)1 StatusAndMessages (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)1