Skip to content

Commit

Permalink
Addresses checkstyle violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Shin committed Jun 26, 2013
1 parent 83b5098 commit 1a84664
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 14 deletions.
67 changes: 54 additions & 13 deletions fcrepo-metrics/src/main/java/org/fcrepo/metrics/MetricsConfig.java
Expand Up @@ -13,35 +13,61 @@

/**
* Configuration class for Metrics reporting to Graphite and JMX.
*
* <p>To enable Metrics reporting to Graphite, activate the Spring profile
* "metrics.graphite". The system properties fcrepo.metrics.host and
* fcrepo.metrics.port can also be set (defaults to "localhost" and 2003,
* respectively.</p>
*
* <p>To enable Metrics reporting to JMX, activate the Spring profile
* "metrics.jmx".</p>
*
* <p>To enable both Graphite and JMX reporting, the Spring profile "metrics",
* can be used instead of specifying both metrics.graphite and metrics.jmx,
* e.g.:</p>
* <p>
* To enable Metrics reporting to Graphite, activate the Spring profile
* "metrics.graphite". The system properties fcrepo.metrics.host and
* fcrepo.metrics.port can also be set (defaults to "localhost" and 2003,
* respectively.
* </p>
* <p>
* To enable Metrics reporting to JMX, activate the Spring profile
* "metrics.jmx".
* </p>
* <p>
* To enable both Graphite and JMX reporting, the Spring profile "metrics", can
* be used instead of specifying both metrics.graphite and metrics.jmx, e.g.:
* </p>
* <blockquote><code>-Dspring.profiles.active="metrics"</code></blockquote>
*
* @author Edwin Shin
*
*/
@Configuration
public class MetricsConfig {

/**
* TODO
*
* @return
*/
@Bean
public ReporterFactory reporterFactory() {
return new ReporterFactory();
}

/**
* <p>
* Metrics configuration for Graphite reporting.
* </p>
* <p>
* Graphite reporting can be enabled by activating the "metrics.graphite"
* Spring profile.
* </p>
*/
@Configuration
@Profile({"metrics", "metrics.graphite"})
public static class GraphiteConfig {

/**
* <p>
* Host and port may be configured with system properties
* "fcrepo.metrics.host" and "fcrepo.metrics.port", respectively.
* </p>
* <p>
* Host and port default to "localhost" and "2003", respectively.
* </p>
*
* @return a Graphite client to a Carbon server
*/
@Bean
public Graphite graphiteClient() {
String hostname =
Expand All @@ -53,6 +79,9 @@ public Graphite graphiteClient() {
return new Graphite(new InetSocketAddress(hostname, port));
}

/**
* @return a Reporter which publishes metrics to a Graphite server
*/
@Bean
public GraphiteReporter graphiteReporter() {
MetricsConfig cfg = new MetricsConfig();
Expand All @@ -63,13 +92,25 @@ public GraphiteReporter graphiteReporter() {
}
}

/**
* <p>
* JMX configuration for metrics reporting.
* </p>
* <p>
* JMX reporting can be enabled by activating the "metrics.jmx" Spring
* profile.
* </p>
*/
@Configuration
@Profile({"metrics", "metrics.jmx"})
public static class JmxConfig {

String prefix = System.getProperty("fcrepo.metrics.prefix",
"org.fcrepo");

/**
* @return a Reporter that exposes metrics under the "org.fcrepo" prefix
*/
@Bean
public JmxReporter jmxReporter() {
MetricsConfig cfg = new MetricsConfig();
Expand Down
Expand Up @@ -14,7 +14,8 @@
* Metrics servlets expect.
*
* @author Edwin Shin
* @see <a href="http://metrics.codahale.com/manual/servlets/">http://metrics.codahale.com/manual/servlets/</a>
* @see <a
* href="http://metrics.codahale.com/manual/servlets/">http://metrics.codahale.com/manual/servlets/</a>
*/
@WebListener
public class MetricsContextListener extends AdminServletContextListener {
Expand Down
@@ -1,3 +1,4 @@

package org.fcrepo.metrics;

import javax.ws.rs.ext.Provider;
Expand All @@ -7,6 +8,9 @@
@Provider
public class MetricsProvider extends InstrumentedResourceMethodDispatchAdapter {

/**
* Default constructor that provides a MetricsRegistry
*/
public MetricsProvider() {
super(RegistryService.getMetrics());
}
Expand Down
Expand Up @@ -45,6 +45,12 @@ public GraphiteReporter getGraphiteReporter(final String prefix,
return reporter;
}

/**
* TODO
*
* @param prefix
* @return
*/
public JmxReporter getJmxReporter(final String prefix) {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final JmxReporter reporter =
Expand Down

0 comments on commit 1a84664

Please sign in to comment.