Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4544A189EF for ; Mon, 8 Jun 2015 15:12:33 +0000 (UTC) Received: (qmail 70785 invoked by uid 500); 8 Jun 2015 15:12:10 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 70761 invoked by uid 500); 8 Jun 2015 15:12:10 -0000 Mailing-List: contact dev-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list dev@brooklyn.incubator.apache.org Received: (qmail 70712 invoked by uid 99); 8 Jun 2015 15:12:10 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2015 15:12:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 61E3DC0944 for ; Mon, 8 Jun 2015 15:12:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id YPwL_zwEoYNT for ; Mon, 8 Jun 2015 15:12:02 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 7CCF143DA5 for ; Mon, 8 Jun 2015 15:12:01 +0000 (UTC) Received: (qmail 65258 invoked by uid 99); 8 Jun 2015 15:12:01 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Jun 2015 15:12:01 +0000 Date: Mon, 8 Jun 2015 15:12:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@brooklyn.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (BROOKLYN-149) Rebind failed when entity's catalog item not found MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/BROOKLYN-149?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14577317#comment-14577317 ] ASF GitHub Bot commented on BROOKLYN-149: ----------------------------------------- Github user mikezaccardo commented on a diff in the pull request: https://github.com/apache/incubator-brooklyn/pull/683#discussion_r31924327 --- Diff: core/src/main/java/brooklyn/entity/rebind/RebindIteration.java --- @@ -902,45 +902,53 @@ protected void setCatalogItemId(BrooklynObject item, String catalogItemId) { protected Class load(Class bType, Memento memento) { return load(bType, memento.getType(), memento.getCatalogItemId(), memento.getId()); } + @SuppressWarnings("unchecked") protected Class load(Class bType, String jType, String catalogItemId, String contextSuchAsId) { checkNotNull(jType, "Type of %s (%s) must not be null", contextSuchAsId, bType.getSimpleName()); + if (catalogItemId != null) { - BrooklynClassLoadingContext loader = getLoadingContextFromCatalogItemId(catalogItemId, classLoader, rebindContext); - return loader.loadClass(jType, bType); - } else { - // we have previously used reflections; not sure if that's needed? - try { - return (Class)reflections.loadClass(jType); - } catch (Exception e) { - LOG.warn("Unable to load "+jType+" using reflections; will try standard context"); - } - - if (BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_INFER_CATALOG_ITEM_ON_REBIND)) { - //Try loading from whichever catalog bundle succeeds. - BrooklynCatalog catalog = managementContext.getCatalog(); - for (CatalogItem item : catalog.getCatalogItems()) { - BrooklynClassLoadingContext catalogLoader = CatalogUtils.newClassLoadingContext(managementContext, item); - Maybe> catalogClass = catalogLoader.tryLoadClass(jType); - if (catalogClass.isPresent()) { - return (Class) catalogClass.get(); - } + CatalogItem catalogItem = rebindContext.lookup().lookupCatalogItem(catalogItemId); + if (catalogItem == null && BrooklynFeatureEnablement.isEnabled(BrooklynFeatureEnablement.FEATURE_INFER_CATALOG_ITEM_ON_REBIND)) { + // See https://issues.apache.org/jira/browse/BROOKLYN-149 + // This is a dangling reference to the catalog item (which will have been logged by lookupCatalogItem). + // Try loading as any version. + if (CatalogUtils.looksLikeVersionedId(catalogItemId)) { + String symbolicName = CatalogUtils.getIdFromVersionedId(catalogItemId); + catalogItem = rebindContext.lookup().lookupCatalogItem(symbolicName); } - throw new IllegalStateException("No catalogItemId specified and can't load class from either classpath of catalog items"); + } + if (catalogItem != null) { + BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(managementContext, catalogItem); + return loader.loadClass(jType, bType); } else { - throw new IllegalStateException("No catalogItemId specified and can't load class from classpath"); + LOG.warn("Unable to load catalog item "+catalogItemId+" for "+contextSuchAsId + +" ("+bType.getSimpleName()+"); will try default class loader"); } - } - } + + try { + return (Class)reflections.loadClass(jType); + } catch (Exception e) { + Exceptions.propagateIfFatal(e); + LOG.warn("Unable to load "+jType+" using reflections; will try standard context"); + } - protected BrooklynClassLoadingContext getLoadingContextFromCatalogItemId(String catalogItemId, ClassLoader classLoader, RebindContext rebindContext) { - Preconditions.checkNotNull(catalogItemId, "catalogItemId required (should not be null)"); - CatalogItem catalogItem = rebindContext.lookup().lookupCatalogItem(catalogItemId); - if (catalogItem != null) { - return CatalogUtils.newClassLoadingContext(managementContext, catalogItem); + if (catalogItemId != null) { + throw new IllegalStateException("Unable to load catalog item "+catalogItemId+" for "+contextSuchAsId+", or load class from classpath"); --- End diff -- Is this definitely right, an exception if the item is *not* `null`? > Rebind failed when entity's catalog item not found > -------------------------------------------------- > > Key: BROOKLYN-149 > URL: https://issues.apache.org/jira/browse/BROOKLYN-149 > Project: Brooklyn > Issue Type: Bug > Affects Versions: 0.7.0-SNAPSHOT > Reporter: Aled Sage > Fix For: 0.7.0-SNAPSHOT > > > A customer's Brooklyn instance failed to rebind on restart. The error was: > {noformat} > vcompose1476-compose-amp.console-v1.5.3.log:2015-05-15 06:57:12,808 ERROR Management node zdJa2A7Y enountered problem during rebind when promoting self to master; demoting to FAILED and rethrowing: brooklyn.util.exceptions.PropagatedRuntimeException: Failure rebinding, 71 errors including: problem creating ENTITY Ocs2eaWX of type brooklyn.entity.nosql.riak.RiakClusterImpl: Failed to load catalog item OJ081XYKT_0=:1.0 required for rebinding. > oklyn-Allow-Non-Master-Access' to force) > {noformat} > The full exception was: > {noformat} > 2015-05-15 06:40:31,369 WARN b.e.r.RebindExceptionHandlerImpl [brooklyn-execmanager-boo0I83w-0]: No catalog item found with id OJ081XYKT_0=:1.0; returning null > 2015-05-15 06:40:31,395 WARN b.e.r.RebindExceptionHandlerImpl [brooklyn-execmanager-boo0I83w-0]: Rebind: continuing after problem creating ENTITY Ocs2eaWX of type brooklyn.entity.nosql.riak.RiakClusterImpl > java.lang.IllegalStateException: Failed to load catalog item OJ081XYKT_0=:1.0 required for rebinding. > at brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.getLoadingContextFromCatalogItemId(RebindIteration.java:903) ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.load(RebindIteration.java:869) ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindIteration$BrooklynObjectInstantiator.newEntity(RebindIteration.java:814) ~[brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindIteration.instantiateLocationsAndEntities(RebindIteration.java:407) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindIteration.doRun(RebindIteration.java:234) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.InitialFullRebindIteration.doRun(InitialFullRebindIteration.java:69) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindIteration.run(RebindIteration.java:260) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindManagerImpl.rebindImpl(RebindManagerImpl.java:545) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:496) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.entity.rebind.RebindManagerImpl$3.call(RebindManagerImpl.java:494) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at brooklyn.util.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:469) [brooklyn-core-0.7.0-20150509.1751.jar:0.7.0-20150509.1751] > at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71] > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71] > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71] > at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71] > {noformat} > In the persisted state, there is no mention of the catalog item OJ081XYKT_0. > My assumption is that the customer manually added a catalog item (via the web-console), deployed an app (entitled " riak", of type RiakCluster), and then deleted the catalog item (or that "deletion" could have been an issue with persistence of catalog items - see https://github.com/apache/incubator-brooklyn/pull/555). > The desired behaviour is that this does not cause the entire Brooklyn instance to fail to rebind/start. > --- > There are several potential things to investigate/improve: > * Test (manually, and then perhaps automated tests?): > * adding a catalog item (via web-console), deploying an app, and restarting AMP > * adding a catalog item (via web-console), deploying an app, deleting the catalog item (but not the app), and restarting AMP > * Investigate what catalog ids are used when adding through the web-console > (or did they manually choose the name OJ081XYKT_0?) > * Configurable for whether to continue startup onCreateFailed > (e.g. web-console pops up with "there was an error..."), but can click continue. > * Broolyn web-console to have a page showing all errors > * Support "quick fixes" such as deleting the item(s). -- This message was sent by Atlassian JIRA (v6.3.4#6332)