Delete `--catalogReset` from classic mode
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/73abcb76 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/73abcb76 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/73abcb76 Branch: refs/heads/master Commit: 73abcb765e32edca4ffd3d16a6f9c9524f97674b Parents: deb7c6b Author: Aled Sage <[email protected]> Authored: Tue Sep 26 12:40:26 2017 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Oct 2 06:08:30 2017 +0100 ---------------------------------------------------------------------- .../catalog/internal/CatalogInitialization.java | 15 ++--- .../core/mgmt/rebind/RebindIteration.java | 59 ++++---------------- .../launcher/osgi/OsgiLauncherImpl.java | 2 +- .../BrooklynLauncherRebindCatalogTest.java | 2 +- .../brooklyn/launcher/BrooklynLauncherTest.java | 2 +- .../main/java/org/apache/brooklyn/cli/Main.java | 7 +-- 6 files changed, 20 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java index 0b01273..73d836b 100644 --- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java +++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java @@ -53,9 +53,8 @@ public class CatalogInitialization implements ManagementContextInjectable { /* A1) if not persisting, go to B1 - A2) if --catalog-reset, delete persisted catalog items - A3) if there is a persisted catalog (and it wasn't not deleted by A2), read it and go to C1 - A4) go to B1 + A2) if there is a persisted catalog, read it and go to C1 + A3) go to B1 B1) look for --catalog-initial, if so read it, then go to C1 B2) look for BrooklynServerConfig.BROOKLYN_CATALOG_URL, if so, read it, supporting YAML, then go to C1 @@ -72,7 +71,6 @@ public class CatalogInitialization implements ManagementContextInjectable { private static final Logger log = LoggerFactory.getLogger(CatalogInitialization.class); private String initialUri; - private boolean reset; private List<String> additionsUris; private boolean force; @@ -95,12 +93,11 @@ public class CatalogInitialization implements ManagementContextInjectable { private Object populatingCatalogMutex = new Object(); public CatalogInitialization() { - this(null, false, ImmutableList.<String>of(), false); + this(null, ImmutableList.<String>of(), false); } - public CatalogInitialization(String initialUri, boolean reset, Iterable<String> additionUris, boolean force) { + public CatalogInitialization(String initialUri, Iterable<String> additionUris, boolean force) { this.initialUri = initialUri; - this.reset = reset; this.additionsUris = (additionUris != null) ? ImmutableList.copyOf(additionUris) : ImmutableList.<String>of(); this.force = force; } @@ -132,10 +129,6 @@ public class CatalogInitialization implements ManagementContextInjectable { return Preconditions.checkNotNull(managementContext, "management context has not been injected into "+this); } - public boolean isInitialResetRequested() { - return reset; - } - /** Returns true if the canonical initialization has completed, * that is, an initialization which is done when a node is rebinded as master * (or an initialization done by the startup routines when not running persistence); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java index f9f9b1c..1645784 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java @@ -322,7 +322,6 @@ public abstract class RebindIteration { isEmpty = mementoManifest.isEmpty(); } - @SuppressWarnings("deprecation") protected void installBundlesAndRebuildCatalog() { // Build catalog early so we can load other things @@ -401,59 +400,25 @@ public abstract class RebindIteration { // See notes in CatalogInitialization - Collection<CatalogItem<?, ?>> catalogItems = rebindContext.getCatalogItems(); CatalogInitialization catInit = managementContext.getCatalogInitialization(); Collection<CatalogItem<?,?>> itemsForResettingCatalog = null; boolean needsInitialItemsLoaded, needsAdditionalItemsLoaded; if (rebindManager.persistCatalogItemsEnabled) { - if (!catInit.hasRunFinalInitialization() && catInit.isInitialResetRequested()) { - String message = "RebindManager resetting catalog on first run (catalog persistence enabled, but reset explicitly specified). "; - if (catalogItems.isEmpty()) { - message += "Catalog was empty anyway."; - } else { - message += "Deleting "+catalogItems.size()+" persisted catalog item"+Strings.s(catalogItems)+": "+catalogItems; - if (shouldLogRebinding()) { - LOG.info(message); - } - } - logRebindingDebug(message); - - // we will have unnecessarily tried to load the catalog item manifests earlier in this iteration, - // and problems there could fail a rebind even when we are resetting; - // it might be cleaner to check earlier whether a reset is happening and not load those items at all, - // but that would be a significant new code path (to remove a directory in the persistent store, essentially), - // and as it stands we don't do much with those manifests (e.g. we won't register them or fail on missing types) - // so we think it's only really corrupted XML or CatalogItem schema changes which would cause such problems. - // in extremis someone might need to wipe their store but for most purposes i don't think there will be any issue - // with loading the catalog item manifests before wiping all those files. - - itemsForResettingCatalog = MutableList.<CatalogItem<?,?>>of(); - - PersisterDeltaImpl delta = new PersisterDeltaImpl(); - delta.removedCatalogItemIds.addAll(mementoRawData.getCatalogItems().keySet()); - getPersister().queueDelta(delta); - - mementoRawData.clearCatalogItems(); - rebindContext.clearCatalogItems(); - needsInitialItemsLoaded = true; - needsAdditionalItemsLoaded = true; + if (!isEmpty) { + logRebindingDebug("RebindManager clearing local catalog and loading from persisted state"); + itemsForResettingCatalog = rebindContext.getCatalogItems(); + needsInitialItemsLoaded = false; + // only apply "add" if we haven't yet done so while in MASTER mode + needsAdditionalItemsLoaded = !catInit.hasRunFinalInitialization(); } else { - if (!isEmpty) { - logRebindingDebug("RebindManager clearing local catalog and loading from persisted state"); - itemsForResettingCatalog = rebindContext.getCatalogItems(); + if (catInit.hasRunFinalInitialization()) { + logRebindingDebug("RebindManager has already done the final official run, not doing anything (even though persisted state empty)"); needsInitialItemsLoaded = false; - // only apply "add" if we haven't yet done so while in MASTER mode - needsAdditionalItemsLoaded = !catInit.hasRunFinalInitialization(); + needsAdditionalItemsLoaded = false; } else { - if (catInit.hasRunFinalInitialization()) { - logRebindingDebug("RebindManager has already done the final official run, not doing anything (even though persisted state empty)"); - needsInitialItemsLoaded = false; - needsAdditionalItemsLoaded = false; - } else { - logRebindingDebug("RebindManager loading initial catalog locally because persisted state empty and the final official run has not yet been performed"); - needsInitialItemsLoaded = true; - needsAdditionalItemsLoaded = true; - } + logRebindingDebug("RebindManager loading initial catalog locally because persisted state empty and the final official run has not yet been performed"); + needsInitialItemsLoaded = true; + needsAdditionalItemsLoaded = true; } } } else { http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherImpl.java ---------------------------------------------------------------------- diff --git a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherImpl.java b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherImpl.java index 821a8c2..7c8aeb5 100644 --- a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherImpl.java +++ b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncherImpl.java @@ -101,7 +101,7 @@ public class OsgiLauncherImpl extends BasicLauncher<OsgiLauncherImpl> implements final Stopwatch startupTimer = Stopwatch.createStarted(); BrooklynShutdownHooks.resetShutdownFlag(); LOG.debug("OsgiLauncher init, catalog "+defaultCatalogLocation); - catalogInitialization(new CatalogInitialization(String.format("file:%s", defaultCatalogLocation), false, null, false)); + catalogInitialization(new CatalogInitialization(String.format("file:%s", defaultCatalogLocation), null, false)); startPartOne(); startupTimer.stop(); LOG.info("Brooklyn initialisation (part one) complete after {}", startupTimer.toString()); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java ---------------------------------------------------------------------- diff --git a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java index 3f39a18..b991fc1 100644 --- a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java +++ b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherRebindCatalogTest.java @@ -61,7 +61,7 @@ public class BrooklynLauncherRebindCatalogTest { } private BrooklynLauncher newLauncherForTests(String persistenceDir) { - CatalogInitialization catalogInitialization = new CatalogInitialization(CATALOG_INITIAL, false, null, false); + CatalogInitialization catalogInitialization = new CatalogInitialization(CATALOG_INITIAL, null, false); BrooklynLauncher launcher = BrooklynLauncher.newInstance() .brooklynProperties(LocalManagementContextForTests.builder(true).buildProperties()) .catalogInitialization(catalogInitialization) http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java ---------------------------------------------------------------------- diff --git a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java index f2fb412..c590fd4 100644 --- a/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java +++ b/launcher/src/test/java/org/apache/brooklyn/launcher/BrooklynLauncherTest.java @@ -272,7 +272,7 @@ public class BrooklynLauncherTest { @Test // takes a bit of time because starts webapp, but also tests rest api so useful public void testErrorsCaughtByApiAndRestApiWorks() throws Exception { launcher = newLauncherForTests(true) - .catalogInitialization(new CatalogInitialization(null, false, null, false).addPopulationCallback(new Function<CatalogInitialization, Void>() { + .catalogInitialization(new CatalogInitialization(null, null, false).addPopulationCallback(new Function<CatalogInitialization, Void>() { @Override public Void apply(CatalogInitialization input) { throw new RuntimeException("deliberate-exception-for-testing"); http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/73abcb76/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java ---------------------------------------------------------------------- diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java index ebaa024..669eb95 100644 --- a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java +++ b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java @@ -229,10 +229,6 @@ public class Main extends AbstractMain { + "loaded on first run, or when persistence is off/empty or the catalog is reset") public String catalogInitial; - @Option(name = { "--catalogReset" }, - description = "Specifies that any catalog items which have been persisted should be cleared") - public boolean catalogReset; - // Unfortunately does not support arity of 1 or more; only exactly n @Option(name = { "--catalogAdd" }, title = "catalog bom URIs to add", description = "Specifies one or more catalog.bom URIs (or files) to be added to the catalog, as a comma-separated list") @@ -425,7 +421,7 @@ public class Main extends AbstractMain { launcher = createLauncher(); List<String> catalogsAdd = Strings.isBlank(catalogAdd) ? ImmutableList.<String>of() : JavaStringEscapes.unwrapJsonishListIfPossible(catalogAdd); - CatalogInitialization catInit = new CatalogInitialization(catalogInitial, catalogReset, catalogsAdd, catalogForce); + CatalogInitialization catInit = new CatalogInitialization(catalogInitial, catalogsAdd, catalogForce); catInit.addPopulationCallback(new Function<CatalogInitialization,Void>() { @Override public Void apply(CatalogInitialization catInit) { @@ -820,7 +816,6 @@ public class Main extends AbstractMain { .add("startupFailOnManagedAppsErrors", startupFailOnManagedAppsErrors) .add("catalogInitial", catalogInitial) .add("catalogAdd", catalogAdd) - .add("catalogReset", catalogReset) .add("catalogForce", catalogForce) .add("stopWhichAppsOnShutdown", stopWhichAppsOnShutdown) .add("stopOnKeyPress", stopOnKeyPress)
