|
34 | 34 | import org.apache.hadoop.ozone.om.execution.flowcontrol.ExecutionContext; |
35 | 35 | import org.apache.hadoop.ozone.om.request.OMClientRequest; |
36 | 36 | import org.apache.hadoop.ozone.om.request.util.OmResponseUtil; |
| 37 | +import org.apache.hadoop.ozone.om.request.validation.RequestFeatureValidator; |
| 38 | +import org.apache.hadoop.ozone.om.request.validation.ValidationCondition; |
| 39 | +import org.apache.hadoop.ozone.om.request.validation.ValidationContext; |
37 | 40 | import org.apache.hadoop.ozone.om.response.OMClientResponse; |
38 | 41 | import org.apache.hadoop.ozone.om.response.lifecycle.OMLifecycleConfigurationDeleteResponse; |
| 42 | +import org.apache.hadoop.ozone.om.upgrade.OMLayoutFeature; |
39 | 43 | import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteLifecycleConfigurationRequest; |
40 | 44 | import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.DeleteLifecycleConfigurationResponse; |
41 | 45 | import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRequest; |
42 | 46 | import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMResponse; |
| 47 | +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.Type; |
43 | 48 | import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.UserInfo; |
| 49 | +import org.apache.hadoop.ozone.request.validation.RequestProcessingPhase; |
44 | 50 | import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer; |
45 | 51 | import org.apache.hadoop.ozone.security.acl.OzoneObj; |
46 | 52 | import org.slf4j.Logger; |
@@ -168,4 +174,21 @@ public OMClientResponse validateAndUpdateCache(OzoneManager ozoneManager, Execut |
168 | 174 | return omClientResponse; |
169 | 175 | } |
170 | 176 | } |
| 177 | + |
| 178 | + @RequestFeatureValidator( |
| 179 | + conditions = ValidationCondition.CLUSTER_NEEDS_FINALIZATION, |
| 180 | + processingPhase = RequestProcessingPhase.PRE_PROCESS, |
| 181 | + requestType = Type.DeleteLifecycleConfiguration |
| 182 | + ) |
| 183 | + public static OMRequest disallowDeleteLifecycleConfigurationBeforeFinalization( |
| 184 | + OMRequest req, ValidationContext ctx) throws OMException { |
| 185 | + if (!ctx.versionManager() |
| 186 | + .isAllowed(OMLayoutFeature.LIFECYCLE_SUPPORT)) { |
| 187 | + throw new OMException("Cluster does not have the Lifecycle Support" |
| 188 | + + " feature finalized yet. Rejecting the request to delete lifecycle" |
| 189 | + + " configuration. Please finalize the cluster upgrade and then try again.", |
| 190 | + OMException.ResultCodes.NOT_SUPPORTED_OPERATION_PRIOR_FINALIZATION); |
| 191 | + } |
| 192 | + return req; |
| 193 | + } |
171 | 194 | } |
0 commit comments