6
6
import com .xxdb .multithreadedtablewriter .Callback ;
7
7
import com .xxdb .multithreadedtablewriter .MultithreadedTableWriter ;
8
8
import com .xxdb .route .AutoFitTableAppender ;
9
+ import com .xxdb .route .AutoFitTableUpsert ;
9
10
import junit .framework .Assert ;
10
11
import org .junit .After ;
11
12
import org .junit .Before ;
@@ -314,7 +315,20 @@ public void test_MultithreadedTableWriter_compress_morethan_cols() throws Except
314
315
assertEquals (ex .getMessage (),"The number of elements in parameter compressMethods does not match the column size 3" );
315
316
}
316
317
conn .run ("undef(`t1,SHARED)" );
317
-
318
+ }
319
+ @ Test (timeout = 120000 )
320
+ public void test_MultithreadedTableWriter_colType_not_match () throws Exception {
321
+ StringBuilder sb = new StringBuilder ();
322
+ sb .append ("t = table(1000:0, `date`idDFSDF121212中文`values_中文,[TIMESTAMP,INT,INT]);share t as t1;" );
323
+ conn .run (sb .toString ());
324
+ mutithreadTableWriter_ = new MultithreadedTableWriter (HOST , PORT , "admin" , "123456" ,
325
+ "" , "t1" , false , false , null , 10 ,2 ,5 , "date" );
326
+ ErrorCodeInfo pErrorInfo = mutithreadTableWriter_ .insert ( System .currentTimeMillis (), "A" , "A" );
327
+ assertEquals ("code=A1 info=Invalid object error when create scalar for column 'idDFSDF121212中文': Failed to insert data. Cannot convert String to DT_INT." ,pErrorInfo .toString ());
328
+ mutithreadTableWriter_ .waitForThreadCompletion ();
329
+ BasicTable bt = (BasicTable ) conn .run ("select * from t1;" );
330
+ assertEquals (0 , bt .rows ());
331
+ conn .run ("undef(`t1,SHARED)" );
318
332
}
319
333
320
334
@ Test (timeout = 120000 )
@@ -6640,7 +6654,6 @@ public void writeCompletion(Table callbackTable) {
6640
6654
//Assert.assertEquals(true,mtw.getStatus().unsentRows==0);
6641
6655
mtw .waitForThreadCompletion ();
6642
6656
try {conn1 .run ("startDataNode([\" " +HOST +":" +PORT +"\" ])" );
6643
-
6644
6657
}
6645
6658
catch (IOException ex ) {
6646
6659
System .out .println (ex .getMessage ());
@@ -7061,7 +7074,7 @@ public void test_MultithreadedTableWriter_batchSize_greater_than_Number_of_inse
7061
7074
}
7062
7075
}
7063
7076
//mtw.waitForThreadCompletion();
7064
- conn .run ("sleep(2000 )" );
7077
+ conn .run ("sleep(5000 )" );
7065
7078
System .out .println ("callback rows" );
7066
7079
7067
7080
@@ -7671,6 +7684,7 @@ public void test_MultithreadedTableWriter_allDataType_array_null() throws Except
7671
7684
conn .close ();
7672
7685
}
7673
7686
7687
+
7674
7688
// @Test(timeout = 120000)
7675
7689
// public void test_insert_haStreamTable() throws Exception {
7676
7690
// conn.run("haTableName='ha_stream'; " +
@@ -7689,5 +7703,33 @@ public void test_MultithreadedTableWriter_allDataType_array_null() throws Except
7689
7703
// assertEquals(10000,ex.rows());
7690
7704
// mutithreadTableWriter_.waitForThreadCompletion();
7691
7705
// }
7706
+
7707
+ // @Test(timeout = 120000)
7708
+ // public void test_mtw_enableHighAvailability_true() throws Exception {
7709
+ // DBConnection conn1 = new DBConnection();
7710
+ // conn1.connect(HOST,8802,"admin","123456");
7711
+ // conn1.run("share table(10:0,`id`price`val,[INT,DOUBLE,INT]) as table1;\n");
7712
+ //
7713
+ // DBConnection conn2 = new DBConnection();
7714
+ // conn2.connect(HOST,8803,"admin","123456");
7715
+ // conn2.run("share table(10:0,`id`price`val,[INT,DOUBLE,INT]) as table1;\n");
7716
+ //
7717
+ // //System.out.println("节点断掉");
7718
+ // //Thread.sleep(10000);
7719
+ // MultithreadedTableWriter mtw1 = new MultithreadedTableWriter(HOST, PORT, "admin", "123456", "", "table1",
7720
+ // false, true, ipports, 1000, 0.001f, 10, "id");
7721
+ // //检查线程连接情况
7722
+ // for(int i = 0;i <10000;i++) {
7723
+ // int tmp =5;
7724
+ // mtw1.insert(tmp, (double) tmp, 1);
7725
+ // Thread.sleep(100);
7726
+ // }
7727
+ // mtw1.waitForThreadCompletion();
7728
+ // //BasicInt writedData1 = (BasicInt) conn1.run("(exec count(*) from table1 where val = 1)[0]");
7729
+ // BasicInt writedData2 = (BasicInt) conn2.run("(exec count(*) from table1 where val = 1)[0]");
7730
+ // //System.out.println(writedData1);
7731
+ // System.out.println(writedData2);
7732
+ // }
7733
+
7692
7734
}
7693
7735
0 commit comments