public static String getExternalLogViewer(final Props azkProps, final String jobId, final Props jobProps) { // If no topic was configured to be an external analyzer, return empty if (!azkProps .containsKey(Constants.ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_LOGVIEWER_TOPIC)) { return ""; } // Find out which external link we should use to lead to our log viewer final String topic = azkProps .getString(Constants.ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_LOGVIEWER_TOPIC); return getLinkFromJobAndExecId(topic, azkProps, jobId, jobProps); }
/** * Gets the string from the Props. If it doesn't exist, throw and UndefinedPropertiesException */ public String getString(final String key) { if (containsKey(key)) { return get(key); } else { throw new UndefinedPropertyException("Missing required property '" + key + "'"); } }
public EmailMessage createEmailMessage(final String subject, final String mimetype, final Collection<String> emailList) { final EmailMessage message = this.messageCreator.createMessage(); message.addAllToAddress(emailList); message.setMimeType(mimetype); message.setSubject(subject); return message; }
private static Props getMySQLProps(final String sqlScriptsDir) { final Props props = new Props(); props.put("database.type", "mysql"); props.put("mysql.port", "3306"); props.put("mysql.host", "localhost"); props.put("mysql.database", "azkabanunittest"); props.put("mysql.user", "root"); props.put("database.sql.scripts.dir", sqlScriptsDir); props.put("mysql.password", ""); props.put("mysql.numconnections", 10); return props; }
/** * Puts only the local props from p into the current properties */ public void putLocal(final Props p) { for (final String key : p.localKeySet()) { this.put(key, p.get(key)); } }
public static Props fromJSONString(final String json) throws IOException { final Map<String, String> obj = (Map<String, String>) JSONUtils.parseJSONFromString(json); final Props props = new Props(null, obj); return props; }
public static String getExternalAnalyzerOnReq(final Props azkProps, final HttpServletRequest req) { // If no topic was configured to be an external analyzer, return empty if (!azkProps.containsKey(Constants.ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC)) { return ""; } // Find out which external link we should use to lead to our analyzer final String topic = azkProps .getString(Constants.ConfigurationKeys.AZKABAN_SERVER_EXTERNAL_ANALYZER_TOPIC); return getLinkFromRequest(topic, azkProps, req); }
public AbstractMailer(final Props props, final EmailMessageCreator messageCreator) { this.azkabanName = props.getString("azkaban.name", "azkaban"); this.messageCreator = messageCreator; final long maxAttachmentSizeInMB = props.getInt("mail.max.attachment.size.mb", 100); this.attachmentMazSizeInByte = maxAttachmentSizeInMB * MB_IN_BYTES; }
/** * Gets the string from the Props. If it doesn't exist, it will return the defaultValue */ public String getString(final String key, final String defaultValue) { if (containsKey(key)) { return get(key); } else { return defaultValue; } }
/** * Returns a list of strings with the sep as the separator of the value. If the value is null, * it'll return the defaultValue. */ public List<String> getStringList(final String key, final List<String> defaultValue, final String sep) { if (containsKey(key)) { return getStringList(key, sep); } else { return defaultValue; } }
public static String toJSONString(final Props props, final boolean localOnly) { final Map<String, String> map = toStringMap(props, localOnly); return JSONUtils.toJSON(map); }
/** * Create properties from Properties objects */ public Props(final Props parent, final Properties... properties) { this(parent); for (int i = properties.length - 1; i >= 0; i--) { this.put(properties[i]); } }
/** * Send an email to the specified email list */ 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); } }
/** * Returns first and length. */ public static Pair<Integer, Integer> getUtf8Range(final byte[] buffer, final int offset, final int length) { final int start = getUtf8ByteStart(buffer, offset); final int end = getUtf8ByteEnd(buffer, offset + length - 1); return new Pair<>(start, end - start + 1); }
/** * Create a Props object with the contents set to that of props. */ public Props(final Props parent, final Props props) { this(parent); if (props != null) { putAll(props); } }
/** * Clones the Props p object and all of its parents. */ public static Props clone(final Props p) { return copyNext(p); }
/** * Load job schedules from the given directories * * @param dir The directory to look in * @param suffixes File suffixes to load * @return The loaded set of schedules */ public static Props loadPropsInDir(final File dir, final String... suffixes) { return loadPropsInDir(null, dir, suffixes); }