Skip to content

Commit c7821d6

Browse files
committed
feat: can connect db with cmd line
1 parent bbd7b82 commit c7821d6

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

ingester-example/src/main/java/io/greptime/bench/DBConnector.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package io.greptime.bench;
1818

1919
import io.greptime.GreptimeDB;
20+
import io.greptime.common.util.SystemPropertyUtil;
2021
import io.greptime.options.GreptimeOptions;
2122
import io.greptime.quickstart.query.QueryJDBCQuickStart;
23+
import io.greptime.rpc.RpcOptions;
2224
import java.io.IOException;
2325
import java.util.Properties;
2426
import org.slf4j.Logger;
@@ -38,11 +40,23 @@ public static GreptimeDB connect() {
3840
} catch (IOException e) {
3941
throw new RuntimeException(e);
4042
}
41-
String database = (String) prop.get("db.database");
42-
String endpointsStr = prop.getProperty("db.endpoints");
43+
44+
String database = SystemPropertyUtil.get("db.database");
45+
if (database == null) {
46+
database = (String) prop.get("db.database");
47+
}
48+
49+
String endpointsStr = SystemPropertyUtil.get("db.endpoints");
50+
if (endpointsStr == null) {
51+
endpointsStr = prop.getProperty("db.endpoints");
52+
}
53+
4354
String[] endpoints = endpointsStr.split(",");
55+
RpcOptions rpcOptions = RpcOptions.newDefault();
56+
rpcOptions.setDefaultRpcTimeout(60 * 1000);
4457
GreptimeOptions opts = GreptimeOptions.newBuilder(endpoints, database)
4558
.writeMaxRetries(0)
59+
.rpcOptions(rpcOptions)
4660
.defaultStreamMaxWritePointsPerSecond(Integer.MAX_VALUE)
4761
.maxInFlightWritePoints(Integer.MAX_VALUE)
4862
.useZeroCopyWriteInBulkWrite(true)

0 commit comments

Comments
 (0)