mirror of
https://github.com/alibaba/DataX.git
synced 2025-05-02 15:49:13 +08:00
change test case
This commit is contained in:
parent
5da6e34d5c
commit
ff87a6bcff
@ -38,7 +38,7 @@ public class JniConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public long open(String host, int port, String dbname, String user, String password) {
|
||||
public void open(String host, int port, String dbname, String user, String password) {
|
||||
if (this.psql != JNI_NULL_POINTER) {
|
||||
close();
|
||||
this.psql = JNI_NULL_POINTER;
|
||||
@ -49,7 +49,13 @@ public class JniConnection {
|
||||
String errMsg = getErrMsgImp(0);
|
||||
throw new RuntimeException(errMsg);
|
||||
}
|
||||
return this.psql;
|
||||
}
|
||||
|
||||
public long insertOpentsdbJson(String json) {
|
||||
if (this.psql == JNI_NULL_POINTER) {
|
||||
throw new RuntimeException("JNI connection is NULL");
|
||||
}
|
||||
return insertOpentsdbJson(json, this.psql);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
@ -73,11 +73,6 @@ public class TDengineWriter extends Writer {
|
||||
String user = this.writerSliceConfig.getString(USER);
|
||||
String password = this.writerSliceConfig.getString(PASSWORD);
|
||||
|
||||
JniConnection connection = new JniConnection(new Properties());
|
||||
long psql = connection.open(host, port, dbname, user, password);
|
||||
System.out.println("psql: " + psql);
|
||||
connection.close();
|
||||
|
||||
try {
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out, StandardCharsets.UTF_8));
|
||||
|
||||
|
@ -81,6 +81,14 @@ JNIEXPORT jint JNICALL Java_com_alibaba_datax_plugin_writer_JniConnection_getAff
|
||||
JNIEXPORT jint JNICALL Java_com_alibaba_datax_plugin_writer_JniConnection_closeConnectionImp
|
||||
(JNIEnv *, jobject, jlong);
|
||||
|
||||
/*
|
||||
* Class: com_alibaba_datax_plugin_writer_JniConnection
|
||||
* Method: insertOpentsdbJson
|
||||
* Signature: (Ljava/lang/String;J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_com_alibaba_datax_plugin_writer_JniConnection_insertOpentsdbJson
|
||||
(JNIEnv *, jobject, jstring, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -10,8 +10,10 @@ public class JniConnectionTest {
|
||||
public void test() {
|
||||
JniConnection connection = new JniConnection(new Properties());
|
||||
|
||||
long psql = connection.open("192.168.56.107", 6030, "log", "root", "taosdata");
|
||||
System.out.println("psql: " + psql);
|
||||
connection.open("192.168.56.105", 6030, "log", "root", "taosdata");
|
||||
|
||||
String json = "{\"metric\":\"weather.temperature\",\"timestamp\":1609430400000,\"value\":123,\"tags\":{\"location\":\"beijing\",\"id\":123}}";
|
||||
connection.insertOpentsdbJson(json);
|
||||
|
||||
connection.close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user