brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [03/16] git commit: Avoid repeated logging: rest api LocationResource
Date Tue, 27 May 2014 11:05:19 GMT
Avoid repeated logging: rest api LocationResource


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

Branch: refs/heads/master
Commit: d1b5fa83b979a15750595142579ab78128da7fb4
Parents: 1be837e
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu May 22 08:34:27 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Mon May 26 22:09:30 2014 +0100

----------------------------------------------------------------------
 .../java/brooklyn/rest/resources/LocationResource.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d1b5fa83/usage/rest-server/src/main/java/brooklyn/rest/resources/LocationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/brooklyn/rest/resources/LocationResource.java
b/usage/rest-server/src/main/java/brooklyn/rest/resources/LocationResource.java
index b8a8547..b2dc7e7 100644
--- a/usage/rest-server/src/main/java/brooklyn/rest/resources/LocationResource.java
+++ b/usage/rest-server/src/main/java/brooklyn/rest/resources/LocationResource.java
@@ -4,6 +4,7 @@ import java.net.URI;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import javax.ws.rs.core.Response;
 
@@ -28,11 +29,14 @@ import brooklyn.util.text.Identifiers;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 public class LocationResource extends AbstractBrooklynRestResource implements LocationApi
{
 
     private static final Logger log = LoggerFactory.getLogger(LocationResource.class);
     
+    private final Set<String> specsWarnedOnException = Sets.newConcurrentHashSet();
+    
     @Override
   public List<LocationSummary> list() {
     return Lists.newArrayList(Iterables.filter(Iterables.transform(brooklyn().getLocationRegistry().getDefinedLocations().values(),
@@ -43,8 +47,13 @@ public class LocationResource extends AbstractBrooklynRestResource implements
Lo
                   return LocationTransformer.newInstance(mgmt(), l, LocationDetailLevel.LOCAL_EXCLUDING_SECRET);
               } catch (Exception e) {
                   Exceptions.propagateIfFatal(e);
-                  log.warn("Unable to find details of location "+l+" in REST call to list
(ignoring location): "+e);
-                  log.debug("Error details for location "+l, e);
+                  String spec = l.getSpec();
+                  if (spec == null || specsWarnedOnException.add(spec)) {
+                      log.warn("Unable to find details of location {} in REST call to list
(ignoring location): {}", l, e);
+                      if (log.isDebugEnabled()) log.debug("Error details for location "+l,
e);
+                  } else {
+                      if (log.isTraceEnabled()) log.trace("Unable again to find details of
location {} in REST call to list (ignoring location): {}", l, e);
+                  }
                   return null;
               }
           }


Mime
View raw message