Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to have the vert.x metrics options in a MetricsOptions data …
…object
- Loading branch information
Showing
9 changed files
with
276 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/main/java/io/vertx/core/metrics/MetricsOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,135 @@ | |||
/* | |||
* Copyright (c) 2011-2013 The original author or authors | |||
* ------------------------------------------------------ | |||
* All rights reserved. This program and the accompanying materials | |||
* are made available under the terms of the Eclipse Public License v1.0 | |||
* and Apache License v2.0 which accompanies this distribution. | |||
* | |||
* The Eclipse Public License is available at | |||
* http://www.eclipse.org/legal/epl-v10.html | |||
* | |||
* The Apache License v2.0 is available at | |||
* http://www.opensource.org/licenses/apache2.0.php | |||
* | |||
* You may elect to redistribute this code under either of these licenses. | |||
*/ | |||
|
|||
package io.vertx.core.metrics; | |||
|
|||
import io.vertx.codegen.annotations.DataObject; | |||
import io.vertx.core.json.JsonObject; | |||
|
|||
/** | |||
* Vert.x metrics configuration. | |||
* | |||
* @author <a href="mailto:julien@julienviet.com">Julien Viet</a> | |||
*/ | |||
@DataObject | |||
public class MetricsOptions { | |||
|
|||
/** | |||
* The default value of metrics enabled false | |||
*/ | |||
public static final boolean DEFAULT_METRICS_ENABLED = false; | |||
|
|||
/** | |||
* The default value of JMX enabled = false | |||
*/ | |||
public static final boolean DEFAULT_JMX_ENABLED = false; | |||
|
|||
private boolean enabled; | |||
private boolean jmxEnabled; | |||
private String jmxDomain; | |||
|
|||
/** | |||
* Default constructor | |||
*/ | |||
public MetricsOptions() { | |||
enabled = DEFAULT_METRICS_ENABLED; | |||
jmxEnabled = DEFAULT_JMX_ENABLED; | |||
} | |||
|
|||
/** | |||
* Copy constructor | |||
* | |||
* @param other The other {@link MetricsOptions} to copy when creating this | |||
*/ | |||
public MetricsOptions(MetricsOptions other) { | |||
this.enabled = other.isEnabled(); | |||
this.jmxEnabled = other.isJmxEnabled(); | |||
this.jmxDomain = other.getJmxDomain(); | |||
} | |||
|
|||
/** | |||
* Create an instance from a {@link io.vertx.core.json.JsonObject} | |||
* | |||
* @param json the JsonObject to create it from | |||
*/ | |||
public MetricsOptions(JsonObject json) { | |||
this.enabled = json.getBoolean("enabled", DEFAULT_METRICS_ENABLED); | |||
this.jmxEnabled = json.getBoolean("jmxEnabled", DEFAULT_JMX_ENABLED); | |||
this.jmxDomain = json.getString("jmxDomain"); | |||
} | |||
|
|||
/** | |||
* Will metrics be enabled on the Vert.x instance? | |||
* | |||
* @return true if enabled, false if not. | |||
*/ | |||
public boolean isEnabled() { | |||
return enabled; | |||
} | |||
|
|||
/** | |||
* Set whether metrics will be enabled on the Vert.x instance. | |||
* | |||
* @param enable true if metrics enabled, or false if not. | |||
* @return a reference to this, so the API can be used fluently | |||
*/ | |||
public MetricsOptions setEnabled(boolean enable) { | |||
this.enabled = enable; | |||
return this; | |||
} | |||
|
|||
/** | |||
* Will JMX be enabled on the Vert.x instance? | |||
* | |||
* @return true if enabled, false if not. | |||
*/ | |||
public boolean isJmxEnabled() { | |||
return jmxEnabled; | |||
} | |||
|
|||
/** | |||
* Set whether JMX will be enabled on the Vert.x instance. | |||
* | |||
* @param jmxEnabled true if JMX enabled, or false if not. | |||
* @return a reference to this, so the API can be used fluently | |||
*/ | |||
public MetricsOptions setJmxEnabled(boolean jmxEnabled) { | |||
this.jmxEnabled = jmxEnabled; | |||
if (jmxEnabled) enabled = true; | |||
return this; | |||
} | |||
|
|||
/** | |||
* Get the JMX domain to use when JMX metrics are enabled. | |||
* | |||
* @return the JMX domain | |||
*/ | |||
public String getJmxDomain() { | |||
return jmxDomain; | |||
} | |||
|
|||
/** | |||
* Set the JMX domain to use when JMX metrics are enabled. | |||
* | |||
* @param jmxDomain the JMX domain | |||
* @return a reference to this, so the API can be used fluently | |||
*/ | |||
public MetricsOptions setJmxDomain(String jmxDomain) { | |||
this.jmxDomain = jmxDomain; | |||
return this; | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.