brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/3] incubator-brooklyn git commit: Adds catalogItemId to UsageListener.onApplicationEvent
Date Mon, 22 Dec 2014 11:55:35 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 674f54915 -> d14c06961


Adds catalogItemId to UsageListener.onApplicationEvent


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

Branch: refs/heads/master
Commit: 370187c8d1873e911dd6951649a35c548c7a32c5
Parents: c4d907a
Author: Martin Harris <github@nakomis.com>
Authored: Fri Dec 12 14:06:36 2014 +0000
Committer: Martin Harris <github@nakomis.com>
Committed: Fri Dec 19 10:40:30 2014 +0000

----------------------------------------------------------------------
 .../java/brooklyn/management/internal/LocalUsageManager.java | 5 +++--
 .../main/java/brooklyn/management/internal/UsageManager.java | 4 ++--
 .../management/usage/ApplicationUsageTrackingTest.java       | 8 ++++++--
 .../brooklyn/management/usage/RecordingUsageListener.java    | 4 ++--
 4 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/370187c8/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java b/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
index 4e7cc98..e63d462 100644
--- a/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/LocalUsageManager.java
@@ -181,10 +181,11 @@ public class LocalUsageManager implements UsageManager {
             final ApplicationUsage.ApplicationEvent event = new ApplicationUsage.ApplicationEvent(state);
             usage.addEvent(event);        
             eventMap.put(app.getId(), usage);
-            
+
             execOnListeners(new Function<UsageListener, Void>() {
                     public Void apply(UsageListener listener) {
-                        listener.onApplicationEvent(app.getId(), app.getDisplayName(), app.getEntityType().getName(),
((EntityInternal)app).toMetadataRecord(), event);
+                        listener.onApplicationEvent(app.getId(), app.getDisplayName(), app.getEntityType().getName(),
+                                app.getCatalogItemId(), ((EntityInternal)app).toMetadataRecord(),
event);
                         return null;
                     }
                     public String toString() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/370187c8/core/src/main/java/brooklyn/management/internal/UsageManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/management/internal/UsageManager.java b/core/src/main/java/brooklyn/management/internal/UsageManager.java
index 450a73b..88226c6 100644
--- a/core/src/main/java/brooklyn/management/internal/UsageManager.java
+++ b/core/src/main/java/brooklyn/management/internal/UsageManager.java
@@ -56,11 +56,11 @@ public interface UsageManager {
     public interface UsageListener {
         public static final UsageListener NOOP = new UsageListener() {
             @Override public void onApplicationEvent(String applicationId, String applicationName,
String entityType, 
-                    Map<String, String> metadata, ApplicationEvent event) {} 
+                    String catalogItemId, Map<String, String> metadata, ApplicationEvent
event) {}
             @Override public void onLocationEvent(String locationId, Map<String, String>
metadata, LocationEvent event) {}
         };
         
-        void onApplicationEvent(String applicationId, String applicationName, String entityType,

+        void onApplicationEvent(String applicationId, String applicationName, String entityType,
String catalogItemId,
                 Map<String, String> metadata, ApplicationEvent event);
         
         void onLocationEvent(String locationId, Map<String, String> metadata, LocationEvent
event);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/370187c8/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
b/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
index e90f2df..5208fce 100644
--- a/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
+++ b/software/base/src/test/java/brooklyn/management/usage/ApplicationUsageTrackingTest.java
@@ -87,6 +87,7 @@ public class ApplicationUsageTrackingTest {
         mgmt.getUsageManager().addUsageListener(listener);
         
         app = TestApplication.Factory.newManagedInstanceForTests(mgmt);
+        app.setCatalogItemId("testCatalogItem");
         app.start(ImmutableList.<Location>of());
 
         Asserts.succeedsEventually(new Runnable() {
@@ -97,11 +98,14 @@ public class ApplicationUsageTrackingTest {
                 String appId = (String) events.get(0).get(1);
                 String appName = (String) events.get(0).get(2);
                 String entityType = (String) events.get(0).get(3);
-                Map<?,?> metadata = (Map<?, ?>) events.get(0).get(4);
-                ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(5);
+                String catalogItemId = (String) events.get(0).get(4);
+                System.out.println(catalogItemId);
+                Map<?,?> metadata = (Map<?, ?>) events.get(0).get(5);
+                ApplicationEvent appEvent = (ApplicationEvent) events.get(0).get(6);
                 
                 assertEquals(appId, app.getId(), "events="+events);
                 assertNotNull(appName, "events="+events);
+                assertEquals(app.getCatalogItemId(), "testCatalogItem");
                 assertNotNull(entityType, "events="+events);
                 assertNotNull(metadata, "events="+events);
                 assertEquals(appEvent.getState(), Lifecycle.STARTING, "events="+events);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/370187c8/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
b/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
index fa5cadc..97ee7da 100644
--- a/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
+++ b/software/base/src/test/java/brooklyn/management/usage/RecordingUsageListener.java
@@ -35,8 +35,8 @@ public class RecordingUsageListener implements UsageListener {
     
     @Override
     public void onApplicationEvent(String applicationId, String applicationName, String entityType,

-            Map<String, String> metadata, ApplicationEvent event) {
-        events.add(MutableList.of("application", applicationId, applicationName, entityType,
metadata, event));
+            String catalogItemId, Map<String, String> metadata, ApplicationEvent event)
{
+        events.add(MutableList.of("application", applicationId, applicationName, entityType,
catalogItemId, metadata, event));
     }
 
     @Override


Mime
View raw message