Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit 970cbdd

Browse files
committed
Implement Issue influxdata#389 : Support for MessagePack
1 parent f9ca92f commit 970cbdd

File tree

8 files changed

+499
-99
lines changed

8 files changed

+499
-99
lines changed

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@
255255
<artifactId>converter-moshi</artifactId>
256256
<version>2.4.0</version>
257257
</dependency>
258+
<dependency>
259+
<groupId>org.komamitsu</groupId>
260+
<artifactId>retrofit-converter-msgpack</artifactId>
261+
<version>1.0.0</version>
262+
</dependency>
258263
<!-- If we use okhttp instead of java urlconnection we achieve server failover
259264
of the influxdb server address resolves to all influxdb server ips. -->
260265
<dependency>

src/main/java/org/influxdb/InfluxDBFactory.java

+22-1
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,30 @@ public static InfluxDB connect(final String url, final OkHttpClient.Builder clie
7878
*/
7979
public static InfluxDB connect(final String url, final String username, final String password,
8080
final OkHttpClient.Builder client) {
81+
return connect(url, username, password, client, false);
82+
}
83+
84+
/**
85+
* Create a connection to a InfluxDB.
86+
*
87+
* @param url
88+
* the url to connect to.
89+
* @param username
90+
* the username which is used to authorize against the influxDB instance.
91+
* @param password
92+
* the password for the username which is used to authorize against the influxDB
93+
* instance.
94+
* @param client
95+
* the HTTP client to use
96+
* @param useMsgPack
97+
* Accept MessagePack format (TRUE) or JSon (FALSE) for response from InfluxDB server
98+
* @return a InfluxDB adapter suitable to access a InfluxDB.
99+
*/
100+
public static InfluxDB connect(final String url, final String username, final String password,
101+
final OkHttpClient.Builder client, final boolean useMsgPack) {
81102
Preconditions.checkNonEmptyString(url, "url");
82103
Preconditions.checkNonEmptyString(username, "username");
83104
Objects.requireNonNull(client, "client");
84-
return new InfluxDBImpl(url, username, password, client);
105+
return new InfluxDBImpl(url, username, password, client, useMsgPack);
85106
}
86107
}

src/main/java/org/influxdb/dto/QueryResult.java

+99
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.List;
44
import java.util.Map;
55

6+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
7+
68
/**
79
* {Purpose of This Type}.
810
*
@@ -68,10 +70,20 @@ public void setError(final String error) {
6870
this.error = error;
6971
}
7072

73+
@JsonIgnoreProperties(ignoreUnknown = true)
7174
public static class Result {
75+
private List<Abc> abc;
7276
private List<Series> series;
7377
private String error;
7478

79+
public List<Abc> getAbc() {
80+
return abc;
81+
}
82+
83+
public void setAbc(final List<Abc> abc) {
84+
this.abc = abc;
85+
}
86+
7587
/**
7688
* @return the series
7789
*/
@@ -128,6 +140,93 @@ public String toString() {
128140

129141
}
130142

143+
@JsonIgnoreProperties(ignoreUnknown = true)
144+
public static class Abc {
145+
private String name;
146+
private Map<String, String> tags;
147+
private List<String> columns;
148+
private List<List<Object>> values;
149+
150+
/**
151+
* @return the name
152+
*/
153+
public String getName() {
154+
return this.name;
155+
}
156+
157+
/**
158+
* @param name
159+
* the name to set
160+
*/
161+
public void setName(final String name) {
162+
this.name = name;
163+
}
164+
165+
/**
166+
* @return the tags
167+
*/
168+
public Map<String, String> getTags() {
169+
return this.tags;
170+
}
171+
172+
/**
173+
* @param tags
174+
* the tags to set
175+
*/
176+
public void setTags(final Map<String, String> tags) {
177+
this.tags = tags;
178+
}
179+
180+
/**
181+
* @return the columns
182+
*/
183+
public List<String> getColumns() {
184+
return this.columns;
185+
}
186+
187+
/**
188+
* @param columns
189+
* the columns to set
190+
*/
191+
public void setColumns(final List<String> columns) {
192+
this.columns = columns;
193+
}
194+
195+
/**
196+
* @return the values
197+
*/
198+
public List<List<Object>> getValues() {
199+
return this.values;
200+
}
201+
202+
/**
203+
* @param values
204+
* the values to set
205+
*/
206+
public void setValues(final List<List<Object>> values) {
207+
this.values = values;
208+
}
209+
210+
/**
211+
* {@inheritDoc}
212+
*/
213+
@Override
214+
public String toString() {
215+
StringBuilder builder = new StringBuilder();
216+
builder.append("Series [name=");
217+
builder.append(this.name);
218+
builder.append(", tags=");
219+
builder.append(this.tags);
220+
builder.append(", columns=");
221+
builder.append(this.columns);
222+
builder.append(", values=");
223+
builder.append(this.values);
224+
builder.append("]");
225+
return builder.toString();
226+
}
227+
}
228+
229+
@JsonIgnoreProperties(ignoreUnknown = true)
131230
public static class Series {
132231
private String name;
133232
private Map<String, String> tags;

0 commit comments

Comments
 (0)