org.pentaho.di.job.Job.isStopped()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中org.pentaho.di.job.Job.isStopped()方法的一些代码示例,展示了Job.isStopped()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job.isStopped()方法的具体详情如下:
包路径:org.pentaho.di.job.Job
类名称:Job
方法名:isStopped

Job.isStopped介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public void waitUntilFinished() {
  while ( !isFinished() && !job.isStopped() ) {
   try {
    Thread.sleep( 0, 1 );
   } catch ( InterruptedException e ) {
    // Ignore errors
   }
  }
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
 public void testWaitUntilFinished() throws Exception {
  when( mockJob.isStopped() ).thenReturn( true );
  when( mockJob.getParentJob() ).thenReturn( parentJob );
  when( parentJob.isStopped() ).thenReturn( false );
  when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
  jobRunner.waitUntilFinished();
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRunSetsResult() throws Exception {
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( parentJob.isStopped() ).thenReturn( false );
 when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
 jobRunner.run();
 verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRunWithExceptionOnExecuteSetsResult() throws Exception {
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( parentJob.isStopped() ).thenReturn( false );
 doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) );
 jobRunner.run();
 verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Before
public void setUp() throws Exception {
 parentJob = mock( Job.class );
 doReturn( false ).when( parentJob ).isStopped();
 jobEntry = new JobEntryWriteToLog();
 jobEntry = spy( jobEntry );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRunWithExceptionOnExecuteAndFireJobSetsResult() throws KettleException {
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( parentJob.isStopped() ).thenReturn( false );
 when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
 doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) );
 doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners();
 jobRunner.run();
 verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) );
 assertTrue( jobRunner.isFinished() );
}

代码示例来源:origin: pentaho/pentaho-kettle

public String getStatus() {
 String message;
 if ( isActive() ) {
  if ( isStopped() ) {
   message = Trans.STRING_HALTING;
  } else {
   message = Trans.STRING_RUNNING;
  }
 } else if ( isFinished() ) {
  message = Trans.STRING_FINISHED;
  if ( getResult().getNrErrors() > 0 ) {
   message += " (with errors)";
  }
 } else if ( isStopped() ) {
  message = Trans.STRING_STOPPED;
  if ( getResult().getNrErrors() > 0 ) {
   message += " (with errors)";
  }
 } else {
  message = Trans.STRING_WAITING;
 }
 return message;
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRunWithExceptionOnFireJobSetsResult() throws KettleException {
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( parentJob.isStopped() ).thenReturn( false );
 when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
 doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners();
 jobRunner.run();
 verify( mockJob, times( 1 ) ).setResult( Mockito.any( Result.class ) );
 assertTrue( jobRunner.isFinished() );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRunWithException() throws Exception {
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( mockJob.getJobMeta() ).thenReturn( mockJobMeta );
 when( parentJob.isStopped() ).thenReturn( false );
 doThrow( KettleException.class ).when( mockJob ).execute( anyInt(), any( Result.class ) );
 jobRunner.run();
 verify( mockResult, times( 1 ) ).setNrErrors( Mockito.anyInt() );
 //[PDI-14981] catch more general exception to prevent thread hanging
 doThrow( Exception.class ).when( mockJob ).fireJobFinishListeners();
 jobRunner.run();
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testRun() throws Exception {
 // Call all the NO-OP paths
 when( mockJob.isStopped() ).thenReturn( true );
 jobRunner.run();
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( null );
 when( mockJob.getJobMeta() ).thenReturn( mockJobMeta );
 jobRunner.run();
 when( parentJob.isStopped() ).thenReturn( true );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 jobRunner.run();
 when( parentJob.isStopped() ).thenReturn( false );
 when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
 jobRunner.run();
}

代码示例来源:origin: pentaho/pentaho-kettle

@Before
public void setUp() throws Exception {
 jobEntry = new JobEntryDeleteFiles();
 Job parentJob = mock( Job.class );
 doReturn( false ).when( parentJob ).isStopped();
 jobEntry.setParentJob( parentJob );
 JobMeta mockJobMeta = mock( JobMeta.class );
 mockNamedClusterEmbedManager = mock( NamedClusterEmbedManager.class );
 when( mockJobMeta.getNamedClusterEmbedManager() ).thenReturn( mockNamedClusterEmbedManager );
 jobEntry.setParentJobMeta( mockJobMeta );
 jobEntry = spy( jobEntry );
 doReturn( true ).when( jobEntry ).processFile( anyString(), anyString(), eq( parentJob ) );
}

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testIsFinished() throws Exception {
 assertFalse( jobRunner.isFinished() );
 when( mockJob.isStopped() ).thenReturn( false );
 when( mockJob.getParentJob() ).thenReturn( parentJob );
 when( parentJob.isStopped() ).thenReturn( false );
 when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult );
 jobRunner.run();
 assertTrue( jobRunner.isFinished() );
}

代码示例来源:origin: pentaho/pentaho-kettle

LogStatus status;
if ( !isActive() ) {
 if ( isStopped() ) {
  status = LogStatus.STOP;
 } else {

代码示例来源:origin: pentaho/pentaho-kettle

private void setupJobMockExecution() {
 setInternalState( mockedJob, "jobMeta", mockedJobMeta );
 setInternalState( mockedJob, "log", mockedLogChannel );
 setInternalState( mockedJob, "jobTracker", new JobTracker( mockedJobMeta ) );
 setInternalState( mockedJob, "jobEntryListeners", new ArrayList<>(  ) );
 setInternalState( mockedJob, "jobEntryResults", new LinkedList<>(  ) );
 setInternalState( mockedJob, "status", new AtomicInteger( 0 ) );
 when( mockedJobMeta.findJobEntry( JobMeta.STRING_SPECIAL_START, 0, false ) ).thenReturn( mockedJobEntryCopy );
 when( mockedJobEntryCopy.getEntry() ).thenReturn( mockedJobEntrySpecial );
 when( mockedJobEntrySpecial.getLogChannel() ).thenReturn( mockedLogChannel );
 when( mockedJobEntrySpecial.clone() ).thenReturn( mockedJobEntrySpecial );
 when( mockedJob.isStopped() ).thenCallRealMethod();
 doCallRealMethod().when( mockedJob ).setStopped( anyBoolean() );
 KettleLogStore.init();
}

代码示例来源:origin: pentaho/pentaho-kettle

public Result execute( Result previousResult, int nr ) throws KettleJobException {
 Result result = previousResult;
 if ( isStart() ) {
  try {
   long sleepTime = getNextExecutionTime();
   if ( sleepTime > 0 ) {
    parentJob.getLogChannel().logBasic(
     parentJob.getJobname(),
     "Sleeping: " + ( sleepTime / 1000 / 60 ) + " minutes (sleep time=" + sleepTime + ")" );
    long totalSleep = 0L;
    while ( totalSleep < sleepTime && !parentJob.isStopped() ) {
     Thread.sleep( 1000L );
     totalSleep += 1000L;
    }
   }
  } catch ( InterruptedException e ) {
   throw new KettleJobException( e );
  }
  result = previousResult;
  result.setResult( true );
 } else if ( isDummy() ) {
  result = previousResult;
 }
 return result;
}

代码示例来源:origin: pentaho/pentaho-kettle

final String fileMask = environmentSubstitute( pathToMask.getValue() );
if ( parentJob.isStopped() ) {
 break;

代码示例来源:origin: pentaho/pentaho-kettle

try {
 if ( !info.getFile().toString().equals( sourceFolder ) && !parentjob.isStopped() ) {

代码示例来源:origin: pentaho/pentaho-kettle

public void run() {
 try {
  if ( job.isStopped() || ( job.getParentJob() != null && job.getParentJob().isStopped() ) ) {
   return;

代码示例来源:origin: pentaho/pentaho-kettle

public void paintControl( PaintEvent event ) {
  if ( jobGraph.job != null && ( jobGraph.job.isFinished() || jobGraph.job.isStopped() ) ) {
   refreshImage( event.gc );
   if ( image != null && !image.isDisposed() ) {
    event.gc.drawImage( image, 0, 0 );
   }
  } else {
   Rectangle bounds = canvas.getBounds();
   if ( bounds.width <= 0 || bounds.height <= 0 ) {
    return;
   }
   event.gc.setForeground( GUIResource.getInstance().getColorWhite() );
   event.gc.setBackground( GUIResource.getInstance().getColorWhite() );
   event.gc.fillRectangle( new Rectangle( 0, 0, bounds.width, bounds.height ) );
   event.gc.setForeground( GUIResource.getInstance().getColorBlack() );
   String metricsMessage = BaseMessages.getString( PKG, "JobMetricsDelegate.JobIsNotRunning.Message" );
   org.eclipse.swt.graphics.Point extent = event.gc.textExtent( metricsMessage );
   event.gc.drawText( metricsMessage, ( bounds.width - extent.x ) / 2, ( bounds.height - extent.y ) / 2 );
  }
 }
} );

代码示例来源:origin: pentaho/pentaho-kettle

res = execute( nr, result, startpoint, null, BaseMessages.getString( PKG, "Job.Reason.StartOfJobentry" ) );
 setActive( false );
} while ( jes.isRepeat() && !isStopped() );
return res;

相关文章