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 static Object invokeStaticMethod(final ClassLoader loader, final String className, final String methodName, final Object... args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { final Clas...
Call the class constructor with the given arguments @param cls The class @param args The arguments @return The constructed object
invokeStaticMethod
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static void copyStream(final InputStream input, final OutputStream output) throws IOException { final byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } }
Call the class constructor with the given arguments @param cls The class @param args The arguments @return The constructed object
copyStream
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static long parseMemString(final String strMemSize) { if (strMemSize == null) { return 0L; } final long size; if (strMemSize.endsWith("g") || strMemSize.endsWith("G") || strMemSize.endsWith("m") || strMemSize.endsWith("M") || strMemSize.endsWith("k") || strMemSize.endsWith(...
@param strMemSize : memory string in the format such as 1G, 500M, 3000K, 5000 @return : long value of memory amount in kb
parseMemString
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static CronExpression parseCronExpression(final String cronExpression, final DateTimeZone timezone) { if (cronExpression != null) { try { final CronExpression ce = new CronExpression(cronExpression); ce.setTimeZone(TimeZone.getTimeZone(timezone.getID())); return ce; ...
@param cronExpression: A cron expression is a string separated by white space, to provide a parser and evaluator for Quartz cron expressions. @return : org.quartz.CronExpression object. TODO: Currently, we have to transform Joda Timezone to Java Timezone due to CronExpression. Since Java8 enhanced Time functionalities...
parseCronExpression
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static boolean isCronExpressionValid(final String cronExpression, final DateTimeZone timezone) { if (!CronExpression.isValidExpression(cronExpression)) { return false; } /* * The below code is aimed at checking some cases that the above code can not identify, * e.g. <0 0 3 ? * ...
@return if the cronExpression is valid or not.
isCronExpressionValid
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static ArrayList<String> runProcess(String... commands) throws InterruptedException, IOException { final java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder(commands); final ArrayList<String> output = new ArrayList<>(); final Process process = processBuilder.start(); proc...
Run a sequence of commands @param commands sequence of commands @return list of output result
runProcess
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static void mergeTypeClassPaths( List<String> destinationPaths, final List<String> sourcePaths, final String rootPath) { if (sourcePaths != null) { for (String jar : sourcePaths) { File file = new File(jar); if (!file.isAbsolute()) { file = new File(rootPath + File.separ...
Merge the absolute paths of source paths into the list of destination paths @param destinationPaths the path list which the source paths will be merged into @param sourcePaths source paths @param rootPath defined root path for source paths when they are not absolute path
mergeTypeClassPaths
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public static void mergeStringList( final List<String> destinationList, final List<String> sourceList) { if (sourceList != null) { for (String item : sourceList) { if (!destinationList.contains(item)) { destinationList.add(item); } } } }
Merge elements in Source List into the Destination List @param destinationList the list which the source elements will be merged into @param sourceList source List
mergeStringList
java
azkaban/azkaban
az-core/src/main/java/azkaban/utils/Utils.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/main/java/azkaban/utils/Utils.java
Apache-2.0
public long getGaugeValue(final String name) { // Assume that the gauge value can be converted to type long. return (long) this.registry.getGauges().get(name).getValue(); }
This class is designed for a utility class to test drop wizard metrics
getGaugeValue
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
public long getCounterValue(final String name) { return this.registry.getCounters().get(name).getCount(); }
@return the value for the specified {@link Counter}
getCounterValue
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
public long getMeterValue(final String name) { return this.registry.getMeters().get(name).getCount(); }
@return the value for the specified {@link Meter}
getMeterValue
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
public Snapshot getHistogramSnapshot(final String name) { return this.registry.getHistograms().get(name).getSnapshot(); }
@return the {@link Snapshot} for the specified {@link Histogram}.
getHistogramSnapshot
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
public long getTimerCount(final String name) { return this.registry.getTimers().get(name).getCount(); }
@return the count for the specified {@link Timer}.
getTimerCount
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
public Snapshot getTimerSnapshot(final String name) { return this.registry.getTimers().get(name).getSnapshot(); }
@return the {@link Snapshot} for the specified {@link Timer}.
getTimerSnapshot
java
azkaban/azkaban
az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/metrics/MetricsTestUtility.java
Apache-2.0
@Test public void testSplit1() { String s1 = "thrift://hcat1:port,thrift://hcat2:port;thrift://hcat3:port,thrift://hcat4:port;"; p.put(EXTRA_HCAT_CLUSTERS, s1); List<String> s2 = Arrays.asList("thrift://hcat1:port,thrift://hcat2:port" , "thrift://hcat3:port,thrift://hcat4:port"); Assert.assertTrue(p.g...
Test class for azkaban.utils.Props
testSplit1
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/PropsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/PropsTest.java
Apache-2.0
@Test public void testCreateProps() throws IOException { File file = Mockito.mock(File.class); Mockito.when(file.exists()).thenReturn(false); Props parent = new Props(); Props props = new Props(parent, file); Assert.assertNull(props.getSource()); }
Test class for azkaban.utils.Props
testCreateProps
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/PropsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/PropsTest.java
Apache-2.0
@Test public void testUnzipInsecureFile() throws IOException { final File zipFile = new File("myTest.zip"); try { try (final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile))) { final ZipEntry entry = new ZipEntry("../../../../../evil.txt"); out.putNextEntry(entry)...
An insecure zip file may hold path traversal filenames. During unzipping, the filename gets concatenated to the target directory. The final path may end up outside the target directory, causing security issues. @throws IOException the io exception
testUnzipInsecureFile
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/UtilsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/UtilsTest.java
Apache-2.0
@Test public void testRunProcess() throws IOException, InterruptedException { ArrayList<String> result = Utils.runProcess("/bin/bash", "-c", "ls"); Assert.assertNotEquals(result.size(), 0); }
An insecure zip file may hold path traversal filenames. During unzipping, the filename gets concatenated to the target directory. The final path may end up outside the target directory, causing security issues. @throws IOException the io exception
testRunProcess
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/UtilsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/UtilsTest.java
Apache-2.0
@Test public void testMemoryStringConversion() { Assert.assertEquals(Utils.parseMemString("1024"), 1L); Assert.assertEquals(Utils.parseMemString("1K"), 1L); Assert.assertEquals(Utils.parseMemString("1M"), 1024L); Assert.assertEquals(Utils.parseMemString("1G"), 1024L * 1024L); Assert.assertEquals(...
An insecure zip file may hold path traversal filenames. During unzipping, the filename gets concatenated to the target directory. The final path may end up outside the target directory, causing security issues. @throws IOException the io exception
testMemoryStringConversion
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/UtilsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/UtilsTest.java
Apache-2.0
@Test public void testBadMemoryStringFormat() { badMemoryStringFormatHelper("1KB"); badMemoryStringFormatHelper("1MB"); badMemoryStringFormatHelper("1GB"); badMemoryStringFormatHelper("1kb"); badMemoryStringFormatHelper("1mb"); badMemoryStringFormatHelper("1gb"); badMemoryStringFormatHel...
An insecure zip file may hold path traversal filenames. During unzipping, the filename gets concatenated to the target directory. The final path may end up outside the target directory, causing security issues. @throws IOException the io exception
testBadMemoryStringFormat
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/UtilsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/UtilsTest.java
Apache-2.0
private void badMemoryStringFormatHelper(final String str) { try { Utils.parseMemString(str); Assert.fail("should get a runtime exception"); } catch (final Exception e) { Assert.assertTrue(e instanceof NumberFormatException); } }
An insecure zip file may hold path traversal filenames. During unzipping, the filename gets concatenated to the target directory. The final path may end up outside the target directory, causing security issues. @throws IOException the io exception
badMemoryStringFormatHelper
java
azkaban/azkaban
az-core/src/test/java/azkaban/utils/UtilsTest.java
https://github.com/azkaban/azkaban/blob/master/az-core/src/test/java/azkaban/utils/UtilsTest.java
Apache-2.0
public static String encode(final String s) { return Base64.getEncoder().encodeToString(s.getBytes(StandardCharsets.UTF_8)); }
Crypto class that actually delegates to version specific implementation of ICrypto interface. In other words, it's a factory method class that implements ICrypto interface
encode
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Crypto.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Crypto.java
Apache-2.0
public static String decode(final String s) { return new String(Base64.getDecoder().decode(s), StandardCharsets.UTF_8); }
Crypto class that actually delegates to version specific implementation of ICrypto interface. In other words, it's a factory method class that implements ICrypto interface
decode
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Crypto.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Crypto.java
Apache-2.0
@Override public String encrypt(final String plaintext, final String passphrase, final Version cryptoVersion) { Preconditions.checkNotNull(cryptoVersion, "Crypto version is required."); Preconditions.checkArgument(!StringUtils.isEmpty(plaintext), "plaintext should not be empty"); Preconditions.check...
Crypto class that actually delegates to version specific implementation of ICrypto interface. In other words, it's a factory method class that implements ICrypto interface
encrypt
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Crypto.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Crypto.java
Apache-2.0
@Override public String decrypt(final String cipheredText, final String passphrase) { Preconditions .checkArgument(!StringUtils.isEmpty(cipheredText), "cipheredText should not be empty"); Preconditions.checkArgument(!StringUtils.isEmpty(passphrase), "passphrase should not be empty"); try { ...
Crypto class that actually delegates to version specific implementation of ICrypto interface. In other words, it's a factory method class that implements ICrypto interface
decrypt
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Crypto.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Crypto.java
Apache-2.0
@Override public String encrypt(final String plaintext, final String passphrase, final Version cryptoVersion) { Preconditions.checkArgument(Version.V1_1.equals(cryptoVersion)); final String cipheredText = newEncryptor(passphrase).encrypt(plaintext); final ObjectNode node = MAPPER.createObjectNode()...
Uses AES algorithm to encrypt and decrypt.
encrypt
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/CryptoV1_1.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/CryptoV1_1.java
Apache-2.0
@Override public String decrypt(final String cipheredText, final String passphrase) { try { final String jsonStr = Crypto.decode(cipheredText); final JsonNode json = MAPPER.readTree(jsonStr); return newEncryptor(passphrase).decrypt(json.get(CIPHERED_TEXT_KEY).asText()); } catch (final Except...
Uses AES algorithm to encrypt and decrypt.
decrypt
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/CryptoV1_1.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/CryptoV1_1.java
Apache-2.0
public static void main(final String[] args) throws ParseException { final CommandLineParser parser = new DefaultParser(); if (parser.parse(createHelpOptions(), args, true).hasOption(HELP_KEY)) { new HelpFormatter().printHelp(EncryptionCLI.class.getSimpleName(), createOptions(), true); return; ...
Outputs ciphered text to STDOUT. usage: EncryptionCLI [-h] -k <pass phrase> -p <plainText> -v <crypto version> -h,--help print this message -k,--key <pass phrase> Passphrase used for encrypting plain text -p,--plaintext <plainText> Plaintext that needs to be encrypted -v,--version <...
main
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
Apache-2.0
private static Options createHelpOptions() { final Options options = new Options(); options.addOption(Option.builder(HELP_KEY).longOpt("help") .desc("print this message").build()); return options; }
Outputs ciphered text to STDOUT. usage: EncryptionCLI [-h] -k <pass phrase> -p <plainText> -v <crypto version> -h,--help print this message -k,--key <pass phrase> Passphrase used for encrypting plain text -p,--plaintext <plainText> Plaintext that needs to be encrypted -v,--version <...
createHelpOptions
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
Apache-2.0
private static Options createOptions() { final Options options = createHelpOptions(); options.addOption(Option.builder(PLAINTEXT_KEY).longOpt("plaintext").hasArg().required() .desc("Plaintext that needs to be encrypted") .argName("plainText").build()); options.addOption(Option.builder(PASS...
Outputs ciphered text to STDOUT. usage: EncryptionCLI [-h] -k <pass phrase> -p <plainText> -v <crypto version> -h,--help print this message -k,--key <pass phrase> Passphrase used for encrypting plain text -p,--plaintext <plainText> Plaintext that needs to be encrypted -v,--version <...
createOptions
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/EncryptionCLI.java
Apache-2.0
public static Version fromVerString(final String ver) { final Version result = REVERSE_ENTRIES.get(ver); Preconditions.checkNotNull(ver, "Invalid version " + ver); return result; }
Provides Version enum based on version String @param ver Version String
fromVerString
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Version.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Version.java
Apache-2.0
public static List<String> versionStrings() { final List<String> versions = Lists.newArrayList(REVERSE_ENTRIES.keySet()); Collections.sort(versions); return versions; }
@return Naturally ordered list of version String.
versionStrings
java
azkaban/azkaban
az-crypto/src/main/java/azkaban/crypto/Version.java
https://github.com/azkaban/azkaban/blob/master/az-crypto/src/main/java/azkaban/crypto/Version.java
Apache-2.0
public void remove(final DependencyInstanceContext depContext) { final KafkaDependencyInstanceContext depContextCasted = (KafkaDependencyInstanceContext) depContext; this.dependencyMonitor.remove(depContextCasted); }
A factory class which maintaines all KafkaDependencyInstanceContext and creates new KafkaDependencyInstanceContext based on the configuration file.
remove
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
Apache-2.0
private void validate(final DependencyInstanceConfig config, final DependencyInstanceRuntimeProps runtimeProps) { final String LOG_SUFFIX = String.format("for dependency name: %s", config.get(DependencyInstanceConfigKey.NAME)); final String topic = config.get(DependencyInstanceConfigKey.TOPIC); final Strin...
A factory class which maintaines all KafkaDependencyInstanceContext and creates new KafkaDependencyInstanceContext based on the configuration file.
validate
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
Apache-2.0
@Override public DependencyInstanceContext run(final DependencyInstanceConfig config, final DependencyInstanceRuntimeProps runtimeProps, final DependencyInstanceCallback callback) { this.validate(config, runtimeProps); final KafkaDependencyInstanceContext depInstance = new KafkaDependencyInstanceContext...
A factory class which maintaines all KafkaDependencyInstanceContext and creates new KafkaDependencyInstanceContext based on the configuration file.
run
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
Apache-2.0
@Override public void shutdown() { log.info("Shutting down KafkaDependencyCheck"); // disallow new tasks this.executorService.shutdown(); try { // interrupt current threads; this.executorService.shutdownNow(); // Wait a while for tasks to respond to being cancelled if (!this.e...
A factory class which maintaines all KafkaDependencyInstanceContext and creates new KafkaDependencyInstanceContext based on the configuration file.
shutdown
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
Apache-2.0
@Override public void init(final DependencyPluginConfig config) { final Set<String> required = Sets.newHashSet(DependencyPluginConfigKey.KAKFA_BROKER_URL); for (final String requiredField : required) { Preconditions.checkNotNull(config.get(requiredField), requiredField + " is required"); } this....
A factory class which maintaines all KafkaDependencyInstanceContext and creates new KafkaDependencyInstanceContext based on the configuration file.
init
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyCheck.java
Apache-2.0
@Override public void cancel() { log.info(String.format("Canceling dependency %s", this)); this.depCheck.remove(this); this.callback.onCancel(this); }
KafkaDependencyInstanceContext maintains attributes of a running instance of kafka dependency.
cancel
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
Apache-2.0
public String getRegexMatch() { return this.regexMatch; }
KafkaDependencyInstanceContext maintains attributes of a running instance of kafka dependency.
getRegexMatch
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
Apache-2.0
public String getTopicName() { return this.topicName; }
KafkaDependencyInstanceContext maintains attributes of a running instance of kafka dependency.
getTopicName
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
Apache-2.0
public DependencyInstanceCallback getCallback() { return this.callback; }
KafkaDependencyInstanceContext maintains attributes of a running instance of kafka dependency.
getCallback
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDependencyInstanceContext.java
Apache-2.0
public synchronized void add(final KafkaDependencyInstanceContext dep) { final String topic = dep.getTopicName(); Map<String, List<KafkaDependencyInstanceContext>> eventMap = this.topicEventMap.get(topic); List<KafkaDependencyInstanceContext> depList; if (eventMap == null) { eventMap = new HashMap...
A map data structure that enables efficient lookup by topic and adding/removing topic event pairs. Structure looks like: { -Topic1:{ ----Rule1 ---------[List of dependencies] ----Rule2 ---------[List of dependencies] } -Topic2:{ ----Rule1 ---------[List of dependencies] ----Rule2 ---------[List of dependenci...
add
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public boolean hasTopic(final String topic) { return !(this.topicEventMap.get(topic) == null); }
A map data structure that enables efficient lookup by topic and adding/removing topic event pairs. Structure looks like: { -Topic1:{ ----Rule1 ---------[List of dependencies] ----Rule2 ---------[List of dependencies] } -Topic2:{ ----Rule1 ---------[List of dependencies] ----Rule2 ---------[List of dependenci...
hasTopic
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public synchronized List<String> getTopicList() { final List<String> res = new ArrayList<>(this.topicEventMap.keySet()); return res; }
Get a list of topics. @return List of String of topics
getTopicList
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public synchronized Set<String> regexInTopic(final String topic, final String payload) { final Set<String> res = new HashSet<>(); final Map<String, List<KafkaDependencyInstanceContext>> eventMap = this.topicEventMap.get(topic); if (eventMap == null) { return Collections.emptySet(); } for (fin...
Return a set of pattern that matches with the payload. @param payload and topic @return regexs that meet the customized requirement
regexInTopic
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public synchronized List<KafkaDependencyInstanceContext> getDepsByTopicAndEvent(final String topic, final String regex) { final Map<String, List<KafkaDependencyInstanceContext>> regexMap = this.topicEventMap.get(topic); if (regexMap != null) { return regexMap.get(regex); } return Collections...
Returns dependencies with topic and dependency's event regular expression match
getDepsByTopicAndEvent
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public synchronized void remove(final KafkaDependencyInstanceContext dep) { final Map<String, List<KafkaDependencyInstanceContext>> regexMap = this.topicEventMap.get(dep.getTopicName()); if (regexMap != null) { final List<KafkaDependencyInstanceContext> deps = regexMap.get(dep.getRegexMatch()); if (...
Returns dependencies with topic and dependency's event regular expression match
remove
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
public synchronized boolean removeList(final String topic, final String event, final List<KafkaDependencyInstanceContext> list) { final List<String> ori = new ArrayList<>(this.topicEventMap.keySet()); final Map<String, List<KafkaDependencyInstanceContext>> eventMap = this.topicEventMap.get(topic); if ...
Returns dependencies with topic and dependency's event regular expression match
removeList
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
@Override public String toString() { final Joiner.MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator("="); return mapJoiner.join(this.topicEventMap); }
Returns dependencies with topic and dependency's event regular expression match
toString
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaDepInstanceCollection.java
Apache-2.0
private void initKafkaClient(final DependencyPluginConfig pluginConfig) { final Properties props = new Properties(); props.put("bootstrap.servers", pluginConfig.get(DependencyPluginConfigKey.KAKFA_BROKER_URL)); props.put("auto.commit.interval.ms", "1000"); props.put("auto.offset.reset", "latest"); p...
KafkaEventMonitor implements logic for kafka consumer and maintains the KafkaDepInstanceCollection for dependencies.
initKafkaClient
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
public void add(final KafkaDependencyInstanceContext context) { if (!this.depInstances.hasTopic(context.getTopicName())) { this.depInstances.add(context); this.subscribedTopics.addAll(this.depInstances.getTopicList()); } else { this.depInstances.add(context); } }
KafkaEventMonitor implements logic for kafka consumer and maintains the KafkaDepInstanceCollection for dependencies.
add
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
public void remove(final KafkaDependencyInstanceContext context) { this.depInstances.remove(context); if (!this.depInstances.hasTopic(context.getTopicName())) { this.subscribedTopics.addAll(this.depInstances.getTopicList()); } }
KafkaEventMonitor implements logic for kafka consumer and maintains the KafkaDepInstanceCollection for dependencies.
remove
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
public Set<String> getMonitorSubscription() { return this.consumer.subscription(); }
KafkaEventMonitor implements logic for kafka consumer and maintains the KafkaDepInstanceCollection for dependencies.
getMonitorSubscription
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
@Override public void run() { try { while (true && !Thread.interrupted()) { if (!this.subscribedTopics.isEmpty()) { this.consumerSubscriptionRebalance(); } final ConsumerRecords<String, String> records = this.consumer.poll(10000); final Record recordToProcess = null...
KafkaEventMonitor implements logic for kafka consumer and maintains the KafkaDepInstanceCollection for dependencies.
run
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
@VisibleForTesting synchronized void consumerSubscriptionRebalance() { log.debug("Subscribed Topics " + this.consumer.subscription()); if (!this.subscribedTopics.isEmpty()) { final Iterator<String> iter = this.subscribedTopics.iterator(); final List<String> topics = new ArrayList<>(); while ...
Dynamically tune subscription only for the topic that dependencies need.
consumerSubscriptionRebalance
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
private void triggerDependencies(final Set<String> matchedList, final ConsumerRecord<String, String> record) { final List<KafkaDependencyInstanceContext> deleteList = new LinkedList<>(); for (final String it : matchedList) { final List<KafkaDependencyInstanceContext> possibleAvailableDeps = this...
If the matcher returns true, remove the dependency from collection.
triggerDependencies
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/KafkaEventMonitor.java
Apache-2.0
@Override public boolean isMatch(String payload) { return pattern.matcher(payload).find(); }
A RegexKafkaDependencyMatcher implements the regex match for whole kafka payload.
isMatch
java
azkaban/azkaban
az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/RegexKafkaDependencyMatcher.java
https://github.com/azkaban/azkaban/blob/master/az-flow-trigger-dependency-type/kafka-event-trigger/src/main/java/trigger/kafka/RegexKafkaDependencyMatcher.java
Apache-2.0
@Override public void run() throws Exception { try { super.run(); } finally { hadoopProxy.cancelHadoopTokens(getLog()); } }
Abstract Hadoop Java Process Job for Job PlugIn
run
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
@Override public void setupHadoopJobProperties() { String[] tagKeys = new String[]{ CommonJobProperties.EXEC_ID, CommonJobProperties.FLOW_ID, CommonJobProperties.PROJECT_NAME, CommonJobProperties.AZKABAN_WEBSERVERHOST, CommonJobProperties.JOB_ID, CommonJobProperties...
Abstract Hadoop Java Process Job for Job PlugIn
setupHadoopJobProperties
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
protected String getJVMJobTypeParameters() { String args = ""; String jobTypeUserGlobalJVMArgs = getJobProps().getString(HadoopJobUtils.JOBTYPE_GLOBAL_JVM_ARGS, null); if (jobTypeUserGlobalJVMArgs != null) { args += " " + jobTypeUserGlobalJVMArgs; } String jobTypeSysGlobalJVMArgs = getSysProp...
Abstract Hadoop Java Process Job for Job PlugIn
getJVMJobTypeParameters
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
protected String getJVMProxySecureArgument() { return hadoopProxy.getJVMArgument(getSysProps(), getJobProps(), getLog()); }
Abstract Hadoop Java Process Job for Job PlugIn
getJVMProxySecureArgument
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
protected List<String> getAzkabanCommonClassPaths() { return ImmutableList.<String>builder() .add(FileIOUtils.getSourcePathFromClass(Props.class)) // add az-core jar classpath .add(FileIOUtils.getSourcePathFromClass(JavaProcessJob.class)) // add az-common jar classpath .add(FileIOUtils.getSo...
Abstract Hadoop Java Process Job for Job PlugIn
getAzkabanCommonClassPaths
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
@Override public Props appendExtraProps(Props props) { HadoopJobUtils.addAdditionalNamenodesToPropsFromMRJob(props, getLog()); return props; }
Abstract Hadoop Java Process Job for Job PlugIn
appendExtraProps
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
@Override public HadoopProxy getHadoopProxy() { return hadoopProxy; }
Abstract Hadoop Java Process Job for Job PlugIn
getHadoopProxy
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/AbstractHadoopJavaProcessJob.java
Apache-2.0
public static void injectResources(Props props) { // Add mapred, yarn and hdfs site configs (in addition to core-site, which // is automatically added) as default resources before we add the injected // configuration. This will cause the injected properties to override the // default site properties (in...
HadoopConfigurationInjector is responsible for inserting links back to the Azkaban UI in configurations and for automatically injecting designated job properties into the Hadoop configuration. <p> It is assumed that the necessary links have already been loaded into the properties. After writing the necessary links as a...
injectResources
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
public static void prepareResourcesToInject(Props props, String workingDir) { try { Configuration conf = new Configuration(false); // First, inject a series of Azkaban links. These are equivalent to // CommonJobProperties.[EXECUTION,WORKFLOW,JOB,JOBEXEC,ATTEMPT]_LINK addHadoopProperties(pro...
Writes out the XML configuration file that will be injected by the client as a configuration resource. <p> This file will include a series of links injected by Azkaban as well as any job properties that begin with the designated injection prefix. @param props The Azkaban properties @param workingDir The Azkaban job wo...
prepareResourcesToInject
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
private static void addHadoopProperty(Props props, String propertyName) { props.put(INJECT_PREFIX + propertyName, props.get(propertyName)); }
Writes out the XML configuration file that will be injected by the client as a configuration resource. <p> This file will include a series of links injected by Azkaban as well as any job properties that begin with the designated injection prefix. @param props The Azkaban properties @param workingDir The Azkaban job wo...
addHadoopProperty
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
private static void addHadoopWorkflowProperty(Props props, String propertyName) { String workflowID = props.get(CommonJobProperties.PROJECT_NAME) + WORKFLOW_ID_SEPERATOR + props.get(CommonJobProperties.FLOW_ID); props.put(INJECT_PREFIX + propertyName, workflowID); }
Writes out the XML configuration file that will be injected by the client as a configuration resource. <p> This file will include a series of links injected by Azkaban as well as any job properties that begin with the designated injection prefix. @param props The Azkaban properties @param workingDir The Azkaban job wo...
addHadoopWorkflowProperty
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
private static void addHadoopProperties(Props props) { String[] propsToInject = new String[]{ CommonJobProperties.EXEC_ID, CommonJobProperties.FLOW_ID, CommonJobProperties.JOB_ID, CommonJobProperties.PROJECT_NAME, CommonJobProperties.PROJECT_VERSION, CommonJobProperti...
Writes out the XML configuration file that will be injected by the client as a configuration resource. <p> This file will include a series of links injected by Azkaban as well as any job properties that begin with the designated injection prefix. @param props The Azkaban properties @param workingDir The Azkaban job wo...
addHadoopProperties
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
public static File getConfFile(Props props, String workingDir, String fileName) { File jobDir = new File(workingDir, getDirName(props)); if (!jobDir.exists()) { jobDir.mkdir(); } return new File(jobDir, fileName); }
Resolve the location of the file containing the configuration file. @param props The Azkaban properties @param workingDir The Azkaban job working directory @param fileName The desired configuration file name
getConfFile
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
public static String getDirName(Props props) { String dirSuffix = props.get(CommonJobProperties.NESTED_FLOW_PATH); if ((dirSuffix == null) || (dirSuffix.length() == 0)) { dirSuffix = props.get(CommonJobProperties.JOB_ID); if ((dirSuffix == null) || (dirSuffix.length() == 0)) { throw new Run...
For classpath reasons, we'll put each link file in a separate directory. This must be called only after the job id has been inserted by the job. @param props The Azkaban properties
getDirName
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
public static String getPath(Props props, String workingDir) { return new File(workingDir, getDirName(props)).toString(); }
Gets the path to the directory in which the generated links and Hadoop conf properties files are written. @param props The Azkaban properties @param workingDir The Azkaban job working directory
getPath
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
public static void loadProp(Props props, Configuration conf, String name) { String prop = props.get(name); if (prop != null) { conf.set(name, prop); } }
Loads an Azkaban property into the Hadoop configuration. @param props The Azkaban properties @param conf The Hadoop configuration @param name The property name to load from the Azkaban properties into the Hadoop configuration
loadProp
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopConfigurationInjector.java
Apache-2.0
@Override public void cancel() throws InterruptedException { super.cancel(); info("Cancel called. Killing the Hive launched MR jobs on the cluster"); getHadoopProxy().killAllSpawnedHadoopJobs(getJobProps(), getLog()); }
This cancel method, in addition to the default canceling behavior, also kills the MR jobs launched by Hive on Hadoop
cancel
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopHiveJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopHiveJob.java
Apache-2.0
@Override public void run() throws Exception { setupHadoopJobProperties(); HadoopConfigurationInjector.prepareResourcesToInject(getJobProps(), getWorkingDirectory()); getHadoopProxy().setupPropsForProxy(getAllProps(), getJobProps(), getLog()); super.run(); }
Todo kunkun-tang: The legacy code uses a quite outdated method to resolve Azkaban dependencies, and should be replaced later.
run
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
Apache-2.0
@Override protected String getJavaClass() { return HadoopJavaJobRunnerMain.class.getName(); }
Todo kunkun-tang: The legacy code uses a quite outdated method to resolve Azkaban dependencies, and should be replaced later.
getJavaClass
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
Apache-2.0
@Override public String toString() { return "JavaJob{" + "_runMethod='" + _runMethod + '\'' + ", _cancelMethod='" + _cancelMethod + '\'' + ", _progressMethod='" + _progressMethod + '\'' + ", _javaObject=" + _javaObject + ", props=" + getJobProps() + '}'; }
Todo kunkun-tang: The legacy code uses a quite outdated method to resolve Azkaban dependencies, and should be replaced later.
toString
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
Apache-2.0
@Override public void cancel() throws InterruptedException { super.cancel(); info("Cancel called. Killing the launched MR jobs on the cluster"); getHadoopProxy().killAllSpawnedHadoopJobs(getJobProps(), getLog()); }
This cancel method, in addition to the default canceling behavior, also kills the MR jobs launched by this job on Hadoop
cancel
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJavaJob.java
Apache-2.0
public static void addAdditionalNamenodesToPropsFromMRJob(final Props props, final Logger log) { final String additionalNamenodes = (new Configuration()).get(MAPREDUCE_JOB_OTHER_NAMENODES); if (additionalNamenodes != null && additionalNamenodes.length() > 0) { log.info("Found property " + MAPREDUC...
The same as {@link #addAdditionalNamenodesToProps}, but assumes that the calling job is MapReduce-based and so uses the {@link #MAPREDUCE_JOB_OTHER_NAMENODES} from a {@link Configuration} object to get the list of additional namenodes. @param props Props to add the new Namenode URIs to. @see #addAdditionalNamenodesToP...
addAdditionalNamenodesToPropsFromMRJob
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static void addAdditionalNamenodesToProps(final Props props, final String additionalNamenodes) { final String otherNamenodes = props.get(OTHER_NAMENODES_PROPERTY); if (otherNamenodes != null && otherNamenodes.length() > 0) { props.put(OTHER_NAMENODES_PROPERTY, otherNamenodes + "," + additiona...
Takes the list of other Namenodes from which to fetch delegation tokens, the {@link #OTHER_NAMENODES_PROPERTY} property, from Props and inserts it back with the addition of the the potentially JobType-specific Namenode URIs from additionalNamenodes. Modifies props in-place. @param props Props to add the ...
addAdditionalNamenodesToProps
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static File getHadoopTokens(final HadoopSecurityManager hadoopSecurityManager, final Props props, final Logger log) throws HadoopSecurityManagerException { File tokenFile = null; try { tokenFile = File.createTempFile("mr-azkaban", ".token"); } catch (final Exception e) { thro...
Fetching token with the Azkaban user
getHadoopTokens
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static String resolveWildCardForJarSpec(final String workingDirectory, final String unresolvedJarSpec, final Logger log) { log.debug("resolveWildCardForJarSpec: unresolved jar specification: " + unresolvedJarSpec); log.debug("working directory: " + workingDirectory); if (unresolvedJarSp...
<pre> If there's a * specification in the "jar" argument (e.g. jar=./lib/*,./lib2/*), this method helps to resolve the * into actual jar names inside the folder, and in order. This is due to the requirement that Spark 1.4 doesn't seem to do the resolution for users </pre> @return jar file list, comma separated, all ....
resolveWildCardForJarSpec
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
private static File[] getFilesInFolderByRegex(final File folder, final String regex) throws FileNotFoundException { // sanity check if (!folder.exists()) { throw new FileNotFoundException(); } if (!folder.isDirectory()) { throw new IllegalStateException( "execution jar is s...
@return a list of files in the given folder that matches the regex. It may be empty, but will never return a null
getFilesInFolderByRegex
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
@Override public boolean accept(final File dir, final String name) { if (name.matches(regex)) { return true; } else { return false; } }
@return a list of files in the given folder that matches the regex. It may be empty, but will never return a null
accept
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static void proxyUserKillAllSpawnedHadoopJobs( HadoopSecurityManager hadoopSecurityManager, final Props jobProps, final File tokenFile, final Logger log) { final Properties properties = new Properties(); properties.putAll(jobProps.getFlattened()); // todo: use feature flag, default to u...
This method is a decorator around the KillAllSpawnedHadoopJobs method. This method takes additional parameters to determine whether KillAllSpawnedHadoopJobs needs to be executed using doAs as a different user @param jobProps Azkaban job props @param tokenFile Pass in the tokenFile if value is known. It is ok to skip...
proxyUserKillAllSpawnedHadoopJobs
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
@Override public Void run() throws Exception { findAndKillYarnApps(jobProps, log); return null; }
This method is a decorator around the KillAllSpawnedHadoopJobs method. This method takes additional parameters to determine whether KillAllSpawnedHadoopJobs needs to be executed using doAs as a different user @param jobProps Azkaban job props @param tokenFile Pass in the tokenFile if value is known. It is ok to skip...
run
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
private static void findAndKillYarnApps(Props jobProps, Logger log) { // if set to "disabled", skip the whole yarn application kill logic String yarnKillVersion = jobProps.getString(YARN_KILL_VERSION, YARN_KILL_LEGACY).trim(); if (YARN_KILL_DISABLED.equals(yarnKillVersion)) { log.warn("Yarn applicatio...
This method is a decorator around the KillAllSpawnedHadoopJobs method. This method takes additional parameters to determine whether KillAllSpawnedHadoopJobs needs to be executed using doAs as a different user @param jobProps Azkaban job props @param tokenFile Pass in the tokenFile if value is known. It is ok to skip...
findAndKillYarnApps
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static Set<String> getApplicationIDsToKill(YarnClient yarnClient, Props jobProps, final Logger log) { Set<String> jobsToKill; String yarnKillVersion = jobProps.getString(YARN_KILL_VERSION, YARN_KILL_LEGACY).trim(); if (YARN_KILL_USE_API_WITH_TOKEN.equals(yarnKillVersion)) { try { ...
Get the yarn applications' ids that needs to be killed (the ones alive / spawned). First use yarn client to call the cluster, if it fails, fallback to scan the job log file to look for application ids @param yarnClient the started client @param jobProps should contain flow execution id, and the job log file's path @...
getApplicationIDsToKill
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static Set<String> killAllSpawnedHadoopJobs(final String logFilePath, final Logger log, final Props jobProps) { final Set<String> allSpawnedJobs = findApplicationIdFromLog(logFilePath, log); log.info("applicationIds to kill: " + allSpawnedJobs); for (final String appId : allSpawnedJobs) { ...
Pass in a log file, this method will find all the hadoop jobs it has launched, and kills it <p> Only works with Hadoop2 @return a Set<String>. The set will contain the applicationIds that this job tried to kill.
killAllSpawnedHadoopJobs
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static Set<String> findApplicationIdFromLog(final String logFilePath, final Logger log) { // At least one job log file must be there. final File logFile = new File(logFilePath); if (!logFile.exists()) { throw new IllegalArgumentException("the logFilePath does not exist: " + logFilePath); }...
<pre> Takes in a log file, will grep every line to look for the application_id pattern. If it finds multiple, it will return all of them, de-duped (this is possible in the case of pig jobs) This can be used in conjunction with the @killJobOnCluster method in this file. </pre> @return a Set. May be empty, but will neve...
findApplicationIdFromLog
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static void killJobOnCluster(final String applicationId, final Logger log, final Props jobProps) throws YarnException, IOException { final YarnConfiguration yarnConf = new YarnConfiguration(); final YarnClient yarnClient = YarnClient.createYarnClient(); if (jobProps.containsKey(YAR...
<pre> Uses YarnClient to kill the job on HDFS. Using JobClient only works partially: If yarn container has started but spark job haven't, it will kill If spark job has started, the cancel will hang until the spark job is complete If the spark job is complete, it will return immediately, with a job not found on jo...
killJobOnCluster
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static String javaOptStringFromAzkabanProps(final Props props, final String key) { final String value = props.get(key); if (value == null) { throw new RuntimeException(String.format("Cannot find property [%s], in azkaban props: [%s]", key, value)); } return String.format("-D%s=%s"...
<pre> constructions a javaOpts string based on the Props, and the key given, will return String.format("-D%s=%s", key, value); </pre> @return will return String.format("-D%s=%s", key, value). Throws RuntimeException if props not present
javaOptStringFromAzkabanProps
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static List<String> filterCommands(final Collection<String> commands, final String whitelistRegex, final String blacklistRegex, final Logger log) { final List<String> filteredCommands = new LinkedList<>(); final Pattern whitelistPattern = Pattern.compile(whitelistRegex); final Pattern bla...
Filter a collection of String commands to match a whitelist regex and not match a blacklist regex. @param commands Collection of commands to be filtered @param whitelistRegex whitelist regex to work as inclusion criteria @param blacklistRegex blacklist regex to work as exclusion criteria @param log lo...
filterCommands
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static String javaOptStringFromHadoopConfiguration(final Configuration conf, final String key) { final String value = conf.get(key); if (value == null) { throw new RuntimeException( String.format("Cannot find property [%s], in Hadoop configuration: [%s]", key, value));...
<pre> constructions a javaOpts string based on the Props, and the key given, will return String.format("-D%s=%s", key, value); </pre> @return will return String.format("-D%s=%s", key, value). Throws RuntimeException if props not present
javaOptStringFromHadoopConfiguration
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static String constructHadoopTags(final Props props, final String[] keys) { final String[] keysAndValues = new String[keys.length]; for (int i = 0; i < keys.length; i++) { if (props.containsKey(keys[i])) { final String tag = keys[i] + ":" + props.get(keys[i]); keysAndValues[i] = tag...
Construct a CSV of tags for the Hadoop application. @param props job properties @param keys list of keys to construct tags from. @return a CSV of tags
constructHadoopTags
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
public static String constructSubflowTags(final Props props) { if (props.containsKey(CommonJobProperties.NESTED_FLOW_PATH)) { try { // example for nested_flow_path: subflow1:subflow2:job String nestedFlowId = props.getString(CommonJobProperties.NESTED_FLOW_PATH); String[] subflowParts ...
Construct a CSV of tags for the Hadoop application. @param props job properties @param keys list of keys to construct tags from. @return a CSV of tags
constructSubflowTags
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopJobUtils.java
Apache-2.0
private void copyAndModifyScript(File source, File dest, Map<Pattern, String> rampRegisterItems) throws IOException { BufferedReader bufferedReader = null; PrintWriter printWriter = null; bufferedReader = Files.newBufferedReader(source.toPath(), Charset.defaultCharset()); printWriter = new PrintWriter(...
Copy Pig Script from source to destination and update REGISTER statements based on the map of ramp items
copyAndModifyScript
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
Apache-2.0
private String replaceRegisterStatements(String text, Map<Pattern, String> rampRegisterItems) { StringBuilder sb = new StringBuilder(); int start = 0; int end = text.length(); int idx = 0; String statement = null; while(start < end && idx >= 0) { idx = text.indexOf(STATEMENT_TERMINATOR, st...
Replace Register statement to a particular ramp value
replaceRegisterStatements
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
Apache-2.0
@Override protected List<String> getClassPaths() { List<String> classPath = super.getClassPaths(); classPath.addAll(getAzkabanCommonClassPaths()); classPath.add(HadoopConfigurationInjector.getPath(getJobProps(), getWorkingDirectory())); // assuming pig 0.8 and up if (!userPigJar) { ...
Replace Register statement to a particular ramp value
getClassPaths
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
Apache-2.0
private boolean getDebug() { return getJobProps().getBoolean(DEBUG, false); }
Replace Register statement to a particular ramp value
getDebug
java
azkaban/azkaban
az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
https://github.com/azkaban/azkaban/blob/master/az-hadoop-jobtype-plugin/src/main/java/azkaban/jobtype/HadoopPigJob.java
Apache-2.0