Comments (10)
Hi Dennis,
the write is as long as you did not enable batchMode a synchronous call which will throw a RuntimeException if something went wrong, so you will notice it in you app.
If batchMode is enabled, this exception will be thrown in the flusher thread.
I dont see how we could change this behaviour in a way you will get informed about write errors.
Any hints welcome
Stefan
from influxdb-java.
Hi Stefan,
thanks for your reply. Unfortunately I am using batch mode. I'll give it some thought and let you know if I am coming any closer to a possible solution.
One more thing: I am using strings containing lineProtocol to store points/batch points locally. But as far as I can see there is no method to write lineProtocol instead of points/batch points. I tried using query instead, but that wasn't working for me. So I implemented an additional method to InfluxDBImpl.java. I think this is useful for others too, so probably you could include some method like this.
Dennis
public void write(final String database, final String retentionPolicy, final String getLineProtocol) {
TypedString lineProtocol = new TypedString(getLineProtocol);
this.influxDBService.writePoints(
this.username,
this.password,
database,
retentionPolicy,
TimeUtil.toTimePrecision(TimeUnit.NANOSECONDS),
ConsistencyLevel.ONE.toString(),
lineProtocol);
}
from influxdb-java.
Hi,
do you have any special requirements to the content of the lineprotocol which are not fulfilled with the implementation present in Point.java ? If yes please describe these and i will try to implement. Otherwise i want to keep the API as small as possible because this keeps the implementation simple with fewer bugs.
Greetings
Stefan
from influxdb-java.
Hi Stefan,
no, Point.java is allright. What I want to achieve is the following. My influxdb instance is running on a server, data is collected on a mobile device. Every time an exception is thrown, I am storing the point which haven't been sent to influxdb to a local SQLite database. Therefore I am using the method Point#lineProtocol(), which is working fine.
try {
InfluxDB influxDB = InfluxDBFactory.connect(dbUrl, dbUser, dbPassword);
influxDB.write(dbName, dbRetentionPolicy, point);
} catch (Exception e) {
DatabaseSQLite databaseSQLite = new DatabaseSQLite();
databaseSQLite.openConnection();
databaseSQLite.insertLineProtocol(point.lineProtocol());
databaseSQLite.closeConnection();
}
What I am missing is a possibility to send these stored points to influxdb after retrieving them from local database. Therefore I implemented the method mentioned in my comment above and use it as follows:
DatabaseSQLite databaseSQLite = new DatabaseSQLite();
databaseSQLite.openConnection();
String lineProtocol = databaseSQLite.getLineProtocol(id);
databaseSQLite.closeConnection();
InfluxDB influxDB = InfluxDBFactory.connect(dbUrl, dbUser, dbPassword);
influxDB.write(dbName, dbRetentionPolicy, lineProtocol);
Another solution would be to convert lineProtocol strings back to points, which could then be sent by the already existing API.
Hope this explanation helps.
Greetings
Dennis
from influxdb-java.
Hi Dennis,
ok got it, but why not serialize/deserialize The Point instance which failed to json and back to a instance for example with GSON:
Gson gson = new Gson();
String pointAsJson = gson.toJson(point);
// persist to SQLite
Point point = gson.fromJson(pointAsJson,Point.class);
// persist in influxdb
IMHO lineprotocol is not a proper serialization of points.
from influxdb-java.
Close this ticket because there seem to be urgent demand.
from influxdb-java.
Hi Stefan,
sorry for the delayed reply. That was my first guess too. But when I used JSON parser by Jackson execution failed every time (I cant't remember the error message, but it was something like error while building json from Point). Therefore I was looking into the lineProtocol and didn't try GSON. I'll gave it a try now and it seems to work pretty well. Thanks for your hint!
Greetings
Dennis
from influxdb-java.
Hi Stefan,
Is there a way to catch the exceptions while writing to influx in batch mode in the newer versions of Influx?
from influxdb-java.
Yes please read the documentation carefully.
from influxdb-java.
Got it, Thanks @majst01
from influxdb-java.
Related Issues (20)
- About Influx storage type conversion HOT 3
- Support Month in Duration Literal HOT 1
- Queries throw a "missing required parameter "q"" exception using influxdb-java 2.22 with enableGzip set to true HOT 4
- Where can i download a compiled .jar file? HOT 4
- Where can i find okhttp3/Interceptor .jar file? HOT 3
- question of test case: precision() HOT 5
- Why that code doesn't work? HOT 5
- Is the database connection pool available? HOT 4
- com.squareup.moshi.JsonEncodingException: Use JsonReader.setLenient(true) to accept malformed JSON at path $ HOT 1
- How to Not Add Default Options/Params to Write Requests
- InfluxDB Java Client Taking Way Longer Executing Queries
- Does influxdb-java has limitation for the # of select queries in one query() call? HOT 2
- java.lang.NoSuchFieldError: Companion at com.squareup.okhttp3.internal.Util
- `BatchPoints.Builder` not reusable
- Should contain 0
- SelectionQueryImpl should support buildQueryString
- Add support for java records HOT 3
- Support enums as field and tag values
- Default column name to pojo field name, and add `allFields` mode to `Measurement` annotation HOT 4
- influxdb-java.git/pom.xml references no longer maintained com.dkanejs.maven.plugins
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from influxdb-java.