Repository: james-project
Updated Branches:
  refs/heads/master 9ce8f34ef -> 7bcc6201b


JAMES-1868 Add a Metric implementation with DropWizard-metrics


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0254c439
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0254c439
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0254c439

Branch: refs/heads/master
Commit: 0254c439cc28a9e29aa4b798de988d2995237897
Parents: 4374778
Author: Benoit Tellier <btell...@linagora.com>
Authored: Thu Nov 24 11:54:20 2016 +0700
Committer: Benoit Tellier <btell...@linagora.com>
Committed: Wed Nov 30 16:21:43 2016 +0700

----------------------------------------------------------------------
 .../metrics/metrics-dropwizard/pom.xml          | 58 ++++++++++++++++++++
 .../metrics/dropwizard/DropWizardMetric.java    | 43 +++++++++++++++
 .../dropwizard/DropWizardMetricFactory.java     | 43 +++++++++++++++
 3 files changed, 144 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0254c439/server/container/metrics/metrics-dropwizard/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-dropwizard/pom.xml 
b/server/container/metrics/metrics-dropwizard/pom.xml
new file mode 100644
index 0000000..083224e
--- /dev/null
+++ b/server/container/metrics/metrics-dropwizard/pom.xml
@@ -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>james-server</artifactId>
+        <groupId>org.apache.james</groupId>
+        <version>3.0.0-beta6-SNAPSHOT</version>
+        <relativePath>../../../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>james-server-metrics-dropwizard</artifactId>
+
+    <name>Apache James :: Server :: Metrics :: Dropwizard</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-filesystem-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>james-server-metrics-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.dropwizard.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/0254c439/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetric.java
----------------------------------------------------------------------
diff --git 
a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetric.java
 
b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetric.java
new file mode 100644
index 0000000..1e55395
--- /dev/null
+++ 
b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetric.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.james.metrics.dropwizard;
+
+import org.apache.james.metrics.api.Metric;
+
+import com.codahale.metrics.Counter;
+
+public class DropWizardMetric implements Metric {
+
+    private final Counter counter;
+
+    public DropWizardMetric(Counter counter) {
+        this.counter = counter;
+    }
+
+    @Override
+    public void increment() {
+        counter.inc();
+    }
+
+    @Override
+    public void decrement() {
+        counter.dec();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/0254c439/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
----------------------------------------------------------------------
diff --git 
a/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
 
b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
new file mode 100644
index 0000000..2e89060
--- /dev/null
+++ 
b/server/container/metrics/metrics-dropwizard/src/main/java/org/apache/james/metrics/dropwizard/DropWizardMetricFactory.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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.james.metrics.dropwizard;
+
+import javax.inject.Inject;
+
+import org.apache.james.metrics.api.Metric;
+import org.apache.james.metrics.api.MetricFactory;
+
+import com.codahale.metrics.MetricRegistry;
+
+public class DropWizardMetricFactory implements MetricFactory {
+
+    private final MetricRegistry metricRegistry;
+
+    @Inject
+    public DropWizardMetricFactory() {
+        this.metricRegistry = new MetricRegistry();
+    }
+
+    @Override
+    public Metric generate(String name) {
+        return new DropWizardMetric(metricRegistry.counter(name));
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to