@@ -280,6 +280,8 @@ public void testAndWordQueryWithMultipleForests() throws Exception
280280 {
281281 String testMultipleDB = "QBMultipleForestDB" ;
282282 String [] testMultipleForest = {"QBMultipleForestDB-1" , "QBMultipleForestDB-2" , "QBMultipleForestDB-3" };
283+ DatabaseClient clientTmp = null ;
284+ DataMovementManager dmManagerTmp = null ;
283285
284286 try {
285287 System .out .println ("Running testAndWordQueryWithMultipleForests" );
@@ -291,19 +293,22 @@ public void testAndWordQueryWithMultipleForests() throws Exception
291293 associateRESTServerWithDB (restServerName , testMultipleDB );
292294
293295 setupAppServicesConstraint (testMultipleDB );
296+ Thread .sleep (10000 );
294297
295298 String [] filenames = {"constraint1.xml" , "constraint2.xml" , "constraint3.xml" , "constraint4.xml" , "constraint5.xml" };
296299 String queryOptionName = "absRangeConstraintWithVariousGrammarAndWordQueryOpt.xml" ;
300+ clientTmp = DatabaseClientFactory .newClient (restServerHost , restServerPort , "eval-user" , "x" , Authentication .DIGEST );
301+ dmManagerTmp = clientTmp .newDataMovementManager ();
297302
298- setQueryOption (clientQHB , queryOptionName );
303+ setQueryOption (clientTmp , queryOptionName );
299304
300- QueryManager queryMgr = clientQHB .newQueryManager ();
305+ QueryManager queryMgr = clientTmp .newQueryManager ();
301306
302307 StringQueryDefinition querydef = queryMgr .newStringDefinition ();
303308 querydef .setCriteria ("0012" );
304309
305310 //Use WriteBatcher to write the same files.
306- WriteBatcher batcher = dmManager .newWriteBatcher ();
311+ WriteBatcher batcher = dmManagerTmp .newWriteBatcher ();
307312
308313 batcher .withBatchSize (2 );
309314 InputStreamHandle contentHandle1 = new InputStreamHandle ();
@@ -332,7 +337,7 @@ public void testAndWordQueryWithMultipleForests() throws Exception
332337 StringBuilder batchFailResults = new StringBuilder ();
333338
334339 // Run a QueryBatcher on the new URIs.
335- QueryBatcher queryBatcher1 = dmManager .newQueryBatcher (querydef );
340+ QueryBatcher queryBatcher1 = dmManagerTmp .newQueryBatcher (querydef );
336341
337342 queryBatcher1 .onUrisReady (batch -> {
338343 for (String str : batch .getItems ()) {
@@ -346,7 +351,7 @@ public void testAndWordQueryWithMultipleForests() throws Exception
346351 batchFailResults .append ("Test has Exceptions" );
347352 } );
348353
349- JobTicket jobTicket = dmManager .startJob (queryBatcher1 );
354+ JobTicket jobTicket = dmManagerTmp .startJob (queryBatcher1 );
350355 boolean bJobFinished = queryBatcher1 .awaitTermination (3 , TimeUnit .MINUTES );
351356
352357 if (queryBatcher1 .isStopped ()) {
@@ -374,6 +379,8 @@ public void testAndWordQueryWithMultipleForests() throws Exception
374379
375380 deleteForest (testMultipleForest [0 ]);
376381 deleteForest (testMultipleForest [1 ]);
382+ Thread .sleep (10000 );
383+ clientTmp .release ();
377384 }
378385 }
379386
@@ -1149,6 +1156,7 @@ public void testQueryBatcherWithForestRemoveAndAdd() throws IOException, Interru
11491156 deleteForest (testMultipleForest [0 ]);
11501157 deleteForest (testMultipleForest [1 ]);
11511158 deleteForest (testMultipleForest [2 ]);
1159+ Thread .sleep (10000 );
11521160 }
11531161 }
11541162
@@ -1268,6 +1276,7 @@ public void testBatchClientLookupTimeout() throws IOException, InterruptedExcept
12681276 detachForest (testMultipleDB , testMultipleForest [0 ]);
12691277 deleteDB (testMultipleDB );
12701278 deleteForest (testMultipleForest [0 ]);
1279+ Thread .sleep (10000 );
12711280 }
12721281 }
12731282
@@ -1386,6 +1395,8 @@ public void testQueryBatcherJobDetails() throws Exception
13861395 {
13871396 String testMultipleDB = "QHBJobDetaitDB" ;
13881397 String [] testMultipleForest = {"QHBJobDetaitDB-1" };
1398+ DatabaseClient clientTmp = null ;
1399+ DataMovementManager dmManagerTmp = null ;
13891400
13901401 try {
13911402 System .out .println ("Running testQueryBatcherJobDetails" );
@@ -1396,19 +1407,22 @@ public void testQueryBatcherJobDetails() throws Exception
13961407 associateRESTServerWithDB (restServerName , testMultipleDB );
13971408
13981409 setupAppServicesConstraint (testMultipleDB );
1410+ Thread .sleep (10000 );
13991411
14001412 String [] filenames = {"constraint1.xml" , "constraint2.xml" , "constraint3.xml" , "constraint4.xml" , "constraint5.xml" };
14011413 String queryOptionName = "absRangeConstraintWithVariousGrammarAndWordQueryOpt.xml" ;
1414+ clientTmp = DatabaseClientFactory .newClient (restServerHost , restServerPort , "eval-user" , "x" , Authentication .DIGEST );
1415+ dmManagerTmp = clientTmp .newDataMovementManager ();
14021416
1403- setQueryOption (clientQHB , queryOptionName );
1417+ setQueryOption (clientTmp , queryOptionName );
14041418
1405- QueryManager queryMgr = clientQHB .newQueryManager ();
1419+ QueryManager queryMgr = clientTmp .newQueryManager ();
14061420
14071421 StringQueryDefinition querydef = queryMgr .newStringDefinition ();
14081422 querydef .setCriteria ("0012" );
14091423
14101424 //Use WriteBatcher to write the same files.
1411- WriteBatcher batcher = dmManager .newWriteBatcher ();
1425+ WriteBatcher batcher = dmManagerTmp .newWriteBatcher ();
14121426
14131427 batcher .withBatchSize (2 );
14141428 InputStreamHandle contentHandle1 = new InputStreamHandle ();
@@ -1438,7 +1452,7 @@ public void testQueryBatcherJobDetails() throws Exception
14381452 StringBuilder batchFailResults = new StringBuilder ();
14391453
14401454 // Run a QueryBatcher on the new URIs.
1441- QueryBatcher queryBatcher1 = dmManager .newQueryBatcher (querydef );
1455+ QueryBatcher queryBatcher1 = dmManagerTmp .newQueryBatcher (querydef );
14421456
14431457 queryBatcher1 .onUrisReady (batch -> {
14441458 for (String str : batch .getItems ()) {
@@ -1471,7 +1485,7 @@ public void testQueryBatcherJobDetails() throws Exception
14711485 batchFailResults .append ("Test has Exceptions" );
14721486 } );
14731487
1474- JobTicket jobTicket = dmManager .startJob (queryBatcher1 );
1488+ JobTicket jobTicket = dmManagerTmp .startJob (queryBatcher1 );
14751489 String jobId = jobTicket .getJobId ();
14761490 String jobName = jobTicket .getJobType ().name ();
14771491
@@ -1519,6 +1533,8 @@ public void testQueryBatcherJobDetails() throws Exception
15191533 deleteDB (testMultipleDB );
15201534
15211535 deleteForest (testMultipleForest [0 ]);
1536+ Thread .sleep (10000 );
1537+ clientTmp .release ();
15221538 }
15231539 }
15241540
@@ -1534,32 +1550,38 @@ public void testDifferentQueryTypes() throws Exception
15341550 {
15351551 String testMultipleDB = "QBtestDifferentQueryTypesDB" ;
15361552 String [] testMultipleForest = {"QBtestDifferentQueryTypesDB-1" };
1553+ DatabaseClient clientTmp = null ;
1554+ DataMovementManager dmManagerTmp = null ;
15371555
15381556 try {
15391557 System .out .println ("Running testDifferentQueryTypes" );
15401558
15411559 //Setup a separate database/
1542- createDB (testMultipleDB );
1543- createForest (testMultipleForest [0 ], testMultipleDB );
1544-
1560+ createDB (testMultipleDB );
1561+ createForest (testMultipleForest [0 ], testMultipleDB );
15451562 associateRESTServerWithDB (restServerName , testMultipleDB );
1546-
1563+
1564+ // Setup constraints on DB and wait for indexes to setup.
15471565 setupAppServicesConstraint (testMultipleDB );
1566+ Thread .sleep (10000 );
15481567
15491568 String [] filenames = {"constraint1.xml" , "constraint2.xml" , "constraint3.xml" , "constraint4.xml" , "constraint5.xml" };
15501569 ServerConfigurationManager srvMgr = client .newServerConfigManager ();
15511570 srvMgr .readConfiguration ();
15521571 srvMgr .setQueryOptionValidation (true );
15531572 srvMgr .writeConfiguration ();
1573+
1574+ clientTmp = DatabaseClientFactory .newClient (restServerHost , restServerPort , "eval-user" , "x" , Authentication .DIGEST );
1575+ dmManagerTmp = clientTmp .newDataMovementManager ();
15541576
1555- QueryManager queryMgr = clientQHB .newQueryManager ();
1577+ QueryManager queryMgr = clientTmp .newQueryManager ();
15561578
15571579 // create query def
15581580 StructuredQueryBuilder qb = queryMgr .newStructuredQueryBuilder ();
15591581 StructuredQueryDefinition queryWorddef = qb .word (qb .element ("id" ), "0026" );
15601582
1561- //Use WriteBatcher to write the same files.
1562- WriteBatcher batcher = dmManager .newWriteBatcher ();
1583+ //Use WriteBatcher to write the some files.
1584+ WriteBatcher batcher = dmManagerTmp .newWriteBatcher ();
15631585
15641586 batcher .withBatchSize (2 );
15651587 InputStreamHandle contentHandle1 = new InputStreamHandle ();
@@ -1581,12 +1603,13 @@ public void testDifferentQueryTypes() throws Exception
15811603
15821604 // Flush
15831605 batcher .flushAndWait ();
1606+ //batcher.awaitCompletion();
15841607
15851608 StringBuilder batchWordResults = new StringBuilder ();
15861609 StringBuilder batchWordFailResults = new StringBuilder ();
15871610
15881611 // Run a QueryBatcher on the new URIs.
1589- QueryBatcher queryBatcher1 = dmManager .newQueryBatcher (queryWorddef );
1612+ QueryBatcher queryBatcher1 = dmManagerTmp .newQueryBatcher (queryWorddef );
15901613
15911614 queryBatcher1 .onUrisReady (batch -> {
15921615 for (String str : batch .getItems ()) {
@@ -1599,7 +1622,7 @@ public void testDifferentQueryTypes() throws Exception
15991622 throwable .printStackTrace ();
16001623 batchWordFailResults .append ("Test has Exceptions" );
16011624 } );
1602- JobTicket jobTicket = dmManager .startJob (queryBatcher1 );
1625+ JobTicket jobTicket = dmManagerTmp .startJob (queryBatcher1 );
16031626 boolean bJobFinished = queryBatcher1 .awaitTermination (3 , TimeUnit .MINUTES );
16041627 while (!queryBatcher1 .isStopped ()) {
16051628 // do nothing.
@@ -1620,7 +1643,7 @@ public void testDifferentQueryTypes() throws Exception
16201643 // Run a range query.
16211644
16221645 StructuredQueryDefinition queryRangedef = qb .range (qb .element ("popularity" ), "xs:integer" , Operator .GE , 4 );
1623- QueryBatcher queryBatcher2 = dmManager .newQueryBatcher (queryRangedef );
1646+ QueryBatcher queryBatcher2 = dmManagerTmp .newQueryBatcher (queryRangedef );
16241647 //StringBuilder batchRangeResults = new StringBuilder();
16251648 List <String > batchRangeResults = new ArrayList <String >();
16261649 StringBuilder batchRangeFailResults = new StringBuilder ();
@@ -1637,7 +1660,7 @@ public void testDifferentQueryTypes() throws Exception
16371660 throwable .printStackTrace ();
16381661 batchRangeFailResults .append ("Test has Exceptions" );
16391662 } );
1640- jobTicket = dmManager .startJob (queryBatcher2 );
1663+ jobTicket = dmManagerTmp .startJob (queryBatcher2 );
16411664 bJobFinished = queryBatcher2 .awaitTermination (3 , TimeUnit .MINUTES );
16421665 while (!queryBatcher2 .isStopped ()) {
16431666 // do nothing.
@@ -1660,7 +1683,7 @@ public void testDifferentQueryTypes() throws Exception
16601683 // Run a ValueQueryOnAttribute query.
16611684
16621685 StructuredQueryDefinition valuequeyDef = qb .value (qb .elementAttribute (qb .element (new QName ("http://cloudbank.com" , "price" )), qb .attribute ("amt" )), "0.1" );
1663- QueryBatcher queryBatcher3 = dmManager .newQueryBatcher (valuequeyDef );
1686+ QueryBatcher queryBatcher3 = dmManagerTmp .newQueryBatcher (valuequeyDef );
16641687 //StringBuilder batchRangeResults = new StringBuilder();
16651688 List <String > batchValueResults = new ArrayList <String >();
16661689 StringBuilder batchvalueFailResults = new StringBuilder ();
@@ -1675,7 +1698,7 @@ public void testDifferentQueryTypes() throws Exception
16751698 throwable .printStackTrace ();
16761699 batchvalueFailResults .append ("Test has Exceptions" );
16771700 } );
1678- jobTicket = dmManager .startJob (queryBatcher3 );
1701+ jobTicket = dmManagerTmp .startJob (queryBatcher3 );
16791702 bJobFinished = queryBatcher3 .awaitTermination (3 , TimeUnit .MINUTES );
16801703 while (!queryBatcher3 .isStopped ()) {
16811704 // do nothing.
@@ -1702,6 +1725,8 @@ public void testDifferentQueryTypes() throws Exception
17021725 detachForest (testMultipleDB , testMultipleForest [0 ]);
17031726 deleteDB (testMultipleDB );
17041727 deleteForest (testMultipleForest [0 ]);
1728+ clientTmp .release ();
1729+ Thread .sleep (10000 );
17051730 }
17061731 }
17071732}
0 commit comments