2016-10-13 8 views
0

InfluxDBにJavaを使用して書き込みをしていますが、以下に示すように無限ループを使用してDBにポイントを書き込んでいます。InfluxDBの書き込み操作が24時間/ 1日後に自動的に動作しなくなる

私がチェックし、ディスク圧縮とディスク書き込み速度がやっているかを確認するための時間の長い期間のためにこのプログラムを実行しているが、以下に示すように、24時間後または1日後、私は「時間外」の例外を取得しています保つ
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); 
    } 

どうすれば同じプログラムを2,3日間実行し続けることができますか。私は例外をキャッチして接続を再作成することができますが、それを行う他の方法はありますか?

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$3.newTimeoutException(Okio.java:207) 
    at okio.AsyncTimeout.exit(AsyncTimeout.java:261) 
    at okio.AsyncTimeout$2.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.access$200(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$2.read(Okio.java:139) 
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:211) 
    ... 26 more 
+0

どのバージョンのInfluxDBを使用していますか? –

+0

バージョンはv1.0.2です。 – Ammad

+0

100kポイントのバッチを作成しているようですが、これは間違いなく最適ではありません。バッチサイズを5-10kに落として、問題が解決しないかどうかを確認してください。 –

答えて

1

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); 
} 
関連する問題