Closed davide195 closed 6 years ago
@davide195 one of the InfluxDB key features[1] is the capability of "efficiently auto-expire stale data" using "Retention Policy"[2].
For example, you could create a RP to keep 1 year, 6 months or just 1 day of data. This will automatically remove stale data and I strongly advise you to adopt a RP (or multiple RP's) instead of building your own cleanup solution in Java.
Regarding your code:
a) If you have only one InfluxDB database with a single user, declare InfluxDB dbc
as a class scoped object and create it only once instead of creating every time you call a method. InfluxDB dbc
object can be shared and used concurrently.
b) If you have multiple InfluxDB databases with multiple users and don't want to adapt the approach mentioned before, call InfluxDBFactory.connect(String url, String username, String password, OkHttpClient.Builder client)
[3] passing a shared OkHttpClient.Builder
object. This will make all InfluxDB
client objects share the same HTTP connection pool[4].
Take a look on the links that I am sharing with you. If you need more help or something is not clear, ask again. ;)
Fernando
[1] https://docs.influxdata.com/influxdb/v1.4/#key-features [2] https://docs.influxdata.com/influxdb/v1.4/concepts/glossary/#retention-policy-rp [3] https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/InfluxDBFactory.java#L79 [4] https://github.com/square/okhttp/wiki/Concurrency#connection-pool
Hello @fmachado , thanks for the reply.
I'm passed to the "one shared instance" of dbc.
i know the possibility to use the RP but before the deleting of the data i need to aggregate it. What i need is an aggregation from the raw 10 sec to 1h only for the data older then 28 days. Using the RP there is the possibility to delete before the aggregation, loosing the data. I know that there is the CQ but it aggregate the data between now() and now()-1h and its not what i need. Am i wrong?
Thanks
One last comment before closing this issue: googling "SocketException: No buffer space available" I found posts from users executing the Java code on Windows platform and getting the mentioned exception because they were hitting the max # of TCP ports allowed to be active/open on Windows (5000). Check this link[1] for more information.
IMO does not matter what OS you are using because "SocketException: No buffer space available" means that you are probably doing something wrong.
If you are still facing this issue, please reopen it with more details about your code. Would be great if you could provide a test case that I can reproduce.
[1] http://mashijie.blogspot.de/2009/05/change-default-setting-of-tcp-ports.html
Hi all, i've this issue with a function that delete from the DB sequentially a lot of measure. Error log is:
My conf:
The function:
Why i get this error?
Thanks.