This is an automated email from the ASF dual-hosted git repository. arafat2198 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push: new f191492aef3 HDDS-13571. Add upgrade action for NSSummary aggregated totals Improvement. (#8938). f191492aef3 is described below commit f191492aef3a807b4492beb5f817c4b2ca4c9e83 Author: Arafat2198 <arafatp...@gmail.com> AuthorDate: Mon Aug 18 13:05:14 2025 +0530 HDDS-13571. Add upgrade action for NSSummary aggregated totals Improvement. (#8938). --- .../recon/ReconGuiceServletContextListener.java | 7 +++ .../org/apache/hadoop/ozone/recon/ReconServer.java | 27 ++++----- .../org/apache/hadoop/ozone/recon/ReconUtils.java | 4 +- .../upgrade/NSSummaryAggregatedTotalsUpgrade.java | 65 ++++++++++++++++++++++ .../ozone/recon/upgrade/ReconLayoutFeature.java | 5 +- 5 files changed, 92 insertions(+), 16 deletions(-) diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconGuiceServletContextListener.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconGuiceServletContextListener.java index d58e2a38381..cbc78a0139a 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconGuiceServletContextListener.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconGuiceServletContextListener.java @@ -36,4 +36,11 @@ public Injector getInjector() { static void setInjector(Injector inj) { injector = inj; } + + /** + * Expose injector for internal upgrade actions that run outside Jersey. + */ + public static Injector getGlobalInjector() { + return injector; + } } diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconServer.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconServer.java index 0a1437ada78..d290a3e66ca 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconServer.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconServer.java @@ -146,19 +146,6 @@ public Void call() throws Exception { reconSchemaManager.createReconSchema(); LOG.debug("Recon schema creation done."); - LOG.info("Finalizing Layout Features."); - // Handle Recon Schema Versioning - ReconSchemaVersionTableManager versionTableManager = - injector.getInstance(ReconSchemaVersionTableManager.class); - DataSource dataSource = injector.getInstance(DataSource.class); - - ReconLayoutVersionManager layoutVersionManager = - new ReconLayoutVersionManager(versionTableManager, reconContext, dataSource); - // Run the upgrade framework to finalize layout features if needed - layoutVersionManager.finalizeLayoutFeatures(); - - LOG.info("Recon schema versioning completed."); - this.reconSafeModeMgr = injector.getInstance(ReconSafeModeManager.class); this.reconSafeModeMgr.setInSafeMode(true); httpServer = injector.getInstance(ReconHttpServer.class); @@ -177,6 +164,20 @@ public Void call() throws Exception { // Start all services start(); isStarted = true; + + LOG.info("Finalizing Layout Features."); + // Handle Recon Schema Versioning + ReconSchemaVersionTableManager versionTableManager = + injector.getInstance(ReconSchemaVersionTableManager.class); + DataSource dataSource = injector.getInstance(DataSource.class); + + ReconLayoutVersionManager layoutVersionManager = + new ReconLayoutVersionManager(versionTableManager, reconContext, dataSource); + // Run the upgrade framework to finalize layout features if needed + layoutVersionManager.finalizeLayoutFeatures(); + + LOG.info("Recon schema versioning completed."); + LOG.info("Recon server initialized successfully!"); } catch (Exception e) { LOG.error("Error during initializing Recon server.", e); diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java index 4379b4682a6..5a367a8baad 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java @@ -130,10 +130,11 @@ public static org.apache.hadoop.ozone.recon.tasks.NSSummaryTask.RebuildState get public static boolean triggerAsyncNSSummaryRebuild( ReconNamespaceSummaryManager reconNamespaceSummaryManager, ReconOMMetadataManager omMetadataManager) { - + // Submit rebuild task to single thread executor for async execution NSSUMMARY_REBUILD_EXECUTOR.submit(() -> { try { + // This will go through NSSummaryTask's unified control mechanism reconNamespaceSummaryManager.rebuildNSSummaryTree(omMetadataManager); log.info("Async NSSummary tree rebuild completed successfully."); @@ -142,7 +143,6 @@ public static boolean triggerAsyncNSSummaryRebuild( } }); - log.info("Async NSSummary tree rebuild triggered successfully."); return true; } diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/NSSummaryAggregatedTotalsUpgrade.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/NSSummaryAggregatedTotalsUpgrade.java new file mode 100644 index 00000000000..5f3817a2fd3 --- /dev/null +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/NSSummaryAggregatedTotalsUpgrade.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.ozone.recon.upgrade; + +import static org.apache.hadoop.ozone.recon.upgrade.ReconUpgradeAction.UpgradeActionType.FINALIZE; + +import com.google.inject.Injector; +import javax.sql.DataSource; +import org.apache.hadoop.ozone.recon.ReconGuiceServletContextListener; +import org.apache.hadoop.ozone.recon.ReconUtils; +import org.apache.hadoop.ozone.recon.recovery.ReconOMMetadataManager; +import org.apache.hadoop.ozone.recon.spi.ReconNamespaceSummaryManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Upgrade action that triggers a rebuild of the NSSummary tree to + * populate materialized totals upon upgrade to the feature version. + * + * This runs at FINALIZE and schedules the rebuild asynchronously so + * Recon startup is not blocked. During rebuild, APIs that depend on + * the tree may return initializing responses as designed. + */ +@UpgradeActionRecon(feature = ReconLayoutFeature.NSSUMMARY_AGGREGATED_TOTALS, type = FINALIZE) +public class NSSummaryAggregatedTotalsUpgrade implements ReconUpgradeAction { + + private static final Logger LOG = LoggerFactory.getLogger(NSSummaryAggregatedTotalsUpgrade.class); + + @Override + public void execute(DataSource source) throws Exception { + // Resolve required services from Guice + Injector injector = ReconGuiceServletContextListener.getGlobalInjector(); + if (injector == null) { + throw new IllegalStateException( + "Guice injector not initialized. NSSummary rebuild cannot proceed during upgrade."); + } + + ReconNamespaceSummaryManager nsMgr = injector.getInstance(ReconNamespaceSummaryManager.class); + ReconOMMetadataManager omMgr = injector.getInstance(ReconOMMetadataManager.class); + + // Fire and forget: unified control using ReconUtils -> NSSummaryTask + LOG.info("Triggering asynchronous NSSummary tree rebuild for materialized totals (upgrade action)."); + ReconUtils.triggerAsyncNSSummaryRebuild(nsMgr, omMgr); + } + + @Override + public UpgradeActionType getType() { + return FINALIZE; + } +} diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutFeature.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutFeature.java index 2b4569d449e..bd0b52ae183 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutFeature.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/upgrade/ReconLayoutFeature.java @@ -31,7 +31,10 @@ public enum ReconLayoutFeature { // Represents the starting point for Recon's layout versioning system. INITIAL_VERSION(0, "Recon Layout Versioning Introduction"), TASK_STATUS_STATISTICS(1, "Recon Task Status Statistics Tracking Introduced"), - UNHEALTHY_CONTAINER_REPLICA_MISMATCH(2, "Adding replica mismatch state to the unhealthy container table"); + UNHEALTHY_CONTAINER_REPLICA_MISMATCH(2, "Adding replica mismatch state to the unhealthy container table"), + + // HDDS-13432: Materialize NSSummary totals and rebuild tree on upgrade + NSSUMMARY_AGGREGATED_TOTALS(3, "Aggregated totals for NSSummary and auto-rebuild on upgrade"); private final int version; private final String description; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@ozone.apache.org For additional commands, e-mail: commits-h...@ozone.apache.org