You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/08/29 01:13:19 UTC
[3/4] james-project git commit: JAMES-2131 Enable Cassandra driver
metrics
JAMES-2131 Enable Cassandra driver 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/79ff01fa
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/79ff01fa
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/79ff01fa
Branch: refs/heads/master
Commit: 79ff01fa5107815e4797dc9485819f04a3cc5212
Parents: e9f8a93
Author: benwa <bt...@linagora.com>
Authored: Sun Aug 27 21:41:53 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Aug 29 08:12:09 2017 +0700
----------------------------------------------------------------------
.../apache/james/CassandraJamesServerMain.java | 2 +
.../modules/metrics/CassandraMetricsModule.java | 71 ++++++++++++++++++++
2 files changed, 73 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/79ff01fa/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index 411bee3..f047959 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -29,6 +29,7 @@ import org.apache.james.modules.mailbox.CassandraMailboxModule;
import org.apache.james.modules.mailbox.CassandraSessionModule;
import org.apache.james.modules.mailbox.ElasticSearchMailboxModule;
import org.apache.james.modules.mailbox.TikaMailboxModule;
+import org.apache.james.modules.metrics.CassandraMetricsModule;
import org.apache.james.modules.protocols.IMAPServerModule;
import org.apache.james.modules.protocols.JMAPServerModule;
import org.apache.james.modules.protocols.LMTPServerModule;
@@ -76,6 +77,7 @@ public class CassandraJamesServerMain {
new TikaMailboxModule(),
new ActiveMQQueueModule(),
new ESMetricReporterModule(),
+ new CassandraMetricsModule(),
new MailboxModule());
http://git-wip-us.apache.org/repos/asf/james-project/blob/79ff01fa/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/metrics/CassandraMetricsModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/metrics/CassandraMetricsModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/metrics/CassandraMetricsModule.java
new file mode 100644
index 0000000..08074fe
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/metrics/CassandraMetricsModule.java
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.modules.metrics;
+
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.utils.ConfigurationPerformer;
+
+import com.codahale.metrics.MetricRegistry;
+import com.datastax.driver.core.Session;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
+
+public class CassandraMetricsModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(CassandraMetricsInjector.class)
+ .in(Scopes.SINGLETON);
+
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class)
+ .addBinding()
+ .to(CassandraMetricsInjector.class);
+ }
+
+ public static class CassandraMetricsInjector implements ConfigurationPerformer {
+
+ private final MetricRegistry metricRegistry;
+ private final Session session;
+
+ @Inject
+ public CassandraMetricsInjector(MetricRegistry metricRegistry, Session session) {
+ this.metricRegistry = metricRegistry;
+ this.session = session;
+ }
+
+ @Override
+ public void initModule() {
+ metricRegistry.registerAll(
+ session.getCluster()
+ .getMetrics()
+ .getRegistry());
+ }
+
+ @Override
+ public List<Class<? extends Configurable>> forClasses() {
+ return ImmutableList.of();
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org