brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/3] brooklyn-server git commit: use type registry when confirming catalog on startup
Date Wed, 13 Sep 2017 15:51:26 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 4795aac1b -> 459e892af


use type registry when confirming catalog on startup

prevents errors trying to check legacy catalog items


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/19410218
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/19410218
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/19410218

Branch: refs/heads/master
Commit: 19410218fa694f5dac270bcbf514034224f80384
Parents: 4795aac
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Sep 13 16:22:06 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Sep 13 16:31:59 2017 +0100

----------------------------------------------------------------------
 .../catalog/internal/CatalogInitialization.java |  1 +
 .../main/java/org/apache/brooklyn/cli/Main.java | 28 +++++++++++++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/19410218/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 f906344..ac5698d 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
@@ -401,6 +401,7 @@ public class CatalogInitialization implements ManagementContextInjectable
{
             }
         }
         PropagatedRuntimeException wrap = new PropagatedRuntimeException("Error loading catalog
item "+details, throwable);
+        log.warn(Exceptions.collapseText(wrap));
         log.debug("Trace for: "+wrap, wrap);
 
         ((ManagementContextInternal)getManagementContext()).errors().add(wrap);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/19410218/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 606a2a1..ebaa024 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
@@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import java.io.Console;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.Arrays;
 import java.util.Collection;
@@ -43,6 +42,8 @@ import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
+import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry.RegisteredTypeKind;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.cli.CloudExplorer.BlobstoreGetBlobCommand;
 import org.apache.brooklyn.cli.CloudExplorer.BlobstoreListContainerCommand;
 import org.apache.brooklyn.cli.CloudExplorer.BlobstoreListContainersCommand;
@@ -55,10 +56,7 @@ import org.apache.brooklyn.cli.CloudExplorer.ComputeTerminateInstancesCommand;
 import org.apache.brooklyn.cli.ItemLister.ListAllCommand;
 import org.apache.brooklyn.core.BrooklynVersion;
 import org.apache.brooklyn.core.catalog.internal.CatalogInitialization;
-import org.apache.brooklyn.core.entity.AbstractApplication;
-import org.apache.brooklyn.core.entity.AbstractEntity;
 import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.mgmt.ShutdownHandler;
 import org.apache.brooklyn.core.mgmt.ha.OsgiManager;
@@ -66,6 +64,7 @@ import org.apache.brooklyn.core.mgmt.persist.BrooklynPersistenceUtils;
 import org.apache.brooklyn.core.mgmt.persist.PersistMode;
 import org.apache.brooklyn.core.mgmt.rebind.transformer.CompoundTransformer;
 import org.apache.brooklyn.core.objs.BrooklynTypes;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
 import org.apache.brooklyn.entity.stock.BasicApplication;
 import org.apache.brooklyn.launcher.BrooklynLauncher;
 import org.apache.brooklyn.launcher.BrooklynServerDetails;
@@ -639,8 +638,24 @@ public class Main extends AbstractMain {
         protected void confirmCatalog(CatalogInitialization catInit) {
             // Force load of catalog (so web console is up to date)
             Stopwatch time = Stopwatch.createStarted();
+            Iterable<RegisteredType> all = catInit.getManagementContext().getTypeRegistry().getAll();
+            int errors = 0;
+            for (RegisteredType rt: all) {
+                if (RegisteredTypes.isTemplate(rt)) {
+                    // skip validation of templates, they might contain instructions,
+                    // and additionally they might contain multiple items in which case
+                    // the validation below won't work anyway (you need to go via a deployment
plan)
+                } else {
+                    if (rt.getKind()==RegisteredTypeKind.UNRESOLVED) {
+                        errors++;
+                        catInit.handleException(new UserFacingException("Unresolved type
in catalog"), rt);
+                    }
+                }
+            }
+
+            // and force resolution of legacy items
             BrooklynCatalog catalog = catInit.getManagementContext().getCatalog();
-            Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItems();
+            Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItemsLegacy();
             for (CatalogItem<Object, Object> item: items) {
                 try {
                     if (item.getCatalogItemType()==CatalogItemType.TEMPLATE) {
@@ -658,7 +673,8 @@ public class Main extends AbstractMain {
                     catInit.handleException(throwable, item);
                 }
             }
-            log.debug("Catalog (size "+Iterables.size(items)+") confirmed in "+Duration.of(time));
                     
+            
+            log.debug("Catalog (size "+Iterables.size(all)+", of which "+Iterables.size(items)+"
legacy) confirmed in "+Duration.of(time)+(errors>0 ? ", errors found ("+errors+")" : ""));
             // nothing else added here
         }
         


Mime
View raw message