You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2013/11/15 16:08:16 UTC

svn commit: r1542285 [1/2] - in /incubator/sirona/trunk: core/src/main/java/org/apache/sirona/gauges/ core/src/main/java/org/apache/sirona/repositories/ core/src/main/java/org/apache/sirona/store/gauge/ server/plugins/ server/plugins/api/ server/plugin...

Author: rmannibucau
Date: Fri Nov 15 15:08:14 2013
New Revision: 1542285

URL: http://svn.apache.org/r1542285
Log:
using SortedMap for gauges values (better to get it explicitely) + adding a basic hazelcast plugins (surely to rework, ATM not sure the agent is really needed)

Added:
    incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/
      - copied from r1542180, incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/
    incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Graphs.java
      - copied, changed from r1542180, incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/Line.java
    incubator/sirona/trunk/server/plugins/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/pom.xml
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/HazelcastGaugeFactory.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastGaugeBase.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastMembersGauge.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastPartitionsGauge.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastClientFactory.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastMemberFactory.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/org.apache.sirona.gauges.GaugeFactory
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/BasicHazelcastTest.java
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/
    incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/sirona.properties
    incubator/sirona/trunk/server/plugins/hazelcast/gui/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/pom.xml
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastEndpoints.java
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastPlugin.java
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/org.apache.sirona.reporting.web.plugin.api.Plugin
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/gauges.vm
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/home.vm
      - copied, changed from r1542180, incubator/sirona/trunk/server/reporting/src/main/resources/templates/gauge/home.vm
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/HazelcastGuiTest.java
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/resources/
    incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/resources/arquillian.xml
      - copied unchanged from r1542180, incubator/sirona/trunk/server/reporting/src/test/resources/arquillian.xml
    incubator/sirona/trunk/server/plugins/hazelcast/pom.xml
    incubator/sirona/trunk/src/site/markdown/hazelcast.md
Removed:
    incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Line.java
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/json/
Modified:
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/Gauge.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/GaugeDataStoreAdapter.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/DefaultRepository.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repositories.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repository.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CollectorGaugeDataStore.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CommonGaugeDataStore.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/DelegatedCollectorGaugeDataStore.java
    incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/InMemoryGaugeDataStore.java
    incubator/sirona/trunk/server/plugins/api/pom.xml
    incubator/sirona/trunk/server/plugins/pom.xml
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/gauge/GaugeEndpoints.java
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jta/JTAEndpoints.java
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jvm/JVMEndpoints.java
    incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/web/WebEndpoints.java
    incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/gauge/CassandraCollectorGaugeDataStore.java

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/Gauge.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/Gauge.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/Gauge.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/Gauge.java Fri Nov 15 15:08:14 2013
@@ -44,8 +44,11 @@ public interface Gauge {
                 addGaugeIfNecessary(classLoader, g, excludeParent, includedPrefixes);
             }
             for (final GaugeFactory gf : SPI.INSTANCE.find(GaugeFactory.class, classLoader)) {
-                for (final Gauge g : gf.gauges()) {
-                    addGaugeIfNecessary(classLoader, g, excludeParent, includedPrefixes);
+                final Gauge[] list = gf.gauges();
+                if (list != null) {
+                    for (final Gauge g : list) {
+                        addGaugeIfNecessary(classLoader, g, excludeParent, includedPrefixes);
+                    }
                 }
             }
         }

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/GaugeDataStoreAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/GaugeDataStoreAdapter.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/GaugeDataStoreAdapter.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/gauges/GaugeDataStoreAdapter.java Fri Nov 15 15:08:14 2013
@@ -22,12 +22,13 @@ import org.apache.sirona.store.gauge.Gau
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 public class GaugeDataStoreAdapter implements GaugeDataStore {
     @Override
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
-        return Collections.emptyMap();
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
+        return new TreeMap<Long, Double>();
     }
 
     @Override

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/DefaultRepository.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/DefaultRepository.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/DefaultRepository.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/DefaultRepository.java Fri Nov 15 15:08:14 2013
@@ -43,6 +43,7 @@ import org.apache.sirona.store.status.No
 
 import java.util.Collection;
 import java.util.Map;
+import java.util.SortedMap;
 
 public class DefaultRepository implements Repository {
     protected final CounterDataStore counterDataStore;
@@ -190,7 +191,7 @@ public class DefaultRepository implement
     }
 
     @Override
-    public Map<Long, Double> getGaugeValues(final long start, final long end, final Role role) {
+    public SortedMap<Long, Double> getGaugeValues(final long start, final long end, final Role role) {
         return gaugeDataStore.getGaugeValues(new GaugeValuesRequest(start, end, role));
     }
 

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repositories.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repositories.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repositories.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repositories.java Fri Nov 15 15:08:14 2013
@@ -19,6 +19,7 @@ package org.apache.sirona.repositories;
 import org.apache.sirona.Role;
 import org.apache.sirona.counters.Unit;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 
@@ -45,6 +46,14 @@ public class Repositories {
         return roles;
     }
 
+    public static Collection<String> names(final Collection<Role> membersGauges) {
+        final Collection<String> names = new ArrayList<String>(membersGauges.size());
+        for (final Role role : membersGauges) {
+            names.add(role.getName());
+        }
+        return names;
+    }
+
     private Repositories() {
         // no-op
     }

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repository.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repository.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repository.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/repositories/Repository.java Fri Nov 15 15:08:14 2013
@@ -26,6 +26,7 @@ import org.apache.sirona.stopwatches.Sto
 
 import java.util.Collection;
 import java.util.Map;
+import java.util.SortedMap;
 
 public interface Repository {
     Repository INSTANCE = IoCs.findOrCreateInstance(Repository.class);
@@ -44,7 +45,7 @@ public interface Repository {
 
     void stopGauge(Gauge role);
 
-    Map<Long, Double> getGaugeValues(long start, long end, Role role);
+    SortedMap<Long, Double> getGaugeValues(long start, long end, Role role);
 
     Collection<Role> gauges();
 

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CollectorGaugeDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CollectorGaugeDataStore.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CollectorGaugeDataStore.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CollectorGaugeDataStore.java Fri Nov 15 15:08:14 2013
@@ -19,10 +19,10 @@ package org.apache.sirona.store.gauge;
 import org.apache.sirona.Role;
 
 import java.util.Collection;
-import java.util.Map;
+import java.util.SortedMap;
 
 public interface CollectorGaugeDataStore extends CommonGaugeDataStore {
-    Map<Long, Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest, String marker);
+    SortedMap<Long, Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest, String marker);
     void createOrNoopGauge(Role role, String marker);
     void addToGauge(Role role, long time, double value, String marker);
     Collection<String> markers();

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CommonGaugeDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CommonGaugeDataStore.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CommonGaugeDataStore.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/CommonGaugeDataStore.java Fri Nov 15 15:08:14 2013
@@ -19,10 +19,10 @@ package org.apache.sirona.store.gauge;
 import org.apache.sirona.Role;
 
 import java.util.Collection;
-import java.util.Map;
+import java.util.SortedMap;
 
 public interface CommonGaugeDataStore {
-    Map<Long, Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest);
+    SortedMap<Long, Double> getGaugeValues(GaugeValuesRequest gaugeValuesRequest);
 
     Collection<Role> gauges();
 

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/DelegatedCollectorGaugeDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/DelegatedCollectorGaugeDataStore.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/DelegatedCollectorGaugeDataStore.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/DelegatedCollectorGaugeDataStore.java Fri Nov 15 15:08:14 2013
@@ -16,16 +16,16 @@
  */
 package org.apache.sirona.store.gauge;
 
-import org.apache.sirona.SironaException;
 import org.apache.sirona.Role;
+import org.apache.sirona.SironaException;
 import org.apache.sirona.configuration.Configuration;
 
 import java.lang.reflect.Constructor;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -60,10 +60,10 @@ public class DelegatedCollectorGaugeData
     }
 
     @Override
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest, final String marker) {
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest, final String marker) {
         final GaugeDataStore gaugeDataStore = dataStores.get(marker);
         if (gaugeDataStore == null) {
-            return Collections.emptyMap();
+            return new TreeMap<Long, Double>();
         }
         return gaugeDataStore.getGaugeValues(gaugeValuesRequest);
     }
@@ -93,8 +93,9 @@ public class DelegatedCollectorGaugeData
     }
 
     @Override // TODO: see if using a period to aggregate data wouldn't make more sense
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
-        final Map<Long, Double> values = new TreeMap<Long, Double>();
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
+        final SortedMap<Long, Double> values = new TreeMap<Long, Double>();
+
         for (final Map.Entry<String, GaugeDataStore> marker : dataStores.entrySet()) {
             final Map<Long, Double> gaugeValues = marker.getValue().getGaugeValues(gaugeValuesRequest);
             for (final Map.Entry<Long, Double> entry : gaugeValues.entrySet()) {

Modified: incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/InMemoryGaugeDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/InMemoryGaugeDataStore.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/InMemoryGaugeDataStore.java (original)
+++ incubator/sirona/trunk/core/src/main/java/org/apache/sirona/store/gauge/InMemoryGaugeDataStore.java Fri Nov 15 15:08:14 2013
@@ -20,33 +20,35 @@ import org.apache.sirona.Role;
 import org.apache.sirona.configuration.Configuration;
 
 import java.util.Collection;
-import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
 
 public class InMemoryGaugeDataStore implements GaugeDataStore {
-    protected final ConcurrentMap<Role, Map<Long, Double>> gauges = new ConcurrentHashMap<Role, Map<Long, Double>>();
+    protected final ConcurrentMap<Role, SortedMap<Long, Double>> gauges = new ConcurrentHashMap<Role, SortedMap<Long, Double>>();
     protected final Map<String, Role> roleMapping = new ConcurrentHashMap<String, Role>();
 
     @Override
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
         final Map<Long, Double> map = gauges.get(gaugeValuesRequest.getRole());
         if (map == null) {
-            return Collections.emptyMap();
+            return new TreeMap<Long, Double>();
         }
 
-        final Map<Long, Double> copy = new TreeMap<Long, Double>(map);
+        final Map<Long, Double> copy = new HashMap<Long, Double>(map);
 
-        final Map<Long, Double> out = new TreeMap<Long, Double>();
+        final SortedMap<Long, Double> out = new TreeMap<Long, Double>();
         for (final Map.Entry<Long, Double> entry : copy.entrySet()) {
             final long time = entry.getKey();
             if (time >= gaugeValuesRequest.getStart() && time <= gaugeValuesRequest.getEnd()) {
                 out.put(time, entry.getValue());
             }
         }
+
         return out;
     }
 

Modified: incubator/sirona/trunk/server/plugins/api/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/api/pom.xml?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/plugins/api/pom.xml (original)
+++ incubator/sirona/trunk/server/plugins/api/pom.xml Fri Nov 15 15:08:14 2013
@@ -28,4 +28,11 @@
 
   <artifactId>sirona-plugins-api</artifactId>
   <name>Apache Sirona Incubator :: Server :: Plugins :: API</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-core</artifactId>
+    </dependency>
+  </dependencies>
 </project>

Copied: incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Graphs.java (from r1542180, incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/Line.java)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Graphs.java?p2=incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Graphs.java&p1=incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/Line.java&r1=1542180&r2=1542285&rev=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/graph/Line.java (original)
+++ incubator/sirona/trunk/server/plugins/api/src/main/java/org/apache/sirona/reporting/web/plugin/api/graph/Graphs.java Fri Nov 15 15:08:14 2013
@@ -14,12 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sirona.reporting.web.graph;
+package org.apache.sirona.reporting.web.plugin.api.graph;
 
 import org.apache.sirona.Role;
 import org.apache.sirona.configuration.Configuration;
 import org.apache.sirona.configuration.ioc.IoCs;
-import org.apache.sirona.reporting.web.plugin.json.Jsons;
 import org.apache.sirona.repositories.Repository;
 import org.apache.sirona.store.gauge.CollectorGaugeDataStore;
 import org.apache.sirona.store.gauge.GaugeValuesRequest;
@@ -30,10 +29,12 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Random;
+import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
-public class Line {
+// a helper class to generate JSon (without dependencies) from gauges to plot graphes
+public class Graphs {
     public static final String DEFAULT_COLOR = "#317eac";
 
     private static final int MAX_POINTS = Configuration.getInteger(Configuration.CONFIG_PROPERTY_PREFIX + "reporting.graph.max-points", 200) - 1;
@@ -46,8 +47,21 @@ public class Line {
         generateColor(), generateColor(), generateColor(), generateColor(), generateColor()
     });
 
-    public static String toJson(final String label, final String color, final Map<Long, Double> data) {
-        return "{\"label\":\"" + label + "\",\"color\":\"" + color + "\",\"data\": " + Jsons.toJson(data) + "}";
+    public static String toJson(final String label, final String color, final SortedMap<Long, Double> data) {
+        return "{\"label\":\"" + label + "\",\"color\":\"" + color + "\",\"data\": " + toJson(data) + "}";
+    }
+
+    public static String toJson(final SortedMap<Long, Double> data) { // helper for gauges
+        final StringBuilder builder = new StringBuilder().append("[");
+        final Iterator<Map.Entry<Long,Double>> iterator = data.entrySet().iterator();
+        while (iterator.hasNext()) {
+            final Map.Entry<Long, Double> entry = iterator.next();
+            builder.append("[").append(entry.getKey()).append(", ").append(entry.getValue()).append("]");
+            if (iterator.hasNext()) {
+                builder.append(", ");
+            }
+        }
+        return builder.append("]").toString();
     }
 
     private static String generateColor() {
@@ -65,8 +79,8 @@ public class Line {
 
     public static String generateReport(final String label, final Role role, final long start, final long end) {
         if (!Environment.isCollector()) {
-            final Map<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues(start, end, role);
-            return "[" + Line.toJson(label, Line.DEFAULT_COLOR, aggregate(gaugeValues)) + "]";
+            final SortedMap<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues(start, end, role);
+            return "[" + Graphs.toJson(label, Graphs.DEFAULT_COLOR, aggregate(gaugeValues)) + "]";
         }
 
         final CollectorGaugeDataStore gaugeStore = IoCs.findOrCreateInstance(CollectorGaugeDataStore.class);
@@ -83,7 +97,7 @@ public class Line {
                 COLORS.add(color);
             }
 
-            final Map<Long, Double> gaugeValues = gaugeStore.getGaugeValues(new GaugeValuesRequest(start, end, role), marker);
+            final SortedMap<Long, Double> gaugeValues = gaugeStore.getGaugeValues(new GaugeValuesRequest(start, end, role), marker);
             builder.append(
                 toJson(
                     label + " (" + marker + ")",
@@ -98,7 +112,7 @@ public class Line {
         return builder.append("]").toString();
     }
 
-    private static Map<Long, Double> aggregate(final Map<Long, Double> gaugeValues) {
+    private static SortedMap<Long, Double> aggregate(final SortedMap<Long, Double> gaugeValues) {
         if (gaugeValues.size() < MAX_POINTS || !TreeMap.class.isInstance(gaugeValues)) {
             return gaugeValues;
         }
@@ -107,7 +121,7 @@ public class Line {
         final long max = Number.class.cast(TreeMap.class.cast(gaugeValues).lastKey()).longValue();
         final long step = (long) ((max - min) * 1. / MAX_POINTS);
 
-        final Map<Long, Double> aggregation = new TreeMap<Long, Double>();
+        final SortedMap<Long, Double> aggregation = new TreeMap<Long, Double>();
         double currentValue = 0;
         long switchValue = min + step;
         long number = 0;
@@ -129,7 +143,7 @@ public class Line {
         return aggregation;
     }
 
-    private Line() {
+    private Graphs() {
         // no-op
     }
 }

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/pom.xml?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/pom.xml (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/pom.xml Fri Nov 15 15:08:14 2013
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>sirona-hazelcast</artifactId>
+    <groupId>org.apache.sirona</groupId>
+    <version>0.1-incubating-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>sirona-hazelcast-agent</artifactId>
+  <name>Apache Sirona Incubator :: Server :: Plugins :: Hazelcast :: Agent</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.hazelcast</groupId>
+      <artifactId>hazelcast</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.hazelcast</groupId>
+      <artifactId>hazelcast-client</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/HazelcastGaugeFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/HazelcastGaugeFactory.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/HazelcastGaugeFactory.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/HazelcastGaugeFactory.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent;
+
+import com.hazelcast.core.HazelcastInstance;
+import org.apache.sirona.configuration.Configuration;
+import org.apache.sirona.configuration.ioc.Destroying;
+import org.apache.sirona.configuration.ioc.IoCs;
+import org.apache.sirona.gauges.Gauge;
+import org.apache.sirona.gauges.GaugeFactory;
+import org.apache.sirona.plugin.hazelcast.agent.gauge.HazelcastMembersGauge;
+import org.apache.sirona.plugin.hazelcast.agent.gauge.HazelcastPartitionsGauge;
+import org.apache.sirona.plugin.hazelcast.agent.instance.HazelcastClientFactory;
+import org.apache.sirona.plugin.hazelcast.agent.instance.HazelcastMemberFactory;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+public class HazelcastGaugeFactory implements GaugeFactory {
+    @Override
+    public Gauge[] gauges() {
+        final String instances = Configuration.getProperty(Configuration.CONFIG_PROPERTY_PREFIX + "hazelcast.clusters", "");
+        if (instances.isEmpty()) {
+            return null;
+        }
+
+        final Collection<Gauge> gauges = new LinkedList<Gauge>();
+        for (final String instance : instances.split(",")) {
+            final String trimmed = instance.trim();
+
+            final HazelcastInstance hzInstance;
+            final String prefix = Configuration.CONFIG_PROPERTY_PREFIX + "hazelcast." + trimmed + ".";
+            if (Configuration.is(prefix + "client", true)) {
+                hzInstance = HazelcastClientFactory.newClient(prefix);
+            } else {
+                hzInstance = HazelcastMemberFactory.newMember(trimmed, prefix);
+            }
+
+            IoCs.processInstance(new DestroyInstance(hzInstance)); // ensure to shutdown
+
+            addGauges(gauges, trimmed, hzInstance);
+        }
+        return gauges.toArray(new Gauge[gauges.size()]);
+    }
+
+    private void addGauges(final Collection<Gauge> gauges, final String name, final HazelcastInstance hzInstance) {
+        gauges.add(new HazelcastMembersGauge(name, hzInstance));
+        gauges.add(new HazelcastPartitionsGauge(name, hzInstance));
+    }
+
+    private static class DestroyInstance {
+        private final HazelcastInstance instance;
+
+        public DestroyInstance(final HazelcastInstance instance) {
+            this.instance = instance;
+        }
+
+        @Destroying
+        public void destroy() {
+            instance.getLifecycleService().shutdown();
+        }
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastGaugeBase.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastGaugeBase.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastGaugeBase.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastGaugeBase.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent.gauge;
+
+import com.hazelcast.core.HazelcastInstance;
+import org.apache.sirona.Role;
+import org.apache.sirona.configuration.Configuration;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.gauges.Gauge;
+
+public abstract class HazelcastGaugeBase implements Gauge {
+    private static final int PERIOD = Configuration.getInteger(Configuration.CONFIG_PROPERTY_PREFIX + "hazelcast.gauge.members.period", 4000);
+
+    private final Role role;
+    protected final HazelcastInstance instance;
+
+    public HazelcastGaugeBase(final String name, final HazelcastInstance instance) {
+        this.role = new Role(name, Unit.UNARY);
+        this.instance = instance;
+    }
+
+    @Override
+    public Role role() {
+        return role;
+    }
+
+    @Override
+    public long period() {
+        return PERIOD;
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastMembersGauge.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastMembersGauge.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastMembersGauge.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastMembersGauge.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent.gauge;
+
+import com.hazelcast.core.HazelcastInstance;
+
+public class HazelcastMembersGauge extends HazelcastGaugeBase {
+    public HazelcastMembersGauge(final String name, final HazelcastInstance instance) {
+        super("hazelcast-members-" + name, instance);
+    }
+
+    @Override
+    public double value() {
+        return instance.getCluster().getMembers().size();
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastPartitionsGauge.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastPartitionsGauge.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastPartitionsGauge.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/gauge/HazelcastPartitionsGauge.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent.gauge;
+
+import com.hazelcast.core.HazelcastInstance;
+
+public class HazelcastPartitionsGauge extends HazelcastGaugeBase {
+    public HazelcastPartitionsGauge(final String name, final HazelcastInstance instance) {
+        super("hazelcast-partitions-" + name, instance);
+    }
+
+    @Override
+    public double value() {
+        return instance.getPartitionService().getPartitions().size();
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastClientFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastClientFactory.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastClientFactory.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastClientFactory.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent.instance;
+
+import com.hazelcast.client.HazelcastClient;
+import com.hazelcast.client.config.ClientConfig;
+import com.hazelcast.client.config.XmlClientConfigBuilder;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.security.UsernamePasswordCredentials;
+import org.apache.sirona.configuration.Configuration;
+
+public class HazelcastClientFactory {
+    public static HazelcastInstance newClient(final String prefix) {
+        final ClientConfig config = new XmlClientConfigBuilder().build();
+
+        final String addresses = Configuration.getProperty(prefix + "addresses", null);
+        if (addresses != null) {
+            for (final String address : addresses.split(",")) {
+                config.addAddress(address.trim());
+            }
+        }
+
+        final String credentials = Configuration.getProperty(prefix + "credentials", null);
+        if (credentials != null) {
+            final String[] segments = credentials.split(":");
+            config.setCredentials(new UsernamePasswordCredentials(segments[0], segments[1]));
+        }
+
+        return HazelcastClient.newHazelcastClient(config);
+    }
+
+    private HazelcastClientFactory() {
+        // no-op
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastMemberFactory.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastMemberFactory.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastMemberFactory.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/java/org/apache/sirona/plugin/hazelcast/agent/instance/HazelcastMemberFactory.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.agent.instance;
+
+import com.hazelcast.config.XmlConfigBuilder;
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+
+public class HazelcastMemberFactory {
+    /**
+     * @param name name of the instance in sirona.properties
+     * @param prefix could be used to get further config
+     * @return the hazelcast instance built from hazelcast.xml + instancename = name
+     */
+    public static HazelcastInstance newMember(final String name, final String prefix) {
+        final HazelcastInstance hazelcastInstanceByName = Hazelcast.getHazelcastInstanceByName(name);
+        if (hazelcastInstanceByName != null) {
+            return hazelcastInstanceByName;
+        }
+        return Hazelcast.newHazelcastInstance(new XmlConfigBuilder().build().setInstanceName(name));
+    }
+
+    private HazelcastMemberFactory() {
+        // no-op
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/org.apache.sirona.gauges.GaugeFactory
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/org.apache.sirona.gauges.GaugeFactory?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/org.apache.sirona.gauges.GaugeFactory (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/main/resources/META-INF/services/org.apache.sirona.gauges.GaugeFactory Fri Nov 15 15:08:14 2013
@@ -0,0 +1 @@
+org.apache.sirona.plugin.hazelcast.agent.HazelcastGaugeFactory

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/BasicHazelcastTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/BasicHazelcastTest.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/BasicHazelcastTest.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/java/org/apache/sirona/plugin/hazelcast/BasicHazelcastTest.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.LifecycleEvent;
+import com.hazelcast.core.LifecycleListener;
+import org.apache.sirona.Role;
+import org.apache.sirona.configuration.ioc.IoCs;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.gauges.Gauge;
+import org.apache.sirona.repositories.Repository;
+import org.junit.After;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class BasicHazelcastTest {
+    @After
+    public void after() {
+        Repository.INSTANCE.reset();
+        IoCs.shutdown();
+    }
+
+    @Test
+    public void gauges() throws InterruptedException {
+        final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance();
+        final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance();
+        HazelcastInstance instance3 = null;
+
+        Map<Long, Double> members1 = null, members2 = null, partitions = null;
+
+        final Gauge.LoaderHelper loader = new Gauge.LoaderHelper(false);
+        try {
+            Thread.sleep(250);
+            instance3 = Hazelcast.newHazelcastInstance();
+            Thread.sleep(250);
+
+            members1 = gaugeValues("hazelcast-members-cluster");
+            partitions = gaugeValues("hazelcast-partitions-cluster");
+
+            final CountDownLatch instance1Stopped = new CountDownLatch(1);
+            instance1.getLifecycleService().addLifecycleListener(new LifecycleListener() {
+                @Override
+                public void stateChanged(final LifecycleEvent event) {
+                    if (LifecycleEvent.LifecycleState.SHUTDOWN.equals(event.getState())) {
+                        instance1Stopped.countDown();
+                    }
+                }
+            });
+            instance1.getLifecycleService().shutdown();
+            instance1Stopped.await();
+            Thread.sleep(300);
+
+            assertNotNull(partitions);
+            assertEquals(instance2.getPartitionService().getPartitions().size(), partitions.values().iterator().next(), 0.);
+
+            members2 = gaugeValues("hazelcast-members-cluster");
+        } finally {
+            loader.destroy();
+            instance2.getLifecycleService().shutdown();
+            if (instance3 != null) {
+                instance3.getLifecycleService().shutdown();
+            }
+            if (instance1.getLifecycleService().isRunning()) {
+                instance1.getLifecycleService().shutdown();
+            }
+        }
+
+        assertNotNull(members1);
+        assertNotNull(members2);
+
+        assertEquals(2., members1.values().iterator().next(), 0.);
+        assertEquals(2., members2.values().iterator().next(), 0.);
+        assertEquals(3., new TreeMap<Long, Double>(members1).lastEntry().getValue(), 0.);
+        assertEquals(2., new TreeMap<Long, Double>(members2).lastEntry().getValue(), 0.);
+    }
+
+    private static Map<Long, Double> gaugeValues(final String role) {
+        return Repository.INSTANCE.getGaugeValues(0, System.currentTimeMillis(), new Role(role, Unit.UNARY));
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/sirona.properties
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/sirona.properties?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/sirona.properties (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/agent/src/test/resources/sirona.properties Fri Nov 15 15:08:14 2013
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.sirona.hazelcast.clusters = cluster
+org.apache.sirona.hazelcast.cluster.client = true
+org.apache.sirona.hazelcast.cluster.addresses = localhost:5702
+org.apache.sirona.hazelcast.gauge.members.period = 100

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/pom.xml?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/pom.xml (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/pom.xml Fri Nov 15 15:08:14 2013
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>sirona-hazelcast</artifactId>
+    <groupId>org.apache.sirona</groupId>
+    <version>0.1-incubating-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>sirona-hazelcast-gui</artifactId>
+  <name>Apache Sirona Incubator :: Server :: Plugins :: Hazelcast :: GUI</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-core</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-plugins-api</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.descriptors</groupId>
+      <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.shrinkwrap.resolver</groupId>
+      <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.arquillian.junit</groupId>
+      <artifactId>arquillian-junit-container</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.arquillian.protocol</groupId>
+      <artifactId>arquillian-protocol-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.arquillian.container</groupId>
+      <artifactId>arquillian-tomcat-embedded-7</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-jasper</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomcat.embed</groupId>
+      <artifactId>tomcat-embed-logging-juli</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jdt.core.compiler</groupId>
+      <artifactId>ecj</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>net.sourceforge.htmlunit</groupId>
+      <artifactId>htmlunit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-web</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sirona</groupId>
+      <artifactId>sirona-reporting</artifactId>
+      <version>${project.version}</version>
+      <classifier>classes</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+        <filtering>true</filtering>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>reserve-http-port</id>
+            <phase>generate-test-resources</phase>
+            <goals>
+              <goal>reserve-network-port</goal>
+            </goals>
+            <configuration>
+              <portNames>
+                <portName>tomcat.http</portName>
+              </portNames>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <configuration>
+            <systemPropertyVariables>
+              <arquillian.launch>tomcat7</arquillian.launch>
+            </systemPropertyVariables>
+          </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+</project>

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastEndpoints.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastEndpoints.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastEndpoints.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.gui;
+
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.reporting.web.plugin.api.MapBuilder;
+import org.apache.sirona.reporting.web.plugin.api.Regex;
+import org.apache.sirona.reporting.web.plugin.api.Template;
+import org.apache.sirona.repositories.Repositories;
+import org.apache.sirona.repositories.Repository;
+
+import static org.apache.sirona.reporting.web.plugin.api.graph.Graphs.generateReport;
+
+public class HazelcastEndpoints {
+    @Regex
+    public Template home() {
+        return new Template("hazelcast/home.vm");
+    }
+
+    @Regex("/partitions")
+    public Template partitions() {
+        return hazelcastTemplate("Partition number", "partitions");
+    }
+
+    @Regex("/members")
+    public Template members() {
+        return hazelcastTemplate("Members number", "members");
+    }
+
+    @Regex("/([^/]*)/([0-9]*)/([0-9]*)")
+    public String jsonDetail(final String role, final long start, final long end) {
+        return generateReport(role, Repository.INSTANCE.findGaugeRole(role), start, end);
+    }
+
+    private static Template hazelcastTemplate(final String title, final String name) {
+        return new Template("hazelcast/gauges.vm",
+            new MapBuilder<String, Object>()
+                .set ("title", title)
+                .set("members", Repositories.names(Repositories.findByPrefixAndUnit("hazelcast-" + name + "-", Unit.UNARY)))
+                .build());
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastPlugin.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastPlugin.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastPlugin.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/java/org/apache/sirona/plugin/hazelcast/gui/HazelcastPlugin.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.plugin.hazelcast.gui;
+
+import org.apache.sirona.reporting.web.plugin.api.Plugin;
+
+public class HazelcastPlugin implements Plugin {
+    @Override
+    public String name() {
+        return "Hazelcast";
+    }
+
+    @Override
+    public Class<?> endpoints() {
+        return HazelcastEndpoints.class;
+    }
+
+    @Override
+    public String mapping() {
+        return "/hazelcast";
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/org.apache.sirona.reporting.web.plugin.api.Plugin
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/org.apache.sirona.reporting.web.plugin.api.Plugin?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/org.apache.sirona.reporting.web.plugin.api.Plugin (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/META-INF/services/org.apache.sirona.reporting.web.plugin.api.Plugin Fri Nov 15 15:08:14 2013
@@ -0,0 +1 @@
+org.apache.sirona.plugin.hazelcast.gui.HazelcastPlugin

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/gauges.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/gauges.vm?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/gauges.vm (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/gauges.vm Fri Nov 15 15:08:14 2013
@@ -0,0 +1,44 @@
+#*
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*#
+<h1>Hazelcast :: $title</h1>
+
+#foreach ($members in $members)
+<div class="container-fluid">
+    <div class="row-fluid">
+        #graphBlock("$members", "$members")
+    </div>
+</div>
+#end
+
+<script type="text/javascript" src="$mapping/resources/js/bootstrap-datetimepicker.min.js"></script>
+<script type="text/javascript" src="$mapping/resources/js/jquery.flot.min.js"></script>
+<script type="text/javascript" src="$mapping/resources/js/jquery.flot.time.min.js"></script>
+<script type="text/javascript">
+    $(function() {
+        var options = {
+            canvas: true,
+            series: { lines: { show: true }, points: { show: true } },
+            grid: { hoverable: true, clickable: true },
+            xaxes: [ { mode: "time", timezone: "browser" } ],
+            yaxes: [ { min: 0 } ]
+        };
+
+        #foreach ($members in $members)
+            Sirona.initGraph("$mapping", "hazelcast", "$members", options);
+        #end
+    });
+</script>

Copied: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/home.vm (from r1542180, incubator/sirona/trunk/server/reporting/src/main/resources/templates/gauge/home.vm)
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/home.vm?p2=incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/home.vm&p1=incubator/sirona/trunk/server/reporting/src/main/resources/templates/gauge/home.vm&r1=1542180&r2=1542285&rev=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/resources/templates/gauge/home.vm (original)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/main/resources/templates/hazelcast/home.vm Fri Nov 15 15:08:14 2013
@@ -14,13 +14,12 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 *#
-<h1>Gauges</h1>
+<h1>Hazelcast</h1>
 
 <div>
-    Here is the list of available gauges, click on one of them to get its details:
+    You can choose to see:
     <ul>
-        #foreach ($gauge in $gauges.entrySet())
-            <li><a href="$mapping/gauges/$gauge.value">$gauge.key<a/></li>
-        #end
+        <li><a href="$mapping/hazelcast/members">Members number</a></li>
+        <li><a href="$mapping/hazelcast/partitions">Partitions number</a></li>
     </ul>
 </div>

Added: incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/HazelcastGuiTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/HazelcastGuiTest.java?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/HazelcastGuiTest.java (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/gui/src/test/java/org/apache/sirona/hazelcast/plugin/gui/HazelcastGuiTest.java Fri Nov 15 15:08:14 2013
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sirona.hazelcast.plugin.gui;
+
+import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import org.apache.catalina.startup.Constants;
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.gauges.Gauge;
+import org.apache.sirona.plugin.hazelcast.gui.HazelcastPlugin;
+import org.apache.sirona.reporting.web.plugin.api.Plugin;
+import org.apache.sirona.reporting.web.registration.SironaReportingInitializer;
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.web.lifecycle.SironaLifecycle;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.servlet.ServletContainerInitializer;
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.CountDownLatch;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.junit.Assert.assertThat;
+
+@RunWith(Arquillian.class)
+public class HazelcastGuiTest {
+    static {
+        System.setProperty(Constants.DEFAULT_JARS_TO_SKIP, "a*,c*,d*,e*,g*,h*,i*,j*,l*,m*,n*,p*,r*,sa*,se*,sh*,su*,t*,v*,w*,x*,z*");
+    }
+
+    private static Gauge gauge1;
+    private static Gauge gauge2;
+
+    @Deployment(testable = false)
+    public static Archive<?> war() {
+        return ShrinkWrap.create(WebArchive.class, "sirona-hazelcast.war")
+            .addAsLibraries(
+                ShrinkWrap.create(JavaArchive.class, "sci.jar")
+                    .addAsServiceProvider(ServletContainerInitializer.class, SironaReportingInitializer.class)
+                    .addAsServiceProvider(Plugin.class, HazelcastPlugin.class)
+                    .addClass(SironaLifecycle.class));
+    }
+
+    @ArquillianResource
+    protected URL base;
+
+    protected <P extends Page> P page(final String path) throws IOException {
+        final WebClient webClient = new WebClient();
+        webClient.getOptions().setJavaScriptEnabled(false);
+        webClient.getOptions().setCssEnabled(false);
+        webClient.getOptions().setAppletEnabled(false);
+        webClient.setAjaxController(new NicelyResynchronizingAjaxController());
+        return webClient.getPage(base.toExternalForm() + "sirona/" + path);
+    }
+
+    @BeforeClass
+    public static void feedSomeHazelcastDate() throws InterruptedException {
+        final Role role1 = new Role("hazelcast-members-cluster", Unit.UNARY);
+        final CountDownLatch latch1 = new CountDownLatch(1);
+        gauge1 = new Gauge() {
+            @Override
+            public Role role() {
+                return role1;
+            }
+
+            @Override
+            public double value() {
+                try {
+                    return 2;
+                } finally {
+                    latch1.countDown();
+                }
+            }
+
+            @Override
+            public long period() {
+                return 100;
+            }
+        };
+
+        final Role role2 = new Role("hazelcast-partitions-cluster", Unit.UNARY);
+        final CountDownLatch latch2 = new CountDownLatch(1);
+        gauge2 = new Gauge() {
+            @Override
+            public Role role() {
+                return role2;
+            }
+
+            @Override
+            public double value() {
+                try {
+                    return 3;
+                } finally {
+                    latch2.countDown();
+                }
+            }
+
+            @Override
+            public long period() {
+                return 100;
+            }
+        };
+        Repository.INSTANCE.reset();
+        Repository.INSTANCE.addGauge(gauge1);
+        Repository.INSTANCE.addGauge(gauge2);
+        latch1.await();
+        latch2.await();
+    }
+
+    @AfterClass
+    public static void reset() {
+        Repository.INSTANCE.stopGauge(gauge1);
+        Repository.INSTANCE.stopGauge(gauge2);
+        Repository.INSTANCE.reset();
+    }
+
+    @Test
+    public void sironaHome() throws IOException {
+        assertThat(page("").getWebResponse().getContentAsString(),
+            containsString("<a href=\"/sirona-hazelcast/sirona/hazelcast\">Hazelcast</a>"));
+    }
+
+    @Test
+    public void hazelcastPluginHome() throws IOException {
+        final String hazelcast = page("hazelcast").getWebResponse().getContentAsString();
+        assertThat(hazelcast, containsString("You can choose to see"));
+    }
+
+    @Test
+    public void hazelcastPluginMembers() throws IOException {
+        final String hazelcast = page("hazelcast/members").getWebResponse().getContentAsString();
+        assertThat(hazelcast, containsString("<div id=\"hazelcast-members-cluster-graph\" class=\"plot\">"));
+        assertThat(hazelcast, containsString("Sirona.initGraph(\"/sirona-hazelcast/sirona\", \"hazelcast\", \"hazelcast-members-cluster\", options);"));
+    }
+
+    @Test
+    public void hazelcastPluginPartitions() throws IOException {
+        final String hazelcast = page("hazelcast/partitions").getWebResponse().getContentAsString();
+        assertThat(hazelcast, containsString("<div id=\"hazelcast-partitions-cluster-graph\" class=\"plot\">"));
+        assertThat(hazelcast, containsString("Sirona.initGraph(\"/sirona-hazelcast/sirona\", \"hazelcast\", \"hazelcast-partitions-cluster\", options);"));
+    }
+
+    @Test
+    public void gaugeJsonHome() throws IOException {
+        final long end = System.currentTimeMillis();
+
+        assertThat(page("hazelcast/hazelcast-members-cluster/0/" + end).getWebResponse().getContentAsString(),
+            startsWith("[{\"label\":\"hazelcast-members-cluster\""));
+        assertThat(page("hazelcast/hazelcast-partitions-cluster/0/" + end).getWebResponse().getContentAsString(),
+            startsWith("[{\"label\":\"hazelcast-partitions-cluster\""));
+    }
+}

Added: incubator/sirona/trunk/server/plugins/hazelcast/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/hazelcast/pom.xml?rev=1542285&view=auto
==============================================================================
--- incubator/sirona/trunk/server/plugins/hazelcast/pom.xml (added)
+++ incubator/sirona/trunk/server/plugins/hazelcast/pom.xml Fri Nov 15 15:08:14 2013
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>sirona-plugins</artifactId>
+    <groupId>org.apache.sirona</groupId>
+    <version>0.1-incubating-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>sirona-hazelcast</artifactId>
+  <name>Apache Sirona Incubator :: Server :: Plugins :: Hazelcast</name>
+  <packaging>pom</packaging>
+
+  <modules>
+    <module>agent</module>
+    <module>gui</module>
+  </modules>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>com.hazelcast</groupId>
+        <artifactId>hazelcast</artifactId>
+        <version>${hazelcast.version}</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
+        <groupId>com.hazelcast</groupId>
+        <artifactId>hazelcast-client</artifactId>
+        <version>${hazelcast.version}</version>
+        <scope>provided</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <properties>
+    <hazelcast.version>3.1.1</hazelcast.version>
+  </properties>
+</project>

Modified: incubator/sirona/trunk/server/plugins/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/plugins/pom.xml?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/plugins/pom.xml (original)
+++ incubator/sirona/trunk/server/plugins/pom.xml Fri Nov 15 15:08:14 2013
@@ -33,5 +33,6 @@
   <modules>
     <module>tomee</module>
     <module>api</module>
+    <module>hazelcast</module>
   </modules>
 </project>

Modified: incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/gauge/GaugeEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/gauge/GaugeEndpoints.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/gauge/GaugeEndpoints.java (original)
+++ incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/gauge/GaugeEndpoints.java Fri Nov 15 15:08:14 2013
@@ -29,7 +29,7 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.TreeMap;
 
-import static org.apache.sirona.reporting.web.graph.Line.generateReport;
+import static org.apache.sirona.reporting.web.plugin.api.graph.Graphs.generateReport;
 
 // gauge names can be not so URL friendly so using urlencode(base64), encoding is not in an utility class since it can change depending the data
 public class GaugeEndpoints {

Modified: incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jta/JTAEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jta/JTAEndpoints.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jta/JTAEndpoints.java (original)
+++ incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jta/JTAEndpoints.java Fri Nov 15 15:08:14 2013
@@ -21,7 +21,7 @@ import org.apache.sirona.counters.Unit;
 import org.apache.sirona.reporting.web.plugin.api.Regex;
 import org.apache.sirona.reporting.web.plugin.api.Template;
 
-import static org.apache.sirona.reporting.web.graph.Line.generateReport;
+import static org.apache.sirona.reporting.web.plugin.api.graph.Graphs.generateReport;
 
 public class JTAEndpoints {
     // copied to avoid classloading issue depending on the deployment, see org.apache.sirona.jta.JTAGauges

Modified: incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jvm/JVMEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jvm/JVMEndpoints.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jvm/JVMEndpoints.java (original)
+++ incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/jvm/JVMEndpoints.java Fri Nov 15 15:08:14 2013
@@ -29,7 +29,7 @@ import java.lang.management.OperatingSys
 import java.util.HashMap;
 import java.util.Map;
 
-import static org.apache.sirona.reporting.web.graph.Line.generateReport;
+import static org.apache.sirona.reporting.web.plugin.api.graph.Graphs.generateReport;
 
 public class JVMEndpoints {
     @Regex

Modified: incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/web/WebEndpoints.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/web/WebEndpoints.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/web/WebEndpoints.java (original)
+++ incubator/sirona/trunk/server/reporting/src/main/java/org/apache/sirona/reporting/web/plugin/web/WebEndpoints.java Fri Nov 15 15:08:14 2013
@@ -20,7 +20,7 @@ import org.apache.sirona.Role;
 import org.apache.sirona.counters.Unit;
 import org.apache.sirona.reporting.web.plugin.api.Regex;
 import org.apache.sirona.reporting.web.plugin.api.Template;
-import org.apache.sirona.reporting.web.plugin.json.Jsons;
+import org.apache.sirona.reporting.web.plugin.api.graph.Graphs;
 import org.apache.sirona.repositories.Repositories;
 import org.apache.sirona.repositories.Repository;
 import org.apache.sirona.web.session.SessionGauge;
@@ -36,7 +36,7 @@ public class WebEndpoints {
         final StringBuilder builder = new StringBuilder("[");
         for (final Role gauge : Repositories.findByPrefixAndUnit(SessionGauge.SESSIONS_PREFIX, Unit.UNARY)) {
             builder.append("{ \"data\": ")
-                .append(Jsons.toJson(Repository.INSTANCE.getGaugeValues(start, end, gauge)))
+                .append(Graphs.toJson(Repository.INSTANCE.getGaugeValues(start, end, gauge)))
                 .append(", \"label\": \"").append(gauge.getName()).append("\", \"color\": \"#317eac\" }")
                 .append(",");
         }

Modified: incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/gauge/CassandraCollectorGaugeDataStore.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/gauge/CassandraCollectorGaugeDataStore.java?rev=1542285&r1=1542284&r2=1542285&view=diff
==============================================================================
--- incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/gauge/CassandraCollectorGaugeDataStore.java (original)
+++ incubator/sirona/trunk/server/store/cassandra/src/main/java/org/apache/sirona/cassandra/collector/gauge/CassandraCollectorGaugeDataStore.java Fri Nov 15 15:08:14 2013
@@ -19,7 +19,6 @@ package org.apache.sirona.cassandra.coll
 import me.prettyprint.cassandra.serializers.DoubleSerializer;
 import me.prettyprint.cassandra.serializers.LongSerializer;
 import me.prettyprint.cassandra.serializers.StringSerializer;
-import me.prettyprint.cassandra.service.StringKeyIterator;
 import me.prettyprint.hector.api.Keyspace;
 import me.prettyprint.hector.api.beans.ColumnSlice;
 import me.prettyprint.hector.api.beans.HColumn;
@@ -35,6 +34,7 @@ import org.apache.sirona.store.gauge.Gau
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.SortedMap;
 import java.util.TreeMap;
 
 import static org.apache.sirona.cassandra.collector.CassandraSirona.column;
@@ -91,14 +91,14 @@ public class CassandraCollectorGaugeData
     }
 
     @Override
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest, final String marker) {
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest, final String marker) {
         final QueryResult<ColumnSlice<Long, Double>> qResult = HFactory.createSliceQuery(keyspace, StringSerializer.get(), LongSerializer.get(), DoubleSerializer.get())
             .setKey(id(gaugeValuesRequest.getRole(), marker))
             .setColumnFamily(valueFamily)
             .setRange(gaugeValuesRequest.getStart(), gaugeValuesRequest.getEnd(), false, Integer.MAX_VALUE)
             .execute();
 
-        final Map<Long, Double> result = new TreeMap<Long, Double>();
+        final SortedMap<Long, Double> result = new TreeMap<Long, Double>();
         for (final HColumn<Long, Double> slide : qResult.get().getColumns()) {
             result.put(slide.getName(), slide.getValue());
         }
@@ -107,8 +107,8 @@ public class CassandraCollectorGaugeData
     }
 
     @Override
-    public Map<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
-        final Map<Long, Double> result = new TreeMap<Long, Double>();
+    public SortedMap<Long, Double> getGaugeValues(final GaugeValuesRequest gaugeValuesRequest) {
+        final SortedMap<Long, Double> result = new TreeMap<Long, Double>();
 
         for (final String marker : markers()) {
             for (final Map.Entry<Long, Double> values : getGaugeValues(gaugeValuesRequest, marker).entrySet()) {