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
public Map<String, Map<String, List<String>>> getAlertersConfigs() { return this.alertersConfigs; }
Construct the SLA Option from the original SlaOption, which has been renamed to {@link SlaOptionDeprecated}.
getAlertersConfigs
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public boolean isComponentType(final SlaType.ComponentType componentType) { return this.type.getComponent() == componentType; }
Check the SlaType's ComponentType of this SlaOption's @param componentType component Type @return true/false
isComponentType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public Map<String, Object> toObject() { final List<String> slaActions = new ArrayList<>(); final Map<String, Object> slaInfo = new HashMap<>(); slaInfo.put(SlaOptionDeprecated.INFO_FLOW_NAME, this.flowName); if (hasAlert()) { slaActions.add(SlaOptionDeprecated.ACTION_ALERT); slaInfo.put(SlaOptionDeprecated.ALERT_TYPE, ALERT_TYPE_EMAIL); } if (hasKill()) { if (this.type.getComponent() == ComponentType.FLOW) { slaActions.add(SlaOptionDeprecated.ACTION_CANCEL_FLOW); } else { // JOB slaActions.add(SlaOptionDeprecated.ACTION_KILL_JOB); } } if (this.type.getComponent() == ComponentType.JOB) { slaInfo.put(SlaOptionDeprecated.INFO_JOB_NAME, this.jobName); } String slaType; switch (this.type) { case FLOW_FINISH: slaType = SlaOptionDeprecated.TYPE_FLOW_FINISH; break; case FLOW_SUCCEED: slaType = SlaOptionDeprecated.TYPE_FLOW_SUCCEED; break; case JOB_FINISH: slaType = SlaOptionDeprecated.TYPE_JOB_FINISH; break; case JOB_SUCCEED: slaType = SlaOptionDeprecated.TYPE_JOB_SUCCEED; break; default: throw new IllegalStateException("unsupported SLA type " + this.type.getName()); } slaInfo.put(SlaOptionDeprecated.INFO_DURATION, durationToString(this.duration)); slaInfo.put(SlaOptionDeprecated.INFO_EMAIL_LIST, this.emails); slaInfo.put(SlaOptionDeprecated.INFO_ALERTERS_CONFIGS, this.alertersConfigs); SlaOptionDeprecated slaOption = new SlaOptionDeprecated(slaType, slaActions, slaInfo); return slaOption.toObject(); }
Convert the SLA option to the original JSON format, used by {@link SlaOptionDeprecated}. @return the JSON format for {@link SlaOptionDeprecated}.
toObject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public String toJSON() { return new GsonBuilder().setPrettyPrinting().create().toJson(toObject()); }
Convert the SLA option to the original JSON format, used by {@link SlaOptionDeprecated}. @return the JSON format for {@link SlaOptionDeprecated}.
toJSON
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public static SlaOption fromObject(Object json) { return new SlaOption(SlaOptionDeprecated.fromObject(json)); }
Convert the original JSON format, used by {@link SlaOptionDeprecated}, to an SLA option. @param json the original JSON format for {@link SlaOptionDeprecated}. @return the SLA option.
fromObject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public Object toWebObject() { final HashMap<String, Object> slaObj = new HashMap<>(); if (this.type.getComponent() == SlaType.ComponentType.FLOW) { slaObj.put(WEB_ID, ""); } else { slaObj.put(WEB_ID, this.jobName); } slaObj.put(WEB_DURATION, durationToString(this.duration)); slaObj.put(WEB_STATUS, this.type.getStatus().toString()); final List<String> actionsObj = new ArrayList<>(); if (hasAlert()) { actionsObj.add(WEB_ACTION_EMAIL); } if (hasKill()) { actionsObj.add(WEB_ACTION_KILL); } slaObj.put(WEB_ACTIONS, actionsObj); return slaObj; }
@return the web object representation for the SLA option.
toWebObject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public static List<SlaOption> getJobLevelSLAOptions(final List<SlaOption> options, final String jobId) { return filterSLAOptions(options, ComponentType.JOB, jobId); }
@param options a list of SLA options. @return the job level SLA options.
getJobLevelSLAOptions
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public static List<SlaOption> getFlowLevelSLAOptions(final List<SlaOption> options) { return filterSLAOptions(options, ComponentType.FLOW, null); }
@param options a list of SLA options. @return the flow level SLA options.
getFlowLevelSLAOptions
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
private static List<SlaOption> filterSLAOptions(final List<SlaOption> options, final ComponentType componentType, final String jobId) { return options.stream().filter( option -> option.isComponentType(componentType) && StringUtils.equals(option.getJobName(), jobId)).collect(Collectors.toList()); }
@param options a list of SLA options. @return the flow level SLA options.
filterSLAOptions
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
@Override public String toString() { return "SlaOption{" + "type=" + this.type + ", flowName='" + this.flowName + '\'' + ", jobName='" + this.jobName + '\'' + ", duration=" + this.duration + ", actions=" + this.actions + ", emails=" + this.emails + ", alertersConfigs=" + this.alertersConfigs + '}'; }
@param options a list of SLA options. @return the flow level SLA options.
toString
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SlaOption slaOption = (SlaOption) o; return type == slaOption.type && Objects.equals(flowName, slaOption.flowName) && Objects.equals(jobName, slaOption.jobName) && Objects.equals(duration, slaOption.duration) && Objects.equals(actions, slaOption.actions) && Objects.equals(emails, slaOption.emails) && Objects.equals(alertersConfigs, slaOption.alertersConfigs); }
@param options a list of SLA options. @return the flow level SLA options.
equals
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
@Override public int hashCode() { return Objects.hash(type, flowName, jobName, duration, actions, emails, alertersConfigs); }
@param options a list of SLA options. @return the flow level SLA options.
hashCode
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOption.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOption.java
Apache-2.0
public static SlaOptionDeprecated fromObject(final Object object) { final HashMap<String, Object> slaObj = (HashMap<String, Object>) object; final String type = (String) slaObj.get("type"); final List<String> actions = (List<String>) slaObj.get("actions"); final Map<String, Object> info = (Map<String, Object>) slaObj.get("info"); return new SlaOptionDeprecated(type, actions, info); }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
fromObject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public String getType() { return this.type; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
getType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public void setType(final String type) { this.type = type; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
setType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public Map<String, Object> getInfo() { return this.info; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
getInfo
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public void setInfo(final Map<String, Object> info) { this.info = info; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
setInfo
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public List<String> getActions() { return this.actions; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
getActions
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public void setActions(final List<String> actions) { this.actions = actions; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
setActions
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public Map<String, Object> toObject() { final HashMap<String, Object> slaObj = new HashMap<>(); slaObj.put("type", this.type); slaObj.put("info", this.info); slaObj.put("actions", this.actions); return slaObj; }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
toObject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
@Override public String toString() { return "Sla of " + getType() + getInfo() + getActions(); }
The original version of SlaOption. This has been replaced with a newer version, but is being kept for backward compatibility, for reading and writing the original version from the database.
toString
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaOptionDeprecated.java
Apache-2.0
public String getName() { return name; }
Constructor. @param name the SLA type name. @param component The component the SLA is for, either flow or job. @param status the status the SLA is for, either succeed or finish.
getName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaType.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaType.java
Apache-2.0
public ComponentType getComponent() { return component; }
Constructor. @param name the SLA type name. @param component The component the SLA is for, either flow or job. @param status the status the SLA is for, either succeed or finish.
getComponent
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaType.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaType.java
Apache-2.0
public StatusType getStatus() { return status; }
Constructor. @param name the SLA type name. @param component The component the SLA is for, either flow or job. @param status the status the SLA is for, either succeed or finish.
getStatus
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/sla/SlaType.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/sla/SlaType.java
Apache-2.0
@Override public InputStream getProject(final String key) { throw new UnsupportedOperationException( "Not implemented yet. Use get(projectId, version) instead"); }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
getProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
public ProjectFileHandler getProject(final int projectId, final int version) { return this.projectLoader.getUploadedFile(projectId, version); }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
getProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public String putProject(final ProjectStorageMetadata metadata, final File localFile) { this.projectLoader.uploadProjectFile(metadata.getProjectId(), metadata.getVersion(), localFile, metadata.getUploader(), metadata.getUploaderIPAddr()); return null; }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
putProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public InputStream getDependency(final Dependency dep) { throw new UnsupportedOperationException( "Not implemented yet. Must use HdfsStorage or LocalStorage."); }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
getDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public boolean dependencyFetchingEnabled() { return false; }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
dependencyFetchingEnabled
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public String getDependencyRootPath() { return null; }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
getDependencyRootPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public boolean deleteProject(final String key) { throw new UnsupportedOperationException("Delete is not supported"); }
DatabaseStorage This class helps in storing projects in the DB itself. This is intended to be the default since it is the current behavior of Azkaban.
deleteProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/DatabaseStorage.java
Apache-2.0
@Override public void authorize() { if (this.isSecurityEnabled) { try { login(this.keytabPrincipal, this.keytabPath); } catch (final IOException e) { log.error(e); throw new AzkabanException(String.format( "Error: Unable to authorize to Hadoop. Principal: %s Keytab: %s", this.keytabPrincipal, this.keytabPath)); } } }
API to authorize HDFS access. This logins in the configured user via the keytab. If the user is already logged in then it renews the TGT.
authorize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsAuth.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsAuth.java
Apache-2.0
private void login(final String keytabPrincipal, final String keytabPath) throws IOException { if (this.loggedInUser == null) { log.info( String.format("Logging in using Principal: %s Keytab: %s", keytabPrincipal, keytabPath)); UserGroupInformation.loginUserFromKeytab(keytabPrincipal, keytabPath); this.loggedInUser = UserGroupInformation.getLoginUser(); log.info(String.format("User %s logged in.", this.loggedInUser)); } else { log.info(String.format("User %s already logged in. Refreshing TGT", this.loggedInUser)); this.loggedInUser.checkTGTAndReloginFromKeytab(); } }
This method is used to login using keytab and set loggedInUser. @param keytabPrincipal @param keytabPath @throws IOException
login
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsAuth.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsAuth.java
Apache-2.0
@VisibleForTesting static void uploadLocalFile(final Path localPath, final Path remotePath, final FileContext remoteFileContext) throws IOException { FSDataInputStream localStream = null; FSDataOutputStream remoteStream = null; final String actionString = String.format("upload of local file %s to remote file %s", localPath, remotePath); log.debug("Starting " + actionString); try { final FileContext localFileContext = FileContext.getLocalFSFileContext(); localStream = localFileContext.open(localPath); remoteStream = remoteFileContext.create(remotePath, EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE)); IOUtils.copyBytes(localStream, remoteStream, UPLOAD_BUFFER_SIZE_BYTES, true); } catch (final IOException e) { log.error("Error during " + actionString, e); throw e; } finally { closeStreamsQuietly(localStream, remoteStream); log.debug("Ending " + actionString); // FileContexts (localFileContext in this case) don't need to be 'closed' } }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
uploadLocalFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public String putProject(final ProjectStorageMetadata metadata, final File localFile) { this.hdfsAuth.authorize(); final Path projectsPath = new Path(this.projectRootUri.getPath(), String.valueOf(metadata.getProjectId())); try { this.hdfsFileContext.mkdir(projectsPath, FsPermission.getDefault(), true); log.info("Created project dir: " + projectsPath); final Path targetPath = new Path(projectsPath, StorageUtils.getTargetProjectFilename(metadata.getProjectId(), metadata.getHash())); final Path tmpPath = new Path(projectsPath, TMP_PROJECT_UPLOAD_FILENAME); final Path localFilePath = new Path(localFile.getPath()) .makeQualified(FsConstants.LOCAL_FS_URI, null); log.info("Scheme qualified path of the local zip file is " + localFilePath); // Copy file to HDFS log.info(String.format("Creating project artifact: meta: %s path: %s", metadata, targetPath)); uploadLocalFile(localFilePath, tmpPath, this.hdfsFileContext); // Rename the tmp file to the final file and overwrite the final file if it already exists // (i.e. if the hash is the same). // Note that the base implementation of rename with overwrite in FileContext does not // guarantee atomicity, i.e it's possible the existing file could be deleted without the // subsequent rename completing. This behavior could be problematic for Azkaban as this corner // case may arise when a user re-uploads a zip without any modification, in which case the // hash (thus the filename) will match that of the already existing zip file. // The default/fallback implementation configured in HadoopModule uses the class // org.apache.hadoop.fs.Hdfs for this, which does provide atomicity. Please check, in case // the implementation is picked from core-site.xml that it resolves to a class with atomic // rename. this.hdfsFileContext.rename(tmpPath, targetPath, Options.Rename.OVERWRITE); return getRelativeProjectPath(targetPath); } catch (final IOException e) { log.error("error in putProject(): Metadata: " + metadata); throw new StorageException(e); } }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
putProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public InputStream getDependency(final Dependency dep) throws IOException { if (!dependencyFetchingEnabled()) { throw new UnsupportedOperationException("Dependency fetching is not enabled."); } // CachedHttpFileSystem will cache in HDFS, so it needs to be authenticated to access HDFS! this.hdfsAuth.authorize(); return this.http.open(resolveAbsoluteDependencyURI(dep)); }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
getDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public boolean dependencyFetchingEnabled() { return this.http != null; }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
dependencyFetchingEnabled
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public boolean deleteProject(final String key) { this.hdfsAuth.authorize(); final Path path = fullProjectPath(key); try { return this.hdfsFileContext.delete(path, false); } catch (final IOException e) { log.error("HDFS project file delete failed on " + path, e); return false; } }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
deleteProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
private Path fullProjectPath(final String key) { return new Path(this.projectRootUri.toString(), key); }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
fullProjectPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
private Path resolveAbsoluteDependencyURI(final Dependency dep) { return new Path(this.dependencyRootUri.toString(), StorageUtils.getTargetDependencyPath(dep)); }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
resolveAbsoluteDependencyURI
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public String getDependencyRootPath() { return this.dependencyRootUri != null ? this.dependencyRootUri.toString() : null; }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
getDependencyRootPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
private String getRelativeProjectPath(final Path targetPath) { return URI.create(this.projectRootUri.getPath()).relativize(targetPath.toUri()).getPath(); }
Copy a file from the local file system to a location given by the file context. {@code remotePath and remoteFileContext} will typically point to an external location but don't have to. If {@code remotePath} already exists, it will be overwritten. <p> Note that FileSystem includes a convenient {@code copyFromLocalFile} method that can be directly used in place of this. FileContext does not appear to have a similar functionality built-in, requiring this implementation. @param localPath location on local disk @param remotePath location where the file will be copied to @param remoteFileContext file context for the remote file path @throws IOException
getRelativeProjectPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/HdfsStorage.java
Apache-2.0
@Override public InputStream getDependency(final Dependency dep) throws IOException { if (!dependencyFetchingEnabled()) { throw new UnsupportedOperationException("Dependency fetching is not enabled."); } return this.http.open(resolveAbsoluteDependencyURI(dep)); }
LocalHadoopStorage is an extension of LocalStorage that adds support for dependency fetching. LocalHadoopStorage depends on hadoop-common and can only be injected when hadoop-common is on the classpath.
getDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
Apache-2.0
@Override public boolean dependencyFetchingEnabled() { return this.http != null; }
LocalHadoopStorage is an extension of LocalStorage that adds support for dependency fetching. LocalHadoopStorage depends on hadoop-common and can only be injected when hadoop-common is on the classpath.
dependencyFetchingEnabled
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
Apache-2.0
@Override public String getDependencyRootPath() { return dependencyFetchingEnabled() ? this.dependencyRootUri.toString() : null; }
LocalHadoopStorage is an extension of LocalStorage that adds support for dependency fetching. LocalHadoopStorage depends on hadoop-common and can only be injected when hadoop-common is on the classpath.
getDependencyRootPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
Apache-2.0
private Path resolveAbsoluteDependencyURI(final Dependency dep) { return new Path(this.dependencyRootUri.toString(), getTargetDependencyPath(dep)); }
LocalHadoopStorage is an extension of LocalStorage that adds support for dependency fetching. LocalHadoopStorage depends on hadoop-common and can only be injected when hadoop-common is on the classpath.
resolveAbsoluteDependencyURI
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalHadoopStorage.java
Apache-2.0
@Override public InputStream getProject(final String key) throws IOException { return new FileInputStream(getFileInRoot(key)); }
@param key Relative path of the file from the baseDirectory
getProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@Override public String putProject(final ProjectStorageMetadata metadata, final File localFile) { final File projectDir = new File(this.rootDirectory, String.valueOf(metadata.getProjectId())); if (projectDir.mkdir()) { log.info("Created project dir: " + projectDir.getAbsolutePath()); } final File targetFile = new File(projectDir, getTargetProjectFilename(metadata.getProjectId(), metadata.getHash())); if (targetFile.exists()) { log.info(String.format("Duplicate found: meta: %s, targetFile: %s, ", metadata, targetFile.getAbsolutePath())); return getRelativePath(targetFile); } // Copy file to storage dir try { FileUtils.copyFile(localFile, targetFile); } catch (final IOException e) { log.error("LocalStorage error in putProject(): meta: " + metadata); throw new StorageException(e); } return getRelativePath(targetFile); }
@param key Relative path of the file from the baseDirectory
putProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@Override public InputStream getDependency(final Dependency dep) throws IOException { throw new UnsupportedOperationException( "Dependency fetching is not supported with LocalStorage."); }
@param key Relative path of the file from the baseDirectory
getDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@Override public boolean dependencyFetchingEnabled() { return false; }
@param key Relative path of the file from the baseDirectory
dependencyFetchingEnabled
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@Override public String getDependencyRootPath() { return null; }
@param key Relative path of the file from the baseDirectory
getDependencyRootPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@Override public boolean deleteProject(final String key) { final File file = getFileInRoot(key); final boolean result = file.exists() && file.delete(); if (result) { log.warn("Deleted project file: " + file.getAbsolutePath()); } else { log.warn("Unable to delete project file: " + file.getAbsolutePath()); } return result; }
@param key Relative path of the file from the baseDirectory
deleteProject
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
private String getRelativePath(final File targetFile) { return this.rootDirectory.toURI().relativize(targetFile.toURI()).getPath(); }
@param key Relative path of the file from the baseDirectory
getRelativePath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/LocalStorage.java
Apache-2.0
@VisibleForTesting boolean isCleanupPermitted() { return this.maxArtifactsPerProject > 0; }
The query must sort the versions in reverse order for the cleanup operation to work correctly! TODO spyne: Refactor database storage cleanup to use this When using DatabaseStorage, resourceId is always NULL. Hence, those rows will currently be never cleaned up.
isCleanupPermitted
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
public void cleanupProjectArtifacts(final int projectId, final List<Integer> versionsToExclude) { if (!isCleanupPermitted()) { return; } final Set<String> allResourceIds = findResourceIdsToDelete(projectId, versionsToExclude); if (allResourceIds.size() == 0) { return; } log.warn(String.format("Deleting project artifacts [id: %d]: %s", projectId, allResourceIds)); allResourceIds.forEach(this::delete); }
Remove all but: - last N artifacts as configured by AZKABAN_STORAGE_ARTIFACT_MAX_RETENTION - artifacts with the versions provided Since multiple versions can share the same filename, the algo is to collect all filenames and from them, remove the latest ones. The remaining ones are deleted by the respective storage. From the storage perspective, cleanup just needs the {@link Storage#deleteProject(String)} API to work. Failure cases: - If the storage cleanup fails, the cleanup will be attempted again on the next upload - If the storage cleanup succeeds and the DB cleanup fails, the DB will be cleaned up in the next attempt. @param projectId project ID
cleanupProjectArtifacts
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
private Set<String> findResourceIdsToDelete(final int projectId, final List<Integer> versionsToExclude) { final List<Pair<String, Integer>> resourceIdOrderedList = fetchResourceIdOrderedList(projectId); if (resourceIdOrderedList.size() <= this.maxArtifactsPerProject) { return Collections.emptySet(); } // Different project versions may have the same resource id, we can only delete those // resource ids that are not used by the versions we must keep. Set<String> resourceIdsToKeep = new HashSet<>(); for (int i = 0; i < resourceIdOrderedList.size(); i++) { Pair<String, Integer> pair = resourceIdOrderedList.get(i); if (i < this.maxArtifactsPerProject || versionsToExclude.contains(pair.getSecond())) { resourceIdsToKeep.add(pair.getFirst()); } } Set<String> resourceIdsToDelete = new HashSet<>(); for (Pair<String, Integer> pair: resourceIdOrderedList) { String id = pair.getFirst(); if (!resourceIdsToKeep.contains(id)) { resourceIdsToDelete.add(id); } } return resourceIdsToDelete; }
Remove all but: - last N artifacts as configured by AZKABAN_STORAGE_ARTIFACT_MAX_RETENTION - artifacts with the versions provided Since multiple versions can share the same filename, the algo is to collect all filenames and from them, remove the latest ones. The remaining ones are deleted by the respective storage. From the storage perspective, cleanup just needs the {@link Storage#deleteProject(String)} API to work. Failure cases: - If the storage cleanup fails, the cleanup will be attempted again on the next upload - If the storage cleanup succeeds and the DB cleanup fails, the DB will be cleaned up in the next attempt. @param projectId project ID
findResourceIdsToDelete
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
private boolean delete(final String resourceId) { final boolean isDeleted = this.storage.deleteProject(resourceId) && removeDbEntry(resourceId); if (!isDeleted) { log.info("Failed to delete resourceId: " + resourceId); } return isDeleted; }
Main Delete Utility. Delete the storage first. Then remove metadata from DB. Warning! This order cannot be reversed since if the metadata is lost, there is no reference of the storage blob. @param resourceId the storage key to be deleted. @return true if deletion was successful. false otherwise
delete
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
private boolean removeDbEntry(final String resourceId) { try { final int nAffectedRows = this.databaseOperator.update(SQL_DELETE_RESOURCE_ID, resourceId); return nAffectedRows > 0; } catch (final SQLException e) { log.error("Error while deleting DB metadata resource ID: " + resourceId, e); } return false; }
Main Delete Utility. Delete the storage first. Then remove metadata from DB. Warning! This order cannot be reversed since if the metadata is lost, there is no reference of the storage blob. @param resourceId the storage key to be deleted. @return true if deletion was successful. false otherwise
removeDbEntry
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
private List<Pair<String, Integer>> fetchResourceIdOrderedList(final int projectId) { try { return this.databaseOperator.query(SQL_FETCH_PVR, rs -> { final List<Pair<String, Integer>> results = new ArrayList<>(); while (rs.next()) { final Pair<String, Integer> pair = new Pair<>(rs.getString("resource_id"), rs.getInt("version")); results.add(pair); } return results; }, projectId); } catch (final SQLException e) { log.error("Error performing cleanup of Project: " + projectId, e); } return Collections.emptyList(); }
Main Delete Utility. Delete the storage first. Then remove metadata from DB. Warning! This order cannot be reversed since if the metadata is lost, there is no reference of the storage blob. @param resourceId the storage key to be deleted. @return true if deletion was successful. false otherwise
fetchResourceIdOrderedList
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/storage/StorageCleaner.java
Apache-2.0
public synchronized static void setCheckerLoader(final CheckerTypeLoader loader) { Condition.checkerLoader = loader; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
setCheckerLoader
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public static Condition fromJson(final Object obj) throws Exception { if (checkerLoader == null) { throw new Exception("Condition Checker loader not initialized!"); } final Map<String, Object> jsonObj = (HashMap<String, Object>) obj; Condition cond = null; List<Long> missedCheckTimes = new ArrayList<>(); try { final Map<String, ConditionChecker> checkers = new HashMap<>(); final List<Object> checkersJson = (List<Object>) jsonObj.get("checkers"); for (final Object oneCheckerJson : checkersJson) { final Map<String, Object> oneChecker = (HashMap<String, Object>) oneCheckerJson; final String type = (String) oneChecker.get("type"); final ConditionChecker ck = checkerLoader.createCheckerFromJson(type, oneChecker.get("checkerJson")); checkers.put(ck.getId(), ck); // there is only one BasicTimeChecker associated with each condition if (ck instanceof BasicTimeChecker && ck.getId().equals("BasicTimeChecker_1")) { missedCheckTimes = (((BasicTimeChecker) ck).getMissedCheckTimesBeforeNow()); } } final String expr = (String) jsonObj.get("expression"); final Long nextCheckTime = Long.valueOf((String) jsonObj.get("nextCheckTime")); cond = new Condition(checkers, expr, nextCheckTime, missedCheckTimes); } catch (final Exception e) { e.printStackTrace(); logger.error("Failed to recreate condition from json.", e); throw new Exception("Failed to recreate condition from json.", e); } return cond; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
fromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public long getNextCheckTime() { return this.nextCheckTime; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
getNextCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public List<Long> getMissedCheckTimes() { return this.missedCheckTimes; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
getMissedCheckTimes
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public Map<String, ConditionChecker> getCheckers() { return this.checkers; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
getCheckers
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
private void setCheckers(final Map<String, ConditionChecker> checkers) { this.checkers = checkers; for (final ConditionChecker checker : checkers.values()) { this.context.set(checker.getId(), checker); } updateNextCheckTime(); }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
setCheckers
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
private void updateNextCheckTime() { long time = Long.MAX_VALUE; for (final ConditionChecker checker : this.checkers.values()) { time = Math.min(time, checker.getNextCheckTime()); } this.nextCheckTime = time; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
updateNextCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public void resetCheckers() { for (final ConditionChecker checker : this.checkers.values()) { checker.reset(); if (checker instanceof BasicTimeChecker) { this.missedCheckTimes = ((BasicTimeChecker) checker).getMissedCheckTimesBeforeNow(); } } updateNextCheckTime(); logger.info("Done resetting checkers. The next check time will be " + new DateTime(this.nextCheckTime)); }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
resetCheckers
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public String getExpression() { return this.expression.getExpression(); }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
getExpression
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public void setExpression(final String expr) { this.expression = jexl.createExpression(expr); }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
setExpression
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public boolean isMet() { if (logger.isDebugEnabled()) { logger.debug("Testing condition " + this.expression); } return this.expression.evaluate(this.context).equals(Boolean.TRUE); }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
isMet
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public Object toJson() { final Map<String, Object> jsonObj = new HashMap<>(); jsonObj.put("expression", this.expression.getExpression()); final List<Object> checkersJson = new ArrayList<>(); for (final ConditionChecker checker : this.checkers.values()) { final Map<String, Object> oneChecker = new HashMap<>(); oneChecker.put("type", checker.getType()); oneChecker.put("checkerJson", checker.toJson()); checkersJson.add(oneChecker); } jsonObj.put("checkers", checkersJson); jsonObj.put("nextCheckTime", String.valueOf(this.nextCheckTime)); return jsonObj; }
Used when reload Trigger from DB. It's possible to have missed schedule from last check point.
toJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/Condition.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/Condition.java
Apache-2.0
public static BasicTimeChecker createFromJson(final Object obj) throws Exception { return createFromJson((HashMap<String, Object>) obj); }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
createFromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public static BasicTimeChecker createFromJson(final HashMap<String, Object> obj) throws Exception { final Map<String, Object> jsonObj = (HashMap<String, Object>) obj; if (!jsonObj.get("type").equals(type)) { throw new Exception("Cannot create checker of " + type + " from " + jsonObj.get("type")); } final Long firstCheckTime = Long.valueOf((String) jsonObj.get("firstCheckTime")); final String timezoneId = (String) jsonObj.get("timezone"); final long nextCheckTime = Long.valueOf((String) jsonObj.get("nextCheckTime")); final DateTimeZone timezone = DateTimeZone.forID(timezoneId); final boolean isRecurring = Boolean.valueOf((String) jsonObj.get("isRecurring")); final boolean skipPastChecks = Boolean.valueOf((String) jsonObj.get("skipPastChecks")); final ReadablePeriod period = TimeUtils.parsePeriodString((String) jsonObj.get("period")); final String id = (String) jsonObj.get("id"); final String cronExpression = (String) jsonObj.get("cronExpression"); // TODO: remove skipPastChecks, this is not in use final BasicTimeChecker checker = new BasicTimeChecker(id, firstCheckTime, timezone, nextCheckTime, isRecurring, skipPastChecks, period, cronExpression); checker.updateNextCheckTime(); return checker; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
createFromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public long getFirstCheckTime() { return this.firstCheckTime; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getFirstCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public DateTimeZone getTimeZone() { return this.timezone; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getTimeZone
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public boolean isRecurring() { return this.isRecurring; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
isRecurring
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public boolean isSkipPastChecks() { return this.skipPastChecks; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
isSkipPastChecks
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public ReadablePeriod getPeriod() { return this.period; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getPeriod
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public long getNextCheckTime() { return this.nextCheckTime; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getNextCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public String getCronExpression() { return this.cronExpression; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getCronExpression
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public List<Long> getMissedCheckTimesBeforeNow() { return this.missedCheckTimesBeforeNow; }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
getMissedCheckTimesBeforeNow
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public Boolean eval() { return this.nextCheckTime < DateTimeUtils.currentTimeMillis(); }
This constructor used when recover from DB or end checkers, thus nextCheckTime is specified instead of calculated.
eval
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public void reset() { final NextCheckTime nextCheckTimeObj = calculateNextCheckTime(); this.nextCheckTime = nextCheckTimeObj.nextValidCheckTimeFromNow; nextCheckTimeObj.missedCheckTimeBeforeNow.remove(nextCheckTimeObj.missedCheckTimeBeforeNow.size() - 1); this.missedCheckTimesBeforeNow = nextCheckTimeObj.missedCheckTimeBeforeNow; }
Reset trigger when trigger fired associated action by updating next check time after Now. It will also refresh missedCheckTime list based on this round's check. First miss check would be removed from list because reset happens after trigger fires, thus the first one has already used and does not count towards miss check. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:01:30, fire condition is met (Now > nextCheckTime), trigger action. After trigger action, reset by calculate next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:02, however since trigger condition is used nextCheckTime (20:00) < now (20:01:30), technically it should not be counted as miss schedule, but from user's perspective, even if action is triggered based on 20:00, but it looks like it is triggered by last missed check (20:01). So instead, we remove last missed to maintain the behavior consistency.
reset
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public String getId() { return this.id; }
Reset trigger when trigger fired associated action by updating next check time after Now. It will also refresh missedCheckTime list based on this round's check. First miss check would be removed from list because reset happens after trigger fires, thus the first one has already used and does not count towards miss check. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:01:30, fire condition is met (Now > nextCheckTime), trigger action. After trigger action, reset by calculate next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:02, however since trigger condition is used nextCheckTime (20:00) < now (20:01:30), technically it should not be counted as miss schedule, but from user's perspective, even if action is triggered based on 20:00, but it looks like it is triggered by last missed check (20:01). So instead, we remove last missed to maintain the behavior consistency.
getId
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public String getType() { return type; }
Reset trigger when trigger fired associated action by updating next check time after Now. It will also refresh missedCheckTime list based on this round's check. First miss check would be removed from list because reset happens after trigger fires, thus the first one has already used and does not count towards miss check. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:01:30, fire condition is met (Now > nextCheckTime), trigger action. After trigger action, reset by calculate next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:02, however since trigger condition is used nextCheckTime (20:00) < now (20:01:30), technically it should not be counted as miss schedule, but from user's perspective, even if action is triggered based on 20:00, but it looks like it is triggered by last missed check (20:01). So instead, we remove last missed to maintain the behavior consistency.
getType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public BasicTimeChecker fromJson(final Object obj) throws Exception { return createFromJson(obj); }
Reset trigger when trigger fired associated action by updating next check time after Now. It will also refresh missedCheckTime list based on this round's check. First miss check would be removed from list because reset happens after trigger fires, thus the first one has already used and does not count towards miss check. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:01:30, fire condition is met (Now > nextCheckTime), trigger action. After trigger action, reset by calculate next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:02, however since trigger condition is used nextCheckTime (20:00) < now (20:01:30), technically it should not be counted as miss schedule, but from user's perspective, even if action is triggered based on 20:00, but it looks like it is triggered by last missed check (20:01). So instead, we remove last missed to maintain the behavior consistency.
fromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
protected void updateNextCheckTime() { final NextCheckTime nextCheckTimeObj = calculateNextCheckTime(); this.nextCheckTime = nextCheckTimeObj.nextValidCheckTimeFromNow; this.missedCheckTimesBeforeNow = nextCheckTimeObj.missedCheckTimeBeforeNow; }
Only used on reload trigger from DB to recover Trigger object. missedCheckTimes would count all previous missed checks including the first one. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:00:30, restart process reloads last check point from DB. It calculates next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:01, 20:00 would be marked as a missed schedule.
updateNextCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
private NextCheckTime calculateNextCheckTime() { DateTime date = new DateTime(this.nextCheckTime).withZone(this.timezone); LOG.debug("calculate next check time, current nextCheckTime is {} by cron {}", date, this.cronExpression); final NextCheckTime nextCheckTimeObj = new NextCheckTime(); int count = 0; while (!date.isAfterNow()) { nextCheckTimeObj.missedCheckTimeBeforeNow.add(date.getMillis()); LOG.debug("nextCheckTime {} by {} is before Now, it will be overrides, adding into missedCheckTimeBeforeNow List," + " now the list : {}", date, this.cronExpression, nextCheckTimeObj.missedCheckTimeBeforeNow); if (count > 100000) { throw new IllegalStateException("100000 increments of period did not get to present time."); } if (this.period == null && this.cronExpression == null) { break; } else if (this.cronExecutionTime != null) { final Date nextDate = this.cronExecutionTime.getNextValidTimeAfter(date.toDate()); // Some Cron Expressions possibly do not have follow-up occurrences if (nextDate != null) { date = new DateTime(nextDate); } else { break; } } else { // period is deprecated Schedule API parameter, we use cronSchedule API instead. date = date.plus(this.period); } count += 1; } // it's possible the above while loop exits on break condition instead of that "date refreshed after Now" // this happens when trigger expires before NOW, in such case we remove all missed checkTimes as they're meaningless if (!date.isAfterNow()) { nextCheckTimeObj.missedCheckTimeBeforeNow.clear(); } nextCheckTimeObj.nextValidCheckTimeFromNow = date.getMillis(); LOG.debug("Done calculation, current nextCheckTime {} by cron {} and missScheduleList {}", date, this.cronExpression, nextCheckTimeObj.missedCheckTimeBeforeNow); return nextCheckTimeObj; }
Only used on reload trigger from DB to recover Trigger object. missedCheckTimes would count all previous missed checks including the first one. For example: nextCheckTime from last update is 20:00, the schedule is triggered every minute. Now is system time is 20:00:30, restart process reloads last check point from DB. It calculates next check time, the previous nextCheckTime would be overwritten by the next valid check time after Now which is 20:01, 20:00 would be marked as a missed schedule.
calculateNextCheckTime
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public Object getNum() { return null; }
A metadata class records next check time from cronExpression.
getNum
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public Object toJson() { final Map<String, Object> jsonObj = new HashMap<>(); jsonObj.put("type", type); jsonObj.put("firstCheckTime", String.valueOf(this.firstCheckTime)); jsonObj.put("timezone", this.timezone.getID()); jsonObj.put("nextCheckTime", String.valueOf(this.nextCheckTime)); jsonObj.put("isRecurring", String.valueOf(this.isRecurring)); jsonObj.put("skipPastChecks", String.valueOf(this.skipPastChecks)); jsonObj.put("period", TimeUtils.createPeriodString(this.period)); jsonObj.put("id", this.id); jsonObj.put("cronExpression", this.cronExpression); return jsonObj; }
A metadata class records next check time from cronExpression.
toJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public void stopChecker() { return; }
A metadata class records next check time from cronExpression.
stopChecker
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
@Override public void setContext(final Map<String, Object> context) { }
A metadata class records next check time from cronExpression.
setContext
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/BasicTimeChecker.java
Apache-2.0
public static void setExecutorManager(final ExecutorManagerAdapter em) { executorManagerAdapter = em; }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
setExecutorManager
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
public static KillExecutionAction createFromJson(final Object obj) { return createFromJson((HashMap<String, Object>) obj); }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
createFromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
public static KillExecutionAction createFromJson(final HashMap<String, Object> obj) { final Map<String, Object> jsonObj = (HashMap<String, Object>) obj; final String objType = (String) jsonObj.get("type"); if (!objType.equals(type)) { throw new RuntimeException("Cannot create action of " + type + " from " + objType); } final String actionId = (String) jsonObj.get("actionId"); final int execId = Integer.valueOf((String) jsonObj.get("execId")); return new KillExecutionAction(actionId, execId); }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
createFromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
@Override public String getId() { return this.actionId; }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
getId
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
@Override public String getType() { return type; }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
getType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
@Override public KillExecutionAction fromJson(final Object obj) throws Exception { return createFromJson((HashMap<String, Object>) obj); }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
fromJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
@Override public Object toJson() { final Map<String, Object> jsonObj = new HashMap<>(); jsonObj.put("actionId", this.actionId); jsonObj.put("type", type); jsonObj.put("execId", String.valueOf(this.execId)); return jsonObj; }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
toJson
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0
@Override public void doAction() throws Exception { final ExecutableFlow exFlow = executorManagerAdapter.getExecutableFlow(this.execId); logger.info("ready to kill execution " + this.execId); if (!Status.isStatusFinished(exFlow.getStatus())) { logger.info("Killing execution " + this.execId); executorManagerAdapter.cancelFlow(exFlow, Constants.AZKABAN_SLA_CHECKER_USERNAME); } }
@deprecated Create a new KillExecutionAction using FlowRunnerManager instead of ExecutorManager to kill flow. Still keep the old one here for being compatible with existing SLA trigger in the database. Will remove the old one when all existing triggers expire.
doAction
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/trigger/builtin/KillExecutionAction.java
Apache-2.0