errose28 commented on a change in pull request #2160:
URL: https://github.com/apache/ozone/pull/2160#discussion_r617856406
##########
File path:
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/upgrade/BasicUpgradeFinalizer.java
##########
@@ -50,37 +52,90 @@
/**
* UpgradeFinalizer implementation for the Storage Container Manager service.
*/
-@SuppressWarnings("checkstyle:VisibilityModifier")
public abstract class BasicUpgradeFinalizer
<T, V extends AbstractLayoutVersionManager> implements UpgradeFinalizer<T>
{
- protected V versionManager;
- protected String clientID;
- protected T component;
- protected DefaultUpgradeFinalizationExecutor finalizationExecutor;
+ private V versionManager;
+ private String clientID;
+ private T component;
+ private DefaultUpgradeFinalizationExecutor<T> finalizationExecutor;
private Queue<String> msgs = new ConcurrentLinkedQueue<>();
- protected boolean isDone = false;
+ private boolean isDone = false;
public BasicUpgradeFinalizer(V versionManager) {
this.versionManager = versionManager;
- this.finalizationExecutor =
- new DefaultUpgradeFinalizationExecutor();
+ this.finalizationExecutor = new DefaultUpgradeFinalizationExecutor<>();
}
- /**
- * Sets the Finalization Executor driver.
- * @param executor FinalizationExecutor.
- */
+ public StatusAndMessages finalize(String upgradeClientID, T service)
+ throws IOException {
+ StatusAndMessages response = initFinalize(upgradeClientID, service);
+ if (response.status() != FINALIZATION_REQUIRED) {
+ return response;
+ }
+ finalizationExecutor.execute(service, this);
+ return STARTING_MSG;
+ }
- public void setFinalizationExecutor(DefaultUpgradeFinalizationExecutor
- executor) {
- finalizationExecutor = executor;
+ public synchronized StatusAndMessages reportStatus(
+ String upgradeClientID, boolean takeover) throws UpgradeException {
+ if (takeover) {
+ clientID = upgradeClientID;
+ }
+ assertClientId(upgradeClientID);
+ List<String> returningMsgs = new ArrayList<>(msgs.size() + 10);
+ Status status = versionManager.getUpgradeState();
+ while (msgs.size() > 0) {
+ returningMsgs.add(msgs.poll());
+ }
+ return new StatusAndMessages(status, returningMsgs);
+ }
+
+ protected void preFinalizeUpgrade(T service) throws IOException {
+ // No Op by default.
+ };
+
+ protected void postFinalizeUpgrade(T service) throws IOException {
+ // No Op by default.
}
+ public abstract void finalizeUpgrade(T service) throws UpgradeException;
+
@Override
- public DefaultUpgradeFinalizationExecutor getFinalizationExecutor() {
- return finalizationExecutor;
+ public void finalizeAndWaitForCompletion(
Review comment:
Thanks for the offline explanation @avijayanhwx. I see the DB gets
updated with the new version on the finalization ratis request so we should be
good here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]