Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51E6317821 for ; Mon, 10 Nov 2014 11:25:26 +0000 (UTC) Received: (qmail 98820 invoked by uid 500); 10 Nov 2014 11:25:26 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 98797 invoked by uid 500); 10 Nov 2014 11:25:26 -0000 Mailing-List: contact commits-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 commits@brooklyn.incubator.apache.org Received: (qmail 98788 invoked by uid 99); 10 Nov 2014 11:25:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Nov 2014 11:25:26 +0000 X-ASF-Spam-Status: No, hits=-2000.6 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 10 Nov 2014 11:25:24 +0000 Received: (qmail 98638 invoked by uid 99); 10 Nov 2014 11:25:04 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Nov 2014 11:25:04 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 61D658C043F; Mon, 10 Nov 2014 11:25:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: aledsage@apache.org To: commits@brooklyn.incubator.apache.org Date: Mon, 10 Nov 2014 11:25:07 -0000 Message-Id: <39b2962485334f7f99296755c8fb60bf@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/7] incubator-brooklyn git commit: entity.getAllAttributes() return everything X-Virus-Checked: Checked by ClamAV on apache.org entity.getAllAttributes() return everything - Even if the AttributeSensor is unknown for a given key name, still return it. - There’s a race where persister thread calls getAllAttributes() at same time as new attribute type is being added to entityType. Previously the sensor was not returned, so was not persisted. Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/48c7b447 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/48c7b447 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/48c7b447 Branch: refs/heads/master Commit: 48c7b447a5cf9d29527289a5c2e6f40821fb7196 Parents: 69e2f86 Author: Aled Sage Authored: Fri Nov 7 08:19:53 2014 +0000 Committer: Aled Sage Committed: Fri Nov 7 08:19:53 2014 +0000 ---------------------------------------------------------------------- .../java/brooklyn/entity/basic/AbstractEntity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/48c7b447/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java index c5ca83a..4590990 100644 --- a/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java +++ b/core/src/main/java/brooklyn/entity/basic/AbstractEntity.java @@ -55,6 +55,7 @@ import brooklyn.event.SensorEventListener; import brooklyn.event.basic.AttributeMap; import brooklyn.event.basic.AttributeSensorAndConfigKey; import brooklyn.event.basic.BasicNotificationSensor; +import brooklyn.event.basic.Sensors; import brooklyn.event.feed.AbstractFeed; import brooklyn.event.feed.ConfigToAttributes; import brooklyn.internal.BrooklynFeatureEnablement; @@ -1032,12 +1033,16 @@ public abstract class AbstractEntity extends AbstractBrooklynObject implements E Map result = Maps.newLinkedHashMap(); Map attribs = attributesInternal.asMap(); for (Map.Entry entry : attribs.entrySet()) { - AttributeSensor attribKey = (AttributeSensor) entityType.getSensor(entry.getKey()); + AttributeSensor attribKey = (AttributeSensor) entityType.getSensor(entry.getKey()); if (attribKey == null) { - LOG.warn("When retrieving all attributes of {}, ignoring attribute {} because no matching AttributeSensor found", this, entry.getKey()); - } else { - result.put(attribKey, entry.getValue()); + // Most likely a race: e.g. persister thread calling getAllAttributes; writer thread + // has written attribute value and is in process of calling entityType.addSensorIfAbsent(attribute) + // Just use a synthetic AttributeSensor, rather than ignoring value. + // TODO If it's not a race, then don't log.warn every time! + LOG.warn("When retrieving all attributes of {}, no AttributeSensor for attribute {} (creating synthetic)", this, entry.getKey()); + attribKey = Sensors.newSensor(Object.class, entry.getKey()); } + result.put(attribKey, entry.getValue()); } return result; }