JobEntryPigScriptExecutor extends JobEntryBase implements Cloneable, JobEntryInterface { protected void processScriptExecutionResult( PigResult pigResult, Result result ) { int[] executionStatus = pigResult.getResult(); Exception pigResultException = pigResult.getException(); if ( executionStatus != null && executionStatus.length > 0 ) { int countFailedJob = 0; if ( executionStatus.length > 1 ) { countFailedJob = executionStatus[ 1 ]; } logBasic( BaseMessages.getString( PKG, "JobEntryPigScriptExecutor.JobCompletionStatus", String.valueOf( executionStatus[ 0 ] ), String.valueOf( countFailedJob ) ) ); if ( countFailedJob > 0 ) { result.setStopped( true ); result.setNrErrors( countFailedJob ); result.setResult( false ); } } else if ( pigResultException != null ) { logError( pigResultException.getMessage(), pigResultException ); result.setStopped( true ); result.setNrErrors( 1 ); result.setResult( false ); } FileObject logFile = pigResult.getLogFile(); if ( logFile != null ) { ResultFile resultFile = new ResultFile( ResultFile.FILE_TYPE_LOG, logFile, parentJob.getJobname(), getName() ); result.getResultFiles().put( resultFile.getFile().toString(), resultFile ); } } JobEntryPigScriptExecutor( NamedClusterService namedClusterService,
                                    RuntimeTestActionService runtimeTestActionService, RuntimeTester runtimeTester,
                                    NamedClusterServiceLocator namedClusterServiceLocator ); String getXML(); @Override void loadXML( Node entrynode, List<DatabaseMeta> databases, List<SlaveServer> slaveServers,
                       Repository repository, IMetaStore metaStore ); @Override void loadRep( Repository rep, IMetaStore metaStore, ObjectId id_jobentry, List<DatabaseMeta> databases,
                       List<SlaveServer> slaveServers ); @Override void saveRep( Repository rep, IMetaStore metaStore, ObjectId id_job ); boolean evaluates(); boolean getEnableBlocking(); void setEnableBlocking( boolean block ); boolean getLocalExecution(); void setLocalExecution( boolean l ); String getScriptFilename(); void setScriptFilename( String filename ); Map<String, String> getScriptParameters(); void setScriptParameters( Map<String, String> params ); NamedCluster getNamedCluster(); void setNamedCluster( NamedCluster namedCluster ); NamedClusterService getNamedClusterService(); RuntimeTestActionService getRuntimeTestActionService(); RuntimeTester getRuntimeTester(); Result execute( final Result result, int arg1 ); static final Class<?> PKG; static final String CLUSTER_NAME; static final String HDFS_HOSTNAME; static final String HDFS_PORT; static final String JOBTRACKER_HOSTNAME; static final String JOBTRACKER_PORT; static final String SCRIPT_FILE; static final String ENABLE_BLOCKING; static final String LOCAL_EXECUTION; static final String JOB_ENTRY_PIG_SCRIPT_EXECUTOR_ERROR_NO_PIG_SCRIPT_SPECIFIED; static final String JOB_ENTRY_PIG_SCRIPT_EXECUTOR_WARNING_LOCAL_EXECUTION; }
@Test public void testGettingFailedStatusIfExecutionException() { pigResult = mock( PigResult.class ); result = new Result( ); when( pigResult.getResult() ).thenReturn( null ); when( pigResult.getException() ).thenReturn( new Exception( ) ); jobEntryPigScriptExecutor.processScriptExecutionResult( pigResult, result ); assertFalse( result.getResult() ); assertTrue( result.isStopped() ); assertEquals( 1L, result.getNrErrors() ); }
@Test public void testGettingFailedStatusIfNrErrors() { pigResult = mock( PigResult.class ); result = new Result( ); when( pigResult.getResult() ).thenReturn( new int[] { 0, 1} ).thenReturn( null ); when( pigResult.getException() ).thenReturn( null ); jobEntryPigScriptExecutor.processScriptExecutionResult( pigResult, result ); assertFalse( result.getResult() ); assertTrue( result.isStopped() ); assertEquals( 1L, result.getNrErrors() ); }