InfluxDB 写入操作在 24 hour/one 天后自动停止工作
InfluxDB write operation stops working automatically after 24 hour/one day
我正在使用 Java 写入 InfluxDB,我正在做的是使用无限循环将点写入 DB,如下所示。
while (true) {
for (int i = 0; i < 100000; i++) {
list.add("cpu,atag=test" + i + " idle=100,usertime=10,system=1");
}
influxDB.write(dbName, "autogen", InfluxDB.ConsistencyLevel.ALL, list);
list.clear();
logger.info("WritePoints for " + 1 + " writes of " + 100000 + " Points took:" + watch);
}
我保留 运行 这个程序更长的时间来检查磁盘压缩和磁盘写入速度如何,但是 24 小时或 1 天后我得到 "time out" 异常如下所示。
我怎样才能将 运行 相同的程序保留几天。我可以捕获异常并再次创建连接,但是还有其他方法吗?
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: retrofit.RetrofitError: timeout
at retrofit.RetrofitError.networkError(RetrofitError.java:27)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at org.influxdb.impl.$Proxy0.writePoints(Unknown Source)
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:159)
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:171)
at net.company.influx.InfluxDBBatchWriter.doParse(InfluxDBBatchWriter.java:61)
at net.company.influx.InfluxDBBatchWriter.main(InfluxDBBatchWriter.java:25)
... 5 more
Caused by: java.net.SocketTimeoutException: timeout
at okio.Okio.newTimeoutException(Okio.java:207)
at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
at okio.AsyncTimeout.read(AsyncTimeout.java:215)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
at com.squareup.okhttp.internal.http.HttpEngine.access0(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:722)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
... 11 more
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:190)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at okio.Okio.read(Okio.java:139)
at okio.AsyncTimeout.read(AsyncTimeout.java:211)
... 26 more
InfluxDB 将在非常大的批量大小下执行次优。尝试将您的测试修改为
int n = 0;
int numSeries = 100000;
int batchSize = 5000;
while (true) {
for (int i = 0; i < batchSize; i++) {
n = (n + 1) % numSeries
list.add("cpu,atag=test" + n + " idle=100,usertime=10,system=1");
}
influxDB.write(dbName, "autogen", InfluxDB.ConsistencyLevel.ALL, list);
list.clear();
logger.info("WritePoints for " + 1 + " writes of " + 5000 + " Points took:" + watch);
}
我正在使用 Java 写入 InfluxDB,我正在做的是使用无限循环将点写入 DB,如下所示。
while (true) {
for (int i = 0; i < 100000; i++) {
list.add("cpu,atag=test" + i + " idle=100,usertime=10,system=1");
}
influxDB.write(dbName, "autogen", InfluxDB.ConsistencyLevel.ALL, list);
list.clear();
logger.info("WritePoints for " + 1 + " writes of " + 100000 + " Points took:" + watch);
}
我保留 运行 这个程序更长的时间来检查磁盘压缩和磁盘写入速度如何,但是 24 小时或 1 天后我得到 "time out" 异常如下所示。
我怎样才能将 运行 相同的程序保留几天。我可以捕获异常并再次创建连接,但是还有其他方法吗?
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: retrofit.RetrofitError: timeout
at retrofit.RetrofitError.networkError(RetrofitError.java:27)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at org.influxdb.impl.$Proxy0.writePoints(Unknown Source)
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:159)
at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:171)
at net.company.influx.InfluxDBBatchWriter.doParse(InfluxDBBatchWriter.java:61)
at net.company.influx.InfluxDBBatchWriter.main(InfluxDBBatchWriter.java:25)
... 5 more
Caused by: java.net.SocketTimeoutException: timeout
at okio.Okio.newTimeoutException(Okio.java:207)
at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
at okio.AsyncTimeout.read(AsyncTimeout.java:215)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.squareup.okhttp.internal.http.Http1xStream.readResponse(Http1xStream.java:186)
at com.squareup.okhttp.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:127)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:737)
at com.squareup.okhttp.internal.http.HttpEngine.access0(HttpEngine.java:87)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:722)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
at com.squareup.okhttp.Call.getResponse(Call.java:287)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
... 11 more
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:190)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at okio.Okio.read(Okio.java:139)
at okio.AsyncTimeout.read(AsyncTimeout.java:211)
... 26 more
InfluxDB 将在非常大的批量大小下执行次优。尝试将您的测试修改为
int n = 0;
int numSeries = 100000;
int batchSize = 5000;
while (true) {
for (int i = 0; i < batchSize; i++) {
n = (n + 1) % numSeries
list.add("cpu,atag=test" + n + " idle=100,usertime=10,system=1");
}
influxDB.write(dbName, "autogen", InfluxDB.ConsistencyLevel.ALL, list);
list.clear();
logger.info("WritePoints for " + 1 + " writes of " + 5000 + " Points took:" + watch);
}