Search in sources :

Example 1 with FinalizeUpgradeResponse

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

Example 2 with FinalizeUpgradeResponse

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());
}
Also used : OMRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest) FinalizeUpgradeResponse(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse) UpgradeFinalizationStatus(org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus) FinalizeUpgradeRequest(org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeRequest) StatusAndMessages(org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)

Aggregations

UpgradeFinalizationStatus (org.apache.hadoop.hdds.protocol.proto.HddsProtos.UpgradeFinalizationStatus)2 FinalizeUpgradeRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeRequest)2 FinalizeUpgradeResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.FinalizeUpgradeResponse)2 StatusAndMessages (org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages)2 IOException (java.io.IOException)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 OMRequest (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest)1 OMResponse (org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse)1