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
@Override public boolean accept(final File dir, final String name) { return name.startsWith(JobRunner.this.logFile.getName()); }
If pipelining is set, will block on another flow's jobs.
accept
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void finalizeAttachmentFile() { if (this.attachmentFileName == null) { this.flowLogger.info("Attachment file for job " + this.jobId + " is null"); return; } try { final File file = new File(this.attachmentFileName); if (!file.exists()) { this.flowLogger.info("No attachment file for job " + this.jobId + " written."); return; } this.executorLoader.uploadAttachmentFile(this.node, file); } catch (final ExecutorManagerException e) { this.flowLogger.error( "Error writing out attachment for job " + this.node.getNestedId(), e); } }
If pipelining is set, will block on another flow's jobs.
finalizeAttachmentFile
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private boolean IsSpecifiedWorkingDirectoryValid() { final File usersWorkingDir = new File(this.props.get(AbstractProcessJob.WORKING_DIR)); try { if (!usersWorkingDir.getCanonicalPath().startsWith(this.workingDir.getCanonicalPath())) { return false; } } catch (final IOException e) { this.logger.error("Failed to validate user's " + AbstractProcessJob.WORKING_DIR + " property.", e); return false; } return true; }
Validates execution directory specified by user.
IsSpecifiedWorkingDirectoryValid
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
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 previousJVMArgs = this.props.get(JavaProcessJob.JVM_PARAMS); jobJVMArgs += (previousJVMArgs == null) ? "" : " " + previousJVMArgs; // Add useful Java options for java jobs which are provided through properties final String javaOpts = insertJavaOptions(); jobJVMArgs += (javaOpts == null) ? "" : " " + javaOpts; this.logger.info("job JVM args: " + jobJVMArgs); this.props.put(JavaProcessJob.JVM_PARAMS, jobJVMArgs); }
Add useful JVM arguments so it is easier to map a running Java process to a flow, execution id and job
insertJVMAargs
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private String insertJavaOptions() { if (this.jobtypeManager.getCommonPluginLoadProps() == null) { return null; } final String appendJavaOpts = this.jobtypeManager.getCommonPluginLoadProps().getString( Constants.AZ_JOBS_JAVA_OPTS, null); logger.info("JAVA OPTS appended to each command : " + appendJavaOpts); return appendJavaOpts; }
Add useful Java options for java jobs provided through properties.
insertJavaOptions
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void insertJobMetadata() { final String baseURL = this.azkabanProps.get(AZKABAN_WEBSERVER_URL); if (baseURL != null) { URL webserverURL = null; try { webserverURL = new URL(baseURL); } catch (MalformedURLException e) { logger.error(String.format("Exception in parsing url: %s", baseURL), e); } final String azkabanWebserverHost = (webserverURL != null) ? webserverURL.getHost() : null; final String flowName = this.node.getParentFlow().getFlowId(); final String projectName = this.node.getParentFlow().getProjectName(); this.props.put(CommonJobProperties.AZKABAN_URL, baseURL); this.props.put(CommonJobProperties.AZKABAN_WEBSERVERHOST, azkabanWebserverHost); this.props.put(CommonJobProperties.EXECUTION_LINK, String.format("%s/executor?execid=%d", baseURL, this.executionId)); this.props.put(CommonJobProperties.JOBEXEC_LINK, String.format( "%s/executor?execid=%d&job=%s", baseURL, this.executionId, this.node.getNestedId())); this.props.put(CommonJobProperties.ATTEMPT_LINK, String.format( "%s/executor?execid=%d&job=%s&attempt=%d", baseURL, this.executionId, this.node.getNestedId(), this.node.getAttempt())); this.props.put(CommonJobProperties.WORKFLOW_LINK, String.format( "%s/manager?project=%s&flow=%s", baseURL, projectName, flowName)); this.props.put(CommonJobProperties.JOB_LINK, String.format( "%s/manager?project=%s&flow=%s&job=%s", baseURL, projectName, flowName, this.jobId)); } else { if (this.logger != null) { this.logger.info(AZKABAN_WEBSERVER_URL + " property was not set"); } } // out nodes this.props.put(CommonJobProperties.OUT_NODES, StringUtils.join2(this.node.getOutNodes(), ",")); // in nodes this.props.put(CommonJobProperties.IN_NODES, StringUtils.join2(this.node.getInNodes(), ",")); }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
insertJobMetadata
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private Status runJob() { Status finalStatus; try { this.job.run(); finalStatus = this.node.getStatus(); } catch (final Throwable e) { synchronized (this.syncObject) { if (this.props.getBoolean("job.succeed.on.failure", false)) { finalStatus = changeStatus(Status.FAILED_SUCCEEDED); logInfo( "The job execution failed, but will be handled as a success based on user configs."); } else { if (isKilled() || this.node.getStatus() == Status.KILLED) { finalStatus = Status.KILLED; } else { finalStatus = changeStatus(Status.FAILED); } } logInfo("Azkaban job executor finished with: " + e.getCause()); serverLogger.info(String.format( "Execution of job with id %s and type %s in execution %d failed with status %s.", this.jobId, this.props.getString("type", "--"), this.executionId, finalStatus), e); this.getNode().setFailureMessage(e.toString()); } } if (this.job != null) { this.node.setOutputProps(this.job.getJobGeneratedProperties()); } synchronized (this.syncObject) { // If the job is still running (but not killed), set the status to Success. if (!Status.isStatusFinished(finalStatus) && !isKilled()) { finalStatus = changeStatus(Status.SUCCEEDED); } } return finalStatus; }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
runJob
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private Status changeStatus(final Status status) { changeStatus(status, System.currentTimeMillis()); return status; }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
changeStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private Status changeStatus(final Status status, final long time) { this.node.setStatus(status); this.node.setUpdateTime(time); return status; }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
changeStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void fireEvent(final Event event) { fireEvent(event, true); }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
fireEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void fireEvent(final Event event, final boolean updateTime) { if (updateTime) { this.node.setUpdateTime(System.currentTimeMillis()); } this.fireEventListeners(event); }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
fireEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
public void killBySLA() { synchronized (this.syncObject) { kill(); this.getNode().setModifiedBy("SLA"); this.getNode().setKilledBySLA(true); } }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
killBySLA
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
public void kill() { synchronized (this.syncObject) { if (Status.isStatusFinished(this.node.getStatus())) { return; } logError("Kill has been called."); this.changeStatus(Status.KILLING); this.killed = true; final BlockingStatus status = this.currentBlockStatus; if (status != null) { status.unblock(); } // Cancel code here if (this.job == null) { logError("Job hasn't started yet."); // Just in case we're waiting on the delay synchronized (this) { this.notify(); } return; } try { this.setJobKillTime(System.currentTimeMillis()); this.job.cancel(); } catch (final Exception e) { logError(e.getMessage()); logError( "Failed trying to cancel job. Maybe it hasn't started running yet or just finished."); } } }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
kill
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
public boolean isKilled() { return this.killed; }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
isKilled
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
public Status getStatus() { return this.node.getStatus(); }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
getStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void logError(final String message) { if (this.logger != null) { this.logger.error(message); } }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
logError
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void logError(final String message, final Throwable t) { if (this.logger != null) { this.logger.error(message, t); } }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
logError
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private void logInfo(final String message) { if (this.logger != null) { this.logger.info(message); } }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
logInfo
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
public File getLogFile() { return this.logFile; }
Add relevant links to the job properties so that downstream consumers may know what executions initiated their execution.
getLogFile
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/JobRunner.java
Apache-2.0
private ProjectDirectoryMetadata fetchProjectMetadata(final Path project) { ProjectDirectoryMetadata projectDirectoryMetadata = this.cachedProjects.get(project); try { if (projectDirectoryMetadata == null) { final String fileName = project.getFileName().toString(); final int projectId = Integer.parseInt(fileName.split("\\.")[0]); final int versionNum = Integer.parseInt(fileName.split("\\.")[1]); projectDirectoryMetadata = new ProjectDirectoryMetadata(projectId, versionNum, project.toFile()); /* * Calculate used-space (Equivalent of du command) only if the metadata for * this project was never fetched before. This optimization is important as * recursive space calculation is a very expensive operation. */ projectDirectoryMetadata.setDirSizeInByte( AbstractFlowPreparer.calculateDirSizeAndSave(projectDirectoryMetadata.getInstalledDir())); } projectDirectoryMetadata.setLastAccessTime( Files.getLastModifiedTime(Paths.get(projectDirectoryMetadata.getInstalledDir().toString(), AbstractFlowPreparer.PROJECT_DIR_SIZE_FILE_NAME))); } catch (final Exception e) { log.warn("Error while loading project dir metadata for project {}", project.getFileName(), e); } return projectDirectoryMetadata; }
Get metadata from the OS for the underlying path, lastAccessTime is fetched from the OS regardless of whether the given project already exists, but the space calculation for a project directory is only performed one-time. @param project path for the project cache. Project filepath encodes projectID & version within the filename @return OS Metadata for the given path
fetchProjectMetadata
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private void loadAllProjects() { final List<Path> projects = new ArrayList<>(); for (final File project : Objects .requireNonNull(this.projectCacheDir.listFiles(new FilenameFilter() { String pattern = "[0-9]+\\.[0-9]+"; @Override public boolean accept(final File dir, final String name) { return name.matches(this.pattern); } }))) { if (project.exists() && project.isDirectory() && !projectsUnderDeletion.containsKey(project.toPath())) { ProjectDirectoryMetadata projectDirectoryMetadata = fetchProjectMetadata(project.toPath()); if (projectDirectoryMetadata != null) { cachedProjects.put(project.toPath(), projectDirectoryMetadata); } } } // end of for loop }
Browse Cache root directory to fetch all valid projects and unclean files. If a project already exists in the cache, don't bother to re-fetch the OS metadata again.
loadAllProjects
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
@Override public boolean accept(final File dir, final String name) { return name.matches(this.pattern); }
Browse Cache root directory to fetch all valid projects and unclean files. If a project already exists in the cache, don't bother to re-fetch the OS metadata again.
accept
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private long getProjectDirsTotalSizeInBytes() { long totalSizeInBytes = 0; for (ProjectDirectoryMetadata metadata : cachedProjects.values()) { totalSizeInBytes += metadata.getDirSizeInByte(); } return totalSizeInBytes; }
@return sum of the size of all project dirs
getProjectDirsTotalSizeInBytes
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private void addToDeletionQueue(final File toDelete) { try { barrier.lock(); projectsUnderDeletion.put(toDelete.toPath(), toDelete); } finally { barrier.unlock(); } }
@return sum of the size of all project dirs
addToDeletionQueue
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private void removeFromDeletionQueue(final Path toDelete) { try { barrier.lock(); projectsUnderDeletion.remove(toDelete); emptyQCond.signal(); } finally { barrier.unlock(); } }
@return sum of the size of all project dirs
removeFromDeletionQueue
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private void deleteLeastRecentlyUsedProjects(long sizeToFreeInBytes) { final List<ProjectDirectoryMetadata> lruList = new ArrayList<>(cachedProjects.values()); lruList.sort(Comparator.comparing(ProjectDirectoryMetadata::getLastAccessTime)); for (ProjectDirectoryMetadata lruEntry : lruList) { if (sizeToFreeInBytes > 0) { if (lruEntry.getInstalledDir() != null) { cachedProjects.remove(lruEntry.getInstalledDir().toPath()); submitProjectForDeletion(lruEntry.getInstalledDir()); sizeToFreeInBytes -= lruEntry.getDirSizeInByte(); } } else { break; } } }
Delete least recently used projects to free up space @param sizeToFreeInBytes space to free up
deleteLeastRecentlyUsedProjects
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
private long bytesToMB(final long bytes) { return bytes / (1024 * 1024); }
Delete least recently used projects to free up space @param sizeToFreeInBytes space to free up
bytesToMB
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
public void deleteProjectDirsIfNecessary(final long newProjectSizeInBytes) { final long cachePartitionSize = this.projectCacheDir.getTotalSpace(); final long availablePartitionSize = this.projectCacheDir.getUsableSpace(); final long start = System.currentTimeMillis(); loadAllProjects(); log.info("Loading {} project dirs metadata completed in {} msecs", cachedProjects.size(), System.currentTimeMillis() - start); final long currentCacheSize = getProjectDirsTotalSizeInBytes(); final long projectCacheDirCapacity = currentCacheSize + availablePartitionSize; boolean throttleAfterDeletion = false; final long highWatermark = (long) (projectCacheDirCapacity * this.percentageOfDisk); final long throttleWatermark = (long) (projectCacheDirCapacity * this.throttlePercentage); long projectedCacheSize = currentCacheSize + newProjectSizeInBytes; log.info("Partition = {} MB, Total Capacity = {} MB, Cache Size = {} MB, Projected Size = {} MB", bytesToMB(cachePartitionSize), bytesToMB(projectCacheDirCapacity), bytesToMB(currentCacheSize), bytesToMB(projectedCacheSize)); log.info("High Watermark = {} MB, Throttle Watermark = {} MB", bytesToMB(highWatermark), bytesToMB(throttleWatermark)); if (projectedCacheSize >= throttleWatermark) { throttleAfterDeletion = true; } if (projectedCacheSize >= highWatermark) { log.info("Projected cache size exceeds High Watermark. LRU Eviction will kick in"); deleteLeastRecentlyUsedProjects(projectedCacheSize - highWatermark); } if (throttleAfterDeletion) { /* * Block till already submitted cleanup is done. */ log.info("Throttle Watermark was hit. Blocking till LRU eviction is complete."); finishPendingCleanup(); } }
Deleting least recently accessed project dirs when there's no room to accommodate new project. The logic: 1. Calculates the total dynamic size available for the project cache. This = (Usable space left in the disk partition + Space currently occupied by the project cache). 2. Calculates high water mark & throttle water marks based on the above number. 3. If the occupied bytes > high water mark, lazy (Non-blocking) LRU eviction kicks in 4. If the occupied bytes > throttle water mark, the method will block until LRU eviction is complete. In each case, LRU eviction attempts to keep the occupied space below high water mark. @param newProjectSizeInBytes space in bytes the new project will add to the existing cache
deleteProjectDirsIfNecessary
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
public String queryState() { if (projectsUnderDeletion.isEmpty()) { return STATE_AVAILABLE; } return STATE_CLEANING; }
@return Return the current state of the cleaner service
queryState
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
public void shutdown() { try { new ExecutorServiceUtils().gracefulShutdown(deletionService, Duration.ofDays(1)); } catch (final InterruptedException e) { log.warn("Error when deleting files", e); } }
Makes sure the Cache deletion process cleanly terminates so the possibility of unclean cache directories is eliminated.
shutdown
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectCacheCleaner.java
Apache-2.0
Long getDirSizeInByte() { return this.dirSizeInByte; }
Used in project cache clean-up
getDirSizeInByte
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
void setDirSizeInByte(final Long dirSize) { this.dirSizeInByte = dirSize; }
Used in project cache clean-up
setDirSizeInByte
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
int getProjectId() { return this.projectId; }
Used in project cache clean-up
getProjectId
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
int getVersion() { return this.version; }
Used in project cache clean-up
getVersion
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
String getProjectName() { return this.projectName; }
Used in project cache clean-up
getProjectName
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
File getInstalledDir() { return this.installedDir; }
Used in project cache clean-up
getInstalledDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
void setInstalledDir(final File installedDir) { this.installedDir = installedDir; }
Used in project cache clean-up
setInstalledDir
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
@Override public String toString() { return "ProjectVersion{" + "projectId=" + this.projectId + ", version=" + this.version + ", installedDir=" + this.installedDir + ", dirSizeInByte=" + this.dirSizeInByte + ", lastAccessTime=" + this.lastAccessTime + '}'; }
Used in project cache clean-up
toString
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
FileTime getLastAccessTime() { return this.lastAccessTime; }
Used in project cache clean-up
getLastAccessTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
void setLastAccessTime(final FileTime lastAccessTime) { this.lastAccessTime = lastAccessTime; }
Used in project cache clean-up
setLastAccessTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ProjectDirectoryMetadata.java
Apache-2.0
@Deprecated @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); }
@deprecated GET available for seamless upgrade. azkaban-web now uses POST.
doGet
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
@Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final boolean noCache = null != req && Boolean.valueOf(req.getParameter(noCacheParamName)); if (noCache || System.currentTimeMillis() - lastRefreshedTime > cacheTimeInMilliseconds) { this.populateStatistics(noCache); } JSONUtils.toJSON(cachedstats, resp.getOutputStream(), true); }
Handle all requests to Statistics Servlet {@inheritDoc}
doPost
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
protected void fillRemainingMemoryPercent(final ExecutorInfo stats) { if (exists_Bash && exists_Cat && exists_Grep && exists_Meminfo) { try { final ArrayList<String> output = Utils.runProcess("/bin/bash", "-c", "/bin/cat /proc/meminfo | grep -E \"^MemTotal:|^MemFree:|^Buffers:|^Cached:|^SwapCached:\""); long totalMemory = 0; long totalFreeMemory = 0; Long parsedResult = (long) 0; // process the output from bash call. // we expect the result from the bash call to be something like following - // MemTotal: 65894264 kB // MemFree: 57753844 kB // Buffers: 305552 kB // Cached: 3802432 kB // SwapCached: 0 kB // Note : total free memory = freeMemory + cached + buffers + swapCached // TODO : think about merging the logic in systemMemoryInfo as the logic is similar if (output.size() == 5) { for (final String result : output) { // find the total memory and value the variable. parsedResult = extractMemoryInfo("MemTotal", result); if (null != parsedResult) { totalMemory = parsedResult; continue; } // find the free memory. parsedResult = extractMemoryInfo("MemFree", result); if (null != parsedResult) { totalFreeMemory += parsedResult; continue; } // find the Buffers. parsedResult = extractMemoryInfo("Buffers", result); if (null != parsedResult) { totalFreeMemory += parsedResult; continue; } // find the Cached. parsedResult = extractMemoryInfo("SwapCached", result); if (null != parsedResult) { totalFreeMemory += parsedResult; continue; } // find the Cached. parsedResult = extractMemoryInfo("Cached", result); if (null != parsedResult) { totalFreeMemory += parsedResult; continue; } } } else { logger.error( "failed to get total/free memory info as the bash call returned invalid result." + String.format(" Output from the bash call - %s ", output.toString())); } // the number got from the proc file is in KBs we want to see the number in MBs so we are dividing it by 1024. stats.setRemainingMemoryInMB(totalFreeMemory / 1024); stats.setRemainingMemoryPercent( totalMemory == 0 ? 0 : ((double) totalFreeMemory / (double) totalMemory) * 100); } catch (final Exception ex) { logger.error("failed fetch system memory info " + "as exception is captured when fetching result from bash call. Ex -" + ex .getMessage()); } } else { logger.error( "failed fetch system memory info, one or more files from the following list are missing - " + "'/bin/bash'," + "'/bin/cat'," + "'/proc/loadavg'"); } }
fill the result set with the percent of the remaining system memory on the server. @param stats reference to the result container which contains all the results, this specific method will only work work on the property "remainingMemory" and "remainingMemoryPercent". NOTE: a double value will be used to present the remaining memory, a returning value of '55.6' means 55.6%
fillRemainingMemoryPercent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
private Long extractMemoryInfo(final String field, final String result) { Long returnResult = null; if (null != result && null != field && result.matches(String.format("^%s:.*", field)) && result.split("\\s+").length > 2) { try { returnResult = Long.parseLong(result.split("\\s+")[1]); logger.debug(field + ":" + returnResult); } catch (final NumberFormatException e) { returnResult = 0L; logger.error(String.format("yielding 0 for %s as output is invalid - %s", field, result)); } } return returnResult; }
fill the result set with the percent of the remaining system memory on the server. @param stats reference to the result container which contains all the results, this specific method will only work work on the property "remainingMemory" and "remainingMemoryPercent". NOTE: a double value will be used to present the remaining memory, a returning value of '55.6' means 55.6%
extractMemoryInfo
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
protected synchronized void populateStatistics(final boolean noCache) { //check again before starting the work. if (noCache || System.currentTimeMillis() - lastRefreshedTime > cacheTimeInMilliseconds) { final ExecutorInfo stats = new ExecutorInfo(); fillRemainingMemoryPercent(stats); fillRemainingFlowCapacityAndLastDispatchedTime(stats); fillCpuUsage(stats); cachedstats = stats; lastRefreshedTime = System.currentTimeMillis(); } }
call the data providers to fill the returning data container for statistics data. This function refreshes the static cached copy of data in case if necessary.
populateStatistics
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
protected void fillRemainingFlowCapacityAndLastDispatchedTime(final ExecutorInfo stats) { final AzkabanExecutorServer server = AzkabanExecutorServer.getApp(); if (server != null) { final FlowRunnerManager runnerMgr = AzkabanExecutorServer.getApp().getFlowRunnerManager(); final int assignedFlows = runnerMgr.getNumRunningFlows() + runnerMgr.getNumQueuedFlows(); stats.setRemainingFlowCapacity(runnerMgr.getMaxNumRunningFlows() - assignedFlows); stats.setNumberOfAssignedFlows(assignedFlows); stats.setLastDispatchedTime(runnerMgr.getLastFlowSubmittedTime()); } else { logger.error("failed to get data for remaining flow capacity or LastDispatchedTime" + " as the AzkabanExecutorServer has yet been initialized."); } }
fill the result set with the remaining flow capacity . @param stats reference to the result container which contains all the results, this specific method will only work on the property "remainingFlowCapacity".
fillRemainingFlowCapacityAndLastDispatchedTime
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
protected void fillCpuUsage(final ExecutorInfo stats) { if (exists_Bash && exists_Cat && exists_LoadAvg) { try { final ArrayList<String> output = Utils .runProcess("/bin/bash", "-c", "/bin/cat /proc/loadavg"); // process the output from bash call. if (output.size() > 0) { final String[] splitedresult = output.get(0).split("\\s+"); double cpuUsage = 0.0; try { cpuUsage = Double.parseDouble(splitedresult[0]); } catch (final NumberFormatException e) { logger.error("yielding 0.0 for CPU usage as output is invalid -" + output.get(0)); } logger.info("System load : " + cpuUsage); stats.setCpuUpsage(cpuUsage); } } catch (final Exception ex) { logger.error("failed fetch system load info " + "as exception is captured when fetching result from bash call. Ex -" + ex .getMessage()); } } else { logger.error( "failed fetch system load info, one or more files from the following list are missing - " + "'/bin/bash'," + "'/bin/cat'," + "'/proc/loadavg'"); } }
<pre> fill the result set with the CPU usage . Note : As the 'Top' bash call doesn't yield accurate result for the system load, the implementation has been changed to load from the "proc/loadavg" which keeps the moving average of the system load, we are pulling the average for the recent 1 min. </pre> @param stats reference to the result container which contains all the results, this specific method will only work on the property "cpuUsage".
fillCpuUsage
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/ServerStatisticsServlet.java
Apache-2.0
public boolean hasParam(final HttpServletRequest request, final String param) { return HttpRequestUtils.hasParam(request, param); }
Servlet to communicate with Azkaban exec server This servlet get requests from stats servlet in Azkaban Web server
hasParam
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
public String getParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getParam(request, name); }
Servlet to communicate with Azkaban exec server This servlet get requests from stats servlet in Azkaban Web server
getParam
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
public Boolean getBooleanParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getBooleanParam(request, name); }
Servlet to communicate with Azkaban exec server This servlet get requests from stats servlet in Azkaban Web server
getBooleanParam
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
public long getLongParam(final HttpServletRequest request, final String name) throws ServletException { return HttpRequestUtils.getLongParam(request, name); }
Servlet to communicate with Azkaban exec server This servlet get requests from stats servlet in Azkaban Web server
getLongParam
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
@Deprecated @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { doPost(req, resp); }
@deprecated GET available for seamless upgrade. azkaban-web now uses POST.
doGet
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
@Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final Map<String, Object> ret = new HashMap<>(); if (hasParam(req, ACTION_PARAM)) { final String action = getParam(req, ACTION_PARAM); if (action.equals(STATS_SET_REPORTINGINTERVAL)) { handleChangeMetricInterval(req, ret); } else if (action.equals(STATS_SET_CLEANINGINTERVAL)) { handleChangeCleaningInterval(req, ret); } else if (action.equals(STATS_SET_MAXREPORTERPOINTS)) { handleChangeEmitterPoints(req, ret); } else if (action.equals(STATS_GET_ALLMETRICSNAME)) { handleGetAllMMetricsName(req, ret); } else if (action.equals(STATS_GET_METRICHISTORY)) { handleGetMetricHistory(req, ret); } else if (action.equals(STATS_SET_ENABLEMETRICS)) { handleChangeManagerStatusRequest(req, ret, true); } else if (action.equals(STATS_SET_DISABLEMETRICS)) { handleChangeManagerStatusRequest(req, ret, false); } else { ret.put(RESPONSE_ERROR, "Invalid action"); } } JSONUtils.toJSON(ret, resp.getOutputStream(), true); }
Handle all requests to Stats Servlet {@inheritDoc}
doPost
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
private void handleChangeEmitterPoints(final HttpServletRequest req, final Map<String, Object> ret) { try { final long numInstance = getLongParam(req, STATS_MAP_EMITTERNUMINSTANCES); if (MetricReportManager.isAvailable()) { final MetricReportManager metricManager = MetricReportManager.getInstance(); final InMemoryMetricEmitter memoryEmitter = extractInMemoryMetricEmitter(metricManager); memoryEmitter.setReportingInstances(numInstance); ret.put(STATUS_PARAM, RESPONSE_SUCCESS); } else { ret.put(RESPONSE_ERROR, "MetricManager is not available"); } } catch (final Exception e) { logger.error(e); ret.put(RESPONSE_ERROR, e.getMessage()); } }
Update number of display snapshots for /stats graphs
handleChangeEmitterPoints
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
private void handleGetMetricHistory(final HttpServletRequest req, final Map<String, Object> ret) throws ServletException { if (MetricReportManager.isAvailable()) { final MetricReportManager metricManager = MetricReportManager.getInstance(); final InMemoryMetricEmitter memoryEmitter = extractInMemoryMetricEmitter(metricManager); // if we have a memory emitter if (memoryEmitter != null) { try { final List<InMemoryHistoryNode> result = memoryEmitter.getMetrics( getParam(req, STATS_MAP_METRICNAMEPARAM), parseDate(getParam(req, STATS_MAP_STARTDATE)), parseDate(getParam(req, STATS_MAP_ENDDATE)), getBooleanParam(req, STATS_MAP_METRICRETRIEVALMODE)); if (result != null && result.size() > 0) { ret.put("data", result); } else { ret.put(RESPONSE_ERROR, "No metric stats available"); } } catch (final ParseException ex) { ret.put(RESPONSE_ERROR, "Invalid Date filter"); } } else { ret.put(RESPONSE_ERROR, "InMemoryMetricEmitter not instantiated"); } } else { ret.put(RESPONSE_ERROR, "MetricReportManager is not available"); } }
Get metric snapshots for a metric and date specification
handleGetMetricHistory
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
private void handleGetAllMMetricsName(final HttpServletRequest req, final Map<String, Object> ret) { if (MetricReportManager.isAvailable()) { final MetricReportManager metricManager = MetricReportManager.getInstance(); final List<IMetric<?>> result = metricManager.getAllMetrics(); if (result.size() == 0) { ret.put(RESPONSE_ERROR, "No Metric being tracked"); } else { final List<String> metricNames = new LinkedList<>(); for (final IMetric<?> metric : result) { metricNames.add(metric.getName()); } ret.put("data", metricNames); } } else { ret.put(RESPONSE_ERROR, "MetricReportManager is not available"); } }
Get all the metrics tracked by metric manager
handleGetAllMMetricsName
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
private void handleChangeMetricInterval(final HttpServletRequest req, final Map<String, Object> ret) throws ServletException { try { final String metricName = getParam(req, STATS_MAP_METRICNAMEPARAM); final long newInterval = getLongParam(req, STATS_MAP_REPORTINGINTERVAL); if (MetricReportManager.isAvailable()) { final MetricReportManager metricManager = MetricReportManager.getInstance(); final TimeBasedReportingMetric<?> metric = (TimeBasedReportingMetric<?>) metricManager .getMetricFromName(metricName); metric.updateInterval(newInterval); ret.put(STATUS_PARAM, RESPONSE_SUCCESS); } else { ret.put(RESPONSE_ERROR, "MetricManager is not available"); } } catch (final Exception e) { logger.error(e); ret.put(RESPONSE_ERROR, e.getMessage()); } }
Update tracking interval for a given metrics
handleChangeMetricInterval
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
private Date parseDate(final String date) throws ParseException { final DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); return format.parse(date); }
Update tracking interval for a given metrics
parseDate
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/StatsServlet.java
Apache-2.0
@Override public void run() { logger.info("Running trigger for " + this); if (isTriggerExpired()) { logger.info(this + " expired"); return; } logger.info("Check if trigger condition met for " + this); final boolean isTriggerConditionMet = this.triggerCondition.isMet(); logger.info("Trigger condition for execid = " + this.execId + " met? = " + isTriggerConditionMet); if (isTriggerConditionMet) { logger.info("Condition " + this.triggerCondition.getExpression() + " met"); for (final TriggerAction action : this.actions) { try { if (action instanceof KillExecutionAction) { logger.info("Killing execution " + this.execId); } action.doAction(); } catch (final Exception e) { logger.error("Failed to do action " + action.getDescription() + " for execution " + this.execId, e); } } } }
Perform the action if trigger condition is met
run
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
Apache-2.0
public boolean isTriggerExpired() { return this.expireCondition.isMet(); }
Check if the trigger is expired and reset isExpired @return true if trigger is expired
isTriggerExpired
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
Apache-2.0
@Override public String toString() { final StringBuilder actionsString = new StringBuilder(); for (final TriggerAction act : this.actions) { actionsString.append(", "); actionsString.append(act.getDescription()); } return "Trigger for execution " + this.execId + " with trigger condition of " + this.triggerCondition.getExpression() + " and expire condition of " + this.expireCondition.getExpression() + actionsString; }
Check if the trigger is expired and reset isExpired @return true if trigger is expired
toString
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/Trigger.java
Apache-2.0
protected synchronized void handleJobStatusChange(final String jobId, final Status status) { final BlockingStatus block = this.map.get(jobId); if (block != null) { block.changeStatus(status); } }
Called to fire events to the JobRunner listeners
handleJobStatusChange
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
public int getExecId() { return this.execId; }
Called to fire events to the JobRunner listeners
getExecId
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
public synchronized BlockingStatus getBlockingStatus(final String jobId) { if (this.cancelWatch) { return null; } final ExecutableNode node = this.flow.getExecutableNodePath(jobId); if (node == null) { return null; } BlockingStatus blockingStatus = this.map.get(jobId); if (blockingStatus == null) { blockingStatus = new BlockingStatus(this.execId, jobId, node.getStatus()); this.map.put(jobId, blockingStatus); } return blockingStatus; }
Called to fire events to the JobRunner listeners
getBlockingStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
public Status peekStatus(final String jobId) { if (Status.isStatusFinished(this.flow.getStatus())) { return null; } final ExecutableNode node = this.flow.getExecutableNodePath(jobId); if (node != null) { ExecutableFlowBase parentFlow = node.getParentFlow(); while (parentFlow != null) { Status parentStatus = parentFlow.getStatus(); if (parentStatus == Status.SKIPPED || parentStatus == Status.DISABLED) { return Status.SKIPPED; } parentFlow = parentFlow.getParentFlow(); } return node.getStatus(); } return null; }
Called to fire events to the JobRunner listeners
peekStatus
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
public synchronized void unblockAllWatches() { this.logger.info("Unblock all watches on " + this.execId); this.cancelWatch = true; for (final BlockingStatus status : this.map.values()) { this.logger.info("Unblocking " + status.getJobId()); status.changeStatus(Status.SKIPPED); status.unblock(); } this.logger.info("Successfully unblocked all watches on " + this.execId); }
Called to fire events to the JobRunner listeners
unblockAllWatches
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
public boolean isWatchCancelled() { return this.cancelWatch; }
Called to fire events to the JobRunner listeners
isWatchCancelled
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/event/FlowWatcher.java
Apache-2.0
@Override public synchronized void handleEvent(final Event event) { if (event.getData().isRootFlowEvent() && event.getType() == EventType.FLOW_FINISHED) { final FlowRunner runner = (FlowRunner) event.getRunner(); if (runner != null && runner.getExecutableFlow().getStatus().equals(Status.FAILED)) { this.value = this.value + 1; } } }
Listen for events to maintain correct value of number of failed flows {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
handleEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
Apache-2.0
@Override protected void preTrackingEventMethod() { // Nothing to finalize before tracking event }
Listen for events to maintain correct value of number of failed flows {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
preTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
Apache-2.0
@Override protected synchronized void postTrackingEventMethod() { this.value = 0; }
Listen for events to maintain correct value of number of failed flows {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
postTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedFlowMetric.java
Apache-2.0
@Override public synchronized void handleEvent(final Event event) { if (event.getType() == EventType.JOB_FINISHED && Status.FAILED .equals(event.getData().getStatus())) { this.value = this.value + 1; } }
Listen for events to maintain correct value of number of failed jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
handleEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
Apache-2.0
@Override protected void preTrackingEventMethod() { // Nothing to finalize before tracking event }
Listen for events to maintain correct value of number of failed jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
preTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
Apache-2.0
@Override protected synchronized void postTrackingEventMethod() { this.value = 0; }
Listen for events to maintain correct value of number of failed jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
postTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumFailedJobMetric.java
Apache-2.0
@Override protected synchronized void preTrackingEventMethod() { this.value = this.flowManager.getNumQueuedFlows(); }
Update value using flow manager {@inheritDoc} @see azkaban.metric.TimeBasedReportingMetric#preTrackingEventMethod()
preTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumQueuedFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumQueuedFlowMetric.java
Apache-2.0
@Override protected void postTrackingEventMethod() { // nothing to post process }
Update value using flow manager {@inheritDoc} @see azkaban.metric.TimeBasedReportingMetric#preTrackingEventMethod()
postTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumQueuedFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumQueuedFlowMetric.java
Apache-2.0
@Override protected synchronized void preTrackingEventMethod() { this.value = this.flowManager.getNumRunningFlows(); }
Update value using flow manager {@inheritDoc} @see azkaban.metric.TimeBasedReportingMetric#preTrackingEventMethod()
preTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningFlowMetric.java
Apache-2.0
@Override protected void postTrackingEventMethod() { // nothing to post process }
Update value using flow manager {@inheritDoc} @see azkaban.metric.TimeBasedReportingMetric#preTrackingEventMethod()
postTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningFlowMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningFlowMetric.java
Apache-2.0
@Override public synchronized void handleEvent(final Event event) { if (event.getType() == EventType.JOB_STARTED) { this.value = this.value + 1; } else if (event.getType() == EventType.JOB_FINISHED) { this.value = this.value - 1; } }
Listen for events to maintain correct value of number of running jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
handleEvent
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
Apache-2.0
@Override protected void preTrackingEventMethod() { // nothing to finalize value is already updated }
Listen for events to maintain correct value of number of running jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
preTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
Apache-2.0
@Override protected void postTrackingEventMethod() { // nothing to post process }
Listen for events to maintain correct value of number of running jobs {@inheritDoc} @see azkaban.event.EventListener#handleEvent(azkaban.event.Event)
postTrackingEventMethod
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/NumRunningJobMetric.java
Apache-2.0
@Override public synchronized Ratio getRatio() { final long hitCount = Arrays.stream(this.hits.getSnapshot().getValues()).sum(); return Ratio.of(hitCount, this.hits.getSnapshot().size()); }
Project cache hit ratio of last 100 cache accesses. <p>The advantage of sampling last 100 caches accesses over time-based sampling like last hour's cache accesses is the former is more deterministic. Suppose there's only few execution in last hour, then hit ratio might not be truly informative, which doesn't necessarily reflect performance of the cache.</p>
getRatio
java
azkaban/azkaban
azkaban-exec-server/src/main/java/azkaban/execapp/metric/ProjectCacheHitRatio.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/main/java/azkaban/execapp/metric/ProjectCacheHitRatio.java
Apache-2.0
@Test public void testSslDisabledJettyServer() throws Exception { ExecJettyServerModule execJettyServerModule = new ExecJettyServerModule(); Props props = new Props(); props.put("jetty.use.ssl", "false"); props.put("executor.port", JETTY_PORT); Server jettyServer = execJettyServerModule.createJettyServer(props); Assert.assertEquals(1, jettyServer.getConnectors().length); Assert.assertTrue(jettyServer.getConnectors()[0] instanceof SocketConnector); SocketConnector socketConnector = (SocketConnector) jettyServer.getConnectors()[0]; Assert.assertEquals(JETTY_PORT, socketConnector.getPort()); final Context root = new Context(jettyServer, "/", Context.SESSIONS); root.addServlet(new ServletHolder(new SimpleServlet()), "/simple"); jettyServer.start(); final ExecutorApiClient tlsDisabledClient = new ExecutorApiClient(new Props()); final String postResponse = tlsDisabledClient .doPost(new URI(SimpleServlet.TLS_DISABLED_URI), DispatchMethod.CONTAINERIZED, Optional.empty(),null); Assert.assertEquals(SimpleServlet.POST_RESPONSE_STRING, postResponse); jettyServer.stop(); }
This test tries to create the jetty-server and verify that it is reachable on the attached port via Http.
testSslDisabledJettyServer
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/common/ExecJettyServerModuleTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/common/ExecJettyServerModuleTest.java
Apache-2.0
@Test public void testSslEnabledJettyServer() throws Exception { ExecJettyServerModule execJettyServerModule = new ExecJettyServerModule(); Props props = new Props(); props.put("jetty.use.ssl", "true"); props.put("executor.ssl.port", JETTY_TLS_PORT); props.put("jetty.keystore", KEYSTORE_PATH); props.put("jetty.password", DEFAULT_PASSWORD); props.put("jetty.keypassword", DEFAULT_PASSWORD); props.put("jetty.truststore", TRUSTSTORE_PATH); props.put("jetty.trustpassword", DEFAULT_PASSWORD); Server jettyServer = execJettyServerModule.createJettyServer(props); Assert.assertEquals(1, jettyServer.getConnectors().length); Assert.assertTrue(jettyServer.getConnectors()[0] instanceof SslSocketConnector); SslSocketConnector sslSocketConnector = (SslSocketConnector) jettyServer.getConnectors()[0]; Assert.assertEquals(JETTY_TLS_PORT, sslSocketConnector.getPort()); final Context root = new Context(jettyServer, "/", Context.SESSIONS); root.addServlet(new ServletHolder(new SimpleServlet()), "/simple"); jettyServer.start(); Props clientProps = new Props(); clientProps.put(EXECUTOR_CLIENT_TLS_ENABLED, "true"); clientProps .put(EXECUTOR_CLIENT_TRUSTSTORE_PATH, TRUSTSTORE_PATH); clientProps.put(EXECUTOR_CLIENT_TRUSTSTORE_PASSWORD, "changeit"); final ExecutorApiClient tlsEnabledClient = new ExecutorApiClient(clientProps); final String postResponse = tlsEnabledClient .doPost(new URI(SimpleServlet.TLS_ENABLED_URI), DispatchMethod.CONTAINERIZED, Optional.empty(),null); Assert.assertEquals(SimpleServlet.POST_RESPONSE_STRING, postResponse); jettyServer.stop(); }
This test tries to create the jetty-server and verify that it is reachable on the attached port via Https.
testSslEnabledJettyServer
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/common/ExecJettyServerModuleTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/common/ExecJettyServerModuleTest.java
Apache-2.0
@Test public void testRetryFailures() throws IOException, ServletException, ExecutorManagerException { init(); Mockito.when(this.mockHttpServletRequest.getParameter(ConnectorParams.ACTION_PARAM)) .thenReturn(ConnectorParams.MODIFY_EXECUTION_ACTION); Mockito.when( this.mockHttpServletRequest.getParameter(ConnectorParams.MODIFY_EXECUTION_ACTION_TYPE)) .thenReturn(ConnectorParams.MODIFY_RETRY_FAILURES); Mockito.doCallRealMethod().when(this.mockContainerServlet) .handleModifyExecutionRequest(Mockito.any(), Mockito.anyInt(), Mockito.anyString(), Mockito.any()); Mockito.doCallRealMethod().when(this.mockContainerServlet).setFlowContainer(Mockito.any()); this.mockContainerServlet.setFlowContainer(this.flowContainer); this.mockContainerServlet.handleRequest(this.mockHttpServletRequest, this.mockHttpServletResponse); Mockito.verify(this.mockContainerServlet, Mockito.times(1)) .handleModifyExecutionRequest(Mockito.any(), Mockito.anyInt(), Mockito.anyString(), Mockito.any()); Mockito.verify(this.flowContainer, Mockito.times(1)) .retryFailures(Mockito.anyInt(), Mockito.anyString()); }
Verify that the method handleModifyExecutionRequest indeed is getting called. Verify that the method retryFailures for FlowContainer indeed is getting called.
testRetryFailures
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
Apache-2.0
@Test public void testUnsupportedActions() throws IOException { init(); Mockito.when(this.mockHttpServletRequest.getParameter(ConnectorParams.ACTION_PARAM)) .thenReturn("SomeAction"); this.mockContainerServlet.handleRequest(this.mockHttpServletRequest, this.mockHttpServletResponse); this.baos.flush(); Assert.assertEquals(baos.toString(), "{\"error\":\"Unsupported action type: SomeAction\"}"); }
Verify that the method handleModifyExecutionRequest indeed is getting called. Verify that the method retryFailures for FlowContainer indeed is getting called.
testUnsupportedActions
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
Apache-2.0
private ServletOutputStream getServletOutputStream(ByteArrayOutputStream baos) { return new ServletOutputStream() { @Override public void write(int b) throws IOException { baos.write(b); } }; }
Verify that the method handleModifyExecutionRequest indeed is getting called. Verify that the method retryFailures for FlowContainer indeed is getting called.
getServletOutputStream
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
Apache-2.0
@Override public void write(int b) throws IOException { baos.write(b); }
Verify that the method handleModifyExecutionRequest indeed is getting called. Verify that the method retryFailures for FlowContainer indeed is getting called.
write
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/ContainerServletTest.java
Apache-2.0
@Test public void testCallBackManager() throws Exception { // Enable jobcallback explicitly. props.put("azkaban.executor.jobcallback.enabled", "true"); startFlowContainer(); // The callback manager must be set. assert JobCallbackManager.isInitialized(); // Get the instance final JobCallbackManager jobCallbackManager = JobCallbackManager.getInstance(); assert jobCallbackManager != null; }
Test if Callback Manager is created when Flow Container starts
testCallBackManager
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/FlowContainerTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/FlowContainerTest.java
Apache-2.0
@Test public void testSetResourceUtilization() { FlowContainer flowContainerMock = mock(FlowContainer.class); FlowRunner flowRunnerMock = mock(FlowRunner.class); FlowRunnerProxy flowRunnerProxyMock = mock(FlowRunnerProxy.class); Mockito.doReturn(flowRunnerProxyMock).when(flowRunnerMock).getProxy(); Mockito.doCallRealMethod().when(flowContainerMock).setResourceUtilization(); Mockito.doCallRealMethod().when(flowContainerMock).setFlowRunner(flowRunnerMock); flowContainerMock.setFlowRunner(flowRunnerMock); flowContainerMock.setResourceUtilization(); // CPU_REQUEST and MEMORY_REQUEST ENV variables are not set Mockito.verify(flowRunnerProxyMock, Mockito.times(0)).setCpuUtilization(anyDouble()); Mockito.verify(flowRunnerProxyMock, Mockito.times(0)).setMemoryUtilization(anyLong()); // Set CPU_REQUEST ENV variable environmentVariables.set("CPU_REQUEST", "500m"); flowContainerMock.setResourceUtilization(); Mockito.verify(flowRunnerProxyMock, Mockito.times(1)).setCpuUtilization(0.5d); Mockito.verify(flowRunnerProxyMock, Mockito.times(0)).setMemoryUtilization(524288000L); // Set MEMORY_REQUEST ENV variable environmentVariables.set("MEMORY_REQUEST", "500Mi"); flowContainerMock.setResourceUtilization(); // Times will be two as it already executed once before Mockito.verify(flowRunnerProxyMock, Mockito.times(2)).setCpuUtilization(0.5d); Mockito.verify(flowRunnerProxyMock, Mockito.times(1)).setMemoryUtilization(524288000L); }
Test if Callback Manager is created when Flow Container starts
testSetResourceUtilization
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/container/FlowContainerTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/container/FlowContainerTest.java
Apache-2.0
private void addParentNode(final String childName, final String parentName) { this.dagBuilder.addParentNode(childName, parentName); }
Adds parent as the child's parent node.
addParentNode
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
private void assertDagNodes(final Dag dag) { final List<Node> nodes = dag.getNodes(); assertThat(nodes.size()).isEqualTo(2); final Node node1 = nodes.get(0); final Node node2 = nodes.get(1); assertThat(node1.getName()).isEqualTo("nb1"); assertThat(node2.getName()).isEqualTo("nb2"); assertThat(node1.hasParent()).isFalse(); assertThat(node1.getChildren()).isEqualTo(Collections.singletonList(node2)); assertThat(node2.hasParent()).isTrue(); assertThat(node2.getChildren()).isEmpty(); assertThat(node2.getParents()).isEqualTo(Collections.singletonList(node1)); }
Adds parent as the child's parent node.
assertDagNodes
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
private Node createNode(final String name) { return this.dagBuilder.createNode(name, mock(NodeProcessor.class)); }
Adds parent as the child's parent node.
createNode
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@Test public void build_should_throw_exception_when_circular_dependency_is_detected() { // given final String n1Name = "nb1"; final String n2Name = "nb2"; final String n3Name = "nb3"; createNode(n1Name); createNode(n2Name); createNode(n3Name); addParentNode(n2Name, n1Name); addParentNode(n3Name, n2Name); addParentNode(n1Name, n3Name); // when final Throwable thrown = catchThrowable(this.dagBuilder::build); // then // Expect the exception message to show the loop: nb1 -> nb2 -> nb3 -> nb1. System.out.println("Expect exception: " + thrown); assertThrownIsDagBuilderException(thrown); }
Adds parent as the child's parent node.
build_should_throw_exception_when_circular_dependency_is_detected
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@Test public void can_not_call_createNode_after_dag_already_built() { // given this.dagBuilder.build(); // when final Throwable thrown = catchThrowable(() -> createNode("a")); // then assertThrownIsDagBuilderException(thrown); }
Adds parent as the child's parent node.
can_not_call_createNode_after_dag_already_built
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@Test public void can_not_call_addParentNode_after_dag_already_built() { // given this.dagBuilder.build(); // when final Throwable thrown = catchThrowable(() -> addParentNode("n1", "n2")); // then assertThrownIsDagBuilderException(thrown); }
Adds parent as the child's parent node.
can_not_call_addParentNode_after_dag_already_built
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@Test public void can_not_call_build_after_dag_already_built() { // given this.dagBuilder.build(); // when final Throwable thrown = catchThrowable(this.dagBuilder::build); // then assertThrownIsDagBuilderException(thrown); }
Adds parent as the child's parent node.
can_not_call_build_after_dag_already_built
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@Test public void test_toString() { // given // when final String stringRepresentation = this.dagBuilder.toString(); // then assertThat(stringRepresentation).isEqualTo("DagBuilder (dag builder)"); }
Adds parent as the child's parent node.
test_toString
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagBuilderTest.java
Apache-2.0
@After public void tearDown() throws InterruptedException { this.dagService.shutdownAndAwaitTermination(); }
Tests {@link DagService} <p>Naming conventions: nodes are named with letters such as a, b. Dags are named with 'f' prefix. e.g. "fa". A sub DAG has the prefix "sf" such as "sfb". A sub DAG is a node within the parent DAG.
tearDown
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
Apache-2.0
@Test public void shutdown_calls_service_util_graceful_shutdown() throws InterruptedException { // given final ExecutorServiceUtils serviceUtils = mock(ExecutorServiceUtils.class); final DagService testDagService = new DagService(serviceUtils); // when testDagService.shutdownAndAwaitTermination(); // then final ExecutorService exService = testDagService.getExecutorService(); verify(serviceUtils).gracefulShutdown(exService, Duration.ofSeconds(10)); }
Tests {@link DagService} <p>Naming conventions: nodes are named with letters such as a, b. Dags are named with 'f' prefix. e.g. "fa". A sub DAG has the prefix "sf" such as "sfb". A sub DAG is a node within the parent DAG.
shutdown_calls_service_util_graceful_shutdown
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
Apache-2.0
@Test public void oneNodeSuccess() throws Exception { createNodeInTestDag("a"); addToExpectedSequence("fa", Status.RUNNING); addToExpectedSequence("a", Status.RUNNING); addToExpectedSequence("a", Status.SUCCESS); addToExpectedSequence("fa", Status.SUCCESS); buildDagRunAndVerify(); }
Tests a DAG with one node which will run successfully.
oneNodeSuccess
java
azkaban/azkaban
azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
https://github.com/azkaban/azkaban/blob/master/azkaban-exec-server/src/test/java/azkaban/dag/DagServiceTest.java
Apache-2.0