Updated Branches:
  refs/heads/master 9f854af5f -> ef175ac2b

Move RRD4J dependency to tapestry-ioc
Create skeleton of new modules and services


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/63485952
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/63485952
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/63485952

Branch: refs/heads/master
Commit: 634859522059cb0e0cdd4dfe2e1914826e0f15d1
Parents: 9f854af
Author: Howard M. Lewis Ship <[email protected]>
Authored: Sat Apr 20 14:29:48 2013 +0100
Committer: Howard M. Lewis Ship <[email protected]>
Committed: Sat Apr 20 14:29:48 2013 +0100

----------------------------------------------------------------------
 tapestry-core/build.gradle                         |    4 -
 tapestry-ioc/build.gradle                          |   30 +++---
 .../services/metrics/MetricCollectorImpl.java      |   19 ++++
 .../tapestry5/ioc/modules/MetricsModule.java       |   28 +++++
 .../tapestry5/ioc/modules/MetricsSymbols.java      |   10 ++
 .../tapestry5/ioc/services/TapestryIOCModule.java  |    2 +
 .../tapestry5/ioc/services/metrics/Metric.java     |   81 +++++++++++++++
 .../ioc/services/metrics/MetricCollector.java      |   24 +++++
 8 files changed, 180 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-core/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-core/build.gradle b/tapestry-core/build.gradle
index 5870aab..41eb406 100644
--- a/tapestry-core/build.gradle
+++ b/tapestry-core/build.gradle
@@ -25,10 +25,6 @@ dependencies {
 
     compile "commons-codec:commons-codec:1.5"
 
-    // May want to refactor things at some point, so that the RRD support can 
be
-    // used by non-web applications.
-    compile "org.rrd4j:rrd4j:2.1.1"
-
     // Transitive will bring in the unwanted string template library as well
     compile "org.antlr:antlr-runtime:3.3", { transitive = false }
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/build.gradle
----------------------------------------------------------------------
diff --git a/tapestry-ioc/build.gradle b/tapestry-ioc/build.gradle
index df56d53..b08f585 100644
--- a/tapestry-ioc/build.gradle
+++ b/tapestry-ioc/build.gradle
@@ -1,27 +1,29 @@
 description = "A code-centric, high-performance, simple Inversion of Control 
container"
 
 dependencies {
-  compile project(':tapestry-func')
-  compile project(':tapestry5-annotations')
-  compile project(":plastic")
+    compile project(':tapestry-func')
+    compile project(':tapestry5-annotations')
+    compile project(":plastic")
 
-  provided project(':tapestry-test')
+    provided project(':tapestry-test')
 
-  // For now, keep these compile dependencies synchronized with the binaries 
dependencies
-  // of the top-level build:
+    // For now, keep these compile dependencies synchronized with the binaries 
dependencies
+    // of the top-level build:
 
-  compile "javax.inject:javax.inject:1"
+    compile "javax.inject:javax.inject:1"
 
-  compile "org.slf4j:slf4j-api:${versions.slf4j}"
+    compile "org.slf4j:slf4j-api:${versions.slf4j}"
 
-  testCompile "org.spockframework:spock-core:${versions.spock}"
-  testCompile "commons-lang:commons-lang:2.6"
+    testCompile "org.spockframework:spock-core:${versions.spock}"
+    testCompile "commons-lang:commons-lang:2.6"
 
-  provided "org.testng:testng:${versions.testng}", { transitive = false }
+    compile "org.rrd4j:rrd4j:2.1.1"
+
+    provided "org.testng:testng:${versions.testng}", { transitive = false }
 }
 
 test {
-  useJUnit()
-  // Override the master build.gradle
-  systemProperties.remove("tapestry.service-reloading-enabled")
+    useJUnit()
+    // Override the master build.gradle
+    systemProperties.remove("tapestry.service-reloading-enabled")
 }

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
new file mode 100644
index 0000000..7a2ee47
--- /dev/null
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/internal/services/metrics/MetricCollectorImpl.java
@@ -0,0 +1,19 @@
+package org.apache.tapestry5.ioc.internal.services.metrics;
+
+import org.apache.tapestry5.ioc.services.metrics.Metric;
+import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
+
+import java.util.List;
+
+public class MetricCollectorImpl implements MetricCollector
+{
+    public Metric createRootMetric(String name, Metric.Type type, Metric.Units 
units)
+    {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+
+    public List<Metric> getRootMetrics()
+    {
+        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
new file mode 100644
index 0000000..a44f1c8
--- /dev/null
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsModule.java
@@ -0,0 +1,28 @@
+package org.apache.tapestry5.ioc.modules;
+
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.ServiceBinder;
+import org.apache.tapestry5.ioc.annotations.Contribute;
+import org.apache.tapestry5.ioc.annotations.Marker;
+import org.apache.tapestry5.ioc.internal.services.metrics.MetricCollectorImpl;
+import org.apache.tapestry5.ioc.services.Builtin;
+import org.apache.tapestry5.ioc.services.FactoryDefaults;
+import org.apache.tapestry5.ioc.services.SymbolProvider;
+import org.apache.tapestry5.ioc.services.metrics.MetricCollector;
+
+@Marker(Builtin.class)
+public class MetricsModule
+{
+
+    public static void bind(ServiceBinder binder)
+    {
+        binder.bind(MetricCollector.class, MetricCollectorImpl.class);
+    }
+
+    @Contribute(SymbolProvider.class)
+    @FactoryDefaults
+    public static void provideDefaults(MappedConfiguration<String, Object> 
configuration)
+    {
+        configuration.add(MetricsSymbols.RRD_DB_DIR, "");
+    }
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsSymbols.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsSymbols.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsSymbols.java
new file mode 100644
index 0000000..7a55aeb
--- /dev/null
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/modules/MetricsSymbols.java
@@ -0,0 +1,10 @@
+package org.apache.tapestry5.ioc.modules;
+
+public class MetricsSymbols
+{
+    /**
+     * The directory in which RRDb database files are stored. If blank (the 
default),
+     * then RRD is set up for in-memory databases only (re-created on each 
launch of the application).
+     */
+    public static final String RRD_DB_DIR = "tapestry.rrd-dir";
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
index 3bd7a6d..80436b6 100644
--- 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/TapestryIOCModule.java
@@ -21,6 +21,7 @@ import org.apache.tapestry5.ioc.internal.services.*;
 import org.apache.tapestry5.ioc.internal.services.cron.PeriodicExecutorImpl;
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
+import org.apache.tapestry5.ioc.modules.MetricsModule;
 import org.apache.tapestry5.ioc.services.cron.PeriodicExecutor;
 import org.apache.tapestry5.ioc.util.TimeInterval;
 import org.apache.tapestry5.services.UpdateListenerHub;
@@ -42,6 +43,7 @@ import static 
org.apache.tapestry5.ioc.OrderConstraintBuilder.before;
  */
 @SuppressWarnings("all")
 @Marker(Builtin.class)
+@SubModule(MetricsModule.class)
 public final class TapestryIOCModule
 {
     public static void bind(ServiceBinder binder)

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
new file mode 100644
index 0000000..287094e
--- /dev/null
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/Metric.java
@@ -0,0 +1,81 @@
+package org.apache.tapestry5.ioc.services.metrics;
+
+import org.apache.xpath.operations.String;
+
+import java.util.List;
+
+public interface Metric
+{
+    enum Type
+    {
+        /**
+         * Storing a value accum;ulates into an ever increasing total. Example:
+         * number of burgers served.
+         */
+        TOTAL,
+
+        /**
+         * Storing a value accumulates just for the current time interval.  
Example:
+         * burgers served per second.
+         */
+        RATE
+    }
+
+
+    /**
+     * Primarily used when reporting to indicate the types of values.
+     */
+    enum Units
+    {
+        /**
+         * Appropriate when measuring bytes transferred, etc.
+         */
+        BYTES,
+        /**
+         * Useful when measuring the time to produce a result, such as 
processing some kind of request.
+         */
+        MILLISECONDS,
+        /**
+         * Placeholder for all other kinds of units, such as "pages viewed" or 
"messages processed".
+         */
+        UNIT
+    }
+
+    /**
+     * Creates a child metric with the same type and units.
+     * Values posted to the child are also posted to the container (this
+     * bubbling up can occur across several levels).
+     *
+     * @param name
+     *         child's extension to this Metric's name
+     * @return the child with the given name (creating it if necessary).
+     */
+    Metric createChild(String name);
+
+    /**
+     * Returns the path to this metric: the metric's name appended (after a 
slash) to the parent
+     * metric's path.
+     */
+    String getPath();
+
+    Type getType();
+
+    Units getUnits();
+
+    /**
+     * Stores a value of 1; useful  when the metric's type is {@linkplain 
Units#UNIT unit}.
+     */
+    void increment();
+
+    /**
+     * Stores a value into the current time interval.
+     *
+     * @param value
+     */
+    void store(double value);
+
+    /**
+     * Returns the children of this metric, sorted by name.
+     */
+    List<Metric> getChildren();
+}

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/63485952/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
----------------------------------------------------------------------
diff --git 
a/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
new file mode 100644
index 0000000..d95192b
--- /dev/null
+++ 
b/tapestry-ioc/src/main/java/org/apache/tapestry5/ioc/services/metrics/MetricCollector.java
@@ -0,0 +1,24 @@
+package org.apache.tapestry5.ioc.services.metrics;
+
+import java.util.List;
+
+public interface MetricCollector
+{
+    /**
+     * Creates a root metric, or returns an existing one.
+     *
+     * @param name
+     * @param type
+     * @param units
+     * @return the metric
+     * @throws IllegalMonitorStateException
+     *         if an existing metric is present, but does
+     *         not have the matching type and units.
+     */
+    Metric createRootMetric(String name, Metric.Type type, Metric.Units units);
+
+    /**
+     * Returns root metrics, sorted by name.
+     */
+    List<Metric> getRootMetrics();
+}

Reply via email to