Skip to content

Commit

Permalink
Merge pull request #17 from JCDecaux/allow-path-in-url
Browse files Browse the repository at this point in the history
Allow path in influxdb url
  • Loading branch information
davidB committed Apr 22, 2015
2 parents fd3512a + cb45497 commit 32ce0d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 21 additions & 3 deletions src/main/java/metrics_influxdb/InfluxdbHttp.java
Expand Up @@ -65,18 +65,36 @@ public static String toTimePrecision(TimeUnit t) {
* @throws IOException If the URL is malformed
*/
public InfluxdbHttp(String host, int port, String database, String username, String password) throws Exception {
this(host, port, database, username, password, TimeUnit.MILLISECONDS);
this(host, port, "", database, username, password, TimeUnit.MILLISECONDS);
}

/**
* Constructor with the InfluxDB time_precision parameter set to TimeUnit.MILLISECONDS
* @throws IOException If the URL is malformed
*/
public InfluxdbHttp(String host, int port, String path, String database, String username, String password) throws Exception {
this(host, port, path, database, username, password, TimeUnit.MILLISECONDS);
}

/**
* @param timePrecision The precision of the epoch time that is sent to the server,
* should be TimeUnit.MILLISECONDS unless you are using a custom Clock
* that does not return milliseconds epoch time for getTime()
* @throws IOException If the URL is malformed
*/
public InfluxdbHttp(String host, int port, String database, String username, String password, TimeUnit timePrecision) throws Exception {
this(host, port, "", database, username, password, timePrecision);
}

/**
* @param timePrecision The precision of the epoch time that is sent to the server,
* should be TimeUnit.MILLISECONDS unless you are using a custom Clock
* that does not return milliseconds epoch time for getTime()
* @throws IOException If the URL is malformed
*/
public InfluxdbHttp(String host, int port, String database, String username, String password, TimeUnit timePrecision) throws Exception {
public InfluxdbHttp(String host, int port, String path, String database, String username, String password, TimeUnit timePrecision) throws Exception {
this.url = new URL("http", host, port,
"/db/" + database
path + "/db/" + database
+ "/series?u=" + URLEncoder.encode(username, UTF_8.name())
+ "&p=" + password
+ "&time_precision=" + toTimePrecision(timePrecision)
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/metrics_influxdb/JsonBuilderDefault.java
Expand Up @@ -52,11 +52,11 @@ public void appendSeries(String namePrefix, String name, String nameSuffix, Stri
} else if((value instanceof Collection) && ((Collection<?>)value).size()<1) {
json.append("null");
}
else if (value instanceof Double && !Double.isFinite((double) value))
else if (value instanceof Double && Double.isInfinite((double) value))
{
json.append("null");
}
else if (value instanceof Float && !Float.isFinite((float) value))
else if (value instanceof Float && Float.isInfinite((float) value))
{
json.append("null");
}
Expand Down

0 comments on commit 32ce0d2

Please sign in to comment.