diff --git a/pom.xml b/pom.xml
index af20586ab..335ef5d6d 100755
--- a/pom.xml
+++ b/pom.xml
@@ -400,6 +400,9 @@
false
2003
+
+ 5555
+
UTF-8
@@ -457,6 +460,10 @@
Sonatype Releases Repository
http://oss.sonatype.org/content/repositories/releases/
+
+ clojars.org
+ http://clojars.org/repo
+
3.0.0
@@ -788,6 +795,11 @@
rome
${rome.version}
+
+ com.aphyr
+ riemann-java-client
+ 0.2.8
+
diff --git a/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java b/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
index 1d72b11df..2f2822415 100644
--- a/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
+++ b/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
@@ -54,6 +54,14 @@ public Keyspace keyspaceOperator() {
String cassandraHost = env.getProperty("cassandra.host");
String cassandraClusterName = env.getProperty("cassandra.clusterName");
String cassandraKeyspace = env.getProperty("cassandra.keyspace");
+
+ int cassandraReplicationFactor = 1;
+
+ try {
+ cassandraReplicationFactor = Integer.parseInt(env.getProperty("cassandra.replicationFactor"));
+ } catch (NumberFormatException nfe) {
+ log.warn("cassandra.replicationFactor property should contains a integer. Default to 1.");
+ }
CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(cassandraHost);
cassandraHostConfigurator.setMaxActive(100);
@@ -71,6 +79,7 @@ public Keyspace keyspaceOperator() {
if (keyspaceDef == null) {
log.warn("Keyspace \" {} \" does not exist, creating it!", cassandraKeyspace);
keyspaceDef = new ThriftKsDef(cassandraKeyspace);
+ ((ThriftKsDef)keyspaceDef).setReplicationFactor(cassandraReplicationFactor);
cluster.addKeyspace(keyspaceDef, true);
addColumnFamily(cluster, USER_CF, 0);
diff --git a/src/main/java/fr/ippon/tatami/config/MetricsConfiguration.java b/src/main/java/fr/ippon/tatami/config/MetricsConfiguration.java
index 7afd96861..064b9a79f 100644
--- a/src/main/java/fr/ippon/tatami/config/MetricsConfiguration.java
+++ b/src/main/java/fr/ippon/tatami/config/MetricsConfiguration.java
@@ -1,18 +1,31 @@
package fr.ippon.tatami.config;
import com.yammer.metrics.HealthChecks;
+import com.yammer.metrics.Metrics;
+import com.yammer.metrics.core.MetricsRegistry;
import com.yammer.metrics.reporting.GraphiteReporter;
+import com.yammer.metrics.reporting.JmxReporter;
+import com.yammer.metrics.reporting.RiemannReporter;
+import com.yammer.metrics.reporting.RiemannReporter.ConfigBuilder;
+
import fr.ippon.tatami.config.metrics.CassandraHealthCheck;
import fr.ippon.tatami.config.metrics.JavaMailHealthCheck;
import fr.ippon.tatami.service.MailService;
import me.prettyprint.hector.api.Keyspace;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
+import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
import java.util.concurrent.TimeUnit;
@Configuration
@@ -36,17 +49,51 @@ public void initMetrics() {
HealthChecks.register(new CassandraHealthCheck(keyspaceOperator));
HealthChecks.register(new JavaMailHealthCheck(mailService));
- String graphiteHost = env.getProperty("tatami.metrics.graphite.host");
- if (graphiteHost != null) {
- log.debug("Initializing Metrics Graphite reporting");
- Integer graphitePort = env.getProperty("tatami.metrics.graphite.port", Integer.class);
- GraphiteReporter.enable(1,
- TimeUnit.MINUTES,
- graphiteHost,
- graphitePort);
- } else {
- log.warn("Graphite server is not configured, unable to send any data to Graphite");
- }
+ initGraphite();
+ initRiemann();
}
}
+
+ private void initGraphite() {
+ String graphiteHost = env.getProperty("tatami.metrics.graphite.host");
+ if (!StringUtils.isEmpty(graphiteHost)) {
+ log.debug("Initializing Metrics Graphite reporting");
+ Integer graphitePort = env.getProperty("tatami.metrics.graphite.port", Integer.class);
+ GraphiteReporter.enable(Metrics.defaultRegistry(), 1,
+ TimeUnit.MINUTES,
+ graphiteHost,
+ graphitePort);
+ } else {
+ log.debug("Graphite server is not configured : disabling graphite reporting");
+ }
+ }
+
+ private void initRiemann() {
+
+ String riemannHost = env.getProperty("tatami.metrics.riemann.host");
+ if (!StringUtils.isEmpty(riemannHost)) {
+ log.debug("Initializing Metrics Riemann reporting");
+
+ ConfigBuilder builder = RiemannReporter.Config.newBuilder();
+ builder.host(riemannHost);
+ builder.metricsRegistry(Metrics.defaultRegistry());
+
+ Integer riemannPort = env.getProperty("tatami.metrics.riemann.port", Integer.class);
+ if (riemannPort != null)
+ builder.port(riemannPort);
+
+ List tagsList = new ArrayList();
+ tagsList.add("tatami");
+
+ String tags = env.getProperty("tatami.metrics.riemann.tags");
+ if (!StringUtils.isEmpty(tags)) {
+ tagsList.addAll( Arrays.asList(tags.split(",")));
+ }
+ builder.tags(tagsList);
+
+ RiemannReporter.enable(builder.build());
+ } else {
+ log.debug("Riemann server is not configured : disabling riemann reporting");
+ }
+ }
}
diff --git a/src/main/resources/META-INF/spring/applicationContext-metrics.xml b/src/main/resources/META-INF/spring/applicationContext-metrics.xml
index 66ff2523b..e91884d2b 100644
--- a/src/main/resources/META-INF/spring/applicationContext-metrics.xml
+++ b/src/main/resources/META-INF/spring/applicationContext-metrics.xml
@@ -6,10 +6,8 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"
profile="metrics">
-
-
+
-
\ No newline at end of file
diff --git a/src/main/resources/META-INF/tatami/tatami.properties b/src/main/resources/META-INF/tatami/tatami.properties
index 339426b48..6ba621f0d 100755
--- a/src/main/resources/META-INF/tatami/tatami.properties
+++ b/src/main/resources/META-INF/tatami/tatami.properties
@@ -14,6 +14,9 @@ tatami.automatic.registration=${tatami.automatic.registration}
#Monitoring using Yammer Metrics
tatami.metrics.graphite.host=${tatami.metrics.graphite.host}
tatami.metrics.graphite.port=${tatami.metrics.graphite.port}
+tatami.metrics.riemann.host=${tatami.metrics.riemann.host}
+tatami.metrics.riemann.port=${tatami.metrics.riemann.port}
+tatami.metrics.riemann.tags=${tatami.metrics.riemann.tags}
#User configuration
tatami.admin.users=jdubois@ippon.fr,julien.dubois@gmail.com,vdebelil@ippon.fr,ggruel@ippon.fr
@@ -42,6 +45,7 @@ apple.push.password=${apple.push.password}
cassandra.host=127.0.0.1:9160
cassandra.clusterName=Tatami cluster
cassandra.keyspace=tatami
+cassandra.replicationFactor=1
# Search engine configuration : you can use either Elastic Search in embedded or in remote mode
# - In embedded mode, Elastic Search runs inside Tatami : this is useful for development, test, and small installations