idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
21,900
private void initializePresets ( ) { if ( gobblinPresets == null ) { synchronized ( GobblinHadoopJob . class ) { if ( gobblinPresets == null ) { gobblinPresets = Maps . newHashMap ( ) ; String gobblinPresetDirName = getSysProps ( ) . getString ( GobblinConstants . GOBBLIN_PRESET_DIR_KEY ) ; File gobblinPresetDir = new ...
Initializes presets and cache it into preset map . As presets do not change while server is up this initialization happens only once per JVM .
21,901
private void transformProperties ( ) { String query = getJobProps ( ) . getString ( GOBBLIN_QUERY_KEY , null ) ; if ( query == null ) { return ; } query = query . trim ( ) ; int idx = - 1 ; if ( ( idx = query . indexOf ( ';' ) ) >= 0 ) { if ( idx < query . length ( ) - 1 ) { throw new IllegalArgumentException ( GOBBLIN...
Transform property to make it work for Gobblin .
21,902
@ SuppressWarnings ( "FutureReturnValueIgnored" ) private void deleteProjectDirsInParallel ( final ImmutableSet < File > projectDirsToDelete ) { final int CLEANING_SERVICE_THREAD_NUM = 8 ; final ExecutorService deletionService = Executors . newFixedThreadPool ( CLEANING_SERVICE_THREAD_NUM ) ; for ( final File toDelete ...
Delete all the files in parallel
21,903
private void deleteLeastRecentlyUsedProjects ( long sizeToFreeInBytes , final List < ProjectDirectoryMetadata > projectDirMetadataList ) { projectDirMetadataList . sort ( Comparator . comparing ( ProjectDirectoryMetadata :: getLastAccessTime ) ) ; final Set < File > projectDirsToDelete = new HashSet < > ( ) ; for ( fin...
Delete least recently used projects to free up space
21,904
void deleteProjectDirsIfNecessary ( final long newProjectSizeInBytes ) { final long projectCacheMaxSizeInByte = ( long ) ( this . projectCacheDir . getTotalSpace ( ) * this . percentageOfDisk ) ; final long start = System . currentTimeMillis ( ) ; final List < ProjectDirectoryMetadata > allProjects = loadAllProjects ( ...
Deleting least recently accessed project dirs when there s no room to accommodate new project
21,905
private void createLogger ( final String flowId ) { final String loggerName = this . execId + "." + flowId ; this . logger = Logger . getLogger ( loggerName ) ; final String logName = "_flow." + loggerName + ".log" ; this . logFile = new File ( this . execDir , logName ) ; final String absolutePath = this . logFile . g...
setup logger and execution dir for the flowId
21,906
private void runFlow ( ) throws Exception { this . logger . info ( "Starting flows" ) ; runReadyJob ( this . flow ) ; updateFlow ( ) ; while ( ! this . flowFinished ) { synchronized ( this . mainSyncObj ) { if ( this . flowPaused ) { try { this . mainSyncObj . wait ( CHECK_WAIT_MS ) ; } catch ( final InterruptedExcepti...
Main method that executes the jobs .
21,907
private void propagateStatusAndAlert ( final ExecutableFlowBase base , final Status status ) { if ( ! Status . isStatusFinished ( base . getStatus ( ) ) && base . getStatus ( ) != Status . KILLING ) { this . logger . info ( "Setting " + base . getNestedId ( ) + " to " + status ) ; boolean shouldAlert = false ; if ( bas...
Recursively propagate status to parent flow . Alert on first error of the flow in new AZ dispatching design .
21,908
public Status getImpliedStatus ( final ExecutableNode node ) { if ( Status . isStatusRunning ( node . getStatus ( ) ) || node . getStatus ( ) == Status . SUCCEEDED ) { return null ; } Status status = Status . READY ; switch ( checkConditionOnJobStatus ( node ) ) { case FAILED : this . logger . info ( "Condition on job ...
Determines what the state of the next node should be . Returns null if the node should not be run .
21,909
private void configureJobLevelMetrics ( final JobRunner jobRunner ) { this . logger . info ( "Configuring Azkaban metrics tracking for jobrunner object" ) ; if ( MetricReportManager . isAvailable ( ) ) { final MetricReportManager metricManager = MetricReportManager . getInstance ( ) ; jobRunner . addListener ( ( NumRun...
Configure Azkaban metrics tracking for a new jobRunner instance
21,910
public void recoverIncompleteTriggerInstances ( ) { final Collection < TriggerInstance > unfinishedTriggerInstances = this . flowTriggerInstanceLoader . getIncompleteTriggerInstances ( ) ; for ( final TriggerInstance triggerInstance : unfinishedTriggerInstances ) { if ( triggerInstance . getFlowTrigger ( ) != null ) { ...
Resume executions of all incomplete trigger instances by recovering the state from db .
21,911
public void startTrigger ( final FlowTrigger flowTrigger , final String flowId , final int flowVersion , final String submitUser , final Project project ) { final TriggerInstance triggerInst = createTriggerInstance ( flowTrigger , flowId , flowVersion , submitUser , project ) ; this . flowTriggerExecutorService . submi...
Start the trigger . The method will be scheduled to invoke by azkaban scheduler .
21,912
public void cancelTriggerInstance ( final TriggerInstance triggerInst , final CancellationCause cause ) { if ( triggerInst . getStatus ( ) == Status . RUNNING ) { this . flowTriggerExecutorService . submit ( ( ) -> cancel ( triggerInst , cause ) ) ; } }
Cancel a trigger instance
21,913
public void shutdown ( ) { this . flowTriggerExecutorService . shutdown ( ) ; this . cancelExecutorService . shutdown ( ) ; this . timeoutService . shutdown ( ) ; this . flowTriggerExecutorService . shutdownNow ( ) ; this . cancelExecutorService . shutdownNow ( ) ; this . timeoutService . shutdownNow ( ) ; this . trigg...
Shuts down the service immediately .
21,914
public static boolean isDirWritable ( final File dir ) { File testFile = null ; try { testFile = new File ( dir , "_tmp" ) ; testFile . createNewFile ( ) ; } catch ( final IOException e ) { return false ; } finally { if ( testFile != null ) { testFile . delete ( ) ; } } return true ; }
Check if a directory is writable
21,915
public static void deleteDirectorySilently ( final File dir ) { if ( dir != null ) { try { FileUtils . deleteDirectory ( dir ) ; } catch ( final IOException e ) { log . error ( "error when deleting dir {}" , dir , e ) ; } } }
Delete a directory log the error if deletion fails .
21,916
public static void dumpNumberToFile ( final Path filePath , final long num ) throws IOException { try ( final BufferedWriter writer = Files . newBufferedWriter ( filePath , StandardCharsets . UTF_8 ) ) { writer . write ( String . valueOf ( num ) ) ; } catch ( final IOException e ) { log . error ( "Failed to write the n...
Dumps a number into a new file .
21,917
public static long readNumberFromFile ( final Path filePath ) throws IOException , NumberFormatException { final List < String > allLines = Files . readAllLines ( filePath ) ; if ( ! allLines . isEmpty ( ) ) { return Long . parseLong ( allLines . get ( 0 ) ) ; } else { throw new NumberFormatException ( "unable to parse...
Reads a number from a file .
21,918
public static int createDeepHardlink ( final File sourceDir , final File destDir ) throws IOException { if ( ! sourceDir . exists ( ) ) { throw new IOException ( "Source directory " + sourceDir . getPath ( ) + " doesn't exist" ) ; } else if ( ! destDir . exists ( ) ) { throw new IOException ( "Destination directory " +...
Hard link files and recurse into directories .
21,919
public static Pair < Integer , Integer > getUtf8Range ( final byte [ ] buffer , final int offset , final int length ) { final int start = getUtf8ByteStart ( buffer , offset ) ; final int end = getUtf8ByteEnd ( buffer , offset + length - 1 ) ; return new Pair < > ( start , end - start + 1 ) ; }
Returns first and length .
21,920
private void handlePurgeProject ( final HttpServletRequest req , final HttpServletResponse resp , final Session session ) throws ServletException , IOException { final User user = session . getUser ( ) ; final HashMap < String , Object > ret = new HashMap < > ( ) ; boolean isOperationSuccessful = true ; try { Project p...
validate readiness of a project and user permission and use projectManager to purge the project if things looks good
21,921
private void ajaxGetPermissions ( final Project project , final HashMap < String , Object > ret ) { final ArrayList < HashMap < String , Object > > permissions = new ArrayList < > ( ) ; for ( final Pair < String , Permission > perm : project . getUserPermissions ( ) ) { final HashMap < String , Object > permObj = new H...
this only returns user permissions but not group permissions and proxy users
21,922
private void ajaxSetFlowLock ( final Project project , final HashMap < String , Object > ret , final HttpServletRequest req ) throws ServletException { final String flowName = getParam ( req , FLOW_NAME_PARAM ) ; final Flow flow = project . getFlow ( flowName ) ; if ( flow == null ) { ret . put ( ERROR_PARAM , "Flow " ...
Set if a flow is locked .
21,923
private void ajaxIsFlowLocked ( final Project project , final HashMap < String , Object > ret , final HttpServletRequest req ) throws ServletException { final String flowName = getParam ( req , FLOW_NAME_PARAM ) ; final Flow flow = project . getFlow ( flowName ) ; if ( flow == null ) { ret . put ( ERROR_PARAM , "Flow "...
Returns true if the flow is locked false if it is unlocked .
21,924
private void lockFlowsForProject ( Project project , List < String > lockedFlows ) { for ( String flowId : lockedFlows ) { Flow flow = project . getFlow ( flowId ) ; if ( flow != null ) { flow . setLocked ( true ) ; } } }
Lock the specified flows for the project .
21,925
public static AzkabanDataSource getDataSource ( final Props props ) { final String databaseType = props . getString ( "database.type" ) ; AzkabanDataSource dataSource = null ; if ( databaseType . equals ( "mysql" ) ) { final int port = props . getInt ( "mysql.port" ) ; final String host = props . getString ( "mysql.hos...
Create Datasource from parameters in the properties
21,926
public static AzkabanDataSource getMySQLDataSource ( final String host , final Integer port , final String dbName , final String user , final String password , final Integer numConnections ) { return new MySQLBasicDataSource ( host , port , dbName , user , password , numConnections ) ; }
Create a MySQL DataSource
21,927
private boolean blockOnPipeLine ( ) { if ( this . isKilled ( ) ) { return true ; } if ( ! this . pipelineJobs . isEmpty ( ) ) { String blockedList = "" ; final ArrayList < BlockingStatus > blockingStatus = new ArrayList < > ( ) ; for ( final String waitingJobId : this . pipelineJobs ) { final Status status = this . wat...
If pipelining is set will block on another flow s jobs .
21,928
private String getProjectPermissionsURL ( ) { String projectPermissionsURL = null ; final String baseURL = this . azkabanProps . get ( AZKABAN_WEBSERVER_URL ) ; if ( baseURL != null ) { final String projectName = this . node . getParentFlow ( ) . getProjectName ( ) ; projectPermissionsURL = String . format ( "%s/manage...
Get project permissions page URL
21,929
private void insertJVMAargs ( ) { final String flowName = this . node . getParentFlow ( ) . getFlowId ( ) ; final String jobId = this . node . getId ( ) ; String jobJVMArgs = String . format ( "'-Dazkaban.flowid=%s' '-Dazkaban.execid=%s' '-Dazkaban.jobid=%s'" , flowName , this . executionId , jobId ) ; final String pre...
Add useful JVM arguments so it is easier to map a running Java process to a flow execution id and job
21,930
private void insertJobMetadata ( ) { final String baseURL = this . azkabanProps . get ( AZKABAN_WEBSERVER_URL ) ; if ( baseURL != null ) { final String flowName = this . node . getParentFlow ( ) . getFlowId ( ) ; final String projectName = this . node . getParentFlow ( ) . getProjectName ( ) ; this . props . put ( Comm...
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution .
21,931
public void updatePermissions ( ) { final String [ ] accessViewerList = this . accessViewer . trim ( ) . split ( ACCESS_LIST_SPLIT_REGEX ) ; final String [ ] accessExecutorList = this . accessExecutor . trim ( ) . split ( ACCESS_LIST_SPLIT_REGEX ) ; final String [ ] accessOwnerList = this . accessOwner . trim ( ) . spl...
Updates the project permissions in MEMORY but does NOT update the project in the database .
21,932
private void ajaxFetchExecFlowLogs ( final HttpServletRequest req , final HttpServletResponse resp , final HashMap < String , Object > ret , final User user , final ExecutableFlow exFlow ) throws ServletException { final long startMs = System . currentTimeMillis ( ) ; final Project project = getProjectAjaxByPermission ...
Gets the logs through plain text stream to reduce memory overhead .
21,933
private void ajaxFetchJobLogs ( final HttpServletRequest req , final HttpServletResponse resp , final HashMap < String , Object > ret , final User user , final ExecutableFlow exFlow ) throws ServletException { final Project project = getProjectAjaxByPermission ( ret , exFlow . getProjectId ( ) , user , Type . READ ) ; ...
Gets the logs through ajax plain text stream to reduce memory overhead .
21,934
public static ValidationStatus getInfoMsgLevel ( final String msg ) { if ( msg . startsWith ( "ERROR" ) ) { return ValidationStatus . ERROR ; } if ( msg . startsWith ( "WARN" ) ) { return ValidationStatus . WARN ; } return ValidationStatus . PASS ; }
Return the severity level this information message is associated with .
21,935
public static String getInfoMsg ( final String msg ) { if ( msg . startsWith ( "ERROR" ) ) { return msg . replaceFirst ( "ERROR" , "" ) ; } if ( msg . startsWith ( "WARN" ) ) { return msg . replaceFirst ( "WARN" , "" ) ; } return msg ; }
Get the raw information message .
21,936
public static boolean tryDeleteFileOrDirectory ( File file ) { try { deleteFileOrDirectory ( file ) ; return true ; } catch ( Exception e ) { logger . warn ( "Failed to delete file. file = " + file . getAbsolutePath ( ) , e ) ; return false ; } }
Try to delete File or Directory
21,937
public String getParam ( final HttpServletRequest request , final String name , final String defaultVal ) { return HttpRequestUtils . getParam ( request , name , defaultVal ) ; }
Retrieves the param from the http servlet request .
21,938
protected void setSessionValue ( final HttpServletRequest request , final String key , final Object value ) { request . getSession ( true ) . setAttribute ( key , value ) ; }
Returns the session value of the request .
21,939
protected void addSessionValue ( final HttpServletRequest request , final String key , final Object value ) { List l = ( List ) request . getSession ( true ) . getAttribute ( key ) ; if ( l == null ) { l = new ArrayList ( ) ; } l . add ( value ) ; request . getSession ( true ) . setAttribute ( key , l ) ; }
Adds a session value to the request
21,940
protected void setErrorMessageInCookie ( final HttpServletResponse response , final String errorMsg ) { final Cookie cookie = new Cookie ( AZKABAN_FAILURE_MESSAGE , errorMsg ) ; cookie . setPath ( "/" ) ; response . addCookie ( cookie ) ; }
Sets an error message in azkaban . failure . message in the cookie . This will be used by the web client javascript to somehow display the message
21,941
protected void setWarnMessageInCookie ( final HttpServletResponse response , final String errorMsg ) { final Cookie cookie = new Cookie ( AZKABAN_WARN_MESSAGE , errorMsg ) ; cookie . setPath ( "/" ) ; response . addCookie ( cookie ) ; }
Sets a warning message in azkaban . warn . message in the cookie . This will be used by the web client javascript to somehow display the message
21,942
protected void setSuccessMessageInCookie ( final HttpServletResponse response , final String message ) { final Cookie cookie = new Cookie ( AZKABAN_SUCCESS_MESSAGE , message ) ; cookie . setPath ( "/" ) ; response . addCookie ( cookie ) ; }
Sets a message in azkaban . success . message in the cookie . This will be used by the web client javascript to somehow display the message
21,943
protected String getSuccessMessageFromCookie ( final HttpServletRequest request ) { final Cookie cookie = getCookieByName ( request , AZKABAN_SUCCESS_MESSAGE ) ; if ( cookie == null ) { return null ; } return cookie . getValue ( ) ; }
Retrieves a success message from a cookie . azkaban . success . message
21,944
protected String getWarnMessageFromCookie ( final HttpServletRequest request ) { final Cookie cookie = getCookieByName ( request , AZKABAN_WARN_MESSAGE ) ; if ( cookie == null ) { return null ; } return cookie . getValue ( ) ; }
Retrieves a warn message from a cookie . azkaban . warn . message
21,945
protected String getErrorMessageFromCookie ( final HttpServletRequest request ) { final Cookie cookie = getCookieByName ( request , AZKABAN_FAILURE_MESSAGE ) ; if ( cookie == null ) { return null ; } return cookie . getValue ( ) ; }
Retrieves a success message from a cookie . azkaban . failure . message
21,946
protected Page newPage ( final HttpServletRequest req , final HttpServletResponse resp , final Session session , final String template ) { final Page page = new Page ( req , resp , getApplication ( ) . getVelocityEngine ( ) , template ) ; page . add ( "version" , jarVersion ) ; page . add ( "azkaban_name" , this . name...
Creates a new velocity page to use . With session .
21,947
protected Page newPage ( final HttpServletRequest req , final HttpServletResponse resp , final String template ) { final Page page = new Page ( req , resp , getApplication ( ) . getVelocityEngine ( ) , template ) ; page . add ( "version" , jarVersion ) ; page . add ( "azkaban_name" , this . name ) ; page . add ( "azkab...
Creates a new velocity page to use .
21,948
protected void writeJSON ( final HttpServletResponse resp , final Object obj ) throws IOException { writeJSON ( resp , obj , false ) ; }
Writes json out to the stream .
21,949
private static void populateHiveConf ( HiveConf hiveConf , String [ ] args ) { if ( args == null ) { return ; } int index = 0 ; for ( ; index < args . length ; index ++ ) { if ( "-hiveconf" . equals ( args [ index ] ) ) { String hiveConfParam = stripSingleDoubleQuote ( args [ ++ index ] ) ; String [ ] tokens = hiveConf...
Extract hiveconf from command line arguments and populate them into HiveConf
21,950
private static String stripSingleDoubleQuote ( String input ) { if ( StringUtils . isEmpty ( input ) ) { return input ; } if ( input . startsWith ( SINGLE_QUOTE_STRING ) || input . startsWith ( DOUBLE_QUOTE_STRING ) ) { input = input . substring ( 1 ) ; } if ( input . endsWith ( SINGLE_QUOTE_STRING ) || input . endsWit...
Strip single quote or double quote at either end of the string
21,951
public void setupExecutors ( ) throws ExecutorManagerException { final ImmutableSet < Executor > newExecutors = loadExecutors ( ) ; if ( newExecutors . isEmpty ( ) ) { final String error = "No active executors found" ; logger . error ( error ) ; throw new ExecutorManagerException ( error ) ; } else { this . activeExecu...
Loads executors . Can be also used to reload executors if there have been changes in the DB .
21,952
public static boolean isThereJobCallbackProperty ( final Props props , final JobCallbackStatusEnum status ) { if ( props == null || status == null ) { throw new NullPointerException ( "One of the argument is null" ) ; } final String jobCallBackUrl = firstJobcallbackPropertyMap . get ( status ) ; return props . contains...
Use to quickly determine if there is a job callback related property in the Props .
21,953
public static List < HttpRequestBase > parseJobCallbackProperties ( final Props props , final JobCallbackStatusEnum status , final Map < String , String > contextInfo , final int maxNumCallback , final Logger privateLogger ) { String callbackUrl = null ; if ( ! isThereJobCallbackProperty ( props , status ) ) { return C...
This method is responsible for parsing job call URL properties and convert them into a list of HttpRequestBase which callers can use to execute .
21,954
public static Map < String , String > buildJobContextInfoMap ( final Event event , final String server ) { if ( event . getRunner ( ) instanceof JobRunner ) { final JobRunner jobRunner = ( JobRunner ) event . getRunner ( ) ; final ExecutableNode node = jobRunner . getNode ( ) ; final EventData eventData = event . getDa...
This method takes the job context info . and put the values into a map with keys as the tokens .
21,955
public static String replaceTokens ( final String value , final Map < String , String > contextInfo , final boolean withEncoding ) { String result = value ; String tokenValue = encodeQueryParam ( contextInfo . get ( CONTEXT_SERVER_TOKEN ) , withEncoding ) ; result = result . replaceFirst ( Pattern . quote ( CONTEXT_SER...
Replace the supported tokens in the URL with values in the contextInfo . This will also make sure the values are HTTP encoded .
21,956
public void uploadProject ( final Project project , final int version , final File localFile , final User uploader ) { byte [ ] md5 = null ; if ( ! ( this . storage instanceof DatabaseStorage ) ) { md5 = computeHash ( localFile ) ; } final StorageMetadata metadata = new StorageMetadata ( project . getId ( ) , version ,...
API to a project file into Azkaban Storage
21,957
public ProjectFileHandler getProjectFile ( final int projectId , final int version ) { log . info ( String . format ( "Fetching project file. project ID: %d version: %d" , projectId , version ) ) ; if ( this . storage instanceof DatabaseStorage ) { return ( ( DatabaseStorage ) this . storage ) . get ( projectId , versi...
Fetch project file from storage .
21,958
private Map < String , String > readPrivateConfig ( final File privateConfigFile ) { try { return readConfig ( privateConfigFile ) ; } catch ( final Exception ex ) { return new HashMap < > ( ) ; } }
read config from private property file if the file is not present then return empty .
21,959
public static void croak ( final String message , final int exitCode ) { System . err . println ( message ) ; System . exit ( exitCode ) ; }
Print the message and then exit with the given exit code
21,960
public static Object callConstructor ( final Class < ? > cls , final Object ... args ) { return callConstructor ( cls , getTypes ( args ) , args ) ; }
Construct a class object with the given arguments
21,961
private static Class < ? > [ ] getTypes ( final Object ... args ) { final Class < ? > [ ] argTypes = new Class < ? > [ args . length ] ; for ( int i = 0 ; i < argTypes . length ; i ++ ) { argTypes [ i ] = args [ i ] . getClass ( ) ; } return argTypes ; }
Get the Class of all the objects
21,962
public static ArrayList < String > runProcess ( String ... commands ) throws InterruptedException , IOException { final java . lang . ProcessBuilder processBuilder = new java . lang . ProcessBuilder ( commands ) ; final ArrayList < String > output = new ArrayList < > ( ) ; final Process process = processBuilder . start...
Run a sequence of commands
21,963
public static void mergeTypeClassPaths ( List < String > destinationPaths , final List < String > sourcePaths , final String rootPath ) { if ( sourcePaths != null ) { for ( String jar : sourcePaths ) { File file = new File ( jar ) ; if ( ! file . isAbsolute ( ) ) { file = new File ( rootPath + File . separatorChar + ja...
Merge the absolute paths of source paths into the list of destination paths
21,964
public static void mergeStringList ( final List < String > destinationList , final List < String > sourceList ) { if ( sourceList != null ) { for ( String item : sourceList ) { if ( ! destinationList . contains ( item ) ) { destinationList . add ( item ) ; } } } }
Merge elements in Source List into the Destination List
21,965
static String expandHiveAuxJarsPath ( String original ) throws IOException { if ( original == null || original . contains ( ".jar" ) ) return original ; File [ ] files = new File ( original ) . listFiles ( ) ; if ( files == null || files . length == 0 ) { LOG . info ( "No files in to expand in aux jar path. Returning o...
Normally hive . aux . jars . path is expanded from just being a path to the full list of files in the directory by the hive shell script . Since we normally won t be running from the script it s up to us to do that work here . We use a heuristic that if there is no occurrence of . jar in the original it needs expansion...
21,966
void updateDagStatus ( ) { boolean failed = false ; for ( final Node node : this . nodes ) { final Status nodeStatus = node . getStatus ( ) ; if ( ! nodeStatus . isTerminal ( ) ) { return ; } if ( nodeStatus == Status . FAILURE ) { failed = true ; } } updateDagStatusInternal ( failed ) ; }
Update the final dag status when all nodes are done .
21,967
private void updateDagStatusInternal ( final boolean failed ) { if ( this . status == Status . KILLING ) { changeStatus ( Status . KILLED ) ; } else if ( failed ) { changeStatus ( Status . FAILURE ) ; } else { changeStatus ( Status . SUCCESS ) ; } }
Update the final dag status .
21,968
private synchronized void updateLocal ( ) throws ScheduleManagerException { final List < Schedule > updates = this . loader . loadUpdatedSchedules ( ) ; for ( final Schedule s : updates ) { if ( s . getStatus ( ) . equals ( TriggerStatus . EXPIRED . toString ( ) ) ) { onScheduleExpire ( s ) ; } else { internalSchedule ...
only do this when using external runner
21,969
public Schedule getSchedule ( final int projectId , final String flowId ) throws ScheduleManagerException { updateLocal ( ) ; return this . scheduleIdentityPairMap . get ( new Pair < > ( projectId , flowId ) ) ; }
Returns the scheduled flow for the flow name
21,970
public synchronized void removeSchedule ( final Schedule sched ) { final Pair < Integer , String > identityPairMap = sched . getScheduleIdentityPair ( ) ; final Schedule schedule = this . scheduleIdentityPairMap . get ( identityPairMap ) ; if ( schedule != null ) { this . scheduleIdentityPairMap . remove ( identityPair...
Removes the flow from the schedule if it exists .
21,971
private synchronized void internalSchedule ( final Schedule s ) { this . scheduleIDMap . put ( s . getScheduleId ( ) , s ) ; this . scheduleIdentityPairMap . put ( s . getScheduleIdentityPair ( ) , s ) ; }
Schedules the flow but doesn t save the schedule afterwards .
21,972
public synchronized void insertSchedule ( final Schedule s ) { final Schedule exist = this . scheduleIdentityPairMap . get ( s . getScheduleIdentityPair ( ) ) ; if ( s . updateTime ( ) ) { try { if ( exist == null ) { this . loader . insertSchedule ( s ) ; internalSchedule ( s ) ; } else { s . setScheduleId ( exist . g...
Adds a flow to the schedule .
21,973
public void checkExecutorHealth ( ) { final Map < Optional < Executor > , List < ExecutableFlow > > exFlowMap = getFlowToExecutorMap ( ) ; for ( final Map . Entry < Optional < Executor > , List < ExecutableFlow > > entry : exFlowMap . entrySet ( ) ) { final Optional < Executor > executorOption = entry . getKey ( ) ; if...
Checks executor health . Finalizes the flow if its executor is already removed from DB or sends alert emails if the executor isn t alive any more .
21,974
private Map < Optional < Executor > , List < ExecutableFlow > > getFlowToExecutorMap ( ) { final HashMap < Optional < Executor > , List < ExecutableFlow > > exFlowMap = new HashMap < > ( ) ; try { for ( final Pair < ExecutionReference , ExecutableFlow > runningFlow : this . executorLoader . fetchActiveFlows ( ) . value...
Groups Executable flow by Executors to reduce number of REST calls .
21,975
private void handleExecutorNotAliveCase ( final Entry < Optional < Executor > , List < ExecutableFlow > > entry , final Executor executor , final ExecutorManagerException e ) { logger . error ( "Failed to get update from executor " + executor . getId ( ) , e ) ; this . executorFailureCount . put ( executor . getId ( ) ...
Increments executor failure count . If it reaches max failure count sends alert emails to AZ admin .
21,976
public static List < ExecutableNode > sortExecutableNodes ( final ExecutableFlow flow ) { final List < ExecutableNode > sortedNodes = new ArrayList < > ( ) ; if ( flow != null ) { final List < String > startNodeIds = flow . getStartNodes ( ) ; String nextNodeId = startNodeIds . isEmpty ( ) ? null : startNodeIds . get (...
Returns a list of the executable nodes in the specified flow in execution order . Assumes that the flow is linear .
21,977
public static List < Variable > getRunTimeVariables ( final Collection < Variable > variables ) { final List < Variable > runtimeVariables = ReportalUtil . getVariablesByRegex ( variables , Reportal . REPORTAL_CONFIG_PREFIX_NEGATION_REGEX ) ; return runtimeVariables ; }
Get runtime variables to be set in unscheduled mode of execution . Returns empty list if no runtime variable is found
21,978
public static List < Variable > getVariablesByRegex ( final Collection < Variable > variables , final String regex ) { final List < Variable > shortlistedVariables = new ArrayList < > ( ) ; if ( variables != null && regex != null ) { for ( final Variable var : variables ) { if ( var . getTitle ( ) . matches ( regex ) )...
Shortlist variables which match a given regex . Returns empty empty list if no eligible variable is found
21,979
public static Map < String , String > getVariableMapByPrefix ( final Collection < Variable > variables , final String prefix ) { final Map < String , String > shortlistMap = new HashMap < > ( ) ; if ( variables != null && prefix != null ) { for ( final Variable var : getVariablesByRegex ( variables , Reportal . REPORTA...
Shortlist variables which match a given prefix . Returns empty map if no eligible variable is found .
21,980
public Session getSession ( final String sessionId ) { final Session elem = this . cache . getIfPresent ( sessionId ) ; return elem ; }
Returns the cached session using the session id .
21,981
public Set < Session > findSessionsByIP ( final String ip ) { final Set < Session > ret = new HashSet < > ( ) ; final Map < String , Session > cacheSnapshot = this . cache . asMap ( ) ; for ( final Entry < String , Session > entry : cacheSnapshot . entrySet ( ) ) { if ( entry . getValue ( ) . getIp ( ) . equals ( ip ) ...
Returns sessions whose IP equals to the given IP .
21,982
public void addPluginClass ( final String jobTypeName , final Class < ? extends Job > jobTypeClass ) { this . jobToClass . put ( jobTypeName , jobTypeClass ) ; }
Adds plugin jobtype class
21,983
Map < Integer , Pair < ExecutionReference , ExecutableFlow > > fetchUnfinishedFlows ( ) throws ExecutorManagerException { try { return this . dbOperator . query ( FetchActiveExecutableFlows . FETCH_UNFINISHED_EXECUTABLE_FLOWS , new FetchActiveExecutableFlows ( ) ) ; } catch ( final SQLException e ) { throw new Executor...
Fetch flows that are not in finished status including both dispatched and non - dispatched flows .
21,984
Map < Integer , Pair < ExecutionReference , ExecutableFlow > > fetchActiveFlows ( ) throws ExecutorManagerException { try { return this . dbOperator . query ( FetchActiveExecutableFlows . FETCH_ACTIVE_EXECUTABLE_FLOWS , new FetchActiveExecutableFlows ( ) ) ; } catch ( final SQLException e ) { throw new ExecutorManagerE...
Fetch flows that are dispatched and not yet finished .
21,985
Pair < ExecutionReference , ExecutableFlow > fetchActiveFlowByExecId ( final int execId ) throws ExecutorManagerException { try { return this . dbOperator . query ( FetchActiveExecutableFlow . FETCH_ACTIVE_EXECUTABLE_FLOW_BY_EXEC_ID , new FetchActiveExecutableFlow ( ) , execId ) ; } catch ( final SQLException e ) { thr...
Fetch the flow that is dispatched and not yet finished by execution id .
21,986
public static void cancelHadoopTokens ( HadoopSecurityManager hadoopSecurityManager , String userToProxy , File tokenFile , Logger log ) { if ( tokenFile == null ) { return ; } try { hadoopSecurityManager . cancelTokens ( tokenFile , userToProxy , log ) ; } catch ( HadoopSecurityManagerException e ) { log . error ( e ....
Invalidates a Hadoop authentication token file
21,987
public static HadoopSecurityManager loadHadoopSecurityManager ( Props props , Logger log ) throws RuntimeException { Class < ? > hadoopSecurityManagerClass = props . getClass ( HADOOP_SECURITY_MANAGER_CLASS_PARAM , true , HadoopJobUtils . class . getClassLoader ( ) ) ; log . info ( "Loading hadoop security manager " + ...
Based on the HADOOP_SECURITY_MANAGER_CLASS_PARAM setting in the incoming props finds the correct HadoopSecurityManager Java class
21,988
public static File getHadoopTokens ( HadoopSecurityManager hadoopSecurityManager , Props props , Logger log ) throws HadoopSecurityManagerException { File tokenFile = null ; try { tokenFile = File . createTempFile ( "mr-azkaban" , ".token" ) ; } catch ( Exception e ) { throw new HadoopSecurityManagerException ( "Failed...
Fetching token with the Azkaban user
21,989
public static void proxyUserKillAllSpawnedHadoopJobs ( final String logFilePath , Props jobProps , File tokenFile , final Logger log ) { Properties properties = new Properties ( ) ; properties . putAll ( jobProps . getFlattened ( ) ) ; try { if ( HadoopSecureWrapperUtils . shouldProxy ( properties ) ) { UserGroupInform...
This method is a decorator around the KillAllSpawnedHadoopJobs method . This method takes additional parameters to determine whether KillAllSpawnedHadoopJobs needs to be executed using doAs as a different user
21,990
public static Set < String > killAllSpawnedHadoopJobs ( String logFilePath , Logger log ) { Set < String > allSpawnedJobs = findApplicationIdFromLog ( logFilePath , log ) ; log . info ( "applicationIds to kill: " + allSpawnedJobs ) ; for ( String appId : allSpawnedJobs ) { try { killJobOnCluster ( appId , log ) ; } cat...
Pass in a log file this method will find all the hadoop jobs it has launched and kills it
21,991
public static List < String > filterCommands ( Collection < String > commands , String whitelistRegex , String blacklistRegex , Logger log ) { List < String > filteredCommands = new LinkedList < String > ( ) ; Pattern whitelistPattern = Pattern . compile ( whitelistRegex ) ; Pattern blacklistPattern = Pattern . compile...
Filter a collection of String commands to match a whitelist regex and not match a blacklist regex .
21,992
public static String constructHadoopTags ( Props props , String [ ] keys ) { String [ ] keysAndValues = new String [ keys . length ] ; for ( int i = 0 ; i < keys . length ; i ++ ) { if ( props . containsKey ( keys [ i ] ) ) { keysAndValues [ i ] = keys [ i ] + ":" + props . get ( keys [ i ] ) ; } } Joiner joiner = Join...
Construct a CSV of tags for the Hadoop application .
21,993
long getOsTotalFreeMemorySize ( ) { if ( ! Files . isRegularFile ( Paths . get ( MEM_INFO_FILE ) ) ) { return 0 ; } final List < String > lines ; try { lines = Files . readAllLines ( Paths . get ( MEM_INFO_FILE ) , StandardCharsets . UTF_8 ) ; } catch ( final IOException e ) { final String errMsg = "Failed to open mem ...
Includes OS cache and free swap .
21,994
public int execute ( final String user , final List < String > command ) throws IOException { log . info ( "Command: " + command ) ; final Process process = new ProcessBuilder ( ) . command ( constructExecuteAsCommand ( user , command ) ) . inheritIO ( ) . start ( ) ; int exitCode ; try { exitCode = process . waitFor (...
API to execute a command on behalf of another user .
21,995
public static boolean validateIntegerParam ( final Map < String , String > params , final String paramName ) throws ExecutorManagerException { if ( params != null && params . containsKey ( paramName ) && ! StringUtils . isNumeric ( params . get ( paramName ) ) ) { throw new ExecutorManagerException ( paramName + " shou...
parse a string as number and throws exception if parsed value is not a valid integer
21,996
static long calculateDirSizeAndSave ( final File dir ) throws IOException { final Path path = Paths . get ( dir . getPath ( ) , FlowPreparer . PROJECT_DIR_SIZE_FILE_NAME ) ; if ( ! Files . exists ( path ) ) { final long sizeInByte = FileUtils . sizeOfDirectory ( dir ) ; FileIOUtils . dumpNumberToFile ( path , sizeInByt...
Calculate the directory size and save it to a file .
21,997
void setup ( final ExecutableFlow flow ) throws ExecutorManagerException { final ProjectFileHandler projectFileHandler = null ; File tempDir = null ; try { final ProjectDirectoryMetadata project = new ProjectDirectoryMetadata ( flow . getProjectId ( ) , flow . getVersion ( ) ) ; final long flowPrepStartTime = System . ...
Prepare the flow directory for execution .
21,998
synchronized void consumerSubscriptionRebalance ( ) { log . debug ( "Subscribed Topics " + this . consumer . subscription ( ) ) ; if ( ! this . subscribedTopics . isEmpty ( ) ) { final Iterator < String > iter = this . subscribedTopics . iterator ( ) ; final List < String > topics = new ArrayList < > ( ) ; while ( iter...
Dynamically tune subscription only for the topic that dependencies need .
21,999
private void triggerDependencies ( final Set < String > matchedList , final ConsumerRecord < String , String > record ) { final List < KafkaDependencyInstanceContext > deleteList = new LinkedList < > ( ) ; for ( final String it : matchedList ) { final List < KafkaDependencyInstanceContext > possibleAvailableDeps = this...
If the matcher returns true remove the dependency from collection .