code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
private void handleFetchMetaDataEvent(final int execId, final HttpServletRequest req, final HttpServletResponse resp, final Map<String, Object> respMap) throws ServletException { final int startByte = getIntParam(req, "offset"); final int length = getIntParam(req, "length"); resp.setContentType("text/plain"); resp.setCharacterEncoding("utf-8"); final int attempt = getIntParam(req, "attempt", 0); final String jobId = getParam(req, "jobId"); try { final JobMetaData result = this.flowRunnerManager.readJobMetaData(execId, jobId, attempt, startByte, length); respMap.putAll(result.toObject()); } catch (final Exception e) { logger.error(e.getMessage(), e); respMap.put("error", e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleFetchMetaDataEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxUpdateRequest(final HttpServletRequest req, final Map<String, Object> respMap) throws ServletException, IOException { final ArrayList<Object> updateTimesList = (ArrayList<Object>) JSONUtils.parseJSONFromString(getParam(req, ConnectorParams.UPDATE_TIME_LIST_PARAM)); final ArrayList<Object> execIDList = (ArrayList<Object>) JSONUtils.parseJSONFromString(getParam(req, ConnectorParams.EXEC_ID_LIST_PARAM)); final ArrayList<Object> updateList = new ArrayList<>(); for (int i = 0; i < execIDList.size(); ++i) { final long updateTime = JSONUtils.getLongFromObject(updateTimesList.get(i)); final int execId = (Integer) execIDList.get(i); final ExecutableFlowBase flow = this.flowRunnerManager.getExecutableFlow(execId); if (flow == null) { final Map<String, Object> errorResponse = new HashMap<>(); errorResponse.put(ConnectorParams.RESPONSE_ERROR, "Flow does not exist"); errorResponse.put(ConnectorParams.UPDATE_MAP_EXEC_ID, execId); updateList.add(errorResponse); continue; } if (flow.getUpdateTime() > updateTime) { updateList.add(flow.toUpdateObject(updateTime)); } } respMap.put(ConnectorParams.RESPONSE_UPDATED_FLOWS, updateList); }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxUpdateRequest
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxExecute(final HttpServletRequest req, final Map<String, Object> respMap, final int execId) { try { this.flowRunnerManager.submitFlow(execId); } catch (final ExecutorManagerException e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxExecute
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxFlowStatus(final Map<String, Object> respMap, final int execid) { final ExecutableFlowBase flow = this.flowRunnerManager.getExecutableFlow(execid); if (flow == null) { respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_NOTFOUND); } else { respMap.put(ConnectorParams.STATUS_PARAM, flow.getStatus().toString()); respMap.put(ConnectorParams.RESPONSE_UPDATETIME, flow.getUpdateTime()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxFlowStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxPause(final Map<String, Object> respMap, final int execid, final String user) { if (user == null) { respMap.put(ConnectorParams.RESPONSE_ERROR, "user has not been set"); return; } try { this.flowRunnerManager.pauseFlow(execid, user); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final ExecutorManagerException e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxPause
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxResume(final Map<String, Object> respMap, final int execid, final String user) throws ServletException { if (user == null) { respMap.put(ConnectorParams.RESPONSE_ERROR, "user has not been set"); return; } try { this.flowRunnerManager.resumeFlow(execid, user); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final ExecutorManagerException e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxResume
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleAjaxCancel(final Map<String, Object> respMap, final int execid, final String user) { if (user == null) { respMap.put(ConnectorParams.RESPONSE_ERROR, "user has not been set"); return; } try { this.flowRunnerManager.cancelFlow(execid, user); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final ExecutorManagerException e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleAjaxCancel
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void handleReloadJobTypePlugins(final Map<String, Object> respMap) { try { this.flowRunnerManager.reloadJobTypePlugins(); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final Exception e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
handleReloadJobTypePlugins
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void setActive(final boolean value, final Map<String, Object> respMap) { try { setActiveInternal(value); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final Exception e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
setActive
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void setActiveInternal(final boolean value) throws ExecutorManagerException, InterruptedException { this.flowRunnerManager.setExecutorActive(value, this.application.getHost(), this.application.getPort()); }
Modifies the time interval at which the executor is polling the queue for unassigned jobs, and assigning a job(s) to itself. @param newPollingIntervalMillis The desired polling interval. It needs to be a positive integer (milliseconds) in String format. @param respMap The response map.
setActiveInternal
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void shutdown(final Map<String, Object> respMap) { try { logger.warn("Shutting down executor..."); // Set the executor to inactive. Will receive no new flows. setActiveInternal(false); this.application.shutdown(); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final Exception e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Prepare the executor for shutdown. @param respMap json response object
shutdown
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
private void getStatus(final Map<String, Object> respMap) { try { final ExecutorLoader executorLoader = this.application.getExecutorLoader(); final Executor executor = requireNonNull( executorLoader.fetchExecutor(this.application.getHost(), this.application.getPort()), "The executor can not be null"); respMap.put("executor_id", Integer.toString(executor.getId())); respMap.put("isActive", String.valueOf(executor.isActive())); respMap.put(ConnectorParams.STATUS_PARAM, ConnectorParams.RESPONSE_SUCCESS); } catch (final Exception e) { logger.error(e.getMessage(), e); respMap.put(ConnectorParams.RESPONSE_ERROR, e.getMessage()); } }
Prepare the executor for shutdown. @param respMap json response object
getStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ExecutorServlet.java
Apache-2.0
@Override public void setup(final ExecutableFlow flow) throws ExecutorManagerException { File tempDir = null; try { final ProjectDirectoryMetadata project = new ProjectDirectoryMetadata( flow.getProjectId(), flow.getVersion(), flow.getProjectName()); final long flowPrepStartTime = System.currentTimeMillis(); tempDir = downloadProjectIfNotExists(project, flow.getExecutionId()); LOGGER.info("Project is setup for execution {}", flow.getExecutionId()); // With synchronization, only one thread is allowed to proceed to avoid complicated race // conditions which could arise when multiple threads are downloading/deleting/hard-linking // the same project. But it doesn't prevent multiple executor processes interfering with each // other triggering race conditions. So it's important to operationally make sure that only // one executor process is setting up flow execution against the shared project directory. long criticalSectionStartTime = -1; File execDir = null; synchronized (this) { LOGGER.info("Setting up execution dir for {}", flow.getExecutionId()); criticalSectionStartTime = System.currentTimeMillis(); if (!project.getInstalledDir().exists() && tempDir != null) { // If new project is downloaded and project dir cache clean-up feature is enabled, then // perform clean-up if size of all project dirs exceeds the cache size. this.projectCacheCleaner.ifPresent(cacheCleaner -> cacheCleaner .deleteProjectDirsIfNecessary(project.getDirSizeInByte())); // Rename temp dir to a proper project directory name. Files.move(tempDir.toPath(), project.getInstalledDir().toPath()); } final long start = System.currentTimeMillis(); execDir = setupExecutionDir(project.getInstalledDir().toPath(), flow); final long end = System.currentTimeMillis(); LOGGER.info("Setting up execution dir {} took {} sec(s)", execDir, (end - start) / 1000); } final long flowPrepCompletionTime = System.currentTimeMillis(); LOGGER.info("Flow preparation completed in {} sec(s), out of which {} sec(s) was spent inside " + "critical section. [execid: {}, path: {}]", (flowPrepCompletionTime - flowPrepStartTime) / 1000, (flowPrepCompletionTime - criticalSectionStartTime) / 1000, flow.getExecutionId(), execDir.getPath()); } catch (final Exception ex) { LOGGER.error("Error in preparing flow execution {}", flow.getExecutionId(), ex); throw new ExecutorManagerException(ex); } finally { FileIOUtils.deleteDirectorySilently(tempDir); } }
Prepare the flow directory for execution. @param flow Executable Flow instance.
setup
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
@Override protected File setupExecutionDir(final Path dir, final ExecutableFlow flow) throws ExecutorManagerException { File execDir = null; try { execDir = createExecDir(flow); // Create hardlinks from the project FileIOUtils.createDeepHardlink(dir.toFile(), execDir); return execDir; } catch (final Exception ex) { FileIOUtils.deleteDirectorySilently(execDir); throw new ExecutorManagerException(ex); } }
Prepare the flow directory for execution. @param flow Executable Flow instance.
setupExecutionDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
@VisibleForTesting void updateLastModifiedTime(final Path path) { try { Files.setLastModifiedTime(path, FileTime.fromMillis(System.currentTimeMillis())); } catch (final IOException ex) { LOGGER.warn("Error when updating last modified time for {}", path, ex); } }
Update last modified time of the file if it exists. @param path path to the target file
updateLastModifiedTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
private String generateProjectDirName(final ProjectDirectoryMetadata proj) { return String.valueOf(proj.getProjectId()) + "." + String.valueOf(proj.getVersion()); }
@return the project directory name of a project
generateProjectDirName
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
private File createTempDir(final ProjectDirectoryMetadata proj) throws IOException { final String projectDir = generateProjectDirName(proj); final File tempDir = Files.createTempDirectory( this.projectCacheDir.toPath(), "_temp." + projectDir + ".").toFile(); return tempDir; }
@return the project directory name of a project
createTempDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
@VisibleForTesting File downloadProjectIfNotExists(final ProjectDirectoryMetadata proj, final int execId) throws IOException { final String projectDir = generateProjectDirName(proj); if (proj.getInstalledDir() == null) { proj.setInstalledDir(new File(this.projectCacheDir, projectDir)); } // If directory exists, assume it's prepared and skip. if (proj.getInstalledDir().exists()) { LOGGER.info("Project {} already cached. Skipping download. ExecId: {}", proj, execId); // Hit the local cache. this.projectCacheHitRatio.markHit(); // Update last modified time of the file keeping project dir size when the project is // accessed. This last modified time will be used to determined least recently used // projects when performing project directory clean-up. updateLastModifiedTime( Paths.get(proj.getInstalledDir().getPath(), PROJECT_DIR_SIZE_FILE_NAME)); return null; } this.projectCacheHitRatio.markMiss(); // Download project to a temp dir if not exists in local cache. final File tempDir = createTempDir(proj); downloadAndUnzipProject(proj, execId, tempDir); return tempDir; }
Download project zip and unzip it if not exists locally. @param proj project to download @param execId execution id number @return the temp dir where the new project is downloaded to, null if no project is downloaded. @throws IOException if downloading or unzipping fails.
downloadProjectIfNotExists
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
private File createExecDir(final ExecutableFlow flow) { final int execId = flow.getExecutionId(); final File execDir = new File(this.executionsDir, String.valueOf(execId)); flow.setExecutionPath(execDir.getPath()); execDir.mkdirs(); return execDir; }
Download project zip and unzip it if not exists locally. @param proj project to download @param execId execution id number @return the temp dir where the new project is downloaded to, null if no project is downloaded. @throws IOException if downloading or unzipping fails.
createExecDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
public void shutdown() { if (projectCacheCleaner.isPresent()) { this.projectCacheCleaner.get().shutdown(); } }
Download project zip and unzip it if not exists locally. @param proj project to download @param execId execution id number @return the temp dir where the new project is downloaded to, null if no project is downloaded. @throws IOException if downloading or unzipping fails.
shutdown
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowPreparer.java
Apache-2.0
private boolean isRampFeatureActivated() { if (isRampFeatureEnabled || executableRampMap != null) { if (!executableRampMap.getActivatedAll().isEmpty()) { return true; } } return false; }
Check if the system is activating the ramp feature, aka some system configuration is ramping.
isRampFeatureActivated
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@Override public void handleEvent(Event event) { if (!isRampFeatureActivated()) return; if (event.getData().isRootFlowEvent() && (event.getType() == EventType.FLOW_STARTED || event.getType() == EventType.FLOW_FINISHED)) { final FlowRunner flowRunner = (FlowRunner) event.getRunner(); logFlowEvent(flowRunner, event.getType()); } }
Ramp Feature need to track the health of running flow to determine if stop/pause Ramp will be necessary. FlowRampManager is registered into the FlowRunnerManager's Listeners
handleEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@Override public void beforeExecute(Runnable r) { }
Ramp Feature need to track the health of running flow to determine if stop/pause Ramp will be necessary. FlowRampManager is registered into the FlowRunnerManager's Listeners
beforeExecute
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@Override public void afterExecute(Runnable r) { }
Ramp Feature need to track the health of running flow to determine if stop/pause Ramp will be necessary. FlowRampManager is registered into the FlowRunnerManager's Listeners
afterExecute
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public void shutdown() { if (isRampPollingServiceEnabled) { LOGGER.warn("Shutting down FlowRampManager..."); pollingService.shutdown(); // Persistent cached data into DB saveSettings(); LOGGER.warn("Shutdown FlowRampManager complete."); } }
This shuts down the flow ramp. The call is blocking and awaits execution of all jobs.
shutdown
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public void shutdownNow() { if (isRampPollingServiceEnabled) { LOGGER.warn("Shutting down FlowRampManager now..."); pollingService.shutdown(); } }
This attempts shuts down the flow runner immediately (unsafe). This doesn't wait for jobs to finish but interrupts all threads.
shutdownNow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public int getNumOfRamps() { return executableRampMap.getActivatedAll().size(); }
This attempts shuts down the flow runner immediately (unsafe). This doesn't wait for jobs to finish but interrupts all threads.
getNumOfRamps
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadSettings() { loadExecutableRamps(); loadExecutableRampItems(); loadExecutableRampDependencies(); loadExecutableRampExceptionalFlowItems(); loadExecutableRampExceptionalJobItems(); latestDataBaseSynchronizationTimeStamp = System.currentTimeMillis(); LOGGER.info(String.format("Ramp Settings had been successfully loaded at [%d].", latestDataBaseSynchronizationTimeStamp)); }
Load all ramp Settings from DB
loadSettings
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadExecutableRamps() { try { if (executableRampMap == null) { executableRampMap = executorLoader.fetchExecutableRampMap(); } else { executableRampMap.refresh(executorLoader.fetchExecutableRampMap()); } } catch (ExecutorManagerException e) { LOGGER.error("Load all active Executable Ramp failure"); } }
Load All active ramps, Key = rampId
loadExecutableRamps
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadExecutableRampItems() { try { if (executableRampItemsMap == null) { executableRampItemsMap = executorLoader.fetchExecutableRampItemsMap(); } else { executableRampItemsMap.refresh(executorLoader.fetchExecutableRampItemsMap()); } } catch (ExecutorManagerException e) { LOGGER.error("Load Executable Ramp Items failure"); } }
Load All dependency properties into the executableRampProperties Map, Key = rampId,
loadExecutableRampItems
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadExecutableRampDependencies() { try { if (executableRampDependencyMap == null) { executableRampDependencyMap = executorLoader.fetchExecutableRampDependencyMap(); } else { executableRampDependencyMap.refresh(executorLoader.fetchExecutableRampDependencyMap()); } } catch (ExecutorManagerException e) { LOGGER.error("Load Executable Ramp Dependencies failure"); } }
Load All Default dependency values for ramp When the dependency does not have ramp setting, the default Value will be applied.
loadExecutableRampDependencies
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadExecutableRampExceptionalFlowItems() { try { if (executableRampExceptionalFlowItemsMap == null) { executableRampExceptionalFlowItemsMap = executorLoader.fetchExecutableRampExceptionalFlowItemsMap(); } else { executableRampExceptionalFlowItemsMap.refresh(executorLoader.fetchExecutableRampExceptionalFlowItemsMap()); } } catch (ExecutorManagerException e) { LOGGER.error("Load Executable Ramp Exceptional Items on Flow Level Failure"); } }
Load All Ramp Exceptional Items on Flow Level
loadExecutableRampExceptionalFlowItems
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void loadExecutableRampExceptionalJobItems() { try { if (executableRampExceptionalJobItemsMap == null) { executableRampExceptionalJobItemsMap = executorLoader.fetchExecutableRampExceptionalJobItemsMap(); } else { executableRampExceptionalJobItemsMap.refresh(executorLoader.fetchExecutableRampExceptionalJobItemsMap()); } } catch (ExecutorManagerException e) { LOGGER.error("Load Executable Ramp Exceptional Items on Job Level Failure"); } }
Load All Ramp Exceptional Items on Job Level
loadExecutableRampExceptionalJobItems
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void saveSettings() { executableRampMap .getAll() .stream() .filter(ExecutableRamp::isChanged) .forEach(this::updateExecutableRamp); executableRampExceptionalFlowItemsMap .entrySet() .stream() .forEach(this::updateExecutedRampFlows); rampDataModel.resetFlowCountAfterSave(); LOGGER.info("Ramp Settings had been successfully saved."); }
Save all ramp settings into DB
saveSettings
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting /** * Persistent all Executable Ramp Status in this azkaban executor into the DB */ synchronized void updateExecutableRamp(ExecutableRamp executableRamp) { try { // Save all cachedNumTrail, cachedNumSuccess, cachedNumFailure, cachedNumIgnored, // save isPaused, endTime when it is not zero, lastUpdatedTime when it is changed. executorLoader.updateExecutableRamp(executableRamp); // mark cache has been saved executableRamp.cacheSaved(); } catch (ExecutorManagerException e) { LOGGER.error(String.format("Update Executable Ramp [%s] Failure.", executableRamp.getId())); } }
Save all ramp settings into DB
updateExecutableRamp
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
@VisibleForTesting synchronized void updateExecutedRampFlows(Map.Entry<String, ExecutableRampExceptionalItems> entry) { try { // Save all Identified workflow into the DB executorLoader.updateExecutedRampFlows(entry.getKey(), entry.getValue()); } catch (ExecutorManagerException e) { LOGGER.error("Fail to append ramp items into DB.", e); } }
Save All Ramp Exceptional Items on Flow Level
updateExecutedRampFlows
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized public void configure(ExecutableFlow executableFlow, File flowDirectory) { if (!isRampFeatureActivated()) return; // To be safe, check if there is any jar files in ./excluded folder // and move them back to the place in original location of the package moveFiles( FileIOUtils.getDirectory(flowDirectory, EXCLUDED_SUB_FOLDER_NAME), flowDirectory, ALL_LIB_JAR_REG_EXP ); moveFiles( FileIOUtils.getDirectory(flowDirectory, EXCLUDED_LIB_SUB_FOLDER_NAME), FileIOUtils.getDirectory(flowDirectory, LIB_SUB_FOLDER_NAME), ALL_LIB_JAR_REG_EXP ); String flowName = executableFlow.getFlowName(); ExecutableFlowRampMetadata executableFlowRampMetadata = ExecutableFlowRampMetadata.createInstance( executableRampDependencyMap, executableRampExceptionalJobItemsMap.getExceptionalJobItemsByFlow(flowName) ); for (ExecutableRamp executableRamp : executableRampMap.getActivatedAll()) { try { String rampId = executableRamp.getId(); LOGGER.info("RAMP_CHECK: (rampId = {}, rampStage = {}, executionId = {}, flowName = {}, RampPercentageId = {})", rampId, executableRamp.getStage(), executableFlow.getExecutionId(), flowName, executableFlow.getRampPercentageId() ); // get Base Props Props baseProps = new Props(); baseProps.putAll(executableRampDependencyMap.getDefaultValues(executableRampItemsMap.getDependencies(rampId))); ExecutableRampStatus status = executableRampExceptionalFlowItemsMap.check(rampId, flowName); LOGGER.info("RAMP_STATUS: (Status = {}, flowName = {})", status.name(), flowName); switch (status) { case BLACKLISTED: // blacklist executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( Props.clone(executableRampItemsMap.getRampItems(rampId)), baseProps, ExecutableRampStatus.BLACKLISTED.name() ) ); LOGGER.info("RAMP_BLACKLISTED: (rampId = {}, flowName = {})", rampId, flowName); break; case WHITELISTED: // whitelist executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( baseProps, Props.clone(executableRampItemsMap.getRampItems(rampId)), ExecutableRampStatus.WHITELISTED.name() ) ); LOGGER.info("RAMP_WHITELISTED: (rampId = {}, flowName = {})", rampId, flowName); break; case SELECTED: // selected executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( baseProps, Props.clone(executableRampItemsMap.getRampItems(rampId)), ExecutableRampStatus.SELECTED.name() ) ); LOGGER.info("RAMP_SELECTED: (rampId = {}, flowName = {})", rampId, flowName); break; case UNSELECTED: // selected executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( Props.clone(executableRampItemsMap.getRampItems(rampId)), baseProps, ExecutableRampStatus.UNSELECTED.name() ) ); LOGGER.info("RAMP_UNSELECTED: (rampId = {}, flowName = {})", rampId, flowName); break; case EXCLUDED: executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( null, baseProps, ExecutableRampStatus.EXCLUDED.name() ) ); LOGGER.info("RAMP_EXECLUDED: (rampId = {}, flowName = {})", rampId, flowName); break; default: RampPolicy rampPolicy = rampPolicyManager.buildRampPolicyExecutor(executableRamp.getPolicy(), globalProps); LOGGER.info ("RAMP_POLICY_SELECTING: (policy = {}, rampId = {}, flowName = {}, executionId = {}, RampPercentageId = {})", rampPolicy.getClass().getName(), rampId, flowName, executableFlow.getExecutionId(), executableFlow.getRampPercentageId() ); if (rampPolicy.check(executableFlow, executableRamp)) { // Ramp Enabled executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( baseProps, Props.clone(executableRampItemsMap.getRampItems(rampId)), ExecutableRampStatus.SELECTED.name() ) ); LOGGER.info("RAMP_POLICY_SELECTED: (rampId = {}, flowName = {})", rampId, flowName); } else { executableFlowRampMetadata.setRampProps( rampId, Props.getInstance( Props.clone(executableRampItemsMap.getRampItems(rampId)), baseProps, ExecutableRampStatus.UNSELECTED.name() ) ); LOGGER.info("RAMP_POLICY_UNSELECTED: (rampId = {}, flowName = {})", rampId, flowName); } break; } // Remove Package Dependencies List<String> removableDependencies = executableRampItemsMap .getDependencies(rampId) .stream() .filter(key -> key.startsWith(JAR_DEPENDENCY_PREFIX)) .filter(key -> (!baseProps.get(key).isEmpty() || !executableFlowRampMetadata.getRampItemValue(rampId, key).isEmpty())) .map(key -> key.substring(JAR_DEPENDENCY_PREFIX.length())) .collect(Collectors.toList()); String regExpression = String.format(LIB_JAR_REG_EXP_FORMATTER, String.join("|", removableDependencies)); if (!removableDependencies.isEmpty()) { // Move those selected jar dependencies in ./ and ./lib folders // into the ./excluded and ./excluded/lib folder moveFiles( flowDirectory, FileIOUtils.getDirectory(flowDirectory, EXCLUDED_SUB_FOLDER_NAME), regExpression ); moveFiles( FileIOUtils.getDirectory(flowDirectory, LIB_SUB_FOLDER_NAME), FileIOUtils.getDirectory(flowDirectory, EXCLUDED_LIB_SUB_FOLDER_NAME), regExpression ); } } catch (Exception e) { LOGGER.error("RAMP_EXEC_ERROR: (message = {})", e.getMessage()); } } // Append the result into the executable flow executableFlow.setExecutableFlowRampMetadata(executableFlowRampMetadata); }
Call to set Executable Ramp Metadata into ExecutableFlow
configure
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
private void moveFiles(File sourceDir, File destinationDir, String regExpression) { try { FileIOUtils.moveFiles(sourceDir, destinationDir, regExpression); LOGGER.info("Success to move files from {} to {} with REGEXP {}", sourceDir.getAbsolutePath(), destinationDir.getAbsolutePath(), regExpression); } catch (IOException e) { LOGGER.error( String.format("Fail to move files from %s to %s with REGEXP %s", sourceDir.getAbsolutePath(), destinationDir.getAbsolutePath(), regExpression ), e); } }
Call to set Executable Ramp Metadata into ExecutableFlow
moveFiles
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized private void logFlowEvent(FlowRunner flowRunner, EventType eventType) { final ExecutableFlow flow = flowRunner.getExecutableFlow(); LOGGER.info("RAMP_FLOW_EVENT_CAPTURED: (ID = {}, FlowName = {}, ExecutionId = {}, FlowStatus = {})", flow.getId(), flow.getFlowName(), flow.getExecutionId(), flow.getStatus().toString()); if (eventType == EventType.FLOW_STARTED) { Set<String> activeRamps = flow.getExecutableFlowRampMetadata().getActiveRamps(); rampDataModel.beginFlow(flow.getExecutionId(), activeRamps); LOGGER.info("RAMP_STARTED: (FlowName = {}, ExecutionId = {}, Ramps = {})", flow.getFlowName(), flow.getExecutionId(), activeRamps.toString()); if (isDatabasePullingActionRequired()) { LOGGER.info("BEGIN Reload ramp settings from DB ......"); loadSettings(); LOGGER.info("END Reload ramp settings from DB ......"); } } else { // EventType.FLOW_FINISHED logFlowAction(flowRunner, convertToAction(flow.getStatus())); Set<String> ramps = rampDataModel.endFlow(flow.getExecutionId()); LOGGER.info("RAMP_FINISHED: (FlowName = {}, ExecutionId = {}, Ramps = {})", flow.getFlowName(), flow.getExecutionId(), ramps.toString()); if (isDatabasePushingActionRequired()) { LOGGER.info("BEGIN Save ramp settings into DB ......"); saveSettings(); LOGGER.info("END Save ramp settings into DB ......"); } } }
Call to set Executable Ramp Metadata into ExecutableFlow
logFlowEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized private void logFlowAction(FlowRunner flowRunner, Action action) { flowRunner.getExecutableFlow() .getExecutableFlowRampMetadata() .getActiveRamps() .stream() .map(executableRampMap::get) .forEach(executableRamp -> { LOGGER.info("FlowRunner Save Result after Ramp. [rampId = {}, action = {}]", executableRamp.getId(), action.name()); executableRamp.cacheResult(action); if (Action.FAILED.equals(action)) { String rampId = executableRamp.getId(); String flowName = flowRunner.getExecutableFlow().getFlowName(); LOGGER.warn("RAMP_EXCLUDE_FLOW: [executionId = {}, rampId = {}, flowName = {}, action = {}, ramp = {}]", flowRunner.getExecutableFlow().getExecutionId(), rampId, flowName, action.name(), flowRunner.isRamping() ); if (!executableRamp.ignoreTestFailure()) { executableRampExceptionalFlowItemsMap.add(rampId, flowName, ExecutableRampStatus.EXCLUDED, System.currentTimeMillis(), true); } } }); }
Call to set Executable Ramp Metadata into ExecutableFlow
logFlowAction
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized private boolean isDatabasePushingActionRequired() { return ((!isRampPollingServiceEnabled) && (statusPushIntervalMax <= rampDataModel.getEndFlowCount())); }
Call to set Executable Ramp Metadata into ExecutableFlow
isDatabasePushingActionRequired
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized private boolean isDatabasePullingActionRequired() { return ((!isRampPollingServiceEnabled) && (statusPullIntervalMax <= rampDataModel.getBeginFlowCount())); }
Call to set Executable Ramp Metadata into ExecutableFlow
isDatabasePullingActionRequired
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
synchronized private Action convertToAction(Status status) { if (Status.FAILED.equals(status)) return Action.FAILED; if (Status.isStatusSucceeded(status)) return Action.SUCCEEDED; return Action.IGNORED; }
Call to set Executable Ramp Metadata into ExecutableFlow
convertToAction
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public synchronized void beginFlow(final int executionId, Set<String> ramps) { lock.lock(); executingFlows.put(executionId, ramps); beginFlowCount++; lock.unlock(); }
Call to set Executable Ramp Metadata into ExecutableFlow
beginFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public synchronized Set<String> endFlow(final int executionId) { Set<String> ramps = executingFlows.get(executionId); lock.lock(); executingFlows.remove(executionId); endFlowCount++; lock.unlock(); return ramps; }
Call to set Executable Ramp Metadata into ExecutableFlow
endFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public Map<Integer, Set<String>> getExecutingFlows() { return this.executingFlows; }
Call to set Executable Ramp Metadata into ExecutableFlow
getExecutingFlows
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public int getBeginFlowCount() { return beginFlowCount; }
Call to set Executable Ramp Metadata into ExecutableFlow
getBeginFlowCount
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public int getEndFlowCount() { return endFlowCount; }
Call to set Executable Ramp Metadata into ExecutableFlow
getEndFlowCount
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public void resetFlowCountAfterSave() { lock.lock(); beginFlowCount = executingFlows.size(); endFlowCount = 0; lock.unlock(); }
Call to set Executable Ramp Metadata into ExecutableFlow
resetFlowCountAfterSave
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public boolean hasUnsavedFinishedFlow() { return endFlowCount > 0; }
Call to set Executable Ramp Metadata into ExecutableFlow
hasUnsavedFinishedFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRampManager.java
Apache-2.0
public long getFlowKillTime() { return this.flowKillTime; }
Class that handles the running of a ExecutableFlow DAG
getFlowKillTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public long getFlowKillDuration() { return this.flowKillDuration; }
Class that handles the running of a ExecutableFlow DAG
getFlowKillDuration
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public long getFlowPauseTime() { return this.flowPauseTime; }
Class that handles the running of a ExecutableFlow DAG
getFlowPauseTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public void setFlowCreateTime(final long flowCreateTime) { this.flowCreateTime = flowCreateTime; }
Class that handles the running of a ExecutableFlow DAG
setFlowCreateTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public long getFlowPauseDuration() { return this.flowPauseDuration; }
Class that handles the running of a ExecutableFlow DAG
getFlowPauseDuration
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public long getFlowCreateTime() { return this.flowCreateTime; }
Class that handles the running of a ExecutableFlow DAG
getFlowCreateTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@VisibleForTesting public FlowRunnerProxy getProxy() { return this.flowRunnerProxy; }
@return the proxy class object associated with this instance.
getProxy
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@VisibleForTesting ConcurrentHashMap<String, String> getJobEffectiveUsers() { return this.jobEffectiveUsers; }
@return the proxy class object associated with this instance.
getJobEffectiveUsers
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@VisibleForTesting Logger getLogger() { return this.logger; }
@return the proxy class object associated with this instance.
getLogger
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public FlowRunner setFlowWatcher(final FlowWatcher watcher) { this.watcher = watcher; return this; }
@return the proxy class object associated with this instance.
setFlowWatcher
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public FlowRunner setNumJobThreads(final int jobs) { this.numJobThreads = jobs; return this; }
@return the proxy class object associated with this instance.
setNumJobThreads
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public FlowRunner setJobLogSettings(final String jobLogFileSize, final int jobLogNumFiles) { this.jobLogFileSize = jobLogFileSize; this.jobLogNumFiles = jobLogNumFiles; return this; }
@return the proxy class object associated with this instance.
setJobLogSettings
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public FlowRunner setValidateProxyUser(final boolean validateUserProxy) { this.validateUserProxy = validateUserProxy; return this; }
@return the proxy class object associated with this instance.
setValidateProxyUser
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public File getExecutionDir() { return this.execDir; }
@return the proxy class object associated with this instance.
getExecutionDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@VisibleForTesting AlerterHolder getAlerterHolder() { return this.alerterHolder; }
@return the proxy class object associated with this instance.
getAlerterHolder
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@Override public void run() { // The current thread is used for interrupting blocks this.flowRunnerThread = Thread.currentThread(); this.flowRunnerThread.setName("FlowRunner-exec-" + this.flow.getExecutionId()); // Sanity check if the flow initial status is valid or not. if (Status.isStatusFinished(flow.getStatus()) || Status.isStatusRunning(flow.getStatus())) { // These should still be cleaned up if (this.watcher != null) { this.logger.info("Watcher is attached. Stopping watcher."); this.watcher.stopWatcher(); this.logger .info("Watcher cancelled status is " + this.watcher.isWatchCancelled()); } closeLogger(); return; } this.flowStartupDelayTimer = this.execMetrics.getFlowStartupDelayTimerContext(); try { if (this.executorService == null) { this.executorService = Executors.newFixedThreadPool(this.numJobThreads, new ThreadFactoryBuilder().setNameFormat("azk-job-pool-%d").build()); } setupFlowExecution(); this.flow.setStartTime(System.currentTimeMillis()); this.logger.info("Updating initial flow directory."); updateFlow(); this.logger.info("Fetching job and shared properties."); if (!FlowLoaderUtils.isAzkabanFlowVersion20(this.flow.getAzkabanFlowVersion())) { loadAllProperties(); } this.fireEventListeners( Event.create(this, EventType.FLOW_STARTED, new EventData(this.getExecutableFlow()))); runFlow(); } catch (final Throwable t) { if (this.logger != null) { this.logger .error("An error has occurred during the running of the flow. Quitting.", t); } if (Status.KILLING.equals(this.flow.getStatus())) { this.execMetrics.decrementFlowKillingCount(); } this.flow.setStatus(Status.FAILED); } finally { try { if (this.watcher != null) { this.logger.info("Watcher is attached. Stopping watcher."); this.watcher.stopWatcher(); this.logger .info("Watcher cancelled status is " + this.watcher.isWatchCancelled()); } this.flow.setEndTime(System.currentTimeMillis()); this.logger.info("Setting end time for flow " + this.execId + " to " + System.currentTimeMillis()); closeLogger(); updateFlow(); } finally { reportFlowFinishedMetrics(); this.fireEventListeners( Event.create(this, EventType.FLOW_FINISHED, new EventData(this.flow))); this.logger .info( "Created " + EventType.FLOW_FINISHED + " event for " + this.flow.getExecutionId()); // In polling model, executor will be responsible for sending alerting emails when a flow // finishes. // Todo jamiesjc: switch to event driven model and alert on FLOW_FINISHED event. if (isPollDispatchMethodEnabled() || isContainerizedDispatchMethodEnabled()) { ExecutionControllerUtils.alertUserOnFlowFinished(this.flow, this.alerterHolder, ExecutionControllerUtils.getFinalizeFlowReasons("Flow finished", null)); } } } }
@return the proxy class object associated with this instance.
run
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean isPollDispatchMethodEnabled() { return DispatchMethod.isPollMethodEnabled(this.azkabanProps .getString(Constants.ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD, DispatchMethod.PUSH.name())); }
@return the proxy class object associated with this instance.
isPollDispatchMethodEnabled
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean isContainerizedDispatchMethodEnabled() { return DispatchMethod.isContainerizedMethodEnabled(this.azkabanProps .getString(Constants.ConfigurationKeys.AZKABAN_EXECUTION_DISPATCH_METHOD, DispatchMethod.PUSH.name())); }
@return the proxy class object associated with this instance.
isContainerizedDispatchMethodEnabled
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void reportFlowFinishedMetrics() { final Status status = this.flow.getStatus(); switch (status) { case SUCCEEDED: this.execMetrics.markFlowSuccess(); break; case FAILED: this.commonMetrics.markFlowFail(); break; case KILLED: this.execMetrics.markFlowKilled(); // Compute the duration to kill a flow if (this.flowKillDuration == 0 && this.flowKillTime != -1) { this.flowKillDuration = System.currentTimeMillis() - this.flowKillTime; } this.execMetrics.addFlowTimeToKill(this.flowKillDuration); break; default: break; } }
@return the proxy class object associated with this instance.
reportFlowFinishedMetrics
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void setupFlowExecution() { final int projectId = this.flow.getProjectId(); final int version = this.flow.getVersion(); final String flowId = this.flow.getFlowId(); // Add a bunch of common azkaban properties Props commonFlowProps = FlowUtils.addCommonFlowProperties(null, this.flow); if (FlowLoaderUtils.isAzkabanFlowVersion20(this.flow.getAzkabanFlowVersion())) { final Props flowProps = FlowLoaderUtils.loadPropsFromYamlFile( this.projectLoader, this.flow, null); if (flowProps != null) { flowProps.setParent(commonFlowProps); commonFlowProps = flowProps; } } else { if (this.flow.getJobSource() != null) { final String source = this.flow.getJobSource(); final Props flowProps = this.sharedProps.get(source); flowProps.setParent(commonFlowProps); commonFlowProps = flowProps; } } // If there are flow overrides, we log them & apply them on the flow node. final Map<String, String> flowParam = this.flow.getExecutionOptions().getFlowParameters(); if (flowParam != null && !flowParam.isEmpty()) { this.logger.info("ROOT Runtime Props: " + flowParam); commonFlowProps = new Props(commonFlowProps, flowParam); } this.flow.setInputProps(commonFlowProps); // If there are runtime properties, we log them now. final Map<String, Map<String, String>> runtimeProperties = this.flow.getExecutionOptions() .getRuntimeProperties(); if (runtimeProperties != null && !runtimeProperties.isEmpty()) { this.logger.info("Other Runtime Props: " + runtimeProperties); } if (this.watcher != null) { this.watcher.setLogger(this.logger); } // Avoid NPE in unit tests when the static app instance is not set if (AzkabanExecutorServer.getApp() != null) { this.logger .info("Assigned executor : " + AzkabanExecutorServer.getApp().getExecutorHostPort()); } this.logger.info("Running execid:" + this.execId + " flow:" + flowId + " project:" + projectId + " version:" + version); if (this.pipelineExecId != null) { this.logger.info("Running simulateously with " + this.pipelineExecId + ". Pipelining level " + this.pipelineLevel); } }
@return the proxy class object associated with this instance.
setupFlowExecution
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private synchronized void updateFlow(final long time) { try { this.flow.setUpdateTime(time); this.executorLoader.updateExecutableFlow(this.flow); } catch (final ExecutorManagerException e) { this.logger.error("Error updating flow.", e); } }
@return the proxy class object associated with this instance.
updateFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void createLogger(final String flowId) { // Create logger // If this is a containerized execution then there is no need for a custom logger. // The logs would be appended to server logs and persisted from FlowContainer. if (isContainerizedDispatchMethodEnabled()) { this.logger = Logger.getLogger(FlowRunner.class); return; } // Not containerized execution, fallback to existing logic. final String loggerName = this.execId + "." + flowId; this.logger = Logger.getLogger(loggerName); // Create file appender final String logName = "_flow." + loggerName + ".log"; this.logFile = new File(this.execDir, logName); final String absolutePath = this.logFile.getAbsolutePath(); this.flowAppender = null; try { this.flowAppender = new FileAppender(this.loggerLayout, absolutePath, false); this.logger.addAppender(this.flowAppender); if (this.azkabanProps.getBoolean(Constants.ConfigurationKeys.AZKABAN_LOGGING_KAFKA_ENABLED, false)) { // Keep the names consistent as what we did in uploadLogFile() this.kafkaLog4jAppender = KafkaLog4jUtils.getAzkabanFlowKafkaLog4jAppender(this.azkabanProps, this.loggerLayout, String.valueOf(this.execId), ""); if (this.kafkaLog4jAppender != null) { this.logger.addAppender(this.kafkaLog4jAppender); this.logger.setAdditivity(false); this.logger.info("Attached new Kafka appender for flow"); } } } catch (final IOException e) { this.logger.error("Could not open log file in " + this.execDir, e); } }
setup logger and execution dir for the flowId
createLogger
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void removeAppender(final Appender appender) { if (appender != null) { try { this.logger.removeAppender(appender); appender.close(); } catch (Exception e) { logger.error("Failed to remove appender " + appender.getName(), e); } } }
setup logger and execution dir for the flowId
removeAppender
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void closeLogger() { if (!isContainerizedDispatchMethodEnabled() && this.logger != null) { removeAppender(this.flowAppender); removeAppender(this.kafkaLog4jAppender); try { this.executionLogsLoader.uploadLogFile(this.execId, "", 0, this.logFile); } catch (final ExecutorManagerException e) { logger.error("Failed to close logger", e); } } }
setup logger and execution dir for the flowId
closeLogger
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void loadAllProperties() throws IOException { // First load all the properties for (final ImmutableFlowProps fprops : this.flow.getFlowProps()) { final String source = fprops.getSource(); final File propsPath = new File(this.execDir, source); final Props props = new Props(null, propsPath); this.sharedProps.put(source, props); } // Resolve parents for (final ImmutableFlowProps fprops : this.flow.getFlowProps()) { if (fprops.getInheritedSource() != null) { final String source = fprops.getSource(); final String inherit = fprops.getInheritedSource(); final Props props = this.sharedProps.get(source); final Props inherits = this.sharedProps.get(inherit); props.setParent(inherits); } } }
setup logger and execution dir for the flowId
loadAllProperties
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
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 InterruptedException e) { } continue; } else { if (this.retryFailedJobs) { retryAllFailures(); } else if (!progressGraph()) { try { this.mainSyncObj.wait(CHECK_WAIT_MS); } catch (final InterruptedException e) { } } } } } this.logger.info("Finishing up flow. Awaiting Termination"); boolean result = false; try { this.executorService.shutdown(); this.logger.info("Awaiting termination of job runners"); result = this.executorService.awaitTermination( SHUTDOWN_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); } catch (final InterruptedException e) { this.logger.error(e.getMessage()); } if (!result) { this.logger.warn("ExecutorService did not shut down cleanly yet. Ignoring it."); } updateFlow(); this.logger.info("Finished Flow"); }
Main method that executes the jobs.
runFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void retryAllFailures() throws IOException { this.logger.info("Restarting all failed jobs"); this.retryFailedJobs = false; this.flowKilled = false; this.flowFailed = false; this.flow.setStatus(Status.RUNNING); final ArrayList<ExecutableNode> retryJobs = new ArrayList<>(); resetFailedState(this.flow, retryJobs); for (final ExecutableNode node : retryJobs) { if (node.getStatus() == Status.READY || node.getStatus() == Status.DISABLED) { runReadyJob(node); } else if (node.getStatus() == Status.SUCCEEDED) { for (final String outNodeId : node.getOutNodes()) { final ExecutableFlowBase base = node.getParentFlow(); runReadyJob(base.getExecutableNode(outNodeId)); } } runReadyJob(node); } updateFlow(); }
Main method that executes the jobs.
retryAllFailures
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean progressGraph() throws IOException { this.finishedNodes.swap(); // The following nodes are finished, so we'll collect a list of outnodes // that are candidates for running next. final HashSet<ExecutableNode> nodesToCheck = new HashSet<>(); for (final ExecutableNode node : this.finishedNodes) { Set<String> outNodeIds = node.getOutNodes(); ExecutableFlowBase parentFlow = node.getParentFlow(); // If a job is seen as failed or killed due to failing SLA, then we set the parent flow to // FAILED_FINISHING if (node.getStatus() == Status.FAILED || (node.getStatus() == Status.KILLED && node .isKilledBySLA())) { // The job cannot be retried or has run out of retry attempts. We will // fail the job and its flow now. if (!retryJobIfPossible(node)) { setFlowFailed(node); // Report FLOW_STATUS_CHANGED EVENT when status changes from running to failed this.fireEventListeners( Event.create(this, EventType.FLOW_STATUS_CHANGED, new EventData(this.getExecutableFlow()))); } else { nodesToCheck.add(node); continue; } } if (outNodeIds.isEmpty() && isFlowReadytoFinalize(parentFlow)) { // Todo jamiesjc: For conditional workflows, if conditionOnJobStatus is ONE_SUCCESS or // ONE_FAILED, some jobs might still be running when the end nodes have finished. In this // case, we need to kill all running jobs before finalizing the flow. finalizeFlow(parentFlow); finishExecutableNode(parentFlow); // If the parent has a parent, then we process if (!(parentFlow instanceof ExecutableFlow)) { outNodeIds = parentFlow.getOutNodes(); parentFlow = parentFlow.getParentFlow(); } } // Add all out nodes from the finished job. We'll check against this set // to // see if any are candidates for running. for (final String nodeId : outNodeIds) { final ExecutableNode outNode = parentFlow.getExecutableNode(nodeId); nodesToCheck.add(outNode); } } // Runs candidate jobs. The code will check to see if they are ready to run // before // Instant kill or skip if necessary. boolean jobsRun = false; for (final ExecutableNode node : nodesToCheck) { if (notReadyToRun(node.getStatus())) { // Really shouldn't get in here. continue; } jobsRun |= runReadyJob(node); } if (jobsRun || this.finishedNodes.getSize() > 0) { updateFlow(); return true; } return false; }
Main method that executes the jobs.
progressGraph
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void setFlowFailed(final ExecutableNode node) { boolean shouldFail = true; // As long as there is no outNodes or at least one outNode has conditionOnJobStatus of // ALL_SUCCESS, we should set the flow to failed. Otherwise, it could still statisfy the // condition of conditional workflows, so don't set the flow to failed. for (final String outNodeId : node.getOutNodes()) { if (node.getParentFlow().getExecutableNode(outNodeId).getConditionOnJobStatus() .equals(ConditionOnJobStatus.ALL_SUCCESS)) { shouldFail = true; break; } else { shouldFail = false; } } if (shouldFail) { this.getExecutableFlow().setFailedJobId(node.getId()); propagateStatusAndAlert(node.getParentFlow(), node.getStatus() == Status.KILLED ? Status.KILLED : Status.FAILED_FINISHING); if (this.failureAction == FailureAction.CANCEL_ALL) { this.kill(); } this.flowFailed = true; } }
Main method that executes the jobs.
setFlowFailed
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean notReadyToRun(final Status status) { return Status.isStatusFinished(status) || Status.isStatusRunning(status) || Status.KILLING == status; }
Main method that executes the jobs.
notReadyToRun
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean runReadyJob(final ExecutableNode node) throws IOException { if (Status.isStatusFinished(node.getStatus()) || Status.isStatusRunning(node.getStatus())) { return false; } final Status nextNodeStatus = getImpliedStatus(node); if (nextNodeStatus == null) { return false; } if (nextNodeStatus == Status.CANCELLED) { // if node is root flow if (node instanceof ExecutableFlow && node.getParentFlow() == null) { this.logger.info(String.format("Flow '%s' was cancelled before execution had started.", node.getId())); finalizeFlow((ExecutableFlow) node); } else { this.logger.info(String.format("Cancelling '%s' due to prior errors.", node.getNestedId())); node.cancelNode(System.currentTimeMillis()); finishExecutableNode(node); } } else if (nextNodeStatus == Status.SKIPPED) { this.logger.info("Skipping disabled job '" + node.getId() + "'."); node.skipNode(System.currentTimeMillis()); finishExecutableNode(node); } else if (nextNodeStatus == Status.READY) { if (node instanceof ExecutableFlowBase) { final ExecutableFlowBase flow = ((ExecutableFlowBase) node); this.logger.info("Running flow '" + flow.getNestedId() + "'."); flow.setStatus(Status.RUNNING); // don't overwrite start time of root flows if (flow.getStartTime() <= 0) { flow.setStartTime(System.currentTimeMillis()); } prepareJobProperties(flow); // Only take care of subflow's events if (!(node instanceof ExecutableFlow)) { this.fireEventListeners( Event.create(this, EventType.FLOW_STARTED, new EventData(node))); } for (final String startNodeId : ((ExecutableFlowBase) node).getStartNodes()) { final ExecutableNode startNode = flow.getExecutableNode(startNodeId); runReadyJob(startNode); } } else { runExecutableNode(node); } } return true; }
Main method that executes the jobs.
runReadyJob
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean retryJobIfPossible(final ExecutableNode node) { if (node instanceof ExecutableFlowBase) { return false; } if (node.getRetries() > node.getAttempt()) { this.logger.info("Job '" + node.getId() + "' will be retried. Attempt " + node.getAttempt() + " of " + node.getRetries()); node.setDelayedExecution(node.getRetryBackoff()); node.resetForRetry(); return true; } else { if (node.getRetries() > 0) { this.logger.info("Job '" + node.getId() + "' has run out of retry attempts"); // Setting delayed execution to 0 in case this is manually re-tried. node.setDelayedExecution(0); } return false; } }
Main method that executes the jobs.
retryJobIfPossible
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
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 (base.getStatus() != status) { base.setStatus(status); shouldAlert = true; } if (base.getParentFlow() != null) { propagateStatusAndAlert(base.getParentFlow(), status); } else if (isPollDispatchMethodEnabled()) { // Alert on the root flow if the first error is encountered. // Todo jamiesjc: Add a new FLOW_STATUS_CHANGED event type and alert on that event. if (shouldAlert && base.getStatus() == Status.FAILED_FINISHING) { ExecutionControllerUtils.alertUserOnFirstError((ExecutableFlow) base, this.alerterHolder); } } } }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
propagateStatusAndAlert
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void finishExecutableNode(final ExecutableNode node) { this.finishedNodes.add(node); final EventData eventData = new EventData(node); fireEventListeners(Event.create(this, EventType.JOB_FINISHED, eventData)); }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
finishExecutableNode
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean isFlowReadytoFinalize(final ExecutableFlowBase flow) { // Only when all the end nodes are finished, the flow is ready to finalize. for (final String end : flow.getEndNodes()) { if (!Status.isStatusFinished(flow.getExecutableNode(end).getStatus())) { return false; } } return true; }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
isFlowReadytoFinalize
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void finalizeFlow(final ExecutableFlowBase flow) { final String id = flow == this.flow ? flow.getNestedId() : ""; // If it's not the starting flow, we'll create set of output props // for the finished flow. boolean succeeded = true; Props previousOutput = null; for (final String end : flow.getEndNodes()) { final ExecutableNode node = flow.getExecutableNode(end); if (node.getStatus() == Status.KILLED || node.getStatus() == Status.KILLING || node.getStatus() == Status.FAILED || node.getStatus() == Status.CANCELLED) { succeeded = false; } Props output = node.getOutputProps(); if (output != null) { output = Props.clone(output); output.setParent(previousOutput); previousOutput = output; } } flow.setOutputProps(previousOutput); if (!succeeded && (flow.getStatus() == Status.RUNNING)) { flow.setStatus(Status.KILLED); } flow.setEndTime(System.currentTimeMillis()); flow.setUpdateTime(System.currentTimeMillis()); final long durationSec = (flow.getEndTime() - flow.getStartTime()) / 1000; switch (flow.getStatus()) { case FAILED_FINISHING: this.logger.info("Setting flow '" + id + "' status to FAILED in " + durationSec + " seconds"); flow.setStatus(Status.FAILED); break; case KILLING: this.logger .info("Setting flow '" + id + "' status to KILLED in " + durationSec + " seconds"); flow.setStatus(Status.KILLED); this.execMetrics.decrementFlowKillingCount(); break; case FAILED: case KILLED: case CANCELLED: case FAILED_SUCCEEDED: this.logger.info("Flow '" + id + "' is set to " + flow.getStatus().toString() + " in " + durationSec + " seconds"); break; default: flow.setStatus(Status.SUCCEEDED); this.logger.info("Flow '" + id + "' is set to " + flow.getStatus().toString() + " in " + durationSec + " seconds"); } // Only take care of subflow's events if (!(flow instanceof ExecutableFlow)) { this.fireEventListeners(Event.create(this, EventType.FLOW_FINISHED, new EventData(flow))); } // If the finalized flow is actually the top level flow, than we finish // the main loop. if (flow instanceof ExecutableFlow) { this.flowFinished = true; } }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
finalizeFlow
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void prepareJobProperties(final ExecutableNode node) throws IOException { if (node instanceof ExecutableFlow) { return; } Props props = null; if (!FlowLoaderUtils.isAzkabanFlowVersion20(this.flow.getAzkabanFlowVersion())) { // 1. Shared properties (i.e. *.properties) for the jobs only. This takes // the // least precedence if (!(node instanceof ExecutableFlowBase)) { final String sharedProps = node.getPropsSource(); if (sharedProps != null) { props = this.sharedProps.get(sharedProps); } } } // The following is the hiearchical ordering of dependency resolution // 2. Parent Flow Properties final ExecutableFlowBase parentFlow = node.getParentFlow(); if (parentFlow != null) { // flow level runtime props have been already applied on parent input props final Props flowProps = Props.clone(parentFlow.getInputProps()); flowProps.setEarliestAncestor(props); props = flowProps; } // 3. Output Properties. The call creates a clone, so we can overwrite it. final Props outputProps = collectOutputProps(node); if (outputProps != null) { outputProps.setEarliestAncestor(props); props = outputProps; } // 4. The job source. final Props jobSource = loadJobProps(node); if (jobSource != null) { jobSource.setParent(props); props = jobSource; } // 5. Runtime properties Map<String, Map<String, String>> runtimeProperties = this.flow.getExecutionOptions() .getRuntimeProperties(); if (runtimeProperties == null) { runtimeProperties = new HashMap<>(); } if (isOverrideExistingEnabled()) { // 5.a.1. apply flow level runtime props final Map<String, String> flowParam = this.flow.getExecutionOptions().getFlowParameters(); if (flowParam != null && !flowParam.isEmpty()) { props = new Props(props, flowParam); } // 5.a.2. apply node-specific runtime props recursively props = applyRuntimeProperties(node, runtimeProperties, props); } else if (runtimeProperties.containsKey(node.getNestedId())) { // 5.b. apply node-specific runtime props (current node only) props = new Props(props, runtimeProperties.get(node.getNestedId())); } node.setInputProps(props); }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
prepareJobProperties
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean isOverrideExistingEnabled() { return this.azkabanProps.getBoolean( ConfigurationKeys.AZKABAN_EXECUTOR_RUNTIME_PROPS_OVERRIDE_EAGER, false); }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
isOverrideExistingEnabled
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private Props applyRuntimeProperties(final ExecutableNode node, final Map<String, Map<String, String>> runtimeProperties, final Props props) { Props propsWithOverides = props; if (node.getParentFlow() != null && !parentIsOnTheSameLevel(node)) { // apply recursively top->down propsWithOverides = applyRuntimeProperties(node.getParentFlow(), runtimeProperties, props); } if (runtimeProperties.containsKey(node.getNestedId())) { // runtime props override any existing props propsWithOverides = new Props(propsWithOverides, runtimeProperties.get(node.getNestedId())); } return propsWithOverides; }
Recursively propagate status to parent flow. Alert on first error of the flow in new AZ dispatching design. @param base the base flow @param status the status to be propagated
applyRuntimeProperties
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean parentIsOnTheSameLevel(final ExecutableNode node) { return node.getParentFlow() instanceof ExecutableFlow; }
Detects if the "parent" is actually the root job node.
parentIsOnTheSameLevel
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private void customizeJobProperties(final Props props) { final boolean memoryCheck = this.flow.getExecutionOptions().getMemoryCheck(); props.put(ProcessJob.AZKABAN_MEMORY_CHECK, Boolean.toString(memoryCheck)); }
@param props This method is to put in any job properties customization before feeding to the job.
customizeJobProperties
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private Props loadJobProps(final ExecutableNode node) throws IOException { Props props = null; if (FlowLoaderUtils.isAzkabanFlowVersion20(this.flow.getAzkabanFlowVersion())) { final String jobPath = node.getParentFlow().getFlowId() + Constants.PATH_DELIMITER + node.getId(); props = FlowLoaderUtils.loadPropsFromYamlFile(this.projectLoader, this.flow, jobPath); if (props == null) { this.logger.info("Job props loaded from yaml file is empty for job " + node.getId()); return props; } } else { final String source = node.getJobSource(); if (source == null) { return null; } // load the override props if any try { props = this.projectLoader.fetchProjectProperty(this.flow.getProjectId(), this.flow.getVersion(), node.getId() + Constants.JOB_OVERRIDE_SUFFIX); } catch (final ProjectManagerException e) { e.printStackTrace(); this.logger.error("Error loading job override property for job " + node.getId()); } final File path = new File(this.execDir, source); if (props == null) { // if no override prop, load the original one on disk try { props = new Props(null, path); } catch (final IOException e) { e.printStackTrace(); this.logger.error("Error loading job file " + source + " for job " + node.getId()); } } // setting this fake source as this will be used to determine the location // of log files. if (path.getPath() != null) { props.setSource(path.getPath()); } } customizeJobProperties(props); return props; }
@param props This method is to put in any job properties customization before feeding to the job.
loadJobProps
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@SuppressWarnings("FutureReturnValueIgnored") private void runExecutableNode(final ExecutableNode node) throws IOException { // Collect output props from the job's dependencies. prepareJobProperties(node); node.setStatus(Status.QUEUED); // Attach Ramp Props if there is any desired properties final String jobId = node.getId(); final String jobType = Optional.ofNullable(node.getInputProps()) .map(props -> props.getString("type")) .orElse(null); if (jobType != null && jobId != null) { final Props rampProps = this.flow.getRampPropsForJob(jobId, jobType); if (rampProps != null) { this.flowIsRamping = true; this.logger.info(String.format( "RAMP_FLOW_ATTACH_PROPS_FOR_JOB : (flow.ExecId = %d, flow.Id = %s, flow.flowName = %s, job.id = %s, job.type = %s, props = %s)", this.flow.getExecutionId(), this.flow.getId(), this.flow.getFlowName(), jobId, jobType, rampProps.toString())); node.setRampProps(rampProps); } } else { this.logger.warn(String.format( "RAMP_FLOW_ATTACH_PROPS_FOR_JOB : (flow.ExecId = %d, flow.Id = %s, flow.flowName = %s) does not have Job Type or Id", this.flow.getExecutionId(), this.flow.getId(), this.flow.getFlowName())); } final JobRunner runner = createJobRunner(node); this.logger.info("Submitting job '" + node.getNestedId() + "' to run."); try { // Job starts to queue runner.setTimeInQueue(System.currentTimeMillis()); this.executorService.submit(runner); this.activeJobRunners.add(runner); } catch (final RejectedExecutionException e) { this.logger.error(e); } }
@param props This method is to put in any job properties customization before feeding to the job.
runExecutableNode
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
public Status getImpliedStatus(final ExecutableNode node) { // If it's running or finished with 'SUCCEEDED', than don't even // bother starting this job. if (Status.isStatusRunning(node.getStatus()) || node.getStatus() == Status.SUCCEEDED) { return null; } // Go through the node's dependencies. If all of the previous job's // statuses is finished and not FAILED or KILLED, than we can safely // run this job. Status status = Status.READY; // Check if condition on job status is satisfied switch (checkConditionOnJobStatus(node)) { case FAILED: this.logger.info("Condition on job status: " + node.getConditionOnJobStatus() + " is " + "evaluated to false for " + node.getId()); status = Status.CANCELLED; break; // Condition not satisfied yet, need to wait case PENDING: return null; default: break; } if (status != Status.CANCELLED && !isConditionOnRuntimeVariableMet(node)) { status = Status.CANCELLED; } // If it's disabled but ready to run, we want to make sure it continues // being disabled. if (node.getStatus() == Status.DISABLED || node.getStatus() == Status.SKIPPED) { return Status.SKIPPED; } // If the flow has failed, and we want to finish only the currently running // jobs, we just // kill everything else. We also kill, if the flow has been cancelled. if (this.flowFailed && this.failureAction == ExecutionOptions.FailureAction.FINISH_CURRENTLY_RUNNING) { return Status.CANCELLED; } else if (isKilled()) { return Status.CANCELLED; } return status; }
Determines what the state of the next node should be. Returns null if the node should not be run.
getImpliedStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private Boolean isConditionOnRuntimeVariableMet(final ExecutableNode node) { final String condition = node.getCondition(); if (condition == null) { return true; } String replaced = condition; // Replace the condition on job status macro with "true" to skip the evaluation by Script // Engine since it has already been evaluated. final Matcher jobStatusMatcher = CONDITION_ON_JOB_STATUS_PATTERN.matcher (condition); if (jobStatusMatcher.find()) { replaced = condition.replace(jobStatusMatcher.group(1), "true"); } final Matcher variableMatcher = CONDITION_VARIABLE_REPLACEMENT_PATTERN.matcher(replaced); while (variableMatcher.find()) { final String value = findValueForJobVariable(node, variableMatcher.group(1), variableMatcher.group(2)); replaced = replaced.replace(variableMatcher.group(), "'" + value + "'"); this.logger.info("Resolved condition of " + node.getId() + " is " + replaced); } // Evaluate string expression using script engine return evaluateExpression(replaced); }
Determines what the state of the next node should be. Returns null if the node should not be run.
isConditionOnRuntimeVariableMet
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private String findValueForJobVariable(final ExecutableNode node, final String jobName, final String variable) { // Get job output props final ExecutableNode target = node.getParentFlow().getExecutableNode(jobName); if (target == null) { throw new IllegalStateException("Not able to find executable job name " + jobName + ". The job name might be invalid. Available job names: " + node.getParentFlow().getExecutableNodeIds().stream().collect( Collectors.joining(", "))); } final Props outputProps = target.getOutputProps(); if (outputProps == null) { this.logger.warn("No output properties were generated for job " + jobName + "."); return null; } if (!outputProps.containsKey(variable)) { this.logger.warn("No variable named " + variable + " found in job " + jobName + " output parameters. Properties: " + outputProps); return null; } return outputProps.get(variable); }
Determines what the state of the next node should be. Returns null if the node should not be run.
findValueForJobVariable
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private boolean evaluateExpression(final String expression) { boolean result = false; final ScriptEngineManager sem = new ScriptEngineManager(); final ScriptEngine se = sem.getEngineByName("JavaScript"); // Restrict permission using the two-argument form of doPrivileged() try { final Object object = AccessController.doPrivileged( new PrivilegedExceptionAction<Object>() { @Override public Object run() throws ScriptException { return se.eval(expression); } }, new AccessControlContext( new ProtectionDomain[]{new ProtectionDomain(null, null)}) // no permissions ); if (object != null) { result = (boolean) object; } } catch (final Exception e) { this.logger.error("Failed to evaluate the condition.", e); } this.logger.info("Condition is evaluated to " + result); return result; }
Determines what the state of the next node should be. Returns null if the node should not be run.
evaluateExpression
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
@Override public Object run() throws ScriptException { return se.eval(expression); }
Determines what the state of the next node should be. Returns null if the node should not be run.
run
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private Props collectOutputProps(final ExecutableNode node) { Props previousOutput = null; // Iterate the in nodes again and create the dependencies for (final String dependency : node.getInNodes()) { Props output = node.getParentFlow().getExecutableNode(dependency).getOutputProps(); if (output != null) { output = Props.clone(output); output.setParent(previousOutput); previousOutput = output; } } return previousOutput; }
Determines what the state of the next node should be. Returns null if the node should not be run.
collectOutputProps
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0
private JobRunner createJobRunner(final ExecutableNode node) { // Load job file. final File path = new File(this.execDir, node.getJobSource()); final JobRunner jobRunner = new JobRunner(node, path.getParentFile(), this.executorLoader, this.executionLogsLoader, this.jobtypeManager, this.azkabanProps, this.flowRunnerProxy); if (this.watcher != null) { jobRunner.setPipeline(this.watcher, this.pipelineLevel); } if (this.validateUserProxy) { jobRunner.setValidatedProxyUsers(this.proxyUsers); } jobRunner.setDelayStart(node.getDelayedExecution()); jobRunner.setLogSettings(this.logger, this.jobLogFileSize, this.jobLogNumFiles); jobRunner.addListener(this.listener); if (JobCallbackManager.isInitialized()) { jobRunner.addListener(JobCallbackManager.getInstance()); } configureJobLevelMetrics(jobRunner); return jobRunner; }
Determines what the state of the next node should be. Returns null if the node should not be run.
createJobRunner
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/FlowRunner.java
Apache-2.0