28
28
29
29
import static com .xxdb .Prepare .*;
30
30
import static com .xxdb .comm .SqlStdEnum .*;
31
+ import static java .lang .Thread .sleep ;
31
32
import static org .junit .Assert .*;
32
33
33
34
public class DBConnectionTest {
@@ -2544,7 +2545,7 @@ public void TestPartitionTable() throws IOException, InterruptedException {
2544
2545
sb .append ("pt.append!(t1);" );
2545
2546
conn .run (sb .toString ());
2546
2547
conn .run ("pnodeRun(purgeCacheEngine)" );
2547
- Thread . sleep (5000 );
2548
+ sleep (5000 );
2548
2549
BasicLong res_x = (BasicLong ) conn .run ("exec count(*) from pt where x=1" );
2549
2550
assertEquals (true , res_x .getLong () > 0 );
2550
2551
//PartitionTableJoin
@@ -2636,10 +2637,10 @@ public void TestCloseOnce() throws IOException, InterruptedException {
2636
2637
DBConnection connClose = new DBConnection ();
2637
2638
//连接一次
2638
2639
connClose .connect (HOST , PORT , "admin" , "123456" );
2639
- Thread . sleep (5000 );
2640
+ sleep (5000 );
2640
2641
int connCount = getConnCount ();
2641
2642
connClose .close ();
2642
- Thread . sleep (5000 );
2643
+ sleep (5000 );
2643
2644
int connCount1 = getConnCount ();
2644
2645
assertEquals (connCount - 1 , connCount1 );
2645
2646
}
@@ -2658,10 +2659,10 @@ public void TestClose() throws IOException, InterruptedException {
2658
2659
}
2659
2660
2660
2661
}
2661
- Thread . sleep (2000 );
2662
+ sleep (2000 );
2662
2663
int connCount = getConnCount ();
2663
2664
connNew .close ();
2664
- Thread . sleep (2000 );
2665
+ sleep (2000 );
2665
2666
int connCount1 = getConnCount ();
2666
2667
assertEquals (connCount - 1 , connCount1 );
2667
2668
}
@@ -3457,7 +3458,7 @@ public void run() {
3457
3458
Timer timer = new Timer ("Timer" );
3458
3459
TimerTask rec = new reconnect ();
3459
3460
timer .scheduleAtFixedRate (rec , 0L , 500L );
3460
- Thread . sleep (500L );
3461
+ sleep (500L );
3461
3462
timer .cancel ();
3462
3463
}
3463
3464
@@ -3553,7 +3554,7 @@ public void test_TryRun_fetchSize() throws IOException, InterruptedException {
3553
3554
conn .tryRun ("x;" ,1 ,1 ,8192 ,true );
3554
3555
long afterDT = System .currentTimeMillis ();
3555
3556
System .out .println (afterDT -beforeDT );
3556
- Thread . sleep (5000 );
3557
+ sleep (5000 );
3557
3558
conn .run ("y=1..10000000" );
3558
3559
long startDT = System .currentTimeMillis ();
3559
3560
conn .tryRun ("y;" ,1 ,1 ,1000000 ,true );
@@ -3686,7 +3687,7 @@ public void test_TryRun_args_fetchSize() throws IOException, InterruptedExceptio
3686
3687
conn .tryRun ("sum" ,argus1 ,1 ,1 ,8192 );
3687
3688
long afterDT = System .currentTimeMillis ();
3688
3689
System .out .println (afterDT -beforeDT );
3689
- Thread . sleep (10000 );
3690
+ sleep (10000 );
3690
3691
List <Entity > argus2 = new ArrayList <>();
3691
3692
conn .run ("y=1..10000000" );
3692
3693
argus2 .add (conn .run ("y;" ));
@@ -4289,7 +4290,7 @@ public void test_insert_into_decimal128_arrayvector() throws Exception {
4289
4290
public void TestConnectWithoutUserid () throws IOException , InterruptedException {
4290
4291
DBConnection conn = new DBConnection ();
4291
4292
conn .connect (HOST ,PORT );
4292
- Thread . sleep (500 );
4293
+ sleep (500 );
4293
4294
assertEquals (true , conn .isConnected ());
4294
4295
}
4295
4296
@ Test
@@ -4308,7 +4309,7 @@ public void Test_connect_EnableHighAvailability_false() throws IOException, Inte
4308
4309
}
4309
4310
//DBConnection conn1 = new DBConnection();
4310
4311
conn1 .connect (HOST ,PORT ,"admin" ,"123456" ,null ,false );
4311
- Thread . sleep (500 );
4312
+ sleep (500 );
4312
4313
String e = null ;
4313
4314
try {
4314
4315
conn1 .run ("a=1;\n a" );
@@ -4318,14 +4319,14 @@ public void Test_connect_EnableHighAvailability_false() throws IOException, Inte
4318
4319
System .out .println (ex );
4319
4320
}
4320
4321
assertNotNull (e );
4321
- Thread . sleep (1000 );
4322
+ sleep (1000 );
4322
4323
try {
4323
4324
conn .run ("startDataNode(\" " +nodeAlias +"\" )" );
4324
4325
}catch (Exception ex )
4325
4326
{
4326
4327
System .out .println (ex );
4327
4328
}
4328
- Thread . sleep (1000 );
4329
+ sleep (1000 );
4329
4330
conn1 .connect (HOST ,PORT ,"admin" ,"123456" ,null ,false );
4330
4331
conn1 .run ("a=1;\n a" );
4331
4332
assertEquals (true , conn1 .isConnected ());
@@ -4345,7 +4346,7 @@ public void Test_connect_EnableHighAvailability_true() throws IOException, Inter
4345
4346
{
4346
4347
System .out .println (ex );
4347
4348
}
4348
- Thread . sleep (1000 );
4349
+ sleep (1000 );
4349
4350
conn1 .run ("a=1;\n a" );
4350
4351
//The connection switches to a different node to execute the code
4351
4352
try {
@@ -4354,7 +4355,7 @@ public void Test_connect_EnableHighAvailability_true() throws IOException, Inter
4354
4355
{
4355
4356
System .out .println (ex );
4356
4357
}
4357
- Thread . sleep (1000 );
4358
+ sleep (1000 );
4358
4359
assertEquals (true , conn1 .isConnected ());
4359
4360
}
4360
4361
//@Test //AJ-287
@@ -4393,7 +4394,7 @@ public void Test_connect_EnableHighAvailability_true_1() throws IOException, Int
4393
4394
{
4394
4395
System .out .println (ex );
4395
4396
}
4396
- Thread . sleep (1000 );
4397
+ sleep (1000 );
4397
4398
conn1 .run ("a=1;\n a" );
4398
4399
//The connection switches to a different node to execute the code
4399
4400
try {
@@ -4402,7 +4403,7 @@ public void Test_connect_EnableHighAvailability_true_1() throws IOException, Int
4402
4403
{
4403
4404
System .out .println (ex );
4404
4405
}
4405
- Thread . sleep (1000 );
4406
+ sleep (1000 );
4406
4407
assertEquals (true , conn1 .isConnected ());
4407
4408
}
4408
4409
@ Test
@@ -4417,7 +4418,7 @@ public void Test_reConnect__true() throws IOException, InterruptedException {
4417
4418
{
4418
4419
System .out .println (ex );
4419
4420
}
4420
- Thread . sleep (1000 );
4421
+ sleep (1000 );
4421
4422
conn1 .run ("a=1;\n a" );
4422
4423
//The connection switches to a different node to execute the code
4423
4424
try {
@@ -4426,7 +4427,7 @@ public void Test_reConnect__true() throws IOException, InterruptedException {
4426
4427
{
4427
4428
System .out .println (ex );
4428
4429
}
4429
- Thread . sleep (1000 );
4430
+ sleep (1000 );
4430
4431
assertEquals (true , conn1 .isConnected ());
4431
4432
}
4432
4433
@ Test //reConnect is not valid
@@ -4441,7 +4442,7 @@ public void Test_reConnect__false() throws IOException, InterruptedException {
4441
4442
{
4442
4443
System .out .println (ex );
4443
4444
}
4444
- Thread . sleep (1000 );
4445
+ sleep (1000 );
4445
4446
conn1 .run ("a=1;\n a" );
4446
4447
//The connection switches to a different node to execute the code
4447
4448
try {
@@ -4450,7 +4451,7 @@ public void Test_reConnect__false() throws IOException, InterruptedException {
4450
4451
{
4451
4452
System .out .println (ex );
4452
4453
}
4453
- Thread . sleep (1000 );
4454
+ sleep (1000 );
4454
4455
assertEquals (true , conn1 .isConnected ());
4455
4456
}
4456
4457
//@Test
@@ -4492,7 +4493,7 @@ public void test_BasicDBTask1223()throws Exception{
4492
4493
public void Test_Connect_SqlStdEnum_DolphinDB () throws IOException , InterruptedException {
4493
4494
DBConnection conn = new DBConnection (DolphinDB );
4494
4495
conn .connect (HOST ,PORT );
4495
- Thread . sleep (500 );
4496
+ sleep (500 );
4496
4497
assertEquals (true , conn .isConnected ());
4497
4498
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("cumavg(1 2 3);" );
4498
4499
System .out .println (ba .getString ());
@@ -4510,7 +4511,7 @@ public void Test_Connect_SqlStdEnum_DolphinDB() throws IOException, InterruptedE
4510
4511
public void Test_Connect_SqlStdEnum_DolphinDB_1 () throws IOException , InterruptedException {
4511
4512
DBConnection conn = new DBConnection ();
4512
4513
conn .connect (HOST ,PORT );
4513
- Thread . sleep (500 );
4514
+ sleep (500 );
4514
4515
assertEquals (true , conn .isConnected ());
4515
4516
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'ddb')" );
4516
4517
System .out .println (ba .getString ());
@@ -4528,7 +4529,7 @@ public void Test_Connect_SqlStdEnum_DolphinDB_1() throws IOException, Interrupte
4528
4529
public void Test_Connect_SqlStdEnum_DolphinDB_2 () throws IOException , InterruptedException {
4529
4530
DBConnection conn = new DBConnection (DolphinDB );
4530
4531
conn .connect (HOST ,PORT );
4531
- Thread . sleep (500 );
4532
+ sleep (500 );
4532
4533
assertEquals (true , conn .isConnected ());
4533
4534
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'ddb')" );
4534
4535
System .out .println (ba .getString ());
@@ -4567,7 +4568,7 @@ public void Test_Connect_SqlStdEnum_Oracle() throws IOException, InterruptedExce
4567
4568
DBConnection conn = new DBConnection (Oracle );
4568
4569
conn .connect (HOST ,PORT );
4569
4570
conn .connect (HOST ,PORT );
4570
- Thread . sleep (500 );
4571
+ sleep (500 );
4571
4572
assertEquals (true , conn .isConnected ());
4572
4573
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("cumavg(1 2 3);" );
4573
4574
System .out .println (ba .getString ());
@@ -4589,7 +4590,7 @@ public void Test_Connect_SqlStdEnum_Oracle_1() throws IOException, InterruptedEx
4589
4590
DBConnection conn = new DBConnection ();
4590
4591
conn .connect (HOST ,PORT );
4591
4592
conn .connect (HOST ,PORT );
4592
- Thread . sleep (500 );
4593
+ sleep (500 );
4593
4594
assertEquals (true , conn .isConnected ());
4594
4595
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'oracle');" );
4595
4596
System .out .println (ba .getString ());
@@ -4611,7 +4612,7 @@ public void Test_Connect_SqlStdEnum_Oracle_2() throws IOException, InterruptedEx
4611
4612
DBConnection conn = new DBConnection (Oracle );
4612
4613
conn .connect (HOST ,PORT );
4613
4614
conn .connect (HOST ,PORT );
4614
- Thread . sleep (500 );
4615
+ sleep (500 );
4615
4616
assertEquals (true , conn .isConnected ());
4616
4617
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'ddb');" );
4617
4618
System .out .println (ba .getString ());
@@ -4632,7 +4633,7 @@ public void Test_Connect_SqlStdEnum_Oracle_2() throws IOException, InterruptedEx
4632
4633
public void Test_Connect_SqlStdEnum_MySQL () throws IOException , InterruptedException {
4633
4634
DBConnection conn = new DBConnection (MySQL );
4634
4635
conn .connect (HOST ,PORT );
4635
- Thread . sleep (500 );
4636
+ sleep (500 );
4636
4637
assertEquals (true , conn .isConnected ());
4637
4638
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("cumavg(1 2 3);" );
4638
4639
System .out .println (ba .getString ());
@@ -4658,7 +4659,7 @@ public void Test_Connect_SqlStdEnum_MySQL() throws IOException, InterruptedExcep
4658
4659
public void Test_Connect_SqlStdEnum_MySQL_1 () throws IOException , InterruptedException {
4659
4660
DBConnection conn = new DBConnection ();
4660
4661
conn .connect (HOST ,PORT );
4661
- Thread . sleep (500 );
4662
+ sleep (500 );
4662
4663
assertEquals (true , conn .isConnected ());
4663
4664
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'mysql');" );
4664
4665
System .out .println (ba .getString ());
@@ -4685,7 +4686,7 @@ public void Test_Connect_SqlStdEnum_MySQL_2() throws IOException, InterruptedExc
4685
4686
DBConnection conn = new DBConnection (MySQL );
4686
4687
conn .connect (HOST ,PORT );
4687
4688
conn .connect (HOST ,PORT );
4688
- Thread . sleep (500 );
4689
+ sleep (500 );
4689
4690
assertEquals (true , conn .isConnected ());
4690
4691
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'ddb');" );
4691
4692
System .out .println (ba .getString ());
@@ -4717,7 +4718,7 @@ public void Test_Connect_SqlStdEnum_getByName() throws IOException, InterruptedE
4717
4718
DBConnection conn = new DBConnection ( getByName ("MySQL" ));
4718
4719
conn .connect (HOST ,PORT );
4719
4720
conn .connect (HOST ,PORT );
4720
- Thread . sleep (500 );
4721
+ sleep (500 );
4721
4722
assertEquals (true , conn .isConnected ());
4722
4723
BasicDoubleVector ba = (BasicDoubleVector )conn .run ("runSQL(\" cumavg(1 2 3)\" , 'ddb');" );
4723
4724
System .out .println (ba .getString ());
@@ -5092,4 +5093,45 @@ public void test_allDateType_array_combine() throws IOException {
5092
5093
// thread1.start();
5093
5094
// thread.join();
5094
5095
// }
5096
+
5097
+ @ Test //api设置的parallelism小于server的setMaxJobParallelism
5098
+ public void test_DBConnection_run_parallelism_1 () throws IOException {
5099
+ PrepareUser ("parallelism_test" ,"123456" );
5100
+ conn = new DBConnection ();
5101
+ conn .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5102
+ conn .run ("setMaxJobParallelism(\" parallelism_test\" ,22);" ,4 ,5 ,false );
5103
+
5104
+ DBConnection conn1 = new DBConnection ();
5105
+ conn1 .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5106
+ BasicTable re1 = (BasicTable )conn .run ("getConsoleJobs();" ,4 ,5 ,false );
5107
+ Assert .assertEquals ("5" ,re1 .getColumn (6 ).get (0 ).getString ());
5108
+ }
5109
+ @ Test //api设置的parallelism大于server的setMaxJobParallelism
5110
+ public void test_DBConnection_run_parallelism_2 () throws IOException {
5111
+ PrepareUser ("parallelism_test" ,"123456" );
5112
+ conn = new DBConnection ();
5113
+ conn .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5114
+ conn .run ("setMaxJobParallelism(\" parallelism_test\" ,22);" ,4 ,30 ,false );
5115
+
5116
+ DBConnection conn1 = new DBConnection ();
5117
+ conn1 .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5118
+ BasicTable re1 = (BasicTable )conn1 .run ("getConsoleJobs();" ,5 ,30 ,false );
5119
+ Assert .assertEquals ("22" ,re1 .getColumn (6 ).get (0 ).getString ());
5120
+ }
5121
+
5122
+ @ Test //api没有设置parallelism,取默认值64,大于server的setMaxJobParallelism
5123
+ public void test_DBConnection_run_parallelism_3 () throws IOException , InterruptedException {
5124
+ DBConnection conn = new DBConnection ();
5125
+ PrepareUser ("parallelism_test" ,"123456" );
5126
+ conn .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5127
+ conn .run ("setMaxJobParallelism(\" parallelism_test\" ,22);" );
5128
+ BasicTable re = (BasicTable )conn .run ("getConsoleJobs();" );
5129
+ System .out .println (re .getString ());
5130
+
5131
+ DBConnection conn1 = new DBConnection ();
5132
+ conn1 .connect (HOST ,PORT ,"parallelism_test" ,"123456" );
5133
+ BasicTable re1 = (BasicTable )conn1 .run ("getConsoleJobs();" );
5134
+ System .out .println (re1 .getString ());
5135
+ Assert .assertEquals ("22" ,re1 .getColumn (6 ).get (0 ).getString ());
5136
+ }
5095
5137
}
0 commit comments