Skip to content

JobReport.isJobComplete() not working #548

@srinathgit

Description

@srinathgit

The test below consists of documents getting loaded and a separate thread printing the job report snapshot at an interval of 3 seconds. It can be seen from the logs (as well as test as it runs forever) that the isJobComplete() method doesn't return true once the job is completed.

exception.txt

Test:

@Test
	public void testJobReport() throws Exception{
		
       	class MyRunnable implements Runnable {
       		
       	  @Override
       	  public void run() {
       		  boolean jobStatus = false;
         		while (!jobStatus){
         		 JobReport report = dmManager.getJobReport(jt);
         		  jobStatus =report.isJobComplete();
         		  System.out.println("Job complete: "+jobStatus);
	   			  System.out.println("batches: "     + report.getSuccessBatchesCount() +
	   			    ", docs: "           + report.getSuccessEventsCount() +
	   			    ", failed docs: "    + report.getFailureEventsCount() +
	   			    ", failed batches: " + report.getFailureBatchesCount());
	   			  try {
					Thread.currentThread().sleep(3000L);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
         			
         		}
       		
           		
       	} 
     	}
		try{
			final String query1 = "fn:count(fn:doc())";
			final AtomicInteger successCount = new AtomicInteger(0);
		    final AtomicInteger failCount = new AtomicInteger(0);
		    			        
			WriteBatcher ihb2 =  dmManager.newWriteBatcher();
			ihb2.withBatchSize(20);
			ihb2.withThreadCount(20);
	
							
			ihb2.onBatchSuccess(
			        batch -> {

			        	successCount.addAndGet(batch.getItems().length);
			           }
			        )
			        .onBatchFailure(
			          (batch, throwable) -> {
			        		        	
			        	 
			        	  throwable.printStackTrace();
			        	  failCount.addAndGet(batch.getItems().length);
			          });
			
			
			jt = dmManager.startJob(ihb2);
			
	
			
		 	Thread t1;
	     	t1 = new Thread(new MyRunnable());
			for (int j =0 ;j < 15000; j++){
				String uri ="/local/ABC-"+ j;
				ihb2.add(uri, stringHandle);
				if(j == 35){
				   	t1.start();
				
				}
				
			}
	
		    ihb2.flushAndWait();
		    
		   
		    
	    	System.out.println("Fail : "+failCount.intValue());
	    	System.out.println("Success : "+successCount.intValue());
	    	System.out.println("Count : "+ dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue());
	  
	    	Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue()==15000);
	    	JobReport report = dmManager.getJobReport(jt);
	    	System.out.println("Main thread : Job complete: "+ report.isJobComplete());
	    	t1.join();
			}
			catch(Exception e){
				e.printStackTrace();
			}
		
 	    	
		
		}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions