public void init() { status = new AtomicInteger(); jobListeners = new ArrayList<JobListener>(); jobEntryListeners = new ArrayList<JobEntryListener>(); delegationListeners = new ArrayList<DelegationListener>(); // these 2 maps are being modified concurrently and must be thread-safe activeJobEntryTransformations = new ConcurrentHashMap<JobEntryCopy, JobEntryTrans>(); activeJobEntryJobs = new ConcurrentHashMap<JobEntryCopy, JobEntryJob>(); extensionDataMap = new HashMap<String, Object>(); jobTracker = new JobTracker( jobMeta ); synchronized ( jobEntryResults ) { jobEntryResults.clear(); } errors = new AtomicInteger( 0 ); batchId = -1; passedBatchId = -1; maxJobEntriesLogged = Const.toInt( EnvUtil.getSystemProperty( Const.KETTLE_MAX_JOB_ENTRIES_LOGGED ), 1000 ); result = null; startJobEntryCopy = null; startJobEntryResult = null; this.setDefaultLogCommitSize(); }
private static JobTracker createTracker( String jobEntryName, int jobEntryNr ) { JobMeta jobMeta = mock( JobMeta.class ); JobTracker jobTracker = new JobTracker( jobMeta ); if ( jobEntryName != null ) { JobEntryResult result = mock( JobEntryResult.class ); when( result.getJobEntryName() ).thenReturn( jobEntryName ); when( result.getJobEntryNr() ).thenReturn( jobEntryNr ); jobTracker.setJobEntryResult( result ); } return jobTracker; }
@Parameterized.Parameters public static List<Object[]> getData() { return Arrays.asList( new Object[] { new JobTracker( mockJobMeta( "parent" ) ) }, new Object[] { new JobTracker( mockJobMeta( "parent" ), jobsLimit ) } ); }
private void emergencyWriteJobTracker( Result res ) { JobEntryResult jerFinalResult = new JobEntryResult( res, this.getLogChannelId(), BaseMessages.getString( PKG, "Job.Comment.JobFinished" ), null, null, 0, null ); JobTracker finalTrack = new JobTracker( this.getJobMeta(), jerFinalResult ); // jobTracker is up to date too. this.jobTracker.addJobTracker( finalTrack ); }
public Job( Repository repository, JobMeta jobMeta, LoggingObjectInterface parentLogging ) { this.rep = repository; this.jobMeta = jobMeta; this.containerObjectId = jobMeta.getContainerObjectId(); this.parentLoggingObject = parentLogging; init(); jobTracker = new JobTracker( jobMeta ); this.log = new LogChannel( this, parentLogging ); this.logLevel = log.getLogLevel(); if ( this.containerObjectId == null ) { this.containerObjectId = log.getContainerObjectId(); } }
@Test // PDI-11389 Number of job trackers should be limited by KETTLE_MAX_JOB_TRACKER_SIZE public void testAddJobTracker() throws Exception { final String old = System.getProperty( Const.KETTLE_MAX_JOB_TRACKER_SIZE ); final Integer maxTestSize = 30; try { System.setProperty( Const.KETTLE_MAX_JOB_TRACKER_SIZE, maxTestSize.toString() ); JobMeta jobMeta = mock( JobMeta.class ); JobTracker jobTracker = new JobTracker( jobMeta ); for ( int n = 0; n < maxTestSize * 2; n++ ) { jobTracker.addJobTracker( mock( JobTracker.class ) ); } assertTrue( "More JobTrackers than allowed were added", jobTracker.getTotalNumberOfItems() <= maxTestSize ); } finally { if ( old == null ) { System.clearProperty( Const.KETTLE_MAX_JOB_TRACKER_SIZE ); } else { System.setProperty( Const.KETTLE_MAX_JOB_TRACKER_SIZE, old ); } } }
@Override public Exception call() throws Exception { Exception exception = null; try { for ( int i = 0; i < cycles; i++ ) { int id = idGenerator.getAndIncrement(); JobEntryResult result = new JobEntryResult(); result.setJobEntryName( String.format( resultNameTemplate, id ) ); result.setJobEntryNr( id ); JobTracker child = new JobTracker( mockJobMeta( "child-" + id ), result ); tracker.addJobTracker( child ); } } catch ( Exception e ) { exception = e; } return exception; } }
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(); }
new JobEntryResult( null, null, BaseMessages.getString( PKG, "Job.Comment.JobStarted" ), reason, jobEntryCopy .getName(), jobEntryCopy.getNr(), environmentSubstitute( jobEntryCopy.getEntry().getFilename() ) ); jobTracker.addJobTracker( new JobTracker( jobMeta, jerBefore ) ); "Job.Comment.JobFinished" ), null, jobEntryCopy.getName(), jobEntryCopy.getNr(), environmentSubstitute( jobEntryCopy.getEntry().getFilename() ) ); jobTracker.addJobTracker( new JobTracker( jobMeta, jerAfter ) ); synchronized ( jobEntryResults ) { jobEntryResults.add( jerAfter );
new JobEntryResult( null, null, BaseMessages.getString( PKG, "Job.Comment.JobStarted" ), BaseMessages .getString( PKG, "Job.Reason.Started" ), null, 0, null ); jobTracker.addJobTracker( new JobTracker( jobMeta, jerStart ) ); jobTracker.addJobTracker( new JobTracker( jobMeta, jerEnd ) ); log.logMinimal( BaseMessages.getString( PKG, "Job.Comment.JobFinished" ) );