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 void setContext(final Map<String, Object> context) { }
@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.
setContext
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 getDescription() { return type + " for " + this.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.
getDescription
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 boolean hasPermissionforAction(final UserManager userManager, final User user, final Permission.Type type) { for (final String roleName : user.getRoles()) { final Role role = userManager.getRole(roleName); final Permission perm = role.getPermission(); if (perm.isPermissionSet(Permission.Type.ADMIN) || perm.isPermissionSet(type)) { return true; } } return false; }
@return - Returns true if the given user is an ADMIN, or if user has the required permission for the action requested.
hasPermissionforAction
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/UserUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/UserUtils.java
Apache-2.0
public static void setupWatch(final Map<String, ParseConfigFile> configFileMap, final FileWatcher watcher) { Preconditions.checkNotNull(configFileMap); Preconditions.checkArgument(configFileMap.size() > 0); // Map to store WatchKey to Dir mapping final Map<WatchKey, Path> keys = new HashMap<>(); // A directory to config files multimap final Multimap<Path, String> dirToFilesMap = HashMultimap.create(); // Iterate over each file. for (final Map.Entry<String, ParseConfigFile> entry : configFileMap.entrySet()) { final String fileName = entry.getKey(); final ParseConfigFile parser = entry.getValue(); Preconditions.checkNotNull(fileName); Preconditions.checkNotNull(parser); final File file = new File(fileName); if (!file.exists()) { log.warn("Failed to setup watch service, user provided file " + fileName + " does not " + "exist."); continue; } try { final Path dir = Paths.get(fileName).getParent(); if (!dirToFilesMap.containsKey(dir)) { // There is no entry for this directory, create a watchkey final WatchKey watchKey = watcher.register(dir); keys.put(watchKey, dir); } // Add the config file to dir map dirToFilesMap.put(dir, fileName); } catch (final IOException e) { // Ignore the IOException log.warn("IOException while setting up watch on conf " + fileName + ". ", e); } } // Return if WatchService is not initialized if (keys.size() == 0) { log.warn("Watchservice was not setup for any config file(s)."); try { watcher.close(); } catch (final IOException e) { log.warn("IOException while closing watchService. ", e); } return; } final Runnable runnable = () -> { // Watchservice is established, now listen for the events till eternity! for (; ; ) { final WatchKey watchKey; try { watchKey = watcher.take(); } catch (final InterruptedException ie) { log.warn(ie.toString()); Thread.currentThread().interrupt(); return; } // Get the directory for which watch service event triggered. final Path dir = keys.get(watchKey); for (final WatchEvent<?> event : watcher.pollEvents(watchKey)) { // Make sure the modification happened to user config file @SuppressWarnings("unchecked") final Path name = ((WatchEvent<Path>) event).context(); final String filename = dir.resolve(name).toString(); // Lookup the file in dirToFilesMap if (!dirToFilesMap.containsEntry(dir, filename)) { continue; } // Match! // Reparse the config file log.info("Modification detected, reloading config file " + filename + "."); try { configFileMap.get(filename).parseConfigFile(); } catch (final Exception e) { // If there is any exception while parsing the config file, log it and move on log.warn("Reload failed for config file " + filename + " due to ", e); } } } }; final Thread thread = new Thread(runnable); // allow JVM to terminate without waiting for this thread if the app is shutting down thread.setDaemon(true); log.info("Starting configuration watching thread."); thread.start(); }
Creates a watch thread which listens to specified files' modification and reloads configurations
setupWatch
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/UserUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/UserUtils.java
Apache-2.0
private void parseXMLFile() { final File file = new File(this.xmlPath); if (!file.exists()) { throw new IllegalArgumentException("User xml file " + this.xmlPath + " doesn't exist."); } final HashMap<String, User> users = new HashMap<>(); final HashMap<String, String> userPassword = new HashMap<>(); final HashMap<String, Role> roles = new HashMap<>(); final HashMap<String, Set<String>> groupRoles = new HashMap<>(); final HashMap<String, Set<String>> proxyUserMap = new HashMap<>(); // Creating the document builder to parse xml. final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; try { builder = docBuilderFactory.newDocumentBuilder(); } catch (final ParserConfigurationException e) { throw new IllegalArgumentException( "Exception while parsing user xml. Document builder not created.", e); } Document doc = null; try { doc = builder.parse(file); } catch (final SAXException e) { throw new IllegalArgumentException("Exception while parsing " + this.xmlPath + ". Invalid XML.", e); } catch (final IOException e) { throw new IllegalArgumentException("Exception while parsing " + this.xmlPath + ". Error reading file.", e); } // Only look at first item, because we should only be seeing // azkaban-users tag. final NodeList tagList = doc.getChildNodes(); final Node azkabanUsers = tagList.item(0); final NodeList azkabanUsersList = azkabanUsers.getChildNodes(); for (int i = 0; i < azkabanUsersList.getLength(); ++i) { final Node node = azkabanUsersList.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { if (node.getNodeName().equals(USER_TAG)) { parseUserTag(node, users, userPassword, proxyUserMap); } else if (node.getNodeName().equals(ROLE_TAG)) { parseRoleTag(node, roles); } else if (node.getNodeName().equals(GROUP_TAG)) { parseGroupRoleTag(node, groupRoles); } } } // Synchronize the swap. Similarly, the gets are synchronized to this. synchronized (this) { this.users = users; this.userPassword = userPassword; this.roles = roles; this.proxyUserMap = proxyUserMap; this.groupRoles = groupRoles; } }
The mandatory UserManager(Props) constructor, which is called via reflection.
parseXMLFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
private void parseUserTag(final Node node, final HashMap<String, User> users, final HashMap<String, String> userPassword, final HashMap<String, Set<String>> proxyUserMap) { final NamedNodeMap userAttrMap = node.getAttributes(); final Node userNameAttr = userAttrMap.getNamedItem(USERNAME_ATTR); if (userNameAttr == null) { throw new RuntimeException("Error loading user. The '" + USERNAME_ATTR + "' attribute doesn't exist"); } final Node passwordAttr = userAttrMap.getNamedItem(PASSWORD_ATTR); if (passwordAttr == null) { throw new RuntimeException("Error loading user. The '" + PASSWORD_ATTR + "' attribute doesn't exist"); } // Add user to the user/password map final String username = userNameAttr.getNodeValue(); final String password = passwordAttr.getNodeValue(); userPassword.put(username, password); // Add the user to the node final User user = new User(userNameAttr.getNodeValue()); users.put(username, user); logger.info("Loading user " + user.getUserId()); final Node roles = userAttrMap.getNamedItem(ROLES_ATTR); if (roles != null) { final String value = roles.getNodeValue(); final String[] roleSplit = value.split("\\s*,\\s*"); for (final String role : roleSplit) { user.addRole(role); } } final Node proxy = userAttrMap.getNamedItem(PROXY_ATTR); if (proxy != null) { final String value = proxy.getNodeValue(); final String[] proxySplit = value.split("\\s*,\\s*"); for (final String proxyUser : proxySplit) { Set<String> proxySet = proxyUserMap.get(username); if (proxySet == null) { proxySet = new HashSet<>(); proxyUserMap.put(username, proxySet); } proxySet.add(proxyUser); } } final Node groups = userAttrMap.getNamedItem(GROUPS_ATTR); if (groups != null) { final String value = groups.getNodeValue(); final String[] groupSplit = value.split("\\s*,\\s*"); for (final String group : groupSplit) { user.addGroup(group); } } final Node emailAttr = userAttrMap.getNamedItem(EMAIL_ATTR); if (emailAttr != null) { user.setEmail(emailAttr.getNodeValue()); } }
The mandatory UserManager(Props) constructor, which is called via reflection.
parseUserTag
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
private void parseRoleTag(final Node node, final HashMap<String, Role> roles) { final NamedNodeMap roleAttrMap = node.getAttributes(); final Node roleNameAttr = roleAttrMap.getNamedItem(ROLENAME_ATTR); if (roleNameAttr == null) { throw new RuntimeException( "Error loading role. The role 'name' attribute doesn't exist"); } final Node permissionAttr = roleAttrMap.getNamedItem(ROLEPERMISSIONS_ATTR); if (permissionAttr == null) { throw new RuntimeException( "Error loading role. The role 'permissions' attribute doesn't exist"); } final String roleName = roleNameAttr.getNodeValue(); final String permissions = permissionAttr.getNodeValue(); final String[] permissionSplit = permissions.split("\\s*,\\s*"); final Permission perm = new Permission(); for (final String permString : permissionSplit) { try { final Permission.Type type = Permission.Type.valueOf(permString); perm.addPermission(type); } catch (final IllegalArgumentException e) { logger.error("Error adding type " + permString + ". Permission doesn't exist.", e); } } final Role role = new Role(roleName, perm); roles.put(roleName, role); }
The mandatory UserManager(Props) constructor, which is called via reflection.
parseRoleTag
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public User getUser(final String username, final String password) throws UserManagerException { if (username == null || username.trim().isEmpty()) { throw new UserManagerException("Username is empty."); } else if (password == null || password.trim().isEmpty()) { throw new UserManagerException("Password is empty."); } // Minimize the synchronization of the get. Shouldn't matter if it // doesn't exist. String foundPassword = null; User user = null; synchronized (this) { foundPassword = this.userPassword.get(username); if (foundPassword != null) { user = this.users.get(username); } } if (foundPassword == null || !foundPassword.equals(password)) { throw new UserManagerException("Username/Password not found."); } // Once it gets to this point, no exception has been thrown. User // shoudn't be // null, but adding this check for if user and user/password hash tables // go // out of sync. if (user == null) { throw new UserManagerException("Internal error: User not found."); } // Add all the roles the group has to the user resolveGroupRoles(user); user.setPermissions(new UserPermissions() { @Override public boolean hasPermission(final String permission) { return true; } @Override public void addPermission(final String permission) { } }); return user; }
The mandatory UserManager(Props) constructor, which is called via reflection.
getUser
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean hasPermission(final String permission) { return true; }
The mandatory UserManager(Props) constructor, which is called via reflection.
hasPermission
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public void addPermission(final String permission) { }
The mandatory UserManager(Props) constructor, which is called via reflection.
addPermission
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
private void resolveGroupRoles(final User user) { for (final String group : user.getGroups()) { final Set<String> groupRoleSet = this.groupRoles.get(group); if (groupRoleSet != null) { for (final String role : groupRoleSet) { user.addRole(role); } } } }
The mandatory UserManager(Props) constructor, which is called via reflection.
resolveGroupRoles
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
private void parseGroupRoleTag(final Node node, final HashMap<String, Set<String>> groupRoles) { final NamedNodeMap groupAttrMap = node.getAttributes(); final Node groupNameAttr = groupAttrMap.getNamedItem(GROUPNAME_ATTR); if (groupNameAttr == null) { throw new RuntimeException( "Error loading role. The role 'name' attribute doesn't exist"); } final String groupName = groupNameAttr.getNodeValue(); final Set<String> roleSet = new HashSet<>(); final Node roles = groupAttrMap.getNamedItem(ROLES_ATTR); if (roles != null) { final String value = roles.getNodeValue(); final String[] roleSplit = value.split("\\s*,\\s*"); for (final String role : roleSplit) { roleSet.add(role); } } groupRoles.put(groupName, roleSet); logger.info("Group roles " + groupName + " added."); }
The mandatory UserManager(Props) constructor, which is called via reflection.
parseGroupRoleTag
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean validateUser(final String username) { return this.users.containsKey(username); }
The mandatory UserManager(Props) constructor, which is called via reflection.
validateUser
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public Role getRole(final String roleName) { return this.roles.get(roleName); }
The mandatory UserManager(Props) constructor, which is called via reflection.
getRole
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean validateGroup(final String group) { // Return true. Validation should be added when groups are added to the xml. return true; }
The mandatory UserManager(Props) constructor, which is called via reflection.
validateGroup
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean validateLdapGroup(String group) { return false; }
The mandatory UserManager(Props) constructor, which is called via reflection.
validateLdapGroup
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean validateProxyUser(final String proxyUser, final User realUser) { if (this.proxyUserMap.containsKey(realUser.getUserId()) && this.proxyUserMap.get(realUser.getUserId()).contains(proxyUser)) { return true; } else { return false; } }
The mandatory UserManager(Props) constructor, which is called via reflection.
validateProxyUser
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
@Override public boolean validateUserGroupMembership(String username, Set<String> groupSet) { return false; }
The mandatory UserManager(Props) constructor, which is called via reflection.
validateUserGroupMembership
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/user/XmlUserManager.java
Apache-2.0
public static HttpURLConnection loginAuthenticatedURL(final URL url, final String keytabPrincipal, final String keytabPath) throws Exception { logger.info( "Logging in URL: " + url.toString() + " using Principal: " + keytabPrincipal + ", Keytab: " + keytabPath); UserGroupInformation loginUser = UserGroupInformation.getLoginUser(); if (loginUser == null) { UserGroupInformation.loginUserFromKeytab(keytabPrincipal, keytabPath); loginUser = UserGroupInformation.getLoginUser(); logger.info("Logged in with user " + loginUser); } else { logger.info("Login user (" + loginUser + ") already created, refreshing tgt."); loginUser.checkTGTAndReloginFromKeytab(); } final HttpURLConnection connection = loginUser.doAs( (PrivilegedExceptionAction<HttpURLConnection>) () -> { final Token token = new Token(); return new AuthenticatedURL().openConnection(url, token); }); return connection; }
The util class for hadoop authentication.
loginAuthenticatedURL
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/AuthenticationUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/AuthenticationUtils.java
Apache-2.0
public V put(final String key, final V value) { return this.map.put(key.toLowerCase(), value); }
A concurrent hash map with a case-insensitive string key. @param <V> the value type
put
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
Apache-2.0
public V get(final String key) { return this.map.get(key.toLowerCase()); }
A concurrent hash map with a case-insensitive string key. @param <V> the value type
get
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
Apache-2.0
public boolean containsKey(final String key) { return this.map.containsKey(key.toLowerCase()); }
A concurrent hash map with a case-insensitive string key. @param <V> the value type
containsKey
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
Apache-2.0
public V remove(final String key) { return this.map.remove(key.toLowerCase()); }
A concurrent hash map with a case-insensitive string key. @param <V> the value type
remove
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
Apache-2.0
public List<String> getKeys() { return new ArrayList<>(this.map.keySet()); }
A concurrent hash map with a case-insensitive string key. @param <V> the value type
getKeys
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CaseInsensitiveConcurrentHashMap.java
Apache-2.0
public void append(final T line) { if (this.lines.size() < this.size) { this.lines.add(line); } else { this.lines.set(this.start, line); this.start = (this.start + 1) % this.size; } }
A circular buffer of items of a given length. It will grow up to the give size as items are appended, then it will begin to overwrite older items. @param <T> The type of the item contained.
append
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
Apache-2.0
@Override public String toString() { return "[" + Joiner.on(", ").join(this.lines) + "]"; }
A circular buffer of items of a given length. It will grow up to the give size as items are appended, then it will begin to overwrite older items. @param <T> The type of the item contained.
toString
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
Apache-2.0
@Override public Iterator<T> iterator() { if (this.start == 0) { return this.lines.iterator(); } else { return Iterators.concat(this.lines.subList(this.start, this.lines.size()).iterator(), this.lines.subList(0, this.start).iterator()); } }
A circular buffer of items of a given length. It will grow up to the give size as items are appended, then it will begin to overwrite older items. @param <T> The type of the item contained.
iterator
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
Apache-2.0
public int getMaxSize() { return this.size; }
A circular buffer of items of a given length. It will grow up to the give size as items are appended, then it will begin to overwrite older items. @param <T> The type of the item contained.
getMaxSize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
Apache-2.0
public int getSize() { return this.lines.size(); }
A circular buffer of items of a given length. It will grow up to the give size as items are appended, then it will begin to overwrite older items. @param <T> The type of the item contained.
getSize
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/CircularBuffer.java
Apache-2.0
@Override public Thread newThread(Runnable r) { Thread t = new Thread(r, this.namePrefix + "-" + this.threadNumber.getAndIncrement()); t.setDaemon(true); return t; }
A thread factory that sets the threads to run as daemons. (Otherwise things that embed the threadpool can't shut themselves down).
newThread
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DaemonThreadFactory.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DaemonThreadFactory.java
Apache-2.0
private void ensureIsEnabled() { if (!isEnabled()) { throw new UnsupportedOperationException("Thin archive support is not enabled!"); } }
Return if the DependencyTransferManager will be able to download dependencies from the current Storage instance. @return if this class is enabled and can download dependencies.
ensureIsEnabled
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
public void downloadAllDependencies(final Set<DependencyFile> deps, String projectName) { if (deps.isEmpty()) { // Nothing for us to do! return; } long startTime = System.currentTimeMillis(); ensureIsEnabled(); CompletableFuture[] taskFutures = deps .stream() .map(f -> CompletableFuture.runAsync(() -> downloadDependency(f, projectName), threadPool)) .toArray(CompletableFuture[]::new); try { waitForAllToSucceedOrOneToFail(taskFutures); logger.info("Time taken to download all thin archive dependencies for project {} in {} ms.", projectName, System.currentTimeMillis() - startTime); } catch (InterruptedException e) { // No point in continuing, let's stop any future downloads and try to interrupt currently running ones. logger.error("Download interrupted. Cancelling all pending downloads for project {}.", projectName); cancelPendingTasks(taskFutures, projectName); throw new DependencyTransferException("Download interrupted.", e); } catch (ExecutionException e) { // ^^^ see above comment ^^^ logger.error("Download failed. Cancelling all pending downloads for project {}.", projectName); cancelPendingTasks(taskFutures, projectName); if (e.getCause() instanceof DependencyTransferException) { throw (DependencyTransferException) e.getCause(); } throw new RuntimeException(e.getCause()); } catch (TimeoutException e) { logger.error("Timed out while downloading dependencies for project {}.", projectName, e); cancelPendingTasks(taskFutures, projectName); throw new DependencyTransferException("Timed out while downloading dependencies.", e); } }
downloads a set of dependencies from an origin. Each downloaded dependency is stored in the file returned by DependencyFile::getFile. @param deps set of DependencyFile to download @param projectName name of the project for which the dependencies are being downloaded
downloadAllDependencies
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
private void downloadDependency(final DependencyFile f, String projectName) { try { downloadDependency(f, 0, projectName); logger.info("Successfully downloaded dependency {} for project {}.", f.getFileName(), projectName); } catch (IOException e) { logger.error("Error while downloading dependency {} for project {}.", f.getFileName(), projectName, e); throw new DependencyTransferException("Error while downloading dependency " + f.getFileName(), e); } catch (HashNotMatchException e) { logger.error("Checksum did not match when downloading dependency {} for project {}.", f.getFileName(), projectName, e); throw new DependencyTransferException("Checksum did not match when downloading dependency " + f.getFileName(), e); } }
downloads a set of dependencies from an origin. Each downloaded dependency is stored in the file returned by DependencyFile::getFile. @param deps set of DependencyFile to download @param projectName name of the project for which the dependencies are being downloaded
downloadDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
@VisibleForTesting void cancelPendingTasks(CompletableFuture[] taskFutures, String projectName) { for (CompletableFuture future : taskFutures) { future.cancel(false); } logger.info("Cancelled the pending tasks for project {} because one of the downloads failed.", projectName); }
downloads a set of dependencies from an origin. Each downloaded dependency is stored in the file returned by DependencyFile::getFile. @param deps set of DependencyFile to download @param projectName name of the project for which the dependencies are being downloaded
cancelPendingTasks
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
private void downloadDependency(final DependencyFile f, final int retries, String projectName) throws HashNotMatchException, IOException { FileOutputStream outputStream = null; InputStream inputStream = null; try { // Make any necessary directories f.getFile().getParentFile().mkdirs(); outputStream = new FileOutputStream(f.getFile()); inputStream = this.storage.getDependency(f); IOUtils.copy(inputStream, outputStream); } catch (IOException e) { if (retries + 1 < dependencyMaxDownloadTries) { // downloadDependency will overwrite our destination file if attempted again exponentialBackoffDelay(retries); downloadDependency(f, retries + 1, projectName); return; } logger.error("Failed to download dependency file {} for project {} with {} max reties.", f.getFileName(), projectName, dependencyMaxDownloadTries, e); throw e; } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(outputStream); } try { validateDependencyHash(f); } catch (HashNotMatchException e) { if (retries + 1 < dependencyMaxDownloadTries) { // downloadDependency will overwrite our destination file if attempted again exponentialBackoffDelay(retries); downloadDependency(f, retries + 1, projectName); return; } logger.error("Failed to complete hash validation for dependency file {} for project {} with {} max download reties." + " Failing Download", f.getFileName(), projectName, dependencyMaxDownloadTries); throw e; } }
downloads a set of dependencies from an origin. Each downloaded dependency is stored in the file returned by DependencyFile::getFile. @param deps set of DependencyFile to download @param projectName name of the project for which the dependencies are being downloaded
downloadDependency
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
private static void exponentialBackoffDelay(final int retries) { try { // Will wait for 1, 2, 4, 8... seconds Thread.sleep((long) (Math.pow(2, retries) * 1000)); } catch (InterruptedException e) { throw new RuntimeException(e); } }
downloads a set of dependencies from an origin. Each downloaded dependency is stored in the file returned by DependencyFile::getFile. @param deps set of DependencyFile to download @param projectName name of the project for which the dependencies are being downloaded
exponentialBackoffDelay
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
@VisibleForTesting void waitForAllToSucceedOrOneToFail(final CompletableFuture<?>[] futures) throws InterruptedException, ExecutionException, TimeoutException { CompletableFuture<?> failure = new CompletableFuture(); for (CompletableFuture<?> f : futures) { // f = f is redundant, but bug checker throws error if we don't do it because it doesn't like us ignoring a // returned future...but we're still going to ignore it. f = f.exceptionally(ex -> { logger.error("Download failed with an exception: " + ex); failure.completeExceptionally(ex); return null; }); } // Wait for either the failure future to complete, or all of the actual futures to complete. CompletableFuture.anyOf(failure, CompletableFuture.allOf(futures)).get(dependencyDownloadMaxTimeout, TimeUnit.SECONDS); }
Add timeout to the download process. @throws TimeoutException, if the download process takes longer than the timeout.
waitForAllToSucceedOrOneToFail
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DependencyTransferManager.java
Apache-2.0
public static ClassLoader getClassLoader(List<URL> resources, ClassLoader parent) { return new URLClassLoader(resources.toArray(new URL[resources.size()]), parent); }
Get ClassLoader From Resources @param resources list of resource @param parent parent class loader @return class loader
getClassLoader
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DIUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DIUtils.java
Apache-2.0
public static List<URL> loadResources( final File pluginDir, final List<String> globalClassPaths, final List<String> classPaths, final List<String> libDirectories ) throws MalformedURLException { final List<URL> resources = new ArrayList<>(); LOGGER.info("Adding global resources"); loadResources(globalClassPaths, resources); LOGGER.info("Adding type resources"); loadResources(classPaths, resources); LOGGER.info("Adding lib resources"); if (libDirectories != null) { for (final String libDir : libDirectories) { loadResources(new File(libDir), resources); } } LOGGER.info("Adding type override resources"); loadResources(pluginDir, resources); return resources; }
Load Setting to Resources @param pluginDir plugin Directory @param globalClassPaths list of global class path @param classPaths list of local class path @param libDirectories list of lib directories @return
loadResources
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DIUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DIUtils.java
Apache-2.0
private static void loadResources(final List<String> classPaths, List<URL> resources) throws MalformedURLException { if (classPaths != null) { for (final String jar : classPaths) { final URL cpItem = new File(jar).toURI().toURL(); if (!resources.contains(cpItem)) { LOGGER.info("adding to classpath " + cpItem); resources.add(cpItem); } } } }
Load Setting from a list of class paths to Resources @param classPaths list of class paths @param resources list of resource @throws MalformedURLException
loadResources
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DIUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DIUtils.java
Apache-2.0
private static void loadResources(final File directory, List<URL> resources) throws MalformedURLException { for (final File file : directory.listFiles()) { if (file.getName().endsWith(".jar")) { resources.add(file.toURI().toURL()); LOGGER.info("adding to classpath " + file.toURI().toURL()); } } }
Load Setting from file directory to Resources @param directory file directory for .jar files @param resources list of resource @throws MalformedURLException
loadResources
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/DIUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/DIUtils.java
Apache-2.0
public void sendEmail(final List<String> emailList, final String subject, final String body) { if (emailList != null && !emailList.isEmpty()) { final EmailMessage message = super.createEmailMessage(subject, "text/html", emailList); message.setBody(body); sendEmail(message, true, "email message " + body); } }
Send an email to the specified email list
sendEmail
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnSla(final ExecutableFlow flow, final SlaOption slaOption) { final String subject = "SLA violation for " + getJobOrFlowName(slaOption) + " on " + getAzkabanName(); final String slaMessage = createSlaMessage(flow, slaOption, getAzkabanURL()); final List<String> emailList = slaOption.getEmails(); logger.info("Sending SLA email " + slaMessage); sendEmail(emailList, subject, slaMessage); }
Send an email to the specified email list
alertOnSla
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnFirstError(final ExecutableFlow flow) { final EmailMessage message = this.messageCreator.createMessage(); final MailCreator mailCreator = getMailCreator(flow); final boolean mailCreated = mailCreator.createFirstErrorMessage(flow, message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber); sendEmail(message, mailCreated, "first error email message for execution " + flow.getExecutionId()); }
Send an email to the specified email list
alertOnFirstError
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnError(final ExecutableFlow flow, final String... extraReasons) { final List<String> emailRecipients = flow.getExecutionOptions().getFailureEmails(); if (emailRecipients == null || emailRecipients.isEmpty()) { return; } final EmailMessage message = this.messageCreator.createMessage(); final MailCreator mailCreator = getMailCreator(flow); List<ExecutableFlow> last72hoursExecutions = new ArrayList<>(); if (flow.getStartTime() > 0) { final long startTime = flow.getStartTime() - Duration.ofHours(72).toMillis(); try { last72hoursExecutions = this.executorLoader.fetchFlowHistory(flow.getProjectId(), flow .getFlowId(), startTime); } catch (final ExecutorManagerException e) { logger.error("unable to fetch past executions", e); } } final boolean mailCreated = mailCreator.createErrorEmail(flow, last72hoursExecutions, message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber, extraReasons); sendEmail(message, mailCreated, "error email message for execution " + flow.getExecutionId()); }
Send an email to the specified email list
alertOnError
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnSuccess(final ExecutableFlow flow) { final List<String> emailRecipients = flow.getExecutionOptions().getSuccessEmails(); if (emailRecipients == null || emailRecipients.isEmpty()) { return; } final EmailMessage message = this.messageCreator.createMessage(); final MailCreator mailCreator = getMailCreator(flow); final boolean mailCreated = mailCreator.createSuccessEmail(flow, message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber); sendEmail(message, mailCreated, "success email message for execution " + flow.getExecutionId()); }
Send an email to the specified email list
alertOnSuccess
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnFailedUpdate(final Executor executor, List<ExecutableFlow> flows, final ExecutorManagerException updateException) { flows = flows.stream() .filter(flow -> flow.getExecutionOptions() != null) .filter(flow -> CollectionUtils.isNotEmpty(flow.getExecutionOptions().getFailureEmails())) .collect(Collectors.toList()); // group by mail creator in case some flows use different creators final ImmutableListMultimap<String, ExecutableFlow> creatorsToFlows = Multimaps .index(flows, flow -> flow.getExecutionOptions().getMailCreator()); for (final String mailCreatorName : creatorsToFlows.keySet()) { final ImmutableList<ExecutableFlow> creatorFlows = creatorsToFlows.get(mailCreatorName); final MailCreator mailCreator = getMailCreator(mailCreatorName); // group by recipients in case some flows have different failure email addresses final ImmutableListMultimap<List<String>, ExecutableFlow> emailsToFlows = Multimaps .index(creatorFlows, flow -> flow.getExecutionOptions().getFailureEmails()); for (final List<String> emailList : emailsToFlows.keySet()) { sendFailedUpdateEmail(executor, updateException, mailCreator, emailsToFlows.get(emailList)); } } }
Sends as many emails as there are unique combinations of: <p> [mail creator] x [failure email address list] <p> Executions with the same combo are grouped into a single message.
alertOnFailedUpdate
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnFailedExecutorHealthCheck(final Executor executor, final List<ExecutableFlow> flows, final ExecutorManagerException failureException, final List<String> emailList) { if (emailList == null || emailList.isEmpty()) { // We should consider throwing an exception here. For now this follows the model of the rest // of the file and simply returns. logger.error("No email list specified for failed health check alert"); return; } final MailCreator mailCreator = DefaultMailCreator.getCreator(DefaultMailCreator.DEFAULT_MAIL_CREATOR); final EmailMessage message = this.messageCreator.createMessage(); final boolean mailCreated = mailCreator .createFailedExecutorHealthCheckMessage(flows, executor, failureException, message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber, emailList); final List<Integer> executionIds = Lists.transform(flows, ExecutableFlow::getExecutionId); sendEmail(message, mailCreated, "failed health check message for executions " + executionIds); }
Use the default mail creator to send a failed executor healthcheck message to the given list of addresses. Message includes a list of flows impacted on the executor.
alertOnFailedExecutorHealthCheck
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
@Override public void alertOnJobPropertyOverridden(final Project project, final Flow flow, final Map<String, Object> eventData) { final List<String> emailList = flow.getOverrideEmails(); final String emailSubject = "[Project Property Overridden Alert]"; final String modifier = String.valueOf(eventData.get(MODIFIED_BY)); final String jobName = String.valueOf(eventData.get("jobOverridden")); final String diffMessage = String.valueOf(eventData.get("diffMessage")); final String emailBody = "User " + modifier + " has overridden following job properties in project " + project.getName() + " flow " + flow.getId() + " job " + jobName + ": " + "\n" + diffMessage; sendEmail(emailList, emailSubject, emailBody); }
Alert user when a job property is overridden in a project @param project @param flow @param eventData
alertOnJobPropertyOverridden
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
private void sendFailedUpdateEmail(final Executor executor, final ExecutorManagerException exception, final MailCreator mailCreator, final ImmutableList<ExecutableFlow> flows) { final EmailMessage message = this.messageCreator.createMessage(); final boolean mailCreated = mailCreator .createFailedUpdateMessage(flows, executor, exception, message, this.azkabanName, this.scheme, this.clientHostname, this.clientPortNumber); final List<Integer> executionIds = Lists.transform(flows, ExecutableFlow::getExecutionId); sendEmail(message, mailCreated, "failed update email message for executions " + executionIds); }
Sends a single email about failed updates.
sendFailedUpdateEmail
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
private MailCreator getMailCreator(final ExecutableFlow flow) { final String name = flow.getExecutionOptions().getMailCreator(); return getMailCreator(name); }
Sends a single email about failed updates.
getMailCreator
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
private MailCreator getMailCreator(final String name) { final MailCreator mailCreator = DefaultMailCreator.getCreator(name); logger.debug("ExecutorMailer using mail creator:" + mailCreator.getClass().getCanonicalName()); return mailCreator; }
Sends a single email about failed updates.
getMailCreator
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
public void sendEmail(final EmailMessage message, final boolean mailCreated, final String operation) { if (mailCreated) { try { message.sendEmail(); logger.info("Sent " + operation); this.commonMetrics.markSendEmailSuccess(); } catch (final Exception e) { logger.error("Failed to send " + operation, e); if (!(e instanceof AddressException)) { this.commonMetrics.markSendEmailFail(); } } } }
Sends a single email about failed updates.
sendEmail
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
public static String createSlaMessage(final ExecutableFlow execFlow, final SlaOption slaOption, final String azkabanUrl) { final int execId = execFlow.getExecutionId(); final String durationStr = slaOption.durationToString(slaOption.getDuration()); final String executionUrl = String.format("%s/executor?execid=%d", azkabanUrl, execId); final String executionLink = String.format("<a href=\"%s\">%s Execution Link</a>", executionUrl, execFlow.getFlowId()); final SlaType slaType = slaOption.getType(); switch (slaType.getComponent()) { case FLOW: final String basicinfo = String.format("SLA Alert: Your flow %s failed to %s within %s<br/>%s<br/>", slaOption.getFlowName(), slaType.getStatus(), durationStr, executionLink); final String expected = String.format( "Here are details : <br/>Flow %s in execution %d is expected to FINISH within %s from %s<br/>", slaOption.getFlowName(), execId, durationStr, fmt.print(new DateTime(execFlow.getStartTime()))); final String actual = String.format("Actual flow status is %s", execFlow.getStatus()); return basicinfo + expected + actual; case JOB: return String.format("SLA Alert: Your job %s failed to %s within %s in execution %d</br>%s", slaOption.getJobName(), slaType.getStatus(), durationStr, execId, executionLink); default: return String.format("Unrecognized SLA component type %s", slaType.getComponent()); } }
Construct the message for the SLA. @param execFlow the executable flow. @return the SLA message.
createSlaMessage
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
private String getJobOrFlowName(final SlaOption slaOption) { if (org.apache.commons.lang.StringUtils.isNotBlank(slaOption.getJobName())) { return slaOption.getFlowName() + ":" + slaOption.getJobName(); } else { return slaOption.getFlowName(); } }
Construct the message for the SLA. @param execFlow the executable flow. @return the SLA message.
getJobOrFlowName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/Emailer.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/Emailer.java
Apache-2.0
private void validate() { if (!this.binaryExecutable.canExecute()) { throw new RuntimeException("Unable to execute execute-as-user binary. Invalid Path: " + this.binaryExecutable.getAbsolutePath()); } }
Construct the object @param nativeLibDirectory Absolute path to the native Lib Directory
validate
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
Apache-2.0
public int execute(final String user, final List<String> command) throws IOException { log.info("Command: " + command); final Process process = new ProcessBuilder() .command(constructExecuteAsCommand(user, command)) .inheritIO() .start(); int exitCode; try { exitCode = process.waitFor(); } catch (final InterruptedException e) { log.error(e.getMessage(), e); exitCode = 1; } return exitCode; }
API to execute a command on behalf of another user. @param user The proxy user @param command the list containing the program and its arguments @return The return value of the shell command
execute
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
Apache-2.0
private List<String> constructExecuteAsCommand(final String user, final List<String> command) { final List<String> commandList = new ArrayList<>(); commandList.add(this.binaryExecutable.getAbsolutePath()); commandList.add(user); commandList.addAll(command); return commandList; }
API to execute a command on behalf of another user. @param user The proxy user @param command the list containing the program and its arguments @return The return value of the shell command
constructExecuteAsCommand
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExecuteAsUser.java
Apache-2.0
public static synchronized void addGroupAndUserForEffectiveUser(final ExecuteAsUser executeAsUser, final String effectiveUser) throws Exception { List<String> commands = Arrays.asList(ADD_GROUP_PATH, effectiveUser); int result = executeAsUser.execute("root", commands); // If group is added successfully, it will return code 0. // If group is already added then it will return code 9. if (result == 0 || result == 9) { logger.info("Group is added successfully."); commands = Arrays .asList(ADD_USER_PATH, "-l", "-m", effectiveUser, "-g", effectiveUser); result = executeAsUser.execute("root", commands); // If user is added successfully, it will return code 0. // If user is already added then it will return code 9. if (result == 0 || result == 9) { logger.info("User is added successfully."); } else { final String errorMessage = "Failed to add user:" + effectiveUser + "Return value was: " + result; logger.error(errorMessage); throw new JobExecutionException(errorMessage); } } else { final String errorMessage = "Failed to add group:" + effectiveUser + "Return value was: " + result; logger.error(errorMessage); throw new JobExecutionException(errorMessage); } }
Add group and user on environment where job will run before job process starts. These commands can only be executed by root user. Keep it synchronized in case of race condition. Otherwise, it is possible that while threadA creates a new user and not yet finish the create user call, threadB finds user is already created and thus continue the processing which ends up with user not found error. @param effectiveUser @throws Exception
addGroupAndUserForEffectiveUser
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExecuteAsUserUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExecuteAsUserUtils.java
Apache-2.0
@Override public String toString() { return "ExternalAnalyzer{" + ", topic='" + this.topic + '\'' + ", label='" + this.label + '\'' + ", linkUrl='" + this.linkUrl + '\'' + ", linkUrlValid='" + this.linkUrlValid + '\'' + '}'; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
toString
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
public String getTopic() { return this.topic; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
getTopic
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
public String getLabel() { return this.label; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
getLabel
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
public String getLinkUrl() { return this.linkUrl; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
getLinkUrl
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
public boolean isLinkUrlValid() { return this.linkUrlValid; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
isLinkUrlValid
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ExternalLink link = (ExternalLink) o; return Objects.equals(this.topic, link.topic) && Objects.equals(this.label, link.label) && Objects.equals(this.linkUrl, link.linkUrl) && this.linkUrlValid == link.linkUrlValid; }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
equals
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
@Override public int hashCode() { return Objects.hash(this.topic, this.label, this.linkUrl, this.linkUrlValid); }
Represents an external link. Links are rendered as buttons in the Flow and/or Job execution pages. Its configuration is optional, is done in {@value Constants#AZKABAN_PROPERTIES_FILE}.
hashCode
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLink.java
Apache-2.0
private static boolean validExternalLink(final String externalLinkUrl, final int timeout) { final RequestConfig config = RequestConfig.custom() .setConnectTimeout(timeout) .setConnectionRequestTimeout(timeout) .setSocketTimeout(timeout).build(); final CloseableHttpClient client = HttpClients.custom() .setDefaultRequestConfig(config) .setSSLSocketFactory(null).disableRedirectHandling().build(); try { try { final HttpResponse httpResponse = client.execute(new HttpGet(externalLinkUrl)); final int responseCode = httpResponse.getStatusLine().getStatusCode(); if (responseCode >= HttpStatus.SC_BAD_REQUEST) { logger.warn("validExternalLink url " + externalLinkUrl + " not reachable, response code " + responseCode); return false; } logger.debug("validExternalLink url " + externalLinkUrl + " is reachable."); return true; } finally { client.close(); } } catch (Exception e) { logger.error("validExternalLink url " + externalLinkUrl + " CONNECT ERROR " + e); return false; } }
Check if the external link url is reachable by making a http request to it. If the response has 200x or 300x status code, returns true, and the external link is enabled or rendered clickable in the UI, otherwise returns false, and the external link is rendered disabled.
validExternalLink
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
Apache-2.0
public static List<ExternalLink> parseExternalLinks(final Props azkProps, final ExternalLinkScope level) { final Map<String, Object> params = new HashMap<>(); params.put("level", level.getName()); final String extLinksProperty = StrSubstitutor.replace(ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPICS, params, "${", "}"); final Set<String> topics = new HashSet<>(azkProps.getStringList(extLinksProperty)); final List<ExternalLink> externalLinks = new ArrayList<>(); for (final String topic : topics) { params.put("topic", topic); final String label = azkProps.getString(StrSubstitutor.replace( ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC_LABEL, params, "${", "}"), ""); final String url = azkProps.getString(StrSubstitutor.replace( ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC_URL, params, "${", "}"), ""); if (url.isEmpty() || label.isEmpty()) { continue; } externalLinks.add(new ExternalLink(topic, label, url, true)); } return externalLinks; }
Parse all Flow or Job level external links that may have been configured in the {@value Constants#AZKABAN_PROPERTIES_FILE} file.
parseExternalLinks
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
Apache-2.0
static String buildExternalLinkUrl(final String urlTemplate, final HttpServletRequest req, final int executionId, final String jobId) { final Map<String, Object> params = new HashMap<>(); params.put(ExternalLinkParams.URL.getName(), encodeToUTF8( String.join("?", req.getRequestURL(), req.getQueryString()))); params.put(ExternalLinkParams.EXEC_ID.getName(), executionId); params.put(ExternalLinkParams.JOB_ID.getName(), jobId); params.put(ExternalLinkParams.WEBSERVER_HOST.getName(), req.getServerName()); return StrSubstitutor.replace(urlTemplate, params, "${", "}"); }
Parse all Flow or Job level external links that may have been configured in the {@value Constants#AZKABAN_PROPERTIES_FILE} file.
buildExternalLinkUrl
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
Apache-2.0
public static List<ExternalLink> buildExternalLinksForRequest( final List<ExternalLink> extLinksTemplates, final int extLinksTimeoutMs, final HttpServletRequest req, final int executionId, final String jobId) { final List<ExternalLink> extLinks = new ArrayList<>(); for(final ExternalLink link: extLinksTemplates) { final String url = buildExternalLinkUrl(link.getLinkUrl(), req, executionId, jobId); extLinks.add(new ExternalLink(link.getTopic(), link.getLabel(), url, validExternalLink(url, extLinksTimeoutMs))); } return extLinks; }
Parse all Flow or Job level external links that may have been configured in the {@value Constants#AZKABAN_PROPERTIES_FILE} file.
buildExternalLinksForRequest
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/ExternalLinkUtils.java
Apache-2.0
public static boolean isDirWritable(final File dir) { File testFile = null; try { testFile = new File(dir, "_tmp"); /* * Create and delete a dummy file in order to check file permissions. Maybe * there is a safer way for this check. */ testFile.createNewFile(); } catch (final IOException e) { return false; } finally { if (testFile != null) { testFile.delete(); } } return true; }
Check if a directory is writable @param dir directory file object @return true if it is writable. false, otherwise
isDirWritable
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static boolean isValidDirectory(File directory) { if (!directory.exists()) { LOGGER.warn("Directory [" + directory.toPath() + "] does not exist."); return false; } if (!directory.isDirectory()) { LOGGER.error("Directory [" + directory.toPath() + "] is invalid. No extra plugins will be loaded"); return false; } if (!directory.canRead()) { LOGGER.error("Directory [" + directory.toPath() + "] is not readable. No extra plugins will be loaded"); return false; } return true; }
Check if a directory is a valid directory @param directory directory file object @return true if it exists, valid and readable
isValidDirectory
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static void deleteDirectorySilently(final File dir) { if (dir != null) { try { FileUtils.deleteDirectory(dir); } catch (final IOException e) { LOGGER.error("error when deleting dir {}", dir, e); } } }
Delete a directory, log the error if deletion fails.
deleteDirectorySilently
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static File getDirectory(File parentDirectory, String folderName) { File directory = new File(parentDirectory, folderName); if (!directory.exists()) { directory.mkdir(); } return directory; }
Get Directory or Create a Directory if it does not exist @param parentDirectory parent Directory name @param folderName sub folder name @return handle of File
getDirectory
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static void moveFiles(File sourceDirectory, File destinationDiretory, String fileNamePattern) throws IOException { File[] files = sourceDirectory.listFiles(); for (File file : files) { if (!file.isDirectory()) { if (file.getName().matches(fileNamePattern)) { Files.move( Paths.get(file.getAbsolutePath()), Paths.get(String.format("%s/%s", destinationDiretory.getAbsolutePath(), file.getName()))); } } } }
Move Files from source directory to destinationDirectory if the file name matches the given pattern @param sourceDirectory source directory @param destinationDiretory destination directory @param fileNamePattern regular expression pattern of file name's @throws IOException
moveFiles
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static void dumpNumberToFile(final Path filePath, final long num) throws IOException { try (final BufferedWriter writer = Files .newBufferedWriter(filePath, StandardCharsets.UTF_8)) { writer.write(String.valueOf(num)); } catch (final IOException e) { LOGGER.error("Failed to write the number {} to the file {}", num, filePath, e); throw e; } }
Dumps a number into a new file. @param filePath the target file @param num the number to dump @throws IOException if file already exists
dumpNumberToFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static long readNumberFromFile(final Path filePath) throws IOException, NumberFormatException { final List<String> allLines = Files.readAllLines(filePath); if (!allLines.isEmpty()) { return Long.parseLong(allLines.get(0)); } else { throw new NumberFormatException("unable to parse empty file " + filePath.toString()); } }
Reads a number from a file. @param filePath the target file
readNumberFromFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static String getSourcePathFromClass(final Class<?> containedClass) { final String containedClassPath = containedClass.getProtectionDomain().getCodeSource() .getLocation().getPath(); File file = new File(containedClassPath); if (!file.isDirectory() && file.getName().endsWith(".class")) { final String name = containedClass.getName(); final StringTokenizer tokenizer = new StringTokenizer(name, "."); while (tokenizer.hasMoreTokens()) { tokenizer.nextElement(); file = file.getParentFile(); } return file.getPath(); } else { return containedClassPath; } }
Reads a number from a file. @param filePath the target file
getSourcePathFromClass
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static String getCanonicalPath(final File f) { try { return f.getCanonicalPath(); } catch (IOException e) { throw new RuntimeException(e); } }
A thin wrapper for File.getCanonicalPath() that doesn't throw a checked exception @param f input file @return String canonical path of the file
getCanonicalPath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static Props loadOutputFileProps(final File file) { InputStream reader = null; try { LOGGER.info("output properties file=" + file.getAbsolutePath()); reader = new BufferedInputStream(new FileInputStream(file)); final Props outputProps = new Props(); final String content = Streams.asString(reader).trim(); if (!content.isEmpty()) { final Map<String, Object> propMap = (Map<String, Object>) JSONUtils.parseJSONFromString(content); for (final Map.Entry<String, Object> entry : propMap.entrySet()) { outputProps.put(entry.getKey(), entry.getValue().toString()); } } return outputProps; } catch (final FileNotFoundException e) { LOGGER.info( String.format("File[%s] wasn't found, returning empty props.", file) ); return new Props(); } catch (final Exception e) { LOGGER.error( "Exception thrown when trying to load output file props. Returning empty Props instead of failing. Is this really the best thing to do?", e); return new Props(); } finally { IOUtils.closeQuietly(reader); } }
Load output file into a Props object @param file output properties file @return Props object
loadOutputFileProps
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static File createOutputPropsFile(final String prefix, final String suffix, final String workingDir) { try { final File directory = new File(workingDir); final File tempFile = File.createTempFile(prefix, suffix, directory); return tempFile; } catch (final IOException e) { throw new RuntimeException("Failed to create temp output property file ", e); } }
Create Temp File in a working directory @param prefix file prefix @param suffix file suffix @param workingDir working directory @return File handle
createOutputPropsFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static int createDeepHardlink(final File sourceDir, final File destDir) throws IOException { if (!sourceDir.exists()) { throw new IOException("Source directory " + sourceDir.getPath() + " doesn't exist"); } else if (!destDir.exists()) { throw new IOException("Destination directory " + destDir.getPath() + " doesn't exist"); } else if (sourceDir.isFile() && destDir.isFile()) { throw new IOException("Source or Destination is not a directory."); } final Set<String> paths = new HashSet<>(); createDirsFindFiles(sourceDir, sourceDir, destDir, paths); int linkCount = 0; for (String path : paths) { final File sourceLink = new File(sourceDir, path); path = destDir + path; final File[] targetFiles = sourceLink.listFiles(); for (final File targetFile : targetFiles) { if (targetFile.isFile()) { final File linkFile = new File(path, targetFile.getName()); // NOTE!! If modifying this, you must run this ignored test manually to validate: // FileIOUtilsTest#testHardlinkCopyOfBigDir Files.createLink(linkFile.toPath(), Paths.get(targetFile.getAbsolutePath())); linkCount++; } } } return linkCount; }
Hard link files and recurse into directories.
createDeepHardlink
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
private static void createDirsFindFiles(final File baseDir, final File sourceDir, final File destDir, final Set<String> paths) { final File[] srcList = sourceDir.listFiles(); final String path = getRelativePath(baseDir, sourceDir); paths.add(path); for (final File file : srcList) { if (file.isDirectory()) { final File newDestDir = new File(destDir, file.getName()); newDestDir.mkdirs(); createDirsFindFiles(baseDir, file, newDestDir, paths); } } }
Hard link files and recurse into directories.
createDirsFindFiles
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
private static String getRelativePath(final File basePath, final File sourceDir) { return sourceDir.getPath().substring(basePath.getPath().length()); }
Hard link files and recurse into directories.
getRelativePath
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static Pair<Integer, Integer> readUtf8File(final File file, final int offset, final int length, final OutputStream stream) throws IOException { final byte[] buffer = new byte[length]; final FileInputStream fileStream = new FileInputStream(file); final long skipped = fileStream.skip(offset); if (skipped < offset) { fileStream.close(); return new Pair<>(0, 0); } BufferedInputStream inputStream = null; try { inputStream = new BufferedInputStream(fileStream); inputStream.read(buffer); } finally { IOUtils.closeQuietly(inputStream); } final Pair<Integer, Integer> utf8Range = getUtf8Range(buffer, 0, length); stream.write(buffer, utf8Range.getFirst(), utf8Range.getSecond()); return new Pair<>(offset + utf8Range.getFirst(), utf8Range.getSecond()); }
Hard link files and recurse into directories.
readUtf8File
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static LogData readUtf8File(final File file, final int fileOffset, final int length) throws IOException { final byte[] buffer = new byte[length]; final FileInputStream fileStream = new FileInputStream(file); final long skipped = fileStream.skip(fileOffset); if (skipped < fileOffset) { fileStream.close(); return new LogData(fileOffset, 0, ""); } BufferedInputStream inputStream = null; int read = 0; try { inputStream = new BufferedInputStream(fileStream); read = inputStream.read(buffer); } finally { IOUtils.closeQuietly(inputStream); } if (read <= 0) { return new LogData(fileOffset, 0, ""); } final Pair<Integer, Integer> utf8Range = getUtf8Range(buffer, 0, read); final String outputString = new String(buffer, utf8Range.getFirst(), utf8Range.getSecond(), StandardCharsets.UTF_8); return new LogData(fileOffset + utf8Range.getFirst(), utf8Range.getSecond(), outputString); }
Hard link files and recurse into directories.
readUtf8File
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public static JobMetaData readUtf8MetaDataFile(final File file, final int fileOffset, final int length) throws IOException { final byte[] buffer = new byte[length]; final FileInputStream fileStream = new FileInputStream(file); final long skipped = fileStream.skip(fileOffset); if (skipped < fileOffset) { fileStream.close(); return new JobMetaData(fileOffset, 0, ""); } BufferedInputStream inputStream = null; int read = 0; try { inputStream = new BufferedInputStream(fileStream); read = inputStream.read(buffer); } finally { IOUtils.closeQuietly(inputStream); } if (read <= 0) { return new JobMetaData(fileOffset, 0, ""); } final Pair<Integer, Integer> utf8Range = getUtf8Range(buffer, 0, read); final String outputString = new String(buffer, utf8Range.getFirst(), utf8Range.getSecond(), StandardCharsets.UTF_8); return new JobMetaData(fileOffset + utf8Range.getFirst(), utf8Range.getSecond(), outputString); }
Hard link files and recurse into directories.
readUtf8MetaDataFile
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/FileIOUtils.java
Apache-2.0
public String getName() { return this.name; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
getName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public String getLabel() { return this.label; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
getLabel
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public String getDefaultValue() { return this.defaultValue; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
getDefaultValue
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElementType getType() { return this.type; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
getType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElementBuilder setLabel(final String label) { this.label = label; return this; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
setLabel
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElementBuilder setName(final String name) { this.name = name; return this; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
setName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElementBuilder setType(final HTMLFormElementType type) { this.type = type; return this; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
setType
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElementBuilder setDefaultValue(final String defaultValue) { this.defaultValue = defaultValue; return this; }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
setDefaultValue
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public HTMLFormElement createHTMLFormElement() { return new HTMLFormElement(this.label, this.name, this.type, this.defaultValue); }
Represents an HTML form element. It's used to generate HTML dynamically. For example, custom alerter plugins specify their UI parameters as a list of these objects. That list is then processed when rendering the SLA definition page to generate form elements.
createHTMLFormElement
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/HTMLFormElement.java
Apache-2.0
public Message createMessage() { return new MimeMessage(this.session); }
Wraps javax.mail features, mostly because Session is a final class and can't be mocked.
createMessage
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
Apache-2.0
public void connect(final String mailHost, final int mailPort, final String mailUser, final String mailPassword) throws MessagingException { this.t.connect(mailHost, mailPort, mailUser, mailPassword); }
Wraps javax.mail features, mostly because Session is a final class and can't be mocked.
connect
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
Apache-2.0
public void sendMessage(final Message message, final Address[] recipients) throws MessagingException { this.t.sendMessage(message, recipients); }
Wraps javax.mail features, mostly because Session is a final class and can't be mocked.
sendMessage
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/JavaxMailSender.java
Apache-2.0
private static String getAzkabanKafkaLog4jName(final String[] ids) { return String.join(".", ids); }
Utility class for getting Azkaban Kafka Log4j Appender
getAzkabanKafkaLog4jName
java
azkaban/azkaban
azkaban-common/src/main/java/azkaban/utils/KafkaLog4jUtils.java
https://github.com/azkaban/azkaban/blob/master/azkaban-common/src/main/java/azkaban/utils/KafkaLog4jUtils.java
Apache-2.0