id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
26,000
apache/incubator-gobblin
gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java
InstrumentedConverterBase.beforeConvert
public void beforeConvert(SO outputSchema, DI inputRecord, WorkUnitState workUnit) { Instrumented.markMeter(this.recordsInMeter); }
java
public void beforeConvert(SO outputSchema, DI inputRecord, WorkUnitState workUnit) { Instrumented.markMeter(this.recordsInMeter); }
[ "public", "void", "beforeConvert", "(", "SO", "outputSchema", ",", "DI", "inputRecord", ",", "WorkUnitState", "workUnit", ")", "{", "Instrumented", ".", "markMeter", "(", "this", ".", "recordsInMeter", ")", ";", "}" ]
Called before conversion. @param outputSchema output schema of the {@link #convertSchema(Object, WorkUnitState)} method @param inputRecord an input data record @param workUnit a {@link WorkUnitState} instance
[ "Called", "before", "conversion", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java#L147-L149
26,001
apache/incubator-gobblin
gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java
InstrumentedConverterBase.afterConvert
public void afterConvert(Iterable<DO> iterable, long startTimeNanos) { Instrumented.updateTimer(this.converterTimer, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS); }
java
public void afterConvert(Iterable<DO> iterable, long startTimeNanos) { Instrumented.updateTimer(this.converterTimer, System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS); }
[ "public", "void", "afterConvert", "(", "Iterable", "<", "DO", ">", "iterable", ",", "long", "startTimeNanos", ")", "{", "Instrumented", ".", "updateTimer", "(", "this", ".", "converterTimer", ",", "System", ".", "nanoTime", "(", ")", "-", "startTimeNanos", ",", "TimeUnit", ".", "NANOSECONDS", ")", ";", "}" ]
Called after conversion. @param iterable conversion result. @param startTimeNanos start time of conversion.
[ "Called", "after", "conversion", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core-base/src/main/java/org/apache/gobblin/instrumented/converter/InstrumentedConverterBase.java#L156-L158
26,002
apache/incubator-gobblin
gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/RestClientRequestSender.java
RestClientRequestSender.decorateCallback
protected Callback<Response<PermitAllocation>> decorateCallback(PermitRequest request, Callback<Response<PermitAllocation>> callback) { return callback; }
java
protected Callback<Response<PermitAllocation>> decorateCallback(PermitRequest request, Callback<Response<PermitAllocation>> callback) { return callback; }
[ "protected", "Callback", "<", "Response", "<", "PermitAllocation", ">", ">", "decorateCallback", "(", "PermitRequest", "request", ",", "Callback", "<", "Response", "<", "PermitAllocation", ">", ">", "callback", ")", "{", "return", "callback", ";", "}" ]
Decorate the callback to intercept some responses.
[ "Decorate", "the", "callback", "to", "intercept", "some", "responses", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-client/src/main/java/org/apache/gobblin/util/limiter/RestClientRequestSender.java#L51-L54
26,003
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/DatasetFilterUtils.java
DatasetFilterUtils.getPatternsFromStrings
public static List<Pattern> getPatternsFromStrings(List<String> strings) { List<Pattern> patterns = Lists.newArrayList(); for (String s : strings) { patterns.add(Pattern.compile(s)); } return patterns; }
java
public static List<Pattern> getPatternsFromStrings(List<String> strings) { List<Pattern> patterns = Lists.newArrayList(); for (String s : strings) { patterns.add(Pattern.compile(s)); } return patterns; }
[ "public", "static", "List", "<", "Pattern", ">", "getPatternsFromStrings", "(", "List", "<", "String", ">", "strings", ")", "{", "List", "<", "Pattern", ">", "patterns", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "String", "s", ":", "strings", ")", "{", "patterns", ".", "add", "(", "Pattern", ".", "compile", "(", "s", ")", ")", ";", "}", "return", "patterns", ";", "}" ]
Convert a list of Strings to a list of Patterns.
[ "Convert", "a", "list", "of", "Strings", "to", "a", "list", "of", "Patterns", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/DatasetFilterUtils.java#L49-L55
26,004
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/DatasetFilterUtils.java
DatasetFilterUtils.stringInPatterns
public static boolean stringInPatterns(String s, List<Pattern> patterns) { for (Pattern pattern : patterns) { if (pattern.matcher(s).matches()) { return true; } } return false; }
java
public static boolean stringInPatterns(String s, List<Pattern> patterns) { for (Pattern pattern : patterns) { if (pattern.matcher(s).matches()) { return true; } } return false; }
[ "public", "static", "boolean", "stringInPatterns", "(", "String", "s", ",", "List", "<", "Pattern", ">", "patterns", ")", "{", "for", "(", "Pattern", "pattern", ":", "patterns", ")", "{", "if", "(", "pattern", ".", "matcher", "(", "s", ")", ".", "matches", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines whether a string matches one of the regex patterns.
[ "Determines", "whether", "a", "string", "matches", "one", "of", "the", "regex", "patterns", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/DatasetFilterUtils.java#L92-L99
26,005
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/HivePartitionFinder.java
HivePartitionFinder.findDatasets
@Override public List<HivePartitionDataset> findDatasets() throws IOException { List<HivePartitionDataset> list = new ArrayList<>(); for (HiveDataset hiveDataset : this.hiveDatasets) { for (Partition partition : hiveDataset.getPartitionsFromDataset()) { list.add(new HivePartitionDataset(partition)); } } String selectionPolicyString = this.state.getProp(ComplianceConfigurationKeys.DATASET_SELECTION_POLICY_CLASS, ComplianceConfigurationKeys.DEFAULT_DATASET_SELECTION_POLICY_CLASS); Policy<HivePartitionDataset> selectionPolicy = GobblinConstructorUtils.invokeConstructor(Policy.class, selectionPolicyString); return selectionPolicy.selectedList(list); }
java
@Override public List<HivePartitionDataset> findDatasets() throws IOException { List<HivePartitionDataset> list = new ArrayList<>(); for (HiveDataset hiveDataset : this.hiveDatasets) { for (Partition partition : hiveDataset.getPartitionsFromDataset()) { list.add(new HivePartitionDataset(partition)); } } String selectionPolicyString = this.state.getProp(ComplianceConfigurationKeys.DATASET_SELECTION_POLICY_CLASS, ComplianceConfigurationKeys.DEFAULT_DATASET_SELECTION_POLICY_CLASS); Policy<HivePartitionDataset> selectionPolicy = GobblinConstructorUtils.invokeConstructor(Policy.class, selectionPolicyString); return selectionPolicy.selectedList(list); }
[ "@", "Override", "public", "List", "<", "HivePartitionDataset", ">", "findDatasets", "(", ")", "throws", "IOException", "{", "List", "<", "HivePartitionDataset", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "HiveDataset", "hiveDataset", ":", "this", ".", "hiveDatasets", ")", "{", "for", "(", "Partition", "partition", ":", "hiveDataset", ".", "getPartitionsFromDataset", "(", ")", ")", "{", "list", ".", "add", "(", "new", "HivePartitionDataset", "(", "partition", ")", ")", ";", "}", "}", "String", "selectionPolicyString", "=", "this", ".", "state", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "DATASET_SELECTION_POLICY_CLASS", ",", "ComplianceConfigurationKeys", ".", "DEFAULT_DATASET_SELECTION_POLICY_CLASS", ")", ";", "Policy", "<", "HivePartitionDataset", ">", "selectionPolicy", "=", "GobblinConstructorUtils", ".", "invokeConstructor", "(", "Policy", ".", "class", ",", "selectionPolicyString", ")", ";", "return", "selectionPolicy", ".", "selectedList", "(", "list", ")", ";", "}" ]
Will find all datasets according to whitelist, except the backup, trash and staging tables.
[ "Will", "find", "all", "datasets", "according", "to", "whitelist", "except", "the", "backup", "trash", "and", "staging", "tables", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/HivePartitionFinder.java#L82-L96
26,006
apache/incubator-gobblin
gobblin-service/src/main/java/org/apache/gobblin/service/modules/flowgraph/Dag.java
Dag.build
private void build() { this.startNodes = new ArrayList<>(); this.endNodes = new ArrayList<>(); this.parentChildMap = new HashMap<>(); for (DagNode node : this.nodes) { //If a Node has no parent Node, add it to the list of start Nodes if (node.getParentNodes() == null) { this.startNodes.add(node); } else { List<DagNode> parentNodeList = node.getParentNodes(); for (DagNode parentNode : parentNodeList) { if (parentChildMap.containsKey(parentNode)) { parentChildMap.get(parentNode).add(node); } else { parentChildMap.put(parentNode, Lists.newArrayList(node)); } } } } //Iterate over all the Nodes and add a Node to the list of endNodes if it is not present in the parentChildMap for (DagNode node : this.nodes) { if (!parentChildMap.containsKey(node)) { this.endNodes.add(node); } } }
java
private void build() { this.startNodes = new ArrayList<>(); this.endNodes = new ArrayList<>(); this.parentChildMap = new HashMap<>(); for (DagNode node : this.nodes) { //If a Node has no parent Node, add it to the list of start Nodes if (node.getParentNodes() == null) { this.startNodes.add(node); } else { List<DagNode> parentNodeList = node.getParentNodes(); for (DagNode parentNode : parentNodeList) { if (parentChildMap.containsKey(parentNode)) { parentChildMap.get(parentNode).add(node); } else { parentChildMap.put(parentNode, Lists.newArrayList(node)); } } } } //Iterate over all the Nodes and add a Node to the list of endNodes if it is not present in the parentChildMap for (DagNode node : this.nodes) { if (!parentChildMap.containsKey(node)) { this.endNodes.add(node); } } }
[ "private", "void", "build", "(", ")", "{", "this", ".", "startNodes", "=", "new", "ArrayList", "<>", "(", ")", ";", "this", ".", "endNodes", "=", "new", "ArrayList", "<>", "(", ")", ";", "this", ".", "parentChildMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "DagNode", "node", ":", "this", ".", "nodes", ")", "{", "//If a Node has no parent Node, add it to the list of start Nodes", "if", "(", "node", ".", "getParentNodes", "(", ")", "==", "null", ")", "{", "this", ".", "startNodes", ".", "add", "(", "node", ")", ";", "}", "else", "{", "List", "<", "DagNode", ">", "parentNodeList", "=", "node", ".", "getParentNodes", "(", ")", ";", "for", "(", "DagNode", "parentNode", ":", "parentNodeList", ")", "{", "if", "(", "parentChildMap", ".", "containsKey", "(", "parentNode", ")", ")", "{", "parentChildMap", ".", "get", "(", "parentNode", ")", ".", "add", "(", "node", ")", ";", "}", "else", "{", "parentChildMap", ".", "put", "(", "parentNode", ",", "Lists", ".", "newArrayList", "(", "node", ")", ")", ";", "}", "}", "}", "}", "//Iterate over all the Nodes and add a Node to the list of endNodes if it is not present in the parentChildMap", "for", "(", "DagNode", "node", ":", "this", ".", "nodes", ")", "{", "if", "(", "!", "parentChildMap", ".", "containsKey", "(", "node", ")", ")", "{", "this", ".", "endNodes", ".", "add", "(", "node", ")", ";", "}", "}", "}" ]
Constructs the dag from the Node list.
[ "Constructs", "the", "dag", "from", "the", "Node", "list", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-service/src/main/java/org/apache/gobblin/service/modules/flowgraph/Dag.java#L59-L84
26,007
apache/incubator-gobblin
gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java
GPGFileDecryptor.decryptFile
public InputStream decryptFile(InputStream inputStream, String passPhrase) throws IOException { PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream); PGPPBEEncryptedData pbe = (PGPPBEEncryptedData) enc.get(0); InputStream clear; try { clear = pbe.getDataStream(new JcePBEDataDecryptorFactoryBuilder( new JcaPGPDigestCalculatorProviderBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build()) .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(passPhrase.toCharArray())); JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear); return new LazyMaterializeDecryptorInputStream(pgpFact); } catch (PGPException e) { throw new IOException(e); } }
java
public InputStream decryptFile(InputStream inputStream, String passPhrase) throws IOException { PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream); PGPPBEEncryptedData pbe = (PGPPBEEncryptedData) enc.get(0); InputStream clear; try { clear = pbe.getDataStream(new JcePBEDataDecryptorFactoryBuilder( new JcaPGPDigestCalculatorProviderBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build()) .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(passPhrase.toCharArray())); JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear); return new LazyMaterializeDecryptorInputStream(pgpFact); } catch (PGPException e) { throw new IOException(e); } }
[ "public", "InputStream", "decryptFile", "(", "InputStream", "inputStream", ",", "String", "passPhrase", ")", "throws", "IOException", "{", "PGPEncryptedDataList", "enc", "=", "getPGPEncryptedDataList", "(", "inputStream", ")", ";", "PGPPBEEncryptedData", "pbe", "=", "(", "PGPPBEEncryptedData", ")", "enc", ".", "get", "(", "0", ")", ";", "InputStream", "clear", ";", "try", "{", "clear", "=", "pbe", ".", "getDataStream", "(", "new", "JcePBEDataDecryptorFactoryBuilder", "(", "new", "JcaPGPDigestCalculatorProviderBuilder", "(", ")", ".", "setProvider", "(", "BouncyCastleProvider", ".", "PROVIDER_NAME", ")", ".", "build", "(", ")", ")", ".", "setProvider", "(", "BouncyCastleProvider", ".", "PROVIDER_NAME", ")", ".", "build", "(", "passPhrase", ".", "toCharArray", "(", ")", ")", ")", ";", "JcaPGPObjectFactory", "pgpFact", "=", "new", "JcaPGPObjectFactory", "(", "clear", ")", ";", "return", "new", "LazyMaterializeDecryptorInputStream", "(", "pgpFact", ")", ";", "}", "catch", "(", "PGPException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}" ]
Taking in a file inputstream and a passPhrase, generate a decrypted file inputstream. @param inputStream file inputstream @param passPhrase passPhrase @return @throws IOException
[ "Taking", "in", "a", "file", "inputstream", "and", "a", "passPhrase", "generate", "a", "decrypted", "file", "inputstream", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java#L62-L79
26,008
apache/incubator-gobblin
gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java
GPGFileDecryptor.decryptFile
public InputStream decryptFile(InputStream inputStream, InputStream keyIn, String passPhrase) throws IOException { try { PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream); Iterator it = enc.getEncryptedDataObjects(); PGPPrivateKey sKey = null; PGPPublicKeyEncryptedData pbe = null; PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn), new BcKeyFingerprintCalculator()); while (sKey == null && it.hasNext()) { pbe = (PGPPublicKeyEncryptedData) it.next(); sKey = findSecretKey(pgpSec, pbe.getKeyID(), passPhrase); } if (sKey == null) { throw new IllegalArgumentException("secret key for message not found."); } InputStream clear = pbe.getDataStream( new JcePublicKeyDataDecryptorFactoryBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(sKey)); JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear); return new LazyMaterializeDecryptorInputStream(pgpFact); } catch (PGPException e) { throw new IOException(e); } }
java
public InputStream decryptFile(InputStream inputStream, InputStream keyIn, String passPhrase) throws IOException { try { PGPEncryptedDataList enc = getPGPEncryptedDataList(inputStream); Iterator it = enc.getEncryptedDataObjects(); PGPPrivateKey sKey = null; PGPPublicKeyEncryptedData pbe = null; PGPSecretKeyRingCollection pgpSec = new PGPSecretKeyRingCollection(PGPUtil.getDecoderStream(keyIn), new BcKeyFingerprintCalculator()); while (sKey == null && it.hasNext()) { pbe = (PGPPublicKeyEncryptedData) it.next(); sKey = findSecretKey(pgpSec, pbe.getKeyID(), passPhrase); } if (sKey == null) { throw new IllegalArgumentException("secret key for message not found."); } InputStream clear = pbe.getDataStream( new JcePublicKeyDataDecryptorFactoryBuilder().setProvider(BouncyCastleProvider.PROVIDER_NAME).build(sKey)); JcaPGPObjectFactory pgpFact = new JcaPGPObjectFactory(clear); return new LazyMaterializeDecryptorInputStream(pgpFact); } catch (PGPException e) { throw new IOException(e); } }
[ "public", "InputStream", "decryptFile", "(", "InputStream", "inputStream", ",", "InputStream", "keyIn", ",", "String", "passPhrase", ")", "throws", "IOException", "{", "try", "{", "PGPEncryptedDataList", "enc", "=", "getPGPEncryptedDataList", "(", "inputStream", ")", ";", "Iterator", "it", "=", "enc", ".", "getEncryptedDataObjects", "(", ")", ";", "PGPPrivateKey", "sKey", "=", "null", ";", "PGPPublicKeyEncryptedData", "pbe", "=", "null", ";", "PGPSecretKeyRingCollection", "pgpSec", "=", "new", "PGPSecretKeyRingCollection", "(", "PGPUtil", ".", "getDecoderStream", "(", "keyIn", ")", ",", "new", "BcKeyFingerprintCalculator", "(", ")", ")", ";", "while", "(", "sKey", "==", "null", "&&", "it", ".", "hasNext", "(", ")", ")", "{", "pbe", "=", "(", "PGPPublicKeyEncryptedData", ")", "it", ".", "next", "(", ")", ";", "sKey", "=", "findSecretKey", "(", "pgpSec", ",", "pbe", ".", "getKeyID", "(", ")", ",", "passPhrase", ")", ";", "}", "if", "(", "sKey", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"secret key for message not found.\"", ")", ";", "}", "InputStream", "clear", "=", "pbe", ".", "getDataStream", "(", "new", "JcePublicKeyDataDecryptorFactoryBuilder", "(", ")", ".", "setProvider", "(", "BouncyCastleProvider", ".", "PROVIDER_NAME", ")", ".", "build", "(", "sKey", ")", ")", ";", "JcaPGPObjectFactory", "pgpFact", "=", "new", "JcaPGPObjectFactory", "(", "clear", ")", ";", "return", "new", "LazyMaterializeDecryptorInputStream", "(", "pgpFact", ")", ";", "}", "catch", "(", "PGPException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "}" ]
Taking in a file inputstream, keyring inputstream and a passPhrase, generate a decrypted file inputstream. @param inputStream file inputstream @param keyIn keyring inputstream. This InputStream is owned by the caller. @param passPhrase passPhrase @return an {@link InputStream} for the decrypted content @throws IOException
[ "Taking", "in", "a", "file", "inputstream", "keyring", "inputstream", "and", "a", "passPhrase", "generate", "a", "decrypted", "file", "inputstream", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java#L89-L115
26,009
apache/incubator-gobblin
gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java
GPGFileDecryptor.findSecretKey
private PGPPrivateKey findSecretKey(PGPSecretKeyRingCollection pgpSec, long keyID, String passPhrase) throws PGPException { PGPSecretKey pgpSecKey = pgpSec.getSecretKey(keyID); if (pgpSecKey == null) { return null; } return pgpSecKey.extractPrivateKey( new JcePBESecretKeyDecryptorBuilder() .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(passPhrase.toCharArray())); }
java
private PGPPrivateKey findSecretKey(PGPSecretKeyRingCollection pgpSec, long keyID, String passPhrase) throws PGPException { PGPSecretKey pgpSecKey = pgpSec.getSecretKey(keyID); if (pgpSecKey == null) { return null; } return pgpSecKey.extractPrivateKey( new JcePBESecretKeyDecryptorBuilder() .setProvider(BouncyCastleProvider.PROVIDER_NAME).build(passPhrase.toCharArray())); }
[ "private", "PGPPrivateKey", "findSecretKey", "(", "PGPSecretKeyRingCollection", "pgpSec", ",", "long", "keyID", ",", "String", "passPhrase", ")", "throws", "PGPException", "{", "PGPSecretKey", "pgpSecKey", "=", "pgpSec", ".", "getSecretKey", "(", "keyID", ")", ";", "if", "(", "pgpSecKey", "==", "null", ")", "{", "return", "null", ";", "}", "return", "pgpSecKey", ".", "extractPrivateKey", "(", "new", "JcePBESecretKeyDecryptorBuilder", "(", ")", ".", "setProvider", "(", "BouncyCastleProvider", ".", "PROVIDER_NAME", ")", ".", "build", "(", "passPhrase", ".", "toCharArray", "(", ")", ")", ")", ";", "}" ]
Private util function that finds the private key from keyring collection based on keyId and passPhrase @param pgpSec keyring collection @param keyID keyID for this encryption file @param passPhrase passPhrase for this encryption file @throws PGPException
[ "Private", "util", "function", "that", "finds", "the", "private", "key", "from", "keyring", "collection", "based", "on", "keyId", "and", "passPhrase" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java#L124-L134
26,010
apache/incubator-gobblin
gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java
GPGFileDecryptor.getPGPEncryptedDataList
private PGPEncryptedDataList getPGPEncryptedDataList(InputStream inputStream) throws IOException { if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { Security.addProvider(new BouncyCastleProvider()); } inputStream = PGPUtil.getDecoderStream(inputStream); JcaPGPObjectFactory pgpF = new JcaPGPObjectFactory(inputStream); PGPEncryptedDataList enc; Object pgpfObject = pgpF.nextObject(); if (pgpfObject instanceof PGPEncryptedDataList) { enc = (PGPEncryptedDataList) pgpfObject; } else { enc = (PGPEncryptedDataList) pgpF.nextObject(); } return enc; }
java
private PGPEncryptedDataList getPGPEncryptedDataList(InputStream inputStream) throws IOException { if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { Security.addProvider(new BouncyCastleProvider()); } inputStream = PGPUtil.getDecoderStream(inputStream); JcaPGPObjectFactory pgpF = new JcaPGPObjectFactory(inputStream); PGPEncryptedDataList enc; Object pgpfObject = pgpF.nextObject(); if (pgpfObject instanceof PGPEncryptedDataList) { enc = (PGPEncryptedDataList) pgpfObject; } else { enc = (PGPEncryptedDataList) pgpF.nextObject(); } return enc; }
[ "private", "PGPEncryptedDataList", "getPGPEncryptedDataList", "(", "InputStream", "inputStream", ")", "throws", "IOException", "{", "if", "(", "Security", ".", "getProvider", "(", "BouncyCastleProvider", ".", "PROVIDER_NAME", ")", "==", "null", ")", "{", "Security", ".", "addProvider", "(", "new", "BouncyCastleProvider", "(", ")", ")", ";", "}", "inputStream", "=", "PGPUtil", ".", "getDecoderStream", "(", "inputStream", ")", ";", "JcaPGPObjectFactory", "pgpF", "=", "new", "JcaPGPObjectFactory", "(", "inputStream", ")", ";", "PGPEncryptedDataList", "enc", ";", "Object", "pgpfObject", "=", "pgpF", ".", "nextObject", "(", ")", ";", "if", "(", "pgpfObject", "instanceof", "PGPEncryptedDataList", ")", "{", "enc", "=", "(", "PGPEncryptedDataList", ")", "pgpfObject", ";", "}", "else", "{", "enc", "=", "(", "PGPEncryptedDataList", ")", "pgpF", ".", "nextObject", "(", ")", ";", "}", "return", "enc", ";", "}" ]
Generate a PGPEncryptedDataList from an inputstream @param inputStream file inputstream that needs to be decrypted @throws IOException
[ "Generate", "a", "PGPEncryptedDataList", "from", "an", "inputstream" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto/src/main/java/org/apache/gobblin/crypto/GPGFileDecryptor.java#L141-L158
26,011
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/source/extractor/filebased/CsvFileDownloader.java
CsvFileDownloader.downloadFile
@SuppressWarnings("unchecked") @Override public Iterator<String[]> downloadFile(String file) throws IOException { log.info("Beginning to download file: " + file); final State state = fileBasedExtractor.workUnitState; CSVReader reader; try { if (state.contains(DELIMITER)) { String delimiterStr = state.getProp(DELIMITER).trim(); Preconditions.checkArgument(delimiterStr.length() == 1, "Delimiter should be a character."); char delimiter = delimiterStr.charAt(0); log.info("Using " + delimiter + " as a delimiter."); reader = this.fileBasedExtractor.getCloser().register( new CSVReader(new InputStreamReader( this.fileBasedExtractor.getFsHelper().getFileStream(file), ConfigurationKeys.DEFAULT_CHARSET_ENCODING), delimiter)); } else { reader = this.fileBasedExtractor.getCloser().register( new CSVReader(new InputStreamReader( this.fileBasedExtractor.getFsHelper().getFileStream(file), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); } } catch (FileBasedHelperException e) { throw new IOException(e); } PeekingIterator<String[]> iterator = Iterators.peekingIterator(reader.iterator()); if (state.contains(SKIP_TOP_ROWS_REGEX)) { String regex = state.getProp(SKIP_TOP_ROWS_REGEX); log.info("Trying to skip with regex: " + regex); while (iterator.hasNext()) { String[] row = iterator.peek(); if (row.length == 0) { break; } if (!row[0].matches(regex)) { break; } iterator.next(); } } if (this.fileBasedExtractor.isShouldSkipFirstRecord() && iterator.hasNext()) { log.info("Skipping first record"); iterator.next(); } return iterator; }
java
@SuppressWarnings("unchecked") @Override public Iterator<String[]> downloadFile(String file) throws IOException { log.info("Beginning to download file: " + file); final State state = fileBasedExtractor.workUnitState; CSVReader reader; try { if (state.contains(DELIMITER)) { String delimiterStr = state.getProp(DELIMITER).trim(); Preconditions.checkArgument(delimiterStr.length() == 1, "Delimiter should be a character."); char delimiter = delimiterStr.charAt(0); log.info("Using " + delimiter + " as a delimiter."); reader = this.fileBasedExtractor.getCloser().register( new CSVReader(new InputStreamReader( this.fileBasedExtractor.getFsHelper().getFileStream(file), ConfigurationKeys.DEFAULT_CHARSET_ENCODING), delimiter)); } else { reader = this.fileBasedExtractor.getCloser().register( new CSVReader(new InputStreamReader( this.fileBasedExtractor.getFsHelper().getFileStream(file), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); } } catch (FileBasedHelperException e) { throw new IOException(e); } PeekingIterator<String[]> iterator = Iterators.peekingIterator(reader.iterator()); if (state.contains(SKIP_TOP_ROWS_REGEX)) { String regex = state.getProp(SKIP_TOP_ROWS_REGEX); log.info("Trying to skip with regex: " + regex); while (iterator.hasNext()) { String[] row = iterator.peek(); if (row.length == 0) { break; } if (!row[0].matches(regex)) { break; } iterator.next(); } } if (this.fileBasedExtractor.isShouldSkipFirstRecord() && iterator.hasNext()) { log.info("Skipping first record"); iterator.next(); } return iterator; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "Iterator", "<", "String", "[", "]", ">", "downloadFile", "(", "String", "file", ")", "throws", "IOException", "{", "log", ".", "info", "(", "\"Beginning to download file: \"", "+", "file", ")", ";", "final", "State", "state", "=", "fileBasedExtractor", ".", "workUnitState", ";", "CSVReader", "reader", ";", "try", "{", "if", "(", "state", ".", "contains", "(", "DELIMITER", ")", ")", "{", "String", "delimiterStr", "=", "state", ".", "getProp", "(", "DELIMITER", ")", ".", "trim", "(", ")", ";", "Preconditions", ".", "checkArgument", "(", "delimiterStr", ".", "length", "(", ")", "==", "1", ",", "\"Delimiter should be a character.\"", ")", ";", "char", "delimiter", "=", "delimiterStr", ".", "charAt", "(", "0", ")", ";", "log", ".", "info", "(", "\"Using \"", "+", "delimiter", "+", "\" as a delimiter.\"", ")", ";", "reader", "=", "this", ".", "fileBasedExtractor", ".", "getCloser", "(", ")", ".", "register", "(", "new", "CSVReader", "(", "new", "InputStreamReader", "(", "this", ".", "fileBasedExtractor", ".", "getFsHelper", "(", ")", ".", "getFileStream", "(", "file", ")", ",", "ConfigurationKeys", ".", "DEFAULT_CHARSET_ENCODING", ")", ",", "delimiter", ")", ")", ";", "}", "else", "{", "reader", "=", "this", ".", "fileBasedExtractor", ".", "getCloser", "(", ")", ".", "register", "(", "new", "CSVReader", "(", "new", "InputStreamReader", "(", "this", ".", "fileBasedExtractor", ".", "getFsHelper", "(", ")", ".", "getFileStream", "(", "file", ")", ",", "ConfigurationKeys", ".", "DEFAULT_CHARSET_ENCODING", ")", ")", ")", ";", "}", "}", "catch", "(", "FileBasedHelperException", "e", ")", "{", "throw", "new", "IOException", "(", "e", ")", ";", "}", "PeekingIterator", "<", "String", "[", "]", ">", "iterator", "=", "Iterators", ".", "peekingIterator", "(", "reader", ".", "iterator", "(", ")", ")", ";", "if", "(", "state", ".", "contains", "(", "SKIP_TOP_ROWS_REGEX", ")", ")", "{", "String", "regex", "=", "state", ".", "getProp", "(", "SKIP_TOP_ROWS_REGEX", ")", ";", "log", ".", "info", "(", "\"Trying to skip with regex: \"", "+", "regex", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "String", "[", "]", "row", "=", "iterator", ".", "peek", "(", ")", ";", "if", "(", "row", ".", "length", "==", "0", ")", "{", "break", ";", "}", "if", "(", "!", "row", "[", "0", "]", ".", "matches", "(", "regex", ")", ")", "{", "break", ";", "}", "iterator", ".", "next", "(", ")", ";", "}", "}", "if", "(", "this", ".", "fileBasedExtractor", ".", "isShouldSkipFirstRecord", "(", ")", "&&", "iterator", ".", "hasNext", "(", ")", ")", "{", "log", ".", "info", "(", "\"Skipping first record\"", ")", ";", "iterator", ".", "next", "(", ")", ";", "}", "return", "iterator", ";", "}" ]
Provide iterator via OpenCSV's CSVReader. Provides a way to skip top rows by providing regex.(This is useful when CSV file comes with comments on top rows, but not in fixed size. It also provides validation on schema by matching header names between property's schema and header name in CSV file. {@inheritDoc} @see org.apache.gobblin.source.extractor.filebased.FileDownloader#downloadFile(java.lang.String)
[ "Provide", "iterator", "via", "OpenCSV", "s", "CSVReader", ".", "Provides", "a", "way", "to", "skip", "top", "rows", "by", "providing", "regex", ".", "(", "This", "is", "useful", "when", "CSV", "file", "comes", "with", "comments", "on", "top", "rows", "but", "not", "in", "fixed", "size", ".", "It", "also", "provides", "validation", "on", "schema", "by", "matching", "header", "names", "between", "property", "s", "schema", "and", "header", "name", "in", "CSV", "file", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/source/extractor/filebased/CsvFileDownloader.java#L57-L111
26,012
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/source/workunit/BasicWorkUnitStream.java
BasicWorkUnitStream.transform
public WorkUnitStream transform(Function<WorkUnit, WorkUnit> function) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.transform(this.workUnits, function), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Lists.transform(this.materializedWorkUnits, function))); } }
java
public WorkUnitStream transform(Function<WorkUnit, WorkUnit> function) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.transform(this.workUnits, function), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Lists.transform(this.materializedWorkUnits, function))); } }
[ "public", "WorkUnitStream", "transform", "(", "Function", "<", "WorkUnit", ",", "WorkUnit", ">", "function", ")", "{", "if", "(", "this", ".", "materializedWorkUnits", "==", "null", ")", "{", "return", "new", "BasicWorkUnitStream", "(", "this", ",", "Iterators", ".", "transform", "(", "this", ".", "workUnits", ",", "function", ")", ",", "null", ")", ";", "}", "else", "{", "return", "new", "BasicWorkUnitStream", "(", "this", ",", "null", ",", "Lists", ".", "newArrayList", "(", "Lists", ".", "transform", "(", "this", ".", "materializedWorkUnits", ",", "function", ")", ")", ")", ";", "}", "}" ]
Apply a transformation function to this stream.
[ "Apply", "a", "transformation", "function", "to", "this", "stream", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/BasicWorkUnitStream.java#L81-L87
26,013
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/source/workunit/BasicWorkUnitStream.java
BasicWorkUnitStream.filter
public WorkUnitStream filter(Predicate<WorkUnit> predicate) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.filter(this.workUnits, predicate), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Iterables.filter(this.materializedWorkUnits, predicate))); } }
java
public WorkUnitStream filter(Predicate<WorkUnit> predicate) { if (this.materializedWorkUnits == null) { return new BasicWorkUnitStream(this, Iterators.filter(this.workUnits, predicate), null); } else { return new BasicWorkUnitStream(this, null, Lists.newArrayList(Iterables.filter(this.materializedWorkUnits, predicate))); } }
[ "public", "WorkUnitStream", "filter", "(", "Predicate", "<", "WorkUnit", ">", "predicate", ")", "{", "if", "(", "this", ".", "materializedWorkUnits", "==", "null", ")", "{", "return", "new", "BasicWorkUnitStream", "(", "this", ",", "Iterators", ".", "filter", "(", "this", ".", "workUnits", ",", "predicate", ")", ",", "null", ")", ";", "}", "else", "{", "return", "new", "BasicWorkUnitStream", "(", "this", ",", "null", ",", "Lists", ".", "newArrayList", "(", "Iterables", ".", "filter", "(", "this", ".", "materializedWorkUnits", ",", "predicate", ")", ")", ")", ";", "}", "}" ]
Apply a filtering function to this stream.
[ "Apply", "a", "filtering", "function", "to", "this", "stream", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/BasicWorkUnitStream.java#L92-L98
26,014
apache/incubator-gobblin
gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java
CliTablePrinter.printTable
public void printTable() { if (this.labels != null) { System.out.printf(this.rowFormat, this.labels.toArray()); } for (List<String> row : this.data) { System.out.printf(this.rowFormat, row.toArray()); } }
java
public void printTable() { if (this.labels != null) { System.out.printf(this.rowFormat, this.labels.toArray()); } for (List<String> row : this.data) { System.out.printf(this.rowFormat, row.toArray()); } }
[ "public", "void", "printTable", "(", ")", "{", "if", "(", "this", ".", "labels", "!=", "null", ")", "{", "System", ".", "out", ".", "printf", "(", "this", ".", "rowFormat", ",", "this", ".", "labels", ".", "toArray", "(", ")", ")", ";", "}", "for", "(", "List", "<", "String", ">", "row", ":", "this", ".", "data", ")", "{", "System", ".", "out", ".", "printf", "(", "this", ".", "rowFormat", ",", "row", ".", "toArray", "(", ")", ")", ";", "}", "}" ]
Prints the table of data
[ "Prints", "the", "table", "of", "data" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java#L136-L143
26,015
apache/incubator-gobblin
gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java
CliTablePrinter.getColumnMaxWidths
private List<Integer> getColumnMaxWidths() { int numCols = data.get(0).size(); int[] widths = new int[numCols]; if (this.labels != null) { for (int i=0; i<numCols; i++) { widths[i] = this.labels.get(i).length(); } } for (List<String> row : this.data) { for (int i=0;i<row.size(); i++) { if (row.get(i) == null) { widths[i] = Math.max(widths[i], 4); } else { widths[i] = Math.max(widths[i], row.get(i).length()); } } } return Ints.asList(widths); }
java
private List<Integer> getColumnMaxWidths() { int numCols = data.get(0).size(); int[] widths = new int[numCols]; if (this.labels != null) { for (int i=0; i<numCols; i++) { widths[i] = this.labels.get(i).length(); } } for (List<String> row : this.data) { for (int i=0;i<row.size(); i++) { if (row.get(i) == null) { widths[i] = Math.max(widths[i], 4); } else { widths[i] = Math.max(widths[i], row.get(i).length()); } } } return Ints.asList(widths); }
[ "private", "List", "<", "Integer", ">", "getColumnMaxWidths", "(", ")", "{", "int", "numCols", "=", "data", ".", "get", "(", "0", ")", ".", "size", "(", ")", ";", "int", "[", "]", "widths", "=", "new", "int", "[", "numCols", "]", ";", "if", "(", "this", ".", "labels", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numCols", ";", "i", "++", ")", "{", "widths", "[", "i", "]", "=", "this", ".", "labels", ".", "get", "(", "i", ")", ".", "length", "(", ")", ";", "}", "}", "for", "(", "List", "<", "String", ">", "row", ":", "this", ".", "data", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "row", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "row", ".", "get", "(", "i", ")", "==", "null", ")", "{", "widths", "[", "i", "]", "=", "Math", ".", "max", "(", "widths", "[", "i", "]", ",", "4", ")", ";", "}", "else", "{", "widths", "[", "i", "]", "=", "Math", ".", "max", "(", "widths", "[", "i", "]", ",", "row", ".", "get", "(", "i", ")", ".", "length", "(", ")", ")", ";", "}", "}", "}", "return", "Ints", ".", "asList", "(", "widths", ")", ";", "}" ]
A function for determining the max widths of columns, accounting for labels and data. @return An array of maximum widths for the strings in each column
[ "A", "function", "for", "determining", "the", "max", "widths", "of", "columns", "accounting", "for", "labels", "and", "data", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java#L150-L171
26,016
apache/incubator-gobblin
gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java
CliTablePrinter.getRowFormat
private String getRowFormat(List<Integer> widths) { StringBuilder rowFormat = new StringBuilder(spaces(this.indentation)); for (int i=0; i< widths.size(); i++) { rowFormat.append("%"); rowFormat.append(this.flags != null ? this.flags.get(i) : ""); rowFormat.append(widths.get(i).toString()); rowFormat.append("s"); rowFormat.append(spaces(this.delimiterWidth)); } rowFormat.append("\n"); return rowFormat.toString(); }
java
private String getRowFormat(List<Integer> widths) { StringBuilder rowFormat = new StringBuilder(spaces(this.indentation)); for (int i=0; i< widths.size(); i++) { rowFormat.append("%"); rowFormat.append(this.flags != null ? this.flags.get(i) : ""); rowFormat.append(widths.get(i).toString()); rowFormat.append("s"); rowFormat.append(spaces(this.delimiterWidth)); } rowFormat.append("\n"); return rowFormat.toString(); }
[ "private", "String", "getRowFormat", "(", "List", "<", "Integer", ">", "widths", ")", "{", "StringBuilder", "rowFormat", "=", "new", "StringBuilder", "(", "spaces", "(", "this", ".", "indentation", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "widths", ".", "size", "(", ")", ";", "i", "++", ")", "{", "rowFormat", ".", "append", "(", "\"%\"", ")", ";", "rowFormat", ".", "append", "(", "this", ".", "flags", "!=", "null", "?", "this", ".", "flags", ".", "get", "(", "i", ")", ":", "\"\"", ")", ";", "rowFormat", ".", "append", "(", "widths", ".", "get", "(", "i", ")", ".", "toString", "(", ")", ")", ";", "rowFormat", ".", "append", "(", "\"s\"", ")", ";", "rowFormat", ".", "append", "(", "spaces", "(", "this", ".", "delimiterWidth", ")", ")", ";", "}", "rowFormat", ".", "append", "(", "\"\\n\"", ")", ";", "return", "rowFormat", ".", "toString", "(", ")", ";", "}" ]
Generates a simple row format string given a set of widths @param widths A list of widths for each column in the table @return A row format for each row in the table
[ "Generates", "a", "simple", "row", "format", "string", "given", "a", "set", "of", "widths" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-admin/src/main/java/org/apache/gobblin/cli/CliTablePrinter.java#L179-L191
26,017
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/source/CompactionSource.java
CompactionSource.copyJarDependencies
private void copyJarDependencies (State state) throws IOException { if (this.tmpJobDir == null) { throw new RuntimeException("Job directory is not created"); } if (!state.contains(ConfigurationKeys.JOB_JAR_FILES_KEY)) { return; } // create sub-dir to save jar files LocalFileSystem lfs = FileSystem.getLocal(HadoopUtils.getConfFromState(state)); Path tmpJarFileDir = new Path(this.tmpJobDir, MRCompactor.COMPACTION_JAR_SUBDIR); this.fs.mkdirs(tmpJarFileDir); state.setProp(MRCompactor.COMPACTION_JARS, tmpJarFileDir.toString()); // copy jar files to hdfs for (String jarFile : state.getPropAsList(ConfigurationKeys.JOB_JAR_FILES_KEY)) { for (FileStatus status : lfs.globStatus(new Path(jarFile))) { Path tmpJarFile = new Path(this.fs.makeQualified(tmpJarFileDir), status.getPath().getName()); this.fs.copyFromLocalFile(status.getPath(), tmpJarFile); log.info(String.format("%s will be added to classpath", tmpJarFile)); } } }
java
private void copyJarDependencies (State state) throws IOException { if (this.tmpJobDir == null) { throw new RuntimeException("Job directory is not created"); } if (!state.contains(ConfigurationKeys.JOB_JAR_FILES_KEY)) { return; } // create sub-dir to save jar files LocalFileSystem lfs = FileSystem.getLocal(HadoopUtils.getConfFromState(state)); Path tmpJarFileDir = new Path(this.tmpJobDir, MRCompactor.COMPACTION_JAR_SUBDIR); this.fs.mkdirs(tmpJarFileDir); state.setProp(MRCompactor.COMPACTION_JARS, tmpJarFileDir.toString()); // copy jar files to hdfs for (String jarFile : state.getPropAsList(ConfigurationKeys.JOB_JAR_FILES_KEY)) { for (FileStatus status : lfs.globStatus(new Path(jarFile))) { Path tmpJarFile = new Path(this.fs.makeQualified(tmpJarFileDir), status.getPath().getName()); this.fs.copyFromLocalFile(status.getPath(), tmpJarFile); log.info(String.format("%s will be added to classpath", tmpJarFile)); } } }
[ "private", "void", "copyJarDependencies", "(", "State", "state", ")", "throws", "IOException", "{", "if", "(", "this", ".", "tmpJobDir", "==", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Job directory is not created\"", ")", ";", "}", "if", "(", "!", "state", ".", "contains", "(", "ConfigurationKeys", ".", "JOB_JAR_FILES_KEY", ")", ")", "{", "return", ";", "}", "// create sub-dir to save jar files", "LocalFileSystem", "lfs", "=", "FileSystem", ".", "getLocal", "(", "HadoopUtils", ".", "getConfFromState", "(", "state", ")", ")", ";", "Path", "tmpJarFileDir", "=", "new", "Path", "(", "this", ".", "tmpJobDir", ",", "MRCompactor", ".", "COMPACTION_JAR_SUBDIR", ")", ";", "this", ".", "fs", ".", "mkdirs", "(", "tmpJarFileDir", ")", ";", "state", ".", "setProp", "(", "MRCompactor", ".", "COMPACTION_JARS", ",", "tmpJarFileDir", ".", "toString", "(", ")", ")", ";", "// copy jar files to hdfs", "for", "(", "String", "jarFile", ":", "state", ".", "getPropAsList", "(", "ConfigurationKeys", ".", "JOB_JAR_FILES_KEY", ")", ")", "{", "for", "(", "FileStatus", "status", ":", "lfs", ".", "globStatus", "(", "new", "Path", "(", "jarFile", ")", ")", ")", "{", "Path", "tmpJarFile", "=", "new", "Path", "(", "this", ".", "fs", ".", "makeQualified", "(", "tmpJarFileDir", ")", ",", "status", ".", "getPath", "(", ")", ".", "getName", "(", ")", ")", ";", "this", ".", "fs", ".", "copyFromLocalFile", "(", "status", ".", "getPath", "(", ")", ",", "tmpJarFile", ")", ";", "log", ".", "info", "(", "String", ".", "format", "(", "\"%s will be added to classpath\"", ",", "tmpJarFile", ")", ")", ";", "}", "}", "}" ]
Copy dependent jars to a temporary job directory on HDFS
[ "Copy", "dependent", "jars", "to", "a", "temporary", "job", "directory", "on", "HDFS" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/source/CompactionSource.java#L469-L492
26,018
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/HiveProxyQueryExecutor.java
HiveProxyQueryExecutor.executeQueries
public void executeQueries(List<String> queries, Optional<String> proxy) throws SQLException { Preconditions.checkArgument(!this.statementMap.isEmpty(), "No hive connection. Unable to execute queries"); if (!proxy.isPresent()) { Preconditions.checkArgument(this.statementMap.size() == 1, "Multiple Hive connections. Please specify a user"); proxy = Optional.fromNullable(this.statementMap.keySet().iterator().next()); } Statement statement = this.statementMap.get(proxy.get()); for (String query : queries) { statement.execute(query); } }
java
public void executeQueries(List<String> queries, Optional<String> proxy) throws SQLException { Preconditions.checkArgument(!this.statementMap.isEmpty(), "No hive connection. Unable to execute queries"); if (!proxy.isPresent()) { Preconditions.checkArgument(this.statementMap.size() == 1, "Multiple Hive connections. Please specify a user"); proxy = Optional.fromNullable(this.statementMap.keySet().iterator().next()); } Statement statement = this.statementMap.get(proxy.get()); for (String query : queries) { statement.execute(query); } }
[ "public", "void", "executeQueries", "(", "List", "<", "String", ">", "queries", ",", "Optional", "<", "String", ">", "proxy", ")", "throws", "SQLException", "{", "Preconditions", ".", "checkArgument", "(", "!", "this", ".", "statementMap", ".", "isEmpty", "(", ")", ",", "\"No hive connection. Unable to execute queries\"", ")", ";", "if", "(", "!", "proxy", ".", "isPresent", "(", ")", ")", "{", "Preconditions", ".", "checkArgument", "(", "this", ".", "statementMap", ".", "size", "(", ")", "==", "1", ",", "\"Multiple Hive connections. Please specify a user\"", ")", ";", "proxy", "=", "Optional", ".", "fromNullable", "(", "this", ".", "statementMap", ".", "keySet", "(", ")", ".", "iterator", "(", ")", ".", "next", "(", ")", ")", ";", "}", "Statement", "statement", "=", "this", ".", "statementMap", ".", "get", "(", "proxy", ".", "get", "(", ")", ")", ";", "for", "(", "String", "query", ":", "queries", ")", "{", "statement", ".", "execute", "(", "query", ")", ";", "}", "}" ]
Execute queries. @param queries the queries @param proxy the proxy @throws SQLException the sql exception
[ "Execute", "queries", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/HiveProxyQueryExecutor.java#L180-L191
26,019
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/recordcount/IngestionRecordCountProvider.java
IngestionRecordCountProvider.getRecordCount
@Override public long getRecordCount(Path filepath) { String[] components = filepath.getName().split(Pattern.quote(SEPARATOR)); Preconditions.checkArgument(components.length >= 2 && StringUtils.isNumeric(components[components.length - 2]), String.format("Filename %s does not follow the pattern: FILENAME.RECORDCOUNT.EXTENSION", filepath)); return Long.parseLong(components[components.length - 2]); }
java
@Override public long getRecordCount(Path filepath) { String[] components = filepath.getName().split(Pattern.quote(SEPARATOR)); Preconditions.checkArgument(components.length >= 2 && StringUtils.isNumeric(components[components.length - 2]), String.format("Filename %s does not follow the pattern: FILENAME.RECORDCOUNT.EXTENSION", filepath)); return Long.parseLong(components[components.length - 2]); }
[ "@", "Override", "public", "long", "getRecordCount", "(", "Path", "filepath", ")", "{", "String", "[", "]", "components", "=", "filepath", ".", "getName", "(", ")", ".", "split", "(", "Pattern", ".", "quote", "(", "SEPARATOR", ")", ")", ";", "Preconditions", ".", "checkArgument", "(", "components", ".", "length", ">=", "2", "&&", "StringUtils", ".", "isNumeric", "(", "components", "[", "components", ".", "length", "-", "2", "]", ")", ",", "String", ".", "format", "(", "\"Filename %s does not follow the pattern: FILENAME.RECORDCOUNT.EXTENSION\"", ",", "filepath", ")", ")", ";", "return", "Long", ".", "parseLong", "(", "components", "[", "components", ".", "length", "-", "2", "]", ")", ";", "}" ]
The record count should be the last component before the filename extension.
[ "The", "record", "count", "should", "be", "the", "last", "component", "before", "the", "filename", "extension", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/recordcount/IngestionRecordCountProvider.java#L53-L59
26,020
apache/incubator-gobblin
gobblin-modules/gobblin-http/src/main/java/org/apache/gobblin/r2/R2RestRequestBuilder.java
R2RestRequestBuilder.buildWriteRequest
private R2Request<GenericRecord> buildWriteRequest(BufferedRecord<GenericRecord> record) { if (record == null) { return null; } R2Request<GenericRecord> request = new R2Request<>(); HttpOperation httpOperation = HttpUtils.toHttpOperation(record.getRecord()); // Set uri URI uri = HttpUtils.buildURI(urlTemplate, httpOperation.getKeys(), httpOperation.getQueryParams()); if (uri == null) { return null; } RestRequestBuilder builder = new RestRequestBuilder(uri).setMethod(method.getHttpMethod().toString()); // Set headers Map<String, String> headers = httpOperation.getHeaders(); if (headers != null && headers.size() != 0) { builder.setHeaders(headers); } builder.setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, protocolVersion); builder.setHeader(RestConstants.HEADER_RESTLI_REQUEST_METHOD, method.toString()); // Add payload int bytesWritten = addPayload(builder, httpOperation.getBody()); if (bytesWritten == -1) { throw new RuntimeException("Fail to write payload into request"); } request.markRecord(record, bytesWritten); request.setRawRequest(build(builder)); return request; }
java
private R2Request<GenericRecord> buildWriteRequest(BufferedRecord<GenericRecord> record) { if (record == null) { return null; } R2Request<GenericRecord> request = new R2Request<>(); HttpOperation httpOperation = HttpUtils.toHttpOperation(record.getRecord()); // Set uri URI uri = HttpUtils.buildURI(urlTemplate, httpOperation.getKeys(), httpOperation.getQueryParams()); if (uri == null) { return null; } RestRequestBuilder builder = new RestRequestBuilder(uri).setMethod(method.getHttpMethod().toString()); // Set headers Map<String, String> headers = httpOperation.getHeaders(); if (headers != null && headers.size() != 0) { builder.setHeaders(headers); } builder.setHeader(RestConstants.HEADER_RESTLI_PROTOCOL_VERSION, protocolVersion); builder.setHeader(RestConstants.HEADER_RESTLI_REQUEST_METHOD, method.toString()); // Add payload int bytesWritten = addPayload(builder, httpOperation.getBody()); if (bytesWritten == -1) { throw new RuntimeException("Fail to write payload into request"); } request.markRecord(record, bytesWritten); request.setRawRequest(build(builder)); return request; }
[ "private", "R2Request", "<", "GenericRecord", ">", "buildWriteRequest", "(", "BufferedRecord", "<", "GenericRecord", ">", "record", ")", "{", "if", "(", "record", "==", "null", ")", "{", "return", "null", ";", "}", "R2Request", "<", "GenericRecord", ">", "request", "=", "new", "R2Request", "<>", "(", ")", ";", "HttpOperation", "httpOperation", "=", "HttpUtils", ".", "toHttpOperation", "(", "record", ".", "getRecord", "(", ")", ")", ";", "// Set uri", "URI", "uri", "=", "HttpUtils", ".", "buildURI", "(", "urlTemplate", ",", "httpOperation", ".", "getKeys", "(", ")", ",", "httpOperation", ".", "getQueryParams", "(", ")", ")", ";", "if", "(", "uri", "==", "null", ")", "{", "return", "null", ";", "}", "RestRequestBuilder", "builder", "=", "new", "RestRequestBuilder", "(", "uri", ")", ".", "setMethod", "(", "method", ".", "getHttpMethod", "(", ")", ".", "toString", "(", ")", ")", ";", "// Set headers", "Map", "<", "String", ",", "String", ">", "headers", "=", "httpOperation", ".", "getHeaders", "(", ")", ";", "if", "(", "headers", "!=", "null", "&&", "headers", ".", "size", "(", ")", "!=", "0", ")", "{", "builder", ".", "setHeaders", "(", "headers", ")", ";", "}", "builder", ".", "setHeader", "(", "RestConstants", ".", "HEADER_RESTLI_PROTOCOL_VERSION", ",", "protocolVersion", ")", ";", "builder", ".", "setHeader", "(", "RestConstants", ".", "HEADER_RESTLI_REQUEST_METHOD", ",", "method", ".", "toString", "(", ")", ")", ";", "// Add payload", "int", "bytesWritten", "=", "addPayload", "(", "builder", ",", "httpOperation", ".", "getBody", "(", ")", ")", ";", "if", "(", "bytesWritten", "==", "-", "1", ")", "{", "throw", "new", "RuntimeException", "(", "\"Fail to write payload into request\"", ")", ";", "}", "request", ".", "markRecord", "(", "record", ",", "bytesWritten", ")", ";", "request", ".", "setRawRequest", "(", "build", "(", "builder", ")", ")", ";", "return", "request", ";", "}" ]
Build a request from a single record
[ "Build", "a", "request", "from", "a", "single", "record" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-http/src/main/java/org/apache/gobblin/r2/R2RestRequestBuilder.java#L71-L102
26,021
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.createProject
public AzkabanClientStatus createProject(String projectName, String description) throws AzkabanClientException { AzkabanMultiCallables.CreateProjectCallable callable = AzkabanMultiCallables.CreateProjectCallable.builder() .client(this) .projectName(projectName) .description(description) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
java
public AzkabanClientStatus createProject(String projectName, String description) throws AzkabanClientException { AzkabanMultiCallables.CreateProjectCallable callable = AzkabanMultiCallables.CreateProjectCallable.builder() .client(this) .projectName(projectName) .description(description) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
[ "public", "AzkabanClientStatus", "createProject", "(", "String", "projectName", ",", "String", "description", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "CreateProjectCallable", "callable", "=", "AzkabanMultiCallables", ".", "CreateProjectCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "projectName", "(", "projectName", ")", ".", "description", "(", "description", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanClientStatus", ".", "class", ")", ";", "}" ]
Creates a project. @param projectName project name @param description project description @return A status object indicating if AJAX request is successful.
[ "Creates", "a", "project", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L278-L288
26,022
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.deleteProject
public AzkabanClientStatus deleteProject(String projectName) throws AzkabanClientException { AzkabanMultiCallables.DeleteProjectCallable callable = AzkabanMultiCallables.DeleteProjectCallable.builder() .client(this) .projectName(projectName) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
java
public AzkabanClientStatus deleteProject(String projectName) throws AzkabanClientException { AzkabanMultiCallables.DeleteProjectCallable callable = AzkabanMultiCallables.DeleteProjectCallable.builder() .client(this) .projectName(projectName) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
[ "public", "AzkabanClientStatus", "deleteProject", "(", "String", "projectName", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "DeleteProjectCallable", "callable", "=", "AzkabanMultiCallables", ".", "DeleteProjectCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "projectName", "(", "projectName", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanClientStatus", ".", "class", ")", ";", "}" ]
Deletes a project. Currently no response message will be returned after finishing the delete operation. Thus success status is always expected. @param projectName project name @return A status object indicating if AJAX request is successful.
[ "Deletes", "a", "project", ".", "Currently", "no", "response", "message", "will", "be", "returned", "after", "finishing", "the", "delete", "operation", ".", "Thus", "success", "status", "is", "always", "expected", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L298-L307
26,023
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.uploadProjectZip
public AzkabanClientStatus uploadProjectZip(String projectName, File zipFile) throws AzkabanClientException { AzkabanMultiCallables.UploadProjectCallable callable = AzkabanMultiCallables.UploadProjectCallable.builder() .client(this) .projectName(projectName) .zipFile(zipFile) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
java
public AzkabanClientStatus uploadProjectZip(String projectName, File zipFile) throws AzkabanClientException { AzkabanMultiCallables.UploadProjectCallable callable = AzkabanMultiCallables.UploadProjectCallable.builder() .client(this) .projectName(projectName) .zipFile(zipFile) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
[ "public", "AzkabanClientStatus", "uploadProjectZip", "(", "String", "projectName", ",", "File", "zipFile", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "UploadProjectCallable", "callable", "=", "AzkabanMultiCallables", ".", "UploadProjectCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "projectName", "(", "projectName", ")", ".", "zipFile", "(", "zipFile", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanClientStatus", ".", "class", ")", ";", "}" ]
Updates a project by uploading a new zip file. Before uploading any project zip files, the project should be created first. @param projectName project name @param zipFile zip file @return A status object indicating if AJAX request is successful.
[ "Updates", "a", "project", "by", "uploading", "a", "new", "zip", "file", ".", "Before", "uploading", "any", "project", "zip", "files", "the", "project", "should", "be", "created", "first", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L318-L329
26,024
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.executeFlowWithOptions
public AzkabanExecuteFlowStatus executeFlowWithOptions(String projectName, String flowName, Map<String, String> flowOptions, Map<String, String> flowParameters) throws AzkabanClientException { AzkabanMultiCallables.ExecuteFlowCallable callable = AzkabanMultiCallables.ExecuteFlowCallable.builder() .client(this) .projectName(projectName) .flowName(flowName) .flowOptions(flowOptions) .flowParameters(flowParameters) .build(); return runWithRetry(callable, AzkabanExecuteFlowStatus.class); }
java
public AzkabanExecuteFlowStatus executeFlowWithOptions(String projectName, String flowName, Map<String, String> flowOptions, Map<String, String> flowParameters) throws AzkabanClientException { AzkabanMultiCallables.ExecuteFlowCallable callable = AzkabanMultiCallables.ExecuteFlowCallable.builder() .client(this) .projectName(projectName) .flowName(flowName) .flowOptions(flowOptions) .flowParameters(flowParameters) .build(); return runWithRetry(callable, AzkabanExecuteFlowStatus.class); }
[ "public", "AzkabanExecuteFlowStatus", "executeFlowWithOptions", "(", "String", "projectName", ",", "String", "flowName", ",", "Map", "<", "String", ",", "String", ">", "flowOptions", ",", "Map", "<", "String", ",", "String", ">", "flowParameters", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "ExecuteFlowCallable", "callable", "=", "AzkabanMultiCallables", ".", "ExecuteFlowCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "projectName", "(", "projectName", ")", ".", "flowName", "(", "flowName", ")", ".", "flowOptions", "(", "flowOptions", ")", ".", "flowParameters", "(", "flowParameters", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanExecuteFlowStatus", ".", "class", ")", ";", "}" ]
Execute a flow by providing flow parameters and options. The project and flow should be created first. @param projectName project name @param flowName flow name @param flowOptions flow options @param flowParameters flow parameters @return The status object which contains success status and execution id.
[ "Execute", "a", "flow", "by", "providing", "flow", "parameters", "and", "options", ".", "The", "project", "and", "flow", "should", "be", "created", "first", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L341-L355
26,025
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.executeFlow
public AzkabanExecuteFlowStatus executeFlow(String projectName, String flowName, Map<String, String> flowParameters) throws AzkabanClientException { return executeFlowWithOptions(projectName, flowName, null, flowParameters); }
java
public AzkabanExecuteFlowStatus executeFlow(String projectName, String flowName, Map<String, String> flowParameters) throws AzkabanClientException { return executeFlowWithOptions(projectName, flowName, null, flowParameters); }
[ "public", "AzkabanExecuteFlowStatus", "executeFlow", "(", "String", "projectName", ",", "String", "flowName", ",", "Map", "<", "String", ",", "String", ">", "flowParameters", ")", "throws", "AzkabanClientException", "{", "return", "executeFlowWithOptions", "(", "projectName", ",", "flowName", ",", "null", ",", "flowParameters", ")", ";", "}" ]
Execute a flow with flow parameters. The project and flow should be created first. @param projectName project name @param flowName flow name @param flowParameters flow parameters @return The status object which contains success status and execution id.
[ "Execute", "a", "flow", "with", "flow", "parameters", ".", "The", "project", "and", "flow", "should", "be", "created", "first", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L366-L370
26,026
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.cancelFlow
public AzkabanClientStatus cancelFlow(String execId) throws AzkabanClientException { AzkabanMultiCallables.CancelFlowCallable callable = AzkabanMultiCallables.CancelFlowCallable.builder() .client(this) .execId(execId) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
java
public AzkabanClientStatus cancelFlow(String execId) throws AzkabanClientException { AzkabanMultiCallables.CancelFlowCallable callable = AzkabanMultiCallables.CancelFlowCallable.builder() .client(this) .execId(execId) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
[ "public", "AzkabanClientStatus", "cancelFlow", "(", "String", "execId", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "CancelFlowCallable", "callable", "=", "AzkabanMultiCallables", ".", "CancelFlowCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "execId", "(", "execId", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanClientStatus", ".", "class", ")", ";", "}" ]
Cancel a flow by execution id.
[ "Cancel", "a", "flow", "by", "execution", "id", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L375-L383
26,027
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.fetchExecutionLog
public AzkabanClientStatus fetchExecutionLog(String execId, String jobId, String offset, String length, File ouf) throws AzkabanClientException { AzkabanMultiCallables.FetchExecLogCallable callable = AzkabanMultiCallables.FetchExecLogCallable.builder() .client(this) .execId(execId) .jobId(jobId) .offset(offset) .length(length) .output(ouf) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
java
public AzkabanClientStatus fetchExecutionLog(String execId, String jobId, String offset, String length, File ouf) throws AzkabanClientException { AzkabanMultiCallables.FetchExecLogCallable callable = AzkabanMultiCallables.FetchExecLogCallable.builder() .client(this) .execId(execId) .jobId(jobId) .offset(offset) .length(length) .output(ouf) .build(); return runWithRetry(callable, AzkabanClientStatus.class); }
[ "public", "AzkabanClientStatus", "fetchExecutionLog", "(", "String", "execId", ",", "String", "jobId", ",", "String", "offset", ",", "String", "length", ",", "File", "ouf", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "FetchExecLogCallable", "callable", "=", "AzkabanMultiCallables", ".", "FetchExecLogCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "execId", "(", "execId", ")", ".", "jobId", "(", "jobId", ")", ".", "offset", "(", "offset", ")", ".", "length", "(", "length", ")", ".", "output", "(", "ouf", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanClientStatus", ".", "class", ")", ";", "}" ]
Fetch an execution log.
[ "Fetch", "an", "execution", "log", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L388-L404
26,028
apache/incubator-gobblin
gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java
AzkabanClient.fetchFlowExecution
public AzkabanFetchExecuteFlowStatus fetchFlowExecution(String execId) throws AzkabanClientException { AzkabanMultiCallables.FetchFlowExecCallable callable = AzkabanMultiCallables.FetchFlowExecCallable.builder() .client(this) .execId(execId) .build(); return runWithRetry(callable, AzkabanFetchExecuteFlowStatus.class); }
java
public AzkabanFetchExecuteFlowStatus fetchFlowExecution(String execId) throws AzkabanClientException { AzkabanMultiCallables.FetchFlowExecCallable callable = AzkabanMultiCallables.FetchFlowExecCallable.builder() .client(this) .execId(execId) .build(); return runWithRetry(callable, AzkabanFetchExecuteFlowStatus.class); }
[ "public", "AzkabanFetchExecuteFlowStatus", "fetchFlowExecution", "(", "String", "execId", ")", "throws", "AzkabanClientException", "{", "AzkabanMultiCallables", ".", "FetchFlowExecCallable", "callable", "=", "AzkabanMultiCallables", ".", "FetchFlowExecCallable", ".", "builder", "(", ")", ".", "client", "(", "this", ")", ".", "execId", "(", "execId", ")", ".", "build", "(", ")", ";", "return", "runWithRetry", "(", "callable", ",", "AzkabanFetchExecuteFlowStatus", ".", "class", ")", ";", "}" ]
Given an execution id, fetches all the detailed information of that execution, including a list of all the job executions. @param execId execution id to be fetched. @return The status object which contains success status and all the detailed information of that execution.
[ "Given", "an", "execution", "id", "fetches", "all", "the", "detailed", "information", "of", "that", "execution", "including", "a", "list", "of", "all", "the", "job", "executions", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-azkaban/src/main/java/org/apache/gobblin/service/modules/orchestration/AzkabanClient.java#L415-L423
26,029
apache/incubator-gobblin
gobblin-modules/gobblin-eventhub/src/main/java/org/apache/gobblin/eventhub/writer/EventhubDataWriterBuilder.java
EventhubDataWriterBuilder.getAsyncDataWriter
public AsyncDataWriter getAsyncDataWriter(Properties properties) { EventhubDataWriter eventhubDataWriter = new EventhubDataWriter(properties); EventhubBatchAccumulator accumulator = new EventhubBatchAccumulator(properties); BatchedEventhubDataWriter batchedEventhubDataWriter = new BatchedEventhubDataWriter(accumulator, eventhubDataWriter); return batchedEventhubDataWriter; }
java
public AsyncDataWriter getAsyncDataWriter(Properties properties) { EventhubDataWriter eventhubDataWriter = new EventhubDataWriter(properties); EventhubBatchAccumulator accumulator = new EventhubBatchAccumulator(properties); BatchedEventhubDataWriter batchedEventhubDataWriter = new BatchedEventhubDataWriter(accumulator, eventhubDataWriter); return batchedEventhubDataWriter; }
[ "public", "AsyncDataWriter", "getAsyncDataWriter", "(", "Properties", "properties", ")", "{", "EventhubDataWriter", "eventhubDataWriter", "=", "new", "EventhubDataWriter", "(", "properties", ")", ";", "EventhubBatchAccumulator", "accumulator", "=", "new", "EventhubBatchAccumulator", "(", "properties", ")", ";", "BatchedEventhubDataWriter", "batchedEventhubDataWriter", "=", "new", "BatchedEventhubDataWriter", "(", "accumulator", ",", "eventhubDataWriter", ")", ";", "return", "batchedEventhubDataWriter", ";", "}" ]
Create an eventhub data writer, wrapped into a buffered async data writer
[ "Create", "an", "eventhub", "data", "writer", "wrapped", "into", "a", "buffered", "async", "data", "writer" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-eventhub/src/main/java/org/apache/gobblin/eventhub/writer/EventhubDataWriterBuilder.java#L42-L47
26,030
apache/incubator-gobblin
gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-server/src/main/java/org/apache/gobblin/restli/throttling/DynamicTokenBucket.java
DynamicTokenBucket.getPermitsAndDelay
public PermitsAndDelay getPermitsAndDelay(long requestedPermits, long minPermits, long timeoutMillis) { try { long storedTokens = this.tokenBucket.getStoredTokens(); long eagerTokens = storedTokens / 2; if (eagerTokens > requestedPermits && this.tokenBucket.getTokens(eagerTokens, 0, TimeUnit.MILLISECONDS)) { return new PermitsAndDelay(eagerTokens, 0, true); } long millisToSatisfyMinPermits = (long) (minPermits / this.tokenBucket.getTokensPerMilli()); if (millisToSatisfyMinPermits > timeoutMillis) { return new PermitsAndDelay(0, 0, false); } long allowedTimeout = Math.min(millisToSatisfyMinPermits + this.baseTimeout, timeoutMillis); while (requestedPermits > minPermits) { long wait = this.tokenBucket.tryReserveTokens(requestedPermits, allowedTimeout); if (wait >= 0) { return new PermitsAndDelay(requestedPermits, wait, true); } requestedPermits /= 2; } long wait = this.tokenBucket.tryReserveTokens(minPermits, allowedTimeout); if (wait >= 0) { return new PermitsAndDelay(requestedPermits, wait, true); } } catch (InterruptedException ie) { // Fallback to returning 0 } return new PermitsAndDelay(0, 0, true); }
java
public PermitsAndDelay getPermitsAndDelay(long requestedPermits, long minPermits, long timeoutMillis) { try { long storedTokens = this.tokenBucket.getStoredTokens(); long eagerTokens = storedTokens / 2; if (eagerTokens > requestedPermits && this.tokenBucket.getTokens(eagerTokens, 0, TimeUnit.MILLISECONDS)) { return new PermitsAndDelay(eagerTokens, 0, true); } long millisToSatisfyMinPermits = (long) (minPermits / this.tokenBucket.getTokensPerMilli()); if (millisToSatisfyMinPermits > timeoutMillis) { return new PermitsAndDelay(0, 0, false); } long allowedTimeout = Math.min(millisToSatisfyMinPermits + this.baseTimeout, timeoutMillis); while (requestedPermits > minPermits) { long wait = this.tokenBucket.tryReserveTokens(requestedPermits, allowedTimeout); if (wait >= 0) { return new PermitsAndDelay(requestedPermits, wait, true); } requestedPermits /= 2; } long wait = this.tokenBucket.tryReserveTokens(minPermits, allowedTimeout); if (wait >= 0) { return new PermitsAndDelay(requestedPermits, wait, true); } } catch (InterruptedException ie) { // Fallback to returning 0 } return new PermitsAndDelay(0, 0, true); }
[ "public", "PermitsAndDelay", "getPermitsAndDelay", "(", "long", "requestedPermits", ",", "long", "minPermits", ",", "long", "timeoutMillis", ")", "{", "try", "{", "long", "storedTokens", "=", "this", ".", "tokenBucket", ".", "getStoredTokens", "(", ")", ";", "long", "eagerTokens", "=", "storedTokens", "/", "2", ";", "if", "(", "eagerTokens", ">", "requestedPermits", "&&", "this", ".", "tokenBucket", ".", "getTokens", "(", "eagerTokens", ",", "0", ",", "TimeUnit", ".", "MILLISECONDS", ")", ")", "{", "return", "new", "PermitsAndDelay", "(", "eagerTokens", ",", "0", ",", "true", ")", ";", "}", "long", "millisToSatisfyMinPermits", "=", "(", "long", ")", "(", "minPermits", "/", "this", ".", "tokenBucket", ".", "getTokensPerMilli", "(", ")", ")", ";", "if", "(", "millisToSatisfyMinPermits", ">", "timeoutMillis", ")", "{", "return", "new", "PermitsAndDelay", "(", "0", ",", "0", ",", "false", ")", ";", "}", "long", "allowedTimeout", "=", "Math", ".", "min", "(", "millisToSatisfyMinPermits", "+", "this", ".", "baseTimeout", ",", "timeoutMillis", ")", ";", "while", "(", "requestedPermits", ">", "minPermits", ")", "{", "long", "wait", "=", "this", ".", "tokenBucket", ".", "tryReserveTokens", "(", "requestedPermits", ",", "allowedTimeout", ")", ";", "if", "(", "wait", ">=", "0", ")", "{", "return", "new", "PermitsAndDelay", "(", "requestedPermits", ",", "wait", ",", "true", ")", ";", "}", "requestedPermits", "/=", "2", ";", "}", "long", "wait", "=", "this", ".", "tokenBucket", ".", "tryReserveTokens", "(", "minPermits", ",", "allowedTimeout", ")", ";", "if", "(", "wait", ">=", "0", ")", "{", "return", "new", "PermitsAndDelay", "(", "requestedPermits", ",", "wait", ",", "true", ")", ";", "}", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "// Fallback to returning 0", "}", "return", "new", "PermitsAndDelay", "(", "0", ",", "0", ",", "true", ")", ";", "}" ]
Request tokens. @param requestedPermits the ideal number of tokens to acquire. @param minPermits the minimum number of tokens useful for the calling process. If this many tokens cannot be acquired, the method will return 0 instead, @param timeoutMillis the maximum wait the calling process is willing to wait for tokens. @return a {@link PermitsAndDelay} for the allocated permits.
[ "Request", "tokens", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-throttling-service/gobblin-throttling-service-server/src/main/java/org/apache/gobblin/restli/throttling/DynamicTokenBucket.java#L79-L112
26,031
apache/incubator-gobblin
gobblin-modules/gobblin-crypto-provider/src/main/java/org/apache/gobblin/crypto/GobblinEncryptionProvider.java
GobblinEncryptionProvider.buildStreamEncryptor
public StreamCodec buildStreamEncryptor(Map<String, Object> parameters) { String encryptionType = EncryptionConfigParser.getEncryptionType(parameters); if (encryptionType == null) { throw new IllegalArgumentException("Encryption type not present in parameters!"); } return buildStreamCryptoProvider(encryptionType, parameters); }
java
public StreamCodec buildStreamEncryptor(Map<String, Object> parameters) { String encryptionType = EncryptionConfigParser.getEncryptionType(parameters); if (encryptionType == null) { throw new IllegalArgumentException("Encryption type not present in parameters!"); } return buildStreamCryptoProvider(encryptionType, parameters); }
[ "public", "StreamCodec", "buildStreamEncryptor", "(", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "String", "encryptionType", "=", "EncryptionConfigParser", ".", "getEncryptionType", "(", "parameters", ")", ";", "if", "(", "encryptionType", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Encryption type not present in parameters!\"", ")", ";", "}", "return", "buildStreamCryptoProvider", "(", "encryptionType", ",", "parameters", ")", ";", "}" ]
Return a StreamEncryptor for the given parameters. The algorithm type to use will be extracted from the parameters object. @param parameters Configured parameters for algorithm. @return A StreamCodec for the requested algorithm @throws IllegalArgumentException If the given algorithm/parameter pair cannot be built
[ "Return", "a", "StreamEncryptor", "for", "the", "given", "parameters", ".", "The", "algorithm", "type", "to", "use", "will", "be", "extracted", "from", "the", "parameters", "object", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto-provider/src/main/java/org/apache/gobblin/crypto/GobblinEncryptionProvider.java#L60-L67
26,032
apache/incubator-gobblin
gobblin-modules/gobblin-crypto-provider/src/main/java/org/apache/gobblin/crypto/GobblinEncryptionProvider.java
GobblinEncryptionProvider.buildCredentialStore
public CredentialStore buildCredentialStore(Map<String, Object> parameters) { String ks_type = EncryptionConfigParser.getKeystoreType(parameters); String ks_path = EncryptionConfigParser.getKeystorePath(parameters); String ks_password = EncryptionConfigParser.getKeystorePassword(parameters); try { switch (ks_type) { // TODO this is yet another example of building a broad type (CredentialStore) based on a human-readable name // (json) with a bag of parameters. Need to pull out into its own pattern! case JCEKSKeystoreCredentialStore.TAG: return new JCEKSKeystoreCredentialStore(ks_path, ks_password); case JsonCredentialStore.TAG: return new JsonCredentialStore(ks_path, buildKeyToStringCodec(parameters)); default: return null; } } catch (IOException e) { log.error("Error building credential store, returning null", e); return null; } }
java
public CredentialStore buildCredentialStore(Map<String, Object> parameters) { String ks_type = EncryptionConfigParser.getKeystoreType(parameters); String ks_path = EncryptionConfigParser.getKeystorePath(parameters); String ks_password = EncryptionConfigParser.getKeystorePassword(parameters); try { switch (ks_type) { // TODO this is yet another example of building a broad type (CredentialStore) based on a human-readable name // (json) with a bag of parameters. Need to pull out into its own pattern! case JCEKSKeystoreCredentialStore.TAG: return new JCEKSKeystoreCredentialStore(ks_path, ks_password); case JsonCredentialStore.TAG: return new JsonCredentialStore(ks_path, buildKeyToStringCodec(parameters)); default: return null; } } catch (IOException e) { log.error("Error building credential store, returning null", e); return null; } }
[ "public", "CredentialStore", "buildCredentialStore", "(", "Map", "<", "String", ",", "Object", ">", "parameters", ")", "{", "String", "ks_type", "=", "EncryptionConfigParser", ".", "getKeystoreType", "(", "parameters", ")", ";", "String", "ks_path", "=", "EncryptionConfigParser", ".", "getKeystorePath", "(", "parameters", ")", ";", "String", "ks_password", "=", "EncryptionConfigParser", ".", "getKeystorePassword", "(", "parameters", ")", ";", "try", "{", "switch", "(", "ks_type", ")", "{", "// TODO this is yet another example of building a broad type (CredentialStore) based on a human-readable name", "// (json) with a bag of parameters. Need to pull out into its own pattern!", "case", "JCEKSKeystoreCredentialStore", ".", "TAG", ":", "return", "new", "JCEKSKeystoreCredentialStore", "(", "ks_path", ",", "ks_password", ")", ";", "case", "JsonCredentialStore", ".", "TAG", ":", "return", "new", "JsonCredentialStore", "(", "ks_path", ",", "buildKeyToStringCodec", "(", "parameters", ")", ")", ";", "default", ":", "return", "null", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "log", ".", "error", "(", "\"Error building credential store, returning null\"", ",", "e", ")", ";", "return", "null", ";", "}", "}" ]
Build a credential store with the given parameters.
[ "Build", "a", "credential", "store", "with", "the", "given", "parameters", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-crypto-provider/src/main/java/org/apache/gobblin/crypto/GobblinEncryptionProvider.java#L111-L131
26,033
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java
ContentTypeUtils.getCharset
public String getCharset(String contentType) { String charSet = knownCharsets.get(contentType); if (charSet != null) { return charSet; } // Special cases if (contentType.startsWith("text/") || contentType.endsWith("+json") || contentType.endsWith("+xml")) { return "UTF-8"; } return "BINARY"; }
java
public String getCharset(String contentType) { String charSet = knownCharsets.get(contentType); if (charSet != null) { return charSet; } // Special cases if (contentType.startsWith("text/") || contentType.endsWith("+json") || contentType.endsWith("+xml")) { return "UTF-8"; } return "BINARY"; }
[ "public", "String", "getCharset", "(", "String", "contentType", ")", "{", "String", "charSet", "=", "knownCharsets", ".", "get", "(", "contentType", ")", ";", "if", "(", "charSet", "!=", "null", ")", "{", "return", "charSet", ";", "}", "// Special cases", "if", "(", "contentType", ".", "startsWith", "(", "\"text/\"", ")", "||", "contentType", ".", "endsWith", "(", "\"+json\"", ")", "||", "contentType", ".", "endsWith", "(", "\"+xml\"", ")", ")", "{", "return", "\"UTF-8\"", ";", "}", "return", "\"BINARY\"", ";", "}" ]
Check which character set a given content-type corresponds to. @param contentType Content-type to check @return Charset the mimetype represents. "BINARY" if binary data.
[ "Check", "which", "character", "set", "a", "given", "content", "-", "type", "corresponds", "to", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java#L45-L57
26,034
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java
ContentTypeUtils.inferPrintableFromMetadata
public boolean inferPrintableFromMetadata(Metadata md) { String inferredCharset = "BINARY"; List<String> transferEncoding = md.getGlobalMetadata().getTransferEncoding(); if (transferEncoding != null) { inferredCharset = getCharset(transferEncoding.get(transferEncoding.size() - 1)); } else if (md.getGlobalMetadata().getContentType() != null) { inferredCharset = getCharset(md.getGlobalMetadata().getContentType()); } return inferredCharset.equals("UTF-8"); }
java
public boolean inferPrintableFromMetadata(Metadata md) { String inferredCharset = "BINARY"; List<String> transferEncoding = md.getGlobalMetadata().getTransferEncoding(); if (transferEncoding != null) { inferredCharset = getCharset(transferEncoding.get(transferEncoding.size() - 1)); } else if (md.getGlobalMetadata().getContentType() != null) { inferredCharset = getCharset(md.getGlobalMetadata().getContentType()); } return inferredCharset.equals("UTF-8"); }
[ "public", "boolean", "inferPrintableFromMetadata", "(", "Metadata", "md", ")", "{", "String", "inferredCharset", "=", "\"BINARY\"", ";", "List", "<", "String", ">", "transferEncoding", "=", "md", ".", "getGlobalMetadata", "(", ")", ".", "getTransferEncoding", "(", ")", ";", "if", "(", "transferEncoding", "!=", "null", ")", "{", "inferredCharset", "=", "getCharset", "(", "transferEncoding", ".", "get", "(", "transferEncoding", ".", "size", "(", ")", "-", "1", ")", ")", ";", "}", "else", "if", "(", "md", ".", "getGlobalMetadata", "(", ")", ".", "getContentType", "(", ")", "!=", "null", ")", "{", "inferredCharset", "=", "getCharset", "(", "md", ".", "getGlobalMetadata", "(", ")", ".", "getContentType", "(", ")", ")", ";", "}", "return", "inferredCharset", ".", "equals", "(", "\"UTF-8\"", ")", ";", "}" ]
Heuristic to infer if content is printable from metadata.
[ "Heuristic", "to", "infer", "if", "content", "is", "printable", "from", "metadata", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java#L62-L73
26,035
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java
ContentTypeUtils.registerCharsetMapping
public void registerCharsetMapping(String contentType, String charSet) { if (knownCharsets.contains(contentType)) { log.warn("{} is already registered; re-registering"); } knownCharsets.put(contentType, charSet); }
java
public void registerCharsetMapping(String contentType, String charSet) { if (knownCharsets.contains(contentType)) { log.warn("{} is already registered; re-registering"); } knownCharsets.put(contentType, charSet); }
[ "public", "void", "registerCharsetMapping", "(", "String", "contentType", ",", "String", "charSet", ")", "{", "if", "(", "knownCharsets", ".", "contains", "(", "contentType", ")", ")", "{", "log", ".", "warn", "(", "\"{} is already registered; re-registering\"", ")", ";", "}", "knownCharsets", ".", "put", "(", "contentType", ",", "charSet", ")", ";", "}" ]
Register a new contentType to charSet mapping. @param contentType Content-type to register @param charSet charSet associated with the content-type
[ "Register", "a", "new", "contentType", "to", "charSet", "mapping", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/type/ContentTypeUtils.java#L80-L86
26,036
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/CompactionAuditCountVerifier.java
CompactionAuditCountVerifier.getClientFactory
private static AuditCountClientFactory getClientFactory (State state) { if (!state.contains(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY)) { return new EmptyAuditCountClientFactory (); } try { String factoryName = state.getProp(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY); ClassAliasResolver<AuditCountClientFactory> conditionClassAliasResolver = new ClassAliasResolver<>(AuditCountClientFactory.class); AuditCountClientFactory factory = conditionClassAliasResolver.resolveClass(factoryName).newInstance(); return factory; } catch (Exception e) { throw new RuntimeException(e); } }
java
private static AuditCountClientFactory getClientFactory (State state) { if (!state.contains(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY)) { return new EmptyAuditCountClientFactory (); } try { String factoryName = state.getProp(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY); ClassAliasResolver<AuditCountClientFactory> conditionClassAliasResolver = new ClassAliasResolver<>(AuditCountClientFactory.class); AuditCountClientFactory factory = conditionClassAliasResolver.resolveClass(factoryName).newInstance(); return factory; } catch (Exception e) { throw new RuntimeException(e); } }
[ "private", "static", "AuditCountClientFactory", "getClientFactory", "(", "State", "state", ")", "{", "if", "(", "!", "state", ".", "contains", "(", "AuditCountClientFactory", ".", "AUDIT_COUNT_CLIENT_FACTORY", ")", ")", "{", "return", "new", "EmptyAuditCountClientFactory", "(", ")", ";", "}", "try", "{", "String", "factoryName", "=", "state", ".", "getProp", "(", "AuditCountClientFactory", ".", "AUDIT_COUNT_CLIENT_FACTORY", ")", ";", "ClassAliasResolver", "<", "AuditCountClientFactory", ">", "conditionClassAliasResolver", "=", "new", "ClassAliasResolver", "<>", "(", "AuditCountClientFactory", ".", "class", ")", ";", "AuditCountClientFactory", "factory", "=", "conditionClassAliasResolver", ".", "resolveClass", "(", "factoryName", ")", ".", "newInstance", "(", ")", ";", "return", "factory", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Obtain a client factory @param state job state @return a factory which creates {@link AuditCountClient}. If no factory is set or an error occurred, a {@link EmptyAuditCountClientFactory} is returned which creates a <code>null</code> {@link AuditCountClient}
[ "Obtain", "a", "client", "factory" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/CompactionAuditCountVerifier.java#L95-L109
26,037
apache/incubator-gobblin
gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java
GoogleCommon.buildCredentialFromP12
private static Credential buildCredentialFromP12(String privateKeyPath, Optional<String> fsUri, Optional<String> id, HttpTransport transport, Collection<String> serviceAccountScopes) throws IOException, GeneralSecurityException { Preconditions.checkArgument(id.isPresent(), "user id is required."); FileSystem fs = getFileSystem(fsUri); Path keyPath = getPrivateKey(fs, privateKeyPath); final File localCopied = copyToLocal(fs, keyPath); localCopied.deleteOnExit(); try { return new GoogleCredential.Builder() .setTransport(transport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(id.get()) .setServiceAccountPrivateKeyFromP12File(localCopied) .setServiceAccountScopes(serviceAccountScopes) .build(); } finally { boolean isDeleted = localCopied.delete(); if (!isDeleted) { throw new RuntimeException(localCopied.getAbsolutePath() + " has not been deleted."); } } }
java
private static Credential buildCredentialFromP12(String privateKeyPath, Optional<String> fsUri, Optional<String> id, HttpTransport transport, Collection<String> serviceAccountScopes) throws IOException, GeneralSecurityException { Preconditions.checkArgument(id.isPresent(), "user id is required."); FileSystem fs = getFileSystem(fsUri); Path keyPath = getPrivateKey(fs, privateKeyPath); final File localCopied = copyToLocal(fs, keyPath); localCopied.deleteOnExit(); try { return new GoogleCredential.Builder() .setTransport(transport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(id.get()) .setServiceAccountPrivateKeyFromP12File(localCopied) .setServiceAccountScopes(serviceAccountScopes) .build(); } finally { boolean isDeleted = localCopied.delete(); if (!isDeleted) { throw new RuntimeException(localCopied.getAbsolutePath() + " has not been deleted."); } } }
[ "private", "static", "Credential", "buildCredentialFromP12", "(", "String", "privateKeyPath", ",", "Optional", "<", "String", ">", "fsUri", ",", "Optional", "<", "String", ">", "id", ",", "HttpTransport", "transport", ",", "Collection", "<", "String", ">", "serviceAccountScopes", ")", "throws", "IOException", ",", "GeneralSecurityException", "{", "Preconditions", ".", "checkArgument", "(", "id", ".", "isPresent", "(", ")", ",", "\"user id is required.\"", ")", ";", "FileSystem", "fs", "=", "getFileSystem", "(", "fsUri", ")", ";", "Path", "keyPath", "=", "getPrivateKey", "(", "fs", ",", "privateKeyPath", ")", ";", "final", "File", "localCopied", "=", "copyToLocal", "(", "fs", ",", "keyPath", ")", ";", "localCopied", ".", "deleteOnExit", "(", ")", ";", "try", "{", "return", "new", "GoogleCredential", ".", "Builder", "(", ")", ".", "setTransport", "(", "transport", ")", ".", "setJsonFactory", "(", "JSON_FACTORY", ")", ".", "setServiceAccountId", "(", "id", ".", "get", "(", ")", ")", ".", "setServiceAccountPrivateKeyFromP12File", "(", "localCopied", ")", ".", "setServiceAccountScopes", "(", "serviceAccountScopes", ")", ".", "build", "(", ")", ";", "}", "finally", "{", "boolean", "isDeleted", "=", "localCopied", ".", "delete", "(", ")", ";", "if", "(", "!", "isDeleted", ")", "{", "throw", "new", "RuntimeException", "(", "localCopied", ".", "getAbsolutePath", "(", ")", "+", "\" has not been deleted.\"", ")", ";", "}", "}", "}" ]
As Google API only accepts java.io.File for private key, and this method copies private key into local file system. Once Google credential is instantiated, it deletes copied private key file. @param privateKeyPath @param fsUri @param id @param transport @param serviceAccountScopes @return Credential @throws IOException @throws GeneralSecurityException
[ "As", "Google", "API", "only", "accepts", "java", ".", "io", ".", "File", "for", "private", "key", "and", "this", "method", "copies", "private", "key", "into", "local", "file", "system", ".", "Once", "Google", "credential", "is", "instantiated", "it", "deletes", "copied", "private", "key", "file", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java#L145-L171
26,038
apache/incubator-gobblin
gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java
GoogleCommon.getPrivateKey
private static Path getPrivateKey(FileSystem fs, String privateKeyPath) throws IOException { Path keyPath = new Path(privateKeyPath); FileStatus fileStatus = fs.getFileStatus(keyPath); Preconditions.checkArgument(USER_READ_PERMISSION_ONLY.equals(fileStatus.getPermission()), "Private key file should only have read only permission only on user. " + keyPath); return keyPath; }
java
private static Path getPrivateKey(FileSystem fs, String privateKeyPath) throws IOException { Path keyPath = new Path(privateKeyPath); FileStatus fileStatus = fs.getFileStatus(keyPath); Preconditions.checkArgument(USER_READ_PERMISSION_ONLY.equals(fileStatus.getPermission()), "Private key file should only have read only permission only on user. " + keyPath); return keyPath; }
[ "private", "static", "Path", "getPrivateKey", "(", "FileSystem", "fs", ",", "String", "privateKeyPath", ")", "throws", "IOException", "{", "Path", "keyPath", "=", "new", "Path", "(", "privateKeyPath", ")", ";", "FileStatus", "fileStatus", "=", "fs", ".", "getFileStatus", "(", "keyPath", ")", ";", "Preconditions", ".", "checkArgument", "(", "USER_READ_PERMISSION_ONLY", ".", "equals", "(", "fileStatus", ".", "getPermission", "(", ")", ")", ",", "\"Private key file should only have read only permission only on user. \"", "+", "keyPath", ")", ";", "return", "keyPath", ";", "}" ]
Before retrieving private key, it makes sure that original private key's permission is read only on the owner. This is a way to ensure to keep private key private. @param fs @param privateKeyPath @return @throws IOException
[ "Before", "retrieving", "private", "key", "it", "makes", "sure", "that", "original", "private", "key", "s", "permission", "is", "read", "only", "on", "the", "owner", ".", "This", "is", "a", "way", "to", "ensure", "to", "keep", "private", "key", "private", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java#L181-L187
26,039
apache/incubator-gobblin
gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java
GoogleCommon.newTransport
public static HttpTransport newTransport(String proxyUrl, String portStr) throws NumberFormatException, GeneralSecurityException, IOException { if (!StringUtils.isEmpty(proxyUrl) && !StringUtils.isEmpty(portStr)) { return new NetHttpTransport.Builder() .trustCertificates(GoogleUtils.getCertificateTrustStore()) .setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUrl, Integer.parseInt(portStr)))) .build(); } return GoogleNetHttpTransport.newTrustedTransport(); }
java
public static HttpTransport newTransport(String proxyUrl, String portStr) throws NumberFormatException, GeneralSecurityException, IOException { if (!StringUtils.isEmpty(proxyUrl) && !StringUtils.isEmpty(portStr)) { return new NetHttpTransport.Builder() .trustCertificates(GoogleUtils.getCertificateTrustStore()) .setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUrl, Integer.parseInt(portStr)))) .build(); } return GoogleNetHttpTransport.newTrustedTransport(); }
[ "public", "static", "HttpTransport", "newTransport", "(", "String", "proxyUrl", ",", "String", "portStr", ")", "throws", "NumberFormatException", ",", "GeneralSecurityException", ",", "IOException", "{", "if", "(", "!", "StringUtils", ".", "isEmpty", "(", "proxyUrl", ")", "&&", "!", "StringUtils", ".", "isEmpty", "(", "portStr", ")", ")", "{", "return", "new", "NetHttpTransport", ".", "Builder", "(", ")", ".", "trustCertificates", "(", "GoogleUtils", ".", "getCertificateTrustStore", "(", ")", ")", ".", "setProxy", "(", "new", "Proxy", "(", "Proxy", ".", "Type", ".", "HTTP", ",", "new", "InetSocketAddress", "(", "proxyUrl", ",", "Integer", ".", "parseInt", "(", "portStr", ")", ")", ")", ")", ".", "build", "(", ")", ";", "}", "return", "GoogleNetHttpTransport", ".", "newTrustedTransport", "(", ")", ";", "}" ]
Provides HttpTransport. If both proxyUrl and postStr is defined, it provides transport with Proxy. @param proxyUrl Optional. @param portStr Optional. String type for port so that user can easily pass null. (e.g: state.getProp(key)) @return @throws NumberFormatException @throws GeneralSecurityException @throws IOException
[ "Provides", "HttpTransport", ".", "If", "both", "proxyUrl", "and", "postStr", "is", "defined", "it", "provides", "transport", "with", "Proxy", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/google-ingestion/src/main/java/org/apache/gobblin/source/extractor/extract/google/GoogleCommon.java#L218-L226
26,040
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.mrMode
public EmbeddedGobblin mrMode() throws IOException { this.sysConfigOverrides.put(ConfigurationKeys.JOB_LAUNCHER_TYPE_KEY, JobLauncherFactory.JobLauncherType.MAPREDUCE.name()); this.builtConfigMap.put(ConfigurationKeys.FS_URI_KEY, FileSystem.get(new Configuration()).getUri().toString()); this.builtConfigMap.put(ConfigurationKeys.MR_JOB_ROOT_DIR_KEY, "/tmp/EmbeddedGobblin_" + System.currentTimeMillis()); this.distributeJarsFunction = new Runnable() { @Override public void run() { // Add jars needed at runtime to the sys config so MR job launcher will add them to distributed cache. EmbeddedGobblin.this.sysConfigOverrides.put(ConfigurationKeys.JOB_JAR_FILES_KEY, Joiner.on(",").join(getPrioritizedDistributedJars())); } }; return this; }
java
public EmbeddedGobblin mrMode() throws IOException { this.sysConfigOverrides.put(ConfigurationKeys.JOB_LAUNCHER_TYPE_KEY, JobLauncherFactory.JobLauncherType.MAPREDUCE.name()); this.builtConfigMap.put(ConfigurationKeys.FS_URI_KEY, FileSystem.get(new Configuration()).getUri().toString()); this.builtConfigMap.put(ConfigurationKeys.MR_JOB_ROOT_DIR_KEY, "/tmp/EmbeddedGobblin_" + System.currentTimeMillis()); this.distributeJarsFunction = new Runnable() { @Override public void run() { // Add jars needed at runtime to the sys config so MR job launcher will add them to distributed cache. EmbeddedGobblin.this.sysConfigOverrides.put(ConfigurationKeys.JOB_JAR_FILES_KEY, Joiner.on(",").join(getPrioritizedDistributedJars())); } }; return this; }
[ "public", "EmbeddedGobblin", "mrMode", "(", ")", "throws", "IOException", "{", "this", ".", "sysConfigOverrides", ".", "put", "(", "ConfigurationKeys", ".", "JOB_LAUNCHER_TYPE_KEY", ",", "JobLauncherFactory", ".", "JobLauncherType", ".", "MAPREDUCE", ".", "name", "(", ")", ")", ";", "this", ".", "builtConfigMap", ".", "put", "(", "ConfigurationKeys", ".", "FS_URI_KEY", ",", "FileSystem", ".", "get", "(", "new", "Configuration", "(", ")", ")", ".", "getUri", "(", ")", ".", "toString", "(", ")", ")", ";", "this", ".", "builtConfigMap", ".", "put", "(", "ConfigurationKeys", ".", "MR_JOB_ROOT_DIR_KEY", ",", "\"/tmp/EmbeddedGobblin_\"", "+", "System", ".", "currentTimeMillis", "(", ")", ")", ";", "this", ".", "distributeJarsFunction", "=", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "// Add jars needed at runtime to the sys config so MR job launcher will add them to distributed cache.", "EmbeddedGobblin", ".", "this", ".", "sysConfigOverrides", ".", "put", "(", "ConfigurationKeys", ".", "JOB_JAR_FILES_KEY", ",", "Joiner", ".", "on", "(", "\",\"", ")", ".", "join", "(", "getPrioritizedDistributedJars", "(", ")", ")", ")", ";", "}", "}", ";", "return", "this", ";", "}" ]
Specify job should run in MR mode.
[ "Specify", "job", "should", "run", "in", "MR", "mode", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L176-L189
26,041
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.sysConfig
public EmbeddedGobblin sysConfig(String key, String value) { this.sysConfigOverrides.put(key, value); return this; }
java
public EmbeddedGobblin sysConfig(String key, String value) { this.sysConfigOverrides.put(key, value); return this; }
[ "public", "EmbeddedGobblin", "sysConfig", "(", "String", "key", ",", "String", "value", ")", "{", "this", ".", "sysConfigOverrides", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Override a Gobblin system configuration.
[ "Override", "a", "Gobblin", "system", "configuration", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L258-L261
26,042
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.setConfiguration
public EmbeddedGobblin setConfiguration(String key, String value) { this.userConfigMap.put(key, value); return this; }
java
public EmbeddedGobblin setConfiguration(String key, String value) { this.userConfigMap.put(key, value); return this; }
[ "public", "EmbeddedGobblin", "setConfiguration", "(", "String", "key", ",", "String", "value", ")", "{", "this", ".", "userConfigMap", ".", "put", "(", "key", ",", "value", ")", ";", "return", "this", ";", "}" ]
Manually set a key-value pair in the job configuration.
[ "Manually", "set", "a", "key", "-", "value", "pair", "in", "the", "job", "configuration", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L305-L308
26,043
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.setJobTimeout
public EmbeddedGobblin setJobTimeout(String timeout) { return setJobTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
java
public EmbeddedGobblin setJobTimeout(String timeout) { return setJobTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
[ "public", "EmbeddedGobblin", "setJobTimeout", "(", "String", "timeout", ")", "{", "return", "setJobTimeout", "(", "Period", ".", "parse", "(", "timeout", ")", ".", "getSeconds", "(", ")", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}" ]
Set the timeout for the Gobblin job execution from ISO-style period.
[ "Set", "the", "timeout", "for", "the", "Gobblin", "job", "execution", "from", "ISO", "-", "style", "period", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L332-L334
26,044
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.setLaunchTimeout
public EmbeddedGobblin setLaunchTimeout(String timeout) { return setLaunchTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
java
public EmbeddedGobblin setLaunchTimeout(String timeout) { return setLaunchTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
[ "public", "EmbeddedGobblin", "setLaunchTimeout", "(", "String", "timeout", ")", "{", "return", "setLaunchTimeout", "(", "Period", ".", "parse", "(", "timeout", ")", ".", "getSeconds", "(", ")", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}" ]
Set the timeout for launching the Gobblin job from ISO-style period.
[ "Set", "the", "timeout", "for", "launching", "the", "Gobblin", "job", "from", "ISO", "-", "style", "period", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L347-L349
26,045
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.setShutdownTimeout
public EmbeddedGobblin setShutdownTimeout(String timeout) { return setShutdownTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
java
public EmbeddedGobblin setShutdownTimeout(String timeout) { return setShutdownTimeout(Period.parse(timeout).getSeconds(), TimeUnit.SECONDS); }
[ "public", "EmbeddedGobblin", "setShutdownTimeout", "(", "String", "timeout", ")", "{", "return", "setShutdownTimeout", "(", "Period", ".", "parse", "(", "timeout", ")", ".", "getSeconds", "(", ")", ",", "TimeUnit", ".", "SECONDS", ")", ";", "}" ]
Set the timeout for shutting down the Gobblin instance driver after the job is done from ISO-style period.
[ "Set", "the", "timeout", "for", "shutting", "down", "the", "Gobblin", "instance", "driver", "after", "the", "job", "is", "done", "from", "ISO", "-", "style", "period", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L362-L364
26,046
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.useStateStore
public EmbeddedGobblin useStateStore(String rootDir) { this.setConfiguration(ConfigurationKeys.STATE_STORE_ENABLED, "true"); this.setConfiguration(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, rootDir); return this; }
java
public EmbeddedGobblin useStateStore(String rootDir) { this.setConfiguration(ConfigurationKeys.STATE_STORE_ENABLED, "true"); this.setConfiguration(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, rootDir); return this; }
[ "public", "EmbeddedGobblin", "useStateStore", "(", "String", "rootDir", ")", "{", "this", ".", "setConfiguration", "(", "ConfigurationKeys", ".", "STATE_STORE_ENABLED", ",", "\"true\"", ")", ";", "this", ".", "setConfiguration", "(", "ConfigurationKeys", ".", "STATE_STORE_ROOT_DIR_KEY", ",", "rootDir", ")", ";", "return", "this", ";", "}" ]
Enable state store.
[ "Enable", "state", "store", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L377-L381
26,047
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.enableMetrics
public EmbeddedGobblin enableMetrics() { this.usePlugin(new GobblinMetricsPlugin.Factory()); this.sysConfig(ConfigurationKeys.METRICS_ENABLED_KEY, Boolean.toString(true)); return this; }
java
public EmbeddedGobblin enableMetrics() { this.usePlugin(new GobblinMetricsPlugin.Factory()); this.sysConfig(ConfigurationKeys.METRICS_ENABLED_KEY, Boolean.toString(true)); return this; }
[ "public", "EmbeddedGobblin", "enableMetrics", "(", ")", "{", "this", ".", "usePlugin", "(", "new", "GobblinMetricsPlugin", ".", "Factory", "(", ")", ")", ";", "this", ".", "sysConfig", "(", "ConfigurationKeys", ".", "METRICS_ENABLED_KEY", ",", "Boolean", ".", "toString", "(", "true", ")", ")", ";", "return", "this", ";", "}" ]
Enable metrics. Does not start any reporters.
[ "Enable", "metrics", ".", "Does", "not", "start", "any", "reporters", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L386-L390
26,048
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.run
@NotOnCli public JobExecutionResult run() throws InterruptedException, TimeoutException, ExecutionException { JobExecutionDriver jobDriver = runAsync(); return jobDriver.get(this.jobTimeout.getTimeout(), this.jobTimeout.getTimeUnit()); }
java
@NotOnCli public JobExecutionResult run() throws InterruptedException, TimeoutException, ExecutionException { JobExecutionDriver jobDriver = runAsync(); return jobDriver.get(this.jobTimeout.getTimeout(), this.jobTimeout.getTimeUnit()); }
[ "@", "NotOnCli", "public", "JobExecutionResult", "run", "(", ")", "throws", "InterruptedException", ",", "TimeoutException", ",", "ExecutionException", "{", "JobExecutionDriver", "jobDriver", "=", "runAsync", "(", ")", ";", "return", "jobDriver", ".", "get", "(", "this", ".", "jobTimeout", ".", "getTimeout", "(", ")", ",", "this", ".", "jobTimeout", ".", "getTimeUnit", "(", ")", ")", ";", "}" ]
Run the Gobblin job. This call will block until the job is done. @return a {@link JobExecutionResult} containing the result of the execution.
[ "Run", "the", "Gobblin", "job", ".", "This", "call", "will", "block", "until", "the", "job", "is", "done", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L404-L408
26,049
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java
EmbeddedGobblin.loadCoreGobblinJarsToDistributedJars
private void loadCoreGobblinJarsToDistributedJars() { // Gobblin-api distributeJarByClassWithPriority(State.class, 0); // Gobblin-core distributeJarByClassWithPriority(ConstructState.class, 0); // Gobblin-core-base distributeJarByClassWithPriority(InstrumentedExtractorBase.class, 0); // Gobblin-metrics-base distributeJarByClassWithPriority(MetricContext.class, 0); // Gobblin-metrics distributeJarByClassWithPriority(GobblinMetrics.class, 0); // Gobblin-metastore distributeJarByClassWithPriority(FsStateStore.class, 0); // Gobblin-runtime distributeJarByClassWithPriority(Task.class, 0); // Gobblin-utility distributeJarByClassWithPriority(PathUtils.class, 0); // joda-time distributeJarByClassWithPriority(ReadableInstant.class, 0); // guava distributeJarByClassWithPriority(Escaper.class, -10); // Escaper was added in guava 15, so we use it to identify correct jar // dropwizard.metrics-core distributeJarByClassWithPriority(MetricFilter.class, 0); // pegasus distributeJarByClassWithPriority(DataTemplate.class, 0); // commons-lang3 distributeJarByClassWithPriority(ClassUtils.class, 0); // avro distributeJarByClassWithPriority(SchemaBuilder.class, 0); // guava-retry distributeJarByClassWithPriority(RetryListener.class, 0); // config distributeJarByClassWithPriority(ConfigFactory.class, 0); // reflections distributeJarByClassWithPriority(Reflections.class, 0); // javassist distributeJarByClassWithPriority(ClassFile.class, 0); }
java
private void loadCoreGobblinJarsToDistributedJars() { // Gobblin-api distributeJarByClassWithPriority(State.class, 0); // Gobblin-core distributeJarByClassWithPriority(ConstructState.class, 0); // Gobblin-core-base distributeJarByClassWithPriority(InstrumentedExtractorBase.class, 0); // Gobblin-metrics-base distributeJarByClassWithPriority(MetricContext.class, 0); // Gobblin-metrics distributeJarByClassWithPriority(GobblinMetrics.class, 0); // Gobblin-metastore distributeJarByClassWithPriority(FsStateStore.class, 0); // Gobblin-runtime distributeJarByClassWithPriority(Task.class, 0); // Gobblin-utility distributeJarByClassWithPriority(PathUtils.class, 0); // joda-time distributeJarByClassWithPriority(ReadableInstant.class, 0); // guava distributeJarByClassWithPriority(Escaper.class, -10); // Escaper was added in guava 15, so we use it to identify correct jar // dropwizard.metrics-core distributeJarByClassWithPriority(MetricFilter.class, 0); // pegasus distributeJarByClassWithPriority(DataTemplate.class, 0); // commons-lang3 distributeJarByClassWithPriority(ClassUtils.class, 0); // avro distributeJarByClassWithPriority(SchemaBuilder.class, 0); // guava-retry distributeJarByClassWithPriority(RetryListener.class, 0); // config distributeJarByClassWithPriority(ConfigFactory.class, 0); // reflections distributeJarByClassWithPriority(Reflections.class, 0); // javassist distributeJarByClassWithPriority(ClassFile.class, 0); }
[ "private", "void", "loadCoreGobblinJarsToDistributedJars", "(", ")", "{", "// Gobblin-api", "distributeJarByClassWithPriority", "(", "State", ".", "class", ",", "0", ")", ";", "// Gobblin-core", "distributeJarByClassWithPriority", "(", "ConstructState", ".", "class", ",", "0", ")", ";", "// Gobblin-core-base", "distributeJarByClassWithPriority", "(", "InstrumentedExtractorBase", ".", "class", ",", "0", ")", ";", "// Gobblin-metrics-base", "distributeJarByClassWithPriority", "(", "MetricContext", ".", "class", ",", "0", ")", ";", "// Gobblin-metrics", "distributeJarByClassWithPriority", "(", "GobblinMetrics", ".", "class", ",", "0", ")", ";", "// Gobblin-metastore", "distributeJarByClassWithPriority", "(", "FsStateStore", ".", "class", ",", "0", ")", ";", "// Gobblin-runtime", "distributeJarByClassWithPriority", "(", "Task", ".", "class", ",", "0", ")", ";", "// Gobblin-utility", "distributeJarByClassWithPriority", "(", "PathUtils", ".", "class", ",", "0", ")", ";", "// joda-time", "distributeJarByClassWithPriority", "(", "ReadableInstant", ".", "class", ",", "0", ")", ";", "// guava", "distributeJarByClassWithPriority", "(", "Escaper", ".", "class", ",", "-", "10", ")", ";", "// Escaper was added in guava 15, so we use it to identify correct jar", "// dropwizard.metrics-core", "distributeJarByClassWithPriority", "(", "MetricFilter", ".", "class", ",", "0", ")", ";", "// pegasus", "distributeJarByClassWithPriority", "(", "DataTemplate", ".", "class", ",", "0", ")", ";", "// commons-lang3", "distributeJarByClassWithPriority", "(", "ClassUtils", ".", "class", ",", "0", ")", ";", "// avro", "distributeJarByClassWithPriority", "(", "SchemaBuilder", ".", "class", ",", "0", ")", ";", "// guava-retry", "distributeJarByClassWithPriority", "(", "RetryListener", ".", "class", ",", "0", ")", ";", "// config", "distributeJarByClassWithPriority", "(", "ConfigFactory", ".", "class", ",", "0", ")", ";", "// reflections", "distributeJarByClassWithPriority", "(", "Reflections", ".", "class", ",", "0", ")", ";", "// javassist", "distributeJarByClassWithPriority", "(", "ClassFile", ".", "class", ",", "0", ")", ";", "}" ]
This returns the set of jars required by a basic Gobblin ingestion job. In general, these need to be distributed to workers in a distributed environment.
[ "This", "returns", "the", "set", "of", "jars", "required", "by", "a", "basic", "Gobblin", "ingestion", "job", ".", "In", "general", "these", "need", "to", "be", "distributed", "to", "workers", "in", "a", "distributed", "environment", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/embedded/EmbeddedGobblin.java#L545-L582
26,050
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java
NonObservingFSJobCatalog.put
@Override public synchronized void put(JobSpec jobSpec) { Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName())); Preconditions.checkNotNull(jobSpec); try { long startTime = System.currentTimeMillis(); Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobSpec.getUri()); boolean isUpdate = fs.exists(jobSpecPath); materializedJobSpec(jobSpecPath, jobSpec, this.fs); this.mutableMetrics.updatePutJobTime(startTime); if (isUpdate) { this.listeners.onUpdateJob(jobSpec); } else { this.listeners.onAddJob(jobSpec); } } catch (IOException e) { throw new RuntimeException("When persisting a new JobSpec, unexpected issues happen:" + e.getMessage()); } catch (JobSpecNotFoundException e) { throw new RuntimeException("When replacing a existed JobSpec, unexpected issue happen:" + e.getMessage()); } }
java
@Override public synchronized void put(JobSpec jobSpec) { Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName())); Preconditions.checkNotNull(jobSpec); try { long startTime = System.currentTimeMillis(); Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobSpec.getUri()); boolean isUpdate = fs.exists(jobSpecPath); materializedJobSpec(jobSpecPath, jobSpec, this.fs); this.mutableMetrics.updatePutJobTime(startTime); if (isUpdate) { this.listeners.onUpdateJob(jobSpec); } else { this.listeners.onAddJob(jobSpec); } } catch (IOException e) { throw new RuntimeException("When persisting a new JobSpec, unexpected issues happen:" + e.getMessage()); } catch (JobSpecNotFoundException e) { throw new RuntimeException("When replacing a existed JobSpec, unexpected issue happen:" + e.getMessage()); } }
[ "@", "Override", "public", "synchronized", "void", "put", "(", "JobSpec", "jobSpec", ")", "{", "Preconditions", ".", "checkState", "(", "state", "(", ")", "==", "State", ".", "RUNNING", ",", "String", ".", "format", "(", "\"%s is not running.\"", ",", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ")", ";", "Preconditions", ".", "checkNotNull", "(", "jobSpec", ")", ";", "try", "{", "long", "startTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "Path", "jobSpecPath", "=", "getPathForURI", "(", "this", ".", "jobConfDirPath", ",", "jobSpec", ".", "getUri", "(", ")", ")", ";", "boolean", "isUpdate", "=", "fs", ".", "exists", "(", "jobSpecPath", ")", ";", "materializedJobSpec", "(", "jobSpecPath", ",", "jobSpec", ",", "this", ".", "fs", ")", ";", "this", ".", "mutableMetrics", ".", "updatePutJobTime", "(", "startTime", ")", ";", "if", "(", "isUpdate", ")", "{", "this", ".", "listeners", ".", "onUpdateJob", "(", "jobSpec", ")", ";", "}", "else", "{", "this", ".", "listeners", ".", "onAddJob", "(", "jobSpec", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"When persisting a new JobSpec, unexpected issues happen:\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "JobSpecNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"When replacing a existed JobSpec, unexpected issue happen:\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Allow user to programmatically add a new JobSpec. The method will materialized the jobSpec into real file. @param jobSpec The target JobSpec Object to be materialized. Noted that the URI return by getUri is a relative path.
[ "Allow", "user", "to", "programmatically", "add", "a", "new", "JobSpec", ".", "The", "method", "will", "materialized", "the", "jobSpec", "into", "real", "file", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java#L75-L96
26,051
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java
NonObservingFSJobCatalog.remove
@Override public synchronized void remove(URI jobURI) { Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName())); try { long startTime = System.currentTimeMillis(); JobSpec jobSpec = getJobSpec(jobURI); Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobURI); if (fs.exists(jobSpecPath)) { fs.delete(jobSpecPath, false); this.mutableMetrics.updateRemoveJobTime(startTime); this.listeners.onDeleteJob(jobURI, jobSpec.getVersion()); } else { LOGGER.warn("No file with URI:" + jobSpecPath + " is found. Deletion failed."); } } catch (IOException e) { throw new RuntimeException("When removing a JobConf. file, issues unexpected happen:" + e.getMessage()); } catch (SpecNotFoundException e) { LOGGER.warn("No file with URI:" + jobURI + " is found. Deletion failed."); } }
java
@Override public synchronized void remove(URI jobURI) { Preconditions.checkState(state() == State.RUNNING, String.format("%s is not running.", this.getClass().getName())); try { long startTime = System.currentTimeMillis(); JobSpec jobSpec = getJobSpec(jobURI); Path jobSpecPath = getPathForURI(this.jobConfDirPath, jobURI); if (fs.exists(jobSpecPath)) { fs.delete(jobSpecPath, false); this.mutableMetrics.updateRemoveJobTime(startTime); this.listeners.onDeleteJob(jobURI, jobSpec.getVersion()); } else { LOGGER.warn("No file with URI:" + jobSpecPath + " is found. Deletion failed."); } } catch (IOException e) { throw new RuntimeException("When removing a JobConf. file, issues unexpected happen:" + e.getMessage()); } catch (SpecNotFoundException e) { LOGGER.warn("No file with URI:" + jobURI + " is found. Deletion failed."); } }
[ "@", "Override", "public", "synchronized", "void", "remove", "(", "URI", "jobURI", ")", "{", "Preconditions", ".", "checkState", "(", "state", "(", ")", "==", "State", ".", "RUNNING", ",", "String", ".", "format", "(", "\"%s is not running.\"", ",", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ")", ";", "try", "{", "long", "startTime", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "JobSpec", "jobSpec", "=", "getJobSpec", "(", "jobURI", ")", ";", "Path", "jobSpecPath", "=", "getPathForURI", "(", "this", ".", "jobConfDirPath", ",", "jobURI", ")", ";", "if", "(", "fs", ".", "exists", "(", "jobSpecPath", ")", ")", "{", "fs", ".", "delete", "(", "jobSpecPath", ",", "false", ")", ";", "this", ".", "mutableMetrics", ".", "updateRemoveJobTime", "(", "startTime", ")", ";", "this", ".", "listeners", ".", "onDeleteJob", "(", "jobURI", ",", "jobSpec", ".", "getVersion", "(", ")", ")", ";", "}", "else", "{", "LOGGER", ".", "warn", "(", "\"No file with URI:\"", "+", "jobSpecPath", "+", "\" is found. Deletion failed.\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"When removing a JobConf. file, issues unexpected happen:\"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "catch", "(", "SpecNotFoundException", "e", ")", "{", "LOGGER", ".", "warn", "(", "\"No file with URI:\"", "+", "jobURI", "+", "\" is found. Deletion failed.\"", ")", ";", "}", "}" ]
Allow user to programmatically delete a new JobSpec. This method is designed to be reentrant. @param jobURI The relative Path that specified by user, need to make it into complete path.
[ "Allow", "user", "to", "programmatically", "delete", "a", "new", "JobSpec", ".", "This", "method", "is", "designed", "to", "be", "reentrant", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/job_catalog/NonObservingFSJobCatalog.java#L103-L123
26,052
apache/incubator-gobblin
gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/MetricReportReporter.java
MetricReportReporter.serializeValue
protected Metric serializeValue(String name, Number value, String... path) { return new Metric(MetricRegistry.name(name, path), value.doubleValue()); }
java
protected Metric serializeValue(String name, Number value, String... path) { return new Metric(MetricRegistry.name(name, path), value.doubleValue()); }
[ "protected", "Metric", "serializeValue", "(", "String", "name", ",", "Number", "value", ",", "String", "...", "path", ")", "{", "return", "new", "Metric", "(", "MetricRegistry", ".", "name", "(", "name", ",", "path", ")", ",", "value", ".", "doubleValue", "(", ")", ")", ";", "}" ]
Converts a single key-value pair into a metric. @param name name of the metric @param value value of the metric to report @param path additional suffixes to further identify the meaning of the reported value @return a {@link org.apache.gobblin.metrics.Metric}.
[ "Converts", "a", "single", "key", "-", "value", "pair", "into", "a", "metric", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/reporter/MetricReportReporter.java#L243-L245
26,053
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/converter/avro/JsonRecordAvroSchemaToAvroConverter.java
JsonRecordAvroSchemaToAvroConverter.convertSchema
@Override public Schema convertSchema(SI inputSchema, WorkUnitState workUnit) throws SchemaConversionException { Preconditions.checkArgument(workUnit.contains(ConfigurationKeys.CONVERTER_AVRO_SCHEMA_KEY)); this.schema = new Schema.Parser().parse(workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_SCHEMA_KEY)); return this.schema; }
java
@Override public Schema convertSchema(SI inputSchema, WorkUnitState workUnit) throws SchemaConversionException { Preconditions.checkArgument(workUnit.contains(ConfigurationKeys.CONVERTER_AVRO_SCHEMA_KEY)); this.schema = new Schema.Parser().parse(workUnit.getProp(ConfigurationKeys.CONVERTER_AVRO_SCHEMA_KEY)); return this.schema; }
[ "@", "Override", "public", "Schema", "convertSchema", "(", "SI", "inputSchema", ",", "WorkUnitState", "workUnit", ")", "throws", "SchemaConversionException", "{", "Preconditions", ".", "checkArgument", "(", "workUnit", ".", "contains", "(", "ConfigurationKeys", ".", "CONVERTER_AVRO_SCHEMA_KEY", ")", ")", ";", "this", ".", "schema", "=", "new", "Schema", ".", "Parser", "(", ")", ".", "parse", "(", "workUnit", ".", "getProp", "(", "ConfigurationKeys", ".", "CONVERTER_AVRO_SCHEMA_KEY", ")", ")", ";", "return", "this", ".", "schema", ";", "}" ]
Ignore input schema and parse in Avro schema from config
[ "Ignore", "input", "schema", "and", "parse", "in", "Avro", "schema", "from", "config" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/converter/avro/JsonRecordAvroSchemaToAvroConverter.java#L58-L63
26,054
apache/incubator-gobblin
gobblin-config-management/gobblin-config-client/src/main/java/org/apache/gobblin/config/client/ConfigClientUtils.java
ConfigClientUtils.isAncestorOrSame
public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }
java
public static boolean isAncestorOrSame(URI descendant, URI ancestor) { Preconditions.checkNotNull(descendant, "input can not be null"); Preconditions.checkNotNull(ancestor, "input can not be null"); if (!stringSame(descendant.getScheme(), ancestor.getScheme())) { return false; } if (!stringSame(descendant.getAuthority(), ancestor.getAuthority())) { return false; } return isAncestorOrSame(getConfigKeyPath(descendant.getPath()), getConfigKeyPath(ancestor.getPath())); }
[ "public", "static", "boolean", "isAncestorOrSame", "(", "URI", "descendant", ",", "URI", "ancestor", ")", "{", "Preconditions", ".", "checkNotNull", "(", "descendant", ",", "\"input can not be null\"", ")", ";", "Preconditions", ".", "checkNotNull", "(", "ancestor", ",", "\"input can not be null\"", ")", ";", "if", "(", "!", "stringSame", "(", "descendant", ".", "getScheme", "(", ")", ",", "ancestor", ".", "getScheme", "(", ")", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "stringSame", "(", "descendant", ".", "getAuthority", "(", ")", ",", "ancestor", ".", "getAuthority", "(", ")", ")", ")", "{", "return", "false", ";", "}", "return", "isAncestorOrSame", "(", "getConfigKeyPath", "(", "descendant", ".", "getPath", "(", ")", ")", ",", "getConfigKeyPath", "(", "ancestor", ".", "getPath", "(", ")", ")", ")", ";", "}" ]
Utility method to check whether one URI is the ancestor of the other return true iff both URI's scheme/authority name match and ancestor's path is the prefix of the descendant's path @param descendant: the descendant URI to check @param ancestor : the ancestor URI to check @return
[ "Utility", "method", "to", "check", "whether", "one", "URI", "is", "the", "ancestor", "of", "the", "other" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-config-management/gobblin-config-client/src/main/java/org/apache/gobblin/config/client/ConfigClientUtils.java#L156-L169
26,055
apache/incubator-gobblin
gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/kafka/schemareg/ConfigDrivenMd5SchemaRegistry.java
ConfigDrivenMd5SchemaRegistry.register
@Override public synchronized MD5Digest register(String name, Schema schema) throws IOException, SchemaRegistryException { MD5Digest md5Digest = generateId(schema); if (!_schemaHashMap.containsKey(md5Digest)) { _schemaHashMap.put(md5Digest, schema); _topicSchemaMap.put(name, schema); } return md5Digest; }
java
@Override public synchronized MD5Digest register(String name, Schema schema) throws IOException, SchemaRegistryException { MD5Digest md5Digest = generateId(schema); if (!_schemaHashMap.containsKey(md5Digest)) { _schemaHashMap.put(md5Digest, schema); _topicSchemaMap.put(name, schema); } return md5Digest; }
[ "@", "Override", "public", "synchronized", "MD5Digest", "register", "(", "String", "name", ",", "Schema", "schema", ")", "throws", "IOException", ",", "SchemaRegistryException", "{", "MD5Digest", "md5Digest", "=", "generateId", "(", "schema", ")", ";", "if", "(", "!", "_schemaHashMap", ".", "containsKey", "(", "md5Digest", ")", ")", "{", "_schemaHashMap", ".", "put", "(", "md5Digest", ",", "schema", ")", ";", "_topicSchemaMap", ".", "put", "(", "name", ",", "schema", ")", ";", "}", "return", "md5Digest", ";", "}" ]
Register this schema under the provided name @param name @param schema @return @throws IOException @throws SchemaRegistryException
[ "Register", "this", "schema", "under", "the", "provided", "name" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/kafka/schemareg/ConfigDrivenMd5SchemaRegistry.java#L94-L104
26,056
apache/incubator-gobblin
gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/kafka/schemareg/ConfigDrivenMd5SchemaRegistry.java
ConfigDrivenMd5SchemaRegistry.getById
@Override public Schema getById(MD5Digest id) throws IOException, SchemaRegistryException { if (_schemaHashMap.containsKey(id)) { return _schemaHashMap.get(id); } else { throw new SchemaRegistryException("Could not find schema with id : " + id.asString()); } }
java
@Override public Schema getById(MD5Digest id) throws IOException, SchemaRegistryException { if (_schemaHashMap.containsKey(id)) { return _schemaHashMap.get(id); } else { throw new SchemaRegistryException("Could not find schema with id : " + id.asString()); } }
[ "@", "Override", "public", "Schema", "getById", "(", "MD5Digest", "id", ")", "throws", "IOException", ",", "SchemaRegistryException", "{", "if", "(", "_schemaHashMap", ".", "containsKey", "(", "id", ")", ")", "{", "return", "_schemaHashMap", ".", "get", "(", "id", ")", ";", "}", "else", "{", "throw", "new", "SchemaRegistryException", "(", "\"Could not find schema with id : \"", "+", "id", ".", "asString", "(", ")", ")", ";", "}", "}" ]
Get a schema given an id @param id @return @throws IOException @throws SchemaRegistryException
[ "Get", "a", "schema", "given", "an", "id" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-kafka-common/src/main/java/org/apache/gobblin/kafka/schemareg/ConfigDrivenMd5SchemaRegistry.java#L113-L124
26,057
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/InputRecordCountHelper.java
InputRecordCountHelper.calculateRecordCount
public long calculateRecordCount (Collection<Path> paths) throws IOException { long sum = 0; for (Path path: paths) { sum += inputRecordCountProvider.getRecordCount(DatasetHelper.getApplicableFilePaths(this.fs, path, Lists.newArrayList(AVRO))); } return sum; }
java
public long calculateRecordCount (Collection<Path> paths) throws IOException { long sum = 0; for (Path path: paths) { sum += inputRecordCountProvider.getRecordCount(DatasetHelper.getApplicableFilePaths(this.fs, path, Lists.newArrayList(AVRO))); } return sum; }
[ "public", "long", "calculateRecordCount", "(", "Collection", "<", "Path", ">", "paths", ")", "throws", "IOException", "{", "long", "sum", "=", "0", ";", "for", "(", "Path", "path", ":", "paths", ")", "{", "sum", "+=", "inputRecordCountProvider", ".", "getRecordCount", "(", "DatasetHelper", ".", "getApplicableFilePaths", "(", "this", ".", "fs", ",", "path", ",", "Lists", ".", "newArrayList", "(", "AVRO", ")", ")", ")", ";", "}", "return", "sum", ";", "}" ]
Calculate record count at given paths @param paths all paths where the record count are calculated @return record count after parsing all files under given paths
[ "Calculate", "record", "count", "at", "given", "paths" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/InputRecordCountHelper.java#L88-L94
26,058
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/InputRecordCountHelper.java
InputRecordCountHelper.saveState
public void saveState (Path dir, State state) throws IOException { saveState(this.fs, dir, state); }
java
public void saveState (Path dir, State state) throws IOException { saveState(this.fs, dir, state); }
[ "public", "void", "saveState", "(", "Path", "dir", ",", "State", "state", ")", "throws", "IOException", "{", "saveState", "(", "this", ".", "fs", ",", "dir", ",", "state", ")", ";", "}" ]
Save compaction state file
[ "Save", "compaction", "state", "file" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/verify/InputRecordCountHelper.java#L116-L118
26,059
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/executors/ScalingQueue.java
ScalingQueue.offer
@Override public synchronized boolean offer(Runnable runnable) { int allWorkingThreads = this.executor.getActiveCount() + super.size(); return allWorkingThreads < this.executor.getPoolSize() && super.offer(runnable); }
java
@Override public synchronized boolean offer(Runnable runnable) { int allWorkingThreads = this.executor.getActiveCount() + super.size(); return allWorkingThreads < this.executor.getPoolSize() && super.offer(runnable); }
[ "@", "Override", "public", "synchronized", "boolean", "offer", "(", "Runnable", "runnable", ")", "{", "int", "allWorkingThreads", "=", "this", ".", "executor", ".", "getActiveCount", "(", ")", "+", "super", ".", "size", "(", ")", ";", "return", "allWorkingThreads", "<", "this", ".", "executor", ".", "getPoolSize", "(", ")", "&&", "super", ".", "offer", "(", "runnable", ")", ";", "}" ]
Inserts the specified element at the tail of this queue if there is at least one available thread to run the current task. If all pool threads are actively busy, it rejects the offer. @param runnable the element to add. @return true if it was possible to add the element to this queue, else false @see ThreadPoolExecutor#execute(Runnable)
[ "Inserts", "the", "specified", "element", "at", "the", "tail", "of", "this", "queue", "if", "there", "is", "at", "least", "one", "available", "thread", "to", "run", "the", "current", "task", ".", "If", "all", "pool", "threads", "are", "actively", "busy", "it", "rejects", "the", "offer", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/executors/ScalingQueue.java#L72-L76
26,060
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.getFlowConfig
public FlowConfig getFlowConfig(FlowId flowId) throws FlowConfigLoggedException { log.info("[GAAS-REST] Get called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); try { URI flowUri = FlowUriUtils.createFlowSpecUri(flowId); FlowSpec spec = (FlowSpec) flowCatalog.getSpec(flowUri); FlowConfig flowConfig = new FlowConfig(); Properties flowProps = spec.getConfigAsProperties(); Schedule schedule = null; if (flowProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) { schedule = new Schedule(); schedule.setCronSchedule(flowProps.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY)); } if (flowProps.containsKey(ConfigurationKeys.JOB_TEMPLATE_PATH)) { flowConfig.setTemplateUris(flowProps.getProperty(ConfigurationKeys.JOB_TEMPLATE_PATH)); } else if (spec.getTemplateURIs().isPresent()) { flowConfig.setTemplateUris(StringUtils.join(spec.getTemplateURIs().get(), ",")); } else { flowConfig.setTemplateUris("NA"); } if (schedule != null) { if (flowProps.containsKey(ConfigurationKeys.FLOW_RUN_IMMEDIATELY)) { schedule.setRunImmediately(Boolean.valueOf(flowProps.getProperty(ConfigurationKeys.FLOW_RUN_IMMEDIATELY))); } flowConfig.setSchedule(schedule); } // remove keys that were injected as part of flowSpec creation flowProps.remove(ConfigurationKeys.JOB_SCHEDULE_KEY); flowProps.remove(ConfigurationKeys.JOB_TEMPLATE_PATH); StringMap flowPropsAsStringMap = new StringMap(); flowPropsAsStringMap.putAll(Maps.fromProperties(flowProps)); return flowConfig.setId(new FlowId().setFlowGroup(flowId.getFlowGroup()).setFlowName(flowId.getFlowName())) .setProperties(flowPropsAsStringMap); } catch (URISyntaxException e) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowId.getFlowName(), e); } catch (SpecNotFoundException e) { throw new FlowConfigLoggedException(HttpStatus.S_404_NOT_FOUND, "Flow requested does not exist: " + flowId.getFlowName(), null); } }
java
public FlowConfig getFlowConfig(FlowId flowId) throws FlowConfigLoggedException { log.info("[GAAS-REST] Get called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); try { URI flowUri = FlowUriUtils.createFlowSpecUri(flowId); FlowSpec spec = (FlowSpec) flowCatalog.getSpec(flowUri); FlowConfig flowConfig = new FlowConfig(); Properties flowProps = spec.getConfigAsProperties(); Schedule schedule = null; if (flowProps.containsKey(ConfigurationKeys.JOB_SCHEDULE_KEY)) { schedule = new Schedule(); schedule.setCronSchedule(flowProps.getProperty(ConfigurationKeys.JOB_SCHEDULE_KEY)); } if (flowProps.containsKey(ConfigurationKeys.JOB_TEMPLATE_PATH)) { flowConfig.setTemplateUris(flowProps.getProperty(ConfigurationKeys.JOB_TEMPLATE_PATH)); } else if (spec.getTemplateURIs().isPresent()) { flowConfig.setTemplateUris(StringUtils.join(spec.getTemplateURIs().get(), ",")); } else { flowConfig.setTemplateUris("NA"); } if (schedule != null) { if (flowProps.containsKey(ConfigurationKeys.FLOW_RUN_IMMEDIATELY)) { schedule.setRunImmediately(Boolean.valueOf(flowProps.getProperty(ConfigurationKeys.FLOW_RUN_IMMEDIATELY))); } flowConfig.setSchedule(schedule); } // remove keys that were injected as part of flowSpec creation flowProps.remove(ConfigurationKeys.JOB_SCHEDULE_KEY); flowProps.remove(ConfigurationKeys.JOB_TEMPLATE_PATH); StringMap flowPropsAsStringMap = new StringMap(); flowPropsAsStringMap.putAll(Maps.fromProperties(flowProps)); return flowConfig.setId(new FlowId().setFlowGroup(flowId.getFlowGroup()).setFlowName(flowId.getFlowName())) .setProperties(flowPropsAsStringMap); } catch (URISyntaxException e) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowId.getFlowName(), e); } catch (SpecNotFoundException e) { throw new FlowConfigLoggedException(HttpStatus.S_404_NOT_FOUND, "Flow requested does not exist: " + flowId.getFlowName(), null); } }
[ "public", "FlowConfig", "getFlowConfig", "(", "FlowId", "flowId", ")", "throws", "FlowConfigLoggedException", "{", "log", ".", "info", "(", "\"[GAAS-REST] Get called with flowGroup {} flowName {}\"", ",", "flowId", ".", "getFlowGroup", "(", ")", ",", "flowId", ".", "getFlowName", "(", ")", ")", ";", "try", "{", "URI", "flowUri", "=", "FlowUriUtils", ".", "createFlowSpecUri", "(", "flowId", ")", ";", "FlowSpec", "spec", "=", "(", "FlowSpec", ")", "flowCatalog", ".", "getSpec", "(", "flowUri", ")", ";", "FlowConfig", "flowConfig", "=", "new", "FlowConfig", "(", ")", ";", "Properties", "flowProps", "=", "spec", ".", "getConfigAsProperties", "(", ")", ";", "Schedule", "schedule", "=", "null", ";", "if", "(", "flowProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_SCHEDULE_KEY", ")", ")", "{", "schedule", "=", "new", "Schedule", "(", ")", ";", "schedule", ".", "setCronSchedule", "(", "flowProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_SCHEDULE_KEY", ")", ")", ";", "}", "if", "(", "flowProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_TEMPLATE_PATH", ")", ")", "{", "flowConfig", ".", "setTemplateUris", "(", "flowProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_TEMPLATE_PATH", ")", ")", ";", "}", "else", "if", "(", "spec", ".", "getTemplateURIs", "(", ")", ".", "isPresent", "(", ")", ")", "{", "flowConfig", ".", "setTemplateUris", "(", "StringUtils", ".", "join", "(", "spec", ".", "getTemplateURIs", "(", ")", ".", "get", "(", ")", ",", "\",\"", ")", ")", ";", "}", "else", "{", "flowConfig", ".", "setTemplateUris", "(", "\"NA\"", ")", ";", "}", "if", "(", "schedule", "!=", "null", ")", "{", "if", "(", "flowProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "FLOW_RUN_IMMEDIATELY", ")", ")", "{", "schedule", ".", "setRunImmediately", "(", "Boolean", ".", "valueOf", "(", "flowProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "FLOW_RUN_IMMEDIATELY", ")", ")", ")", ";", "}", "flowConfig", ".", "setSchedule", "(", "schedule", ")", ";", "}", "// remove keys that were injected as part of flowSpec creation", "flowProps", ".", "remove", "(", "ConfigurationKeys", ".", "JOB_SCHEDULE_KEY", ")", ";", "flowProps", ".", "remove", "(", "ConfigurationKeys", ".", "JOB_TEMPLATE_PATH", ")", ";", "StringMap", "flowPropsAsStringMap", "=", "new", "StringMap", "(", ")", ";", "flowPropsAsStringMap", ".", "putAll", "(", "Maps", ".", "fromProperties", "(", "flowProps", ")", ")", ";", "return", "flowConfig", ".", "setId", "(", "new", "FlowId", "(", ")", ".", "setFlowGroup", "(", "flowId", ".", "getFlowGroup", "(", ")", ")", ".", "setFlowName", "(", "flowId", ".", "getFlowName", "(", ")", ")", ")", ".", "setProperties", "(", "flowPropsAsStringMap", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "new", "FlowConfigLoggedException", "(", "HttpStatus", ".", "S_400_BAD_REQUEST", ",", "\"bad URI \"", "+", "flowId", ".", "getFlowName", "(", ")", ",", "e", ")", ";", "}", "catch", "(", "SpecNotFoundException", "e", ")", "{", "throw", "new", "FlowConfigLoggedException", "(", "HttpStatus", ".", "S_404_NOT_FOUND", ",", "\"Flow requested does not exist: \"", "+", "flowId", ".", "getFlowName", "(", ")", ",", "null", ")", ";", "}", "}" ]
Get flow config
[ "Get", "flow", "config" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L61-L104
26,061
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.createFlowConfig
public CreateResponse createFlowConfig(FlowConfig flowConfig, boolean triggerListener) throws FlowConfigLoggedException { log.info("[GAAS-REST] Create called with flowGroup " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); if (flowConfig.hasExplain()) { //Return Error if FlowConfig has explain set. Explain request is only valid for v2 FlowConfig. return new CreateResponse(new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "FlowConfig with explain not supported.")); } FlowSpec flowSpec = createFlowSpecForConfig(flowConfig); // Existence of a flow spec in the flow catalog implies that the flow is currently running. // If the new flow spec has a schedule we should allow submission of the new flow to accept the new schedule. // However, if the new flow spec does not have a schedule, we should allow submission only if it is not running. if (!flowConfig.hasSchedule() && this.flowCatalog.exists(flowSpec.getUri())) { return new CreateResponse(new ComplexResourceKey<>(flowConfig.getId(), new EmptyRecord()), HttpStatus.S_409_CONFLICT); } else { this.flowCatalog.put(flowSpec, triggerListener); return new CreateResponse(new ComplexResourceKey<>(flowConfig.getId(), new EmptyRecord()), HttpStatus.S_201_CREATED); } }
java
public CreateResponse createFlowConfig(FlowConfig flowConfig, boolean triggerListener) throws FlowConfigLoggedException { log.info("[GAAS-REST] Create called with flowGroup " + flowConfig.getId().getFlowGroup() + " flowName " + flowConfig.getId().getFlowName()); if (flowConfig.hasExplain()) { //Return Error if FlowConfig has explain set. Explain request is only valid for v2 FlowConfig. return new CreateResponse(new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "FlowConfig with explain not supported.")); } FlowSpec flowSpec = createFlowSpecForConfig(flowConfig); // Existence of a flow spec in the flow catalog implies that the flow is currently running. // If the new flow spec has a schedule we should allow submission of the new flow to accept the new schedule. // However, if the new flow spec does not have a schedule, we should allow submission only if it is not running. if (!flowConfig.hasSchedule() && this.flowCatalog.exists(flowSpec.getUri())) { return new CreateResponse(new ComplexResourceKey<>(flowConfig.getId(), new EmptyRecord()), HttpStatus.S_409_CONFLICT); } else { this.flowCatalog.put(flowSpec, triggerListener); return new CreateResponse(new ComplexResourceKey<>(flowConfig.getId(), new EmptyRecord()), HttpStatus.S_201_CREATED); } }
[ "public", "CreateResponse", "createFlowConfig", "(", "FlowConfig", "flowConfig", ",", "boolean", "triggerListener", ")", "throws", "FlowConfigLoggedException", "{", "log", ".", "info", "(", "\"[GAAS-REST] Create called with flowGroup \"", "+", "flowConfig", ".", "getId", "(", ")", ".", "getFlowGroup", "(", ")", "+", "\" flowName \"", "+", "flowConfig", ".", "getId", "(", ")", ".", "getFlowName", "(", ")", ")", ";", "if", "(", "flowConfig", ".", "hasExplain", "(", ")", ")", "{", "//Return Error if FlowConfig has explain set. Explain request is only valid for v2 FlowConfig.", "return", "new", "CreateResponse", "(", "new", "RestLiServiceException", "(", "HttpStatus", ".", "S_400_BAD_REQUEST", ",", "\"FlowConfig with explain not supported.\"", ")", ")", ";", "}", "FlowSpec", "flowSpec", "=", "createFlowSpecForConfig", "(", "flowConfig", ")", ";", "// Existence of a flow spec in the flow catalog implies that the flow is currently running.", "// If the new flow spec has a schedule we should allow submission of the new flow to accept the new schedule.", "// However, if the new flow spec does not have a schedule, we should allow submission only if it is not running.", "if", "(", "!", "flowConfig", ".", "hasSchedule", "(", ")", "&&", "this", ".", "flowCatalog", ".", "exists", "(", "flowSpec", ".", "getUri", "(", ")", ")", ")", "{", "return", "new", "CreateResponse", "(", "new", "ComplexResourceKey", "<>", "(", "flowConfig", ".", "getId", "(", ")", ",", "new", "EmptyRecord", "(", ")", ")", ",", "HttpStatus", ".", "S_409_CONFLICT", ")", ";", "}", "else", "{", "this", ".", "flowCatalog", ".", "put", "(", "flowSpec", ",", "triggerListener", ")", ";", "return", "new", "CreateResponse", "(", "new", "ComplexResourceKey", "<>", "(", "flowConfig", ".", "getId", "(", ")", ",", "new", "EmptyRecord", "(", ")", ")", ",", "HttpStatus", ".", "S_201_CREATED", ")", ";", "}", "}" ]
Add flowConfig locally and trigger all listeners iff @param triggerListener is set to true
[ "Add", "flowConfig", "locally", "and", "trigger", "all", "listeners", "iff" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L109-L127
26,062
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.updateFlowConfig
public UpdateResponse updateFlowConfig(FlowId flowId, FlowConfig flowConfig, boolean triggerListener) { log.info("[GAAS-REST] Update called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); if (!flowId.getFlowGroup().equals(flowConfig.getId().getFlowGroup()) || !flowId.getFlowName().equals(flowConfig.getId().getFlowName())) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "flowName and flowGroup cannot be changed in update", null); } if (isUnscheduleRequest(flowConfig)) { // flow config is not changed if it is just a request to un-schedule FlowConfig originalFlowConfig = getFlowConfig(flowId); originalFlowConfig.setSchedule(NEVER_RUN_CRON_SCHEDULE); flowConfig = originalFlowConfig; } this.flowCatalog.put(createFlowSpecForConfig(flowConfig), triggerListener); return new UpdateResponse(HttpStatus.S_200_OK); }
java
public UpdateResponse updateFlowConfig(FlowId flowId, FlowConfig flowConfig, boolean triggerListener) { log.info("[GAAS-REST] Update called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); if (!flowId.getFlowGroup().equals(flowConfig.getId().getFlowGroup()) || !flowId.getFlowName().equals(flowConfig.getId().getFlowName())) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "flowName and flowGroup cannot be changed in update", null); } if (isUnscheduleRequest(flowConfig)) { // flow config is not changed if it is just a request to un-schedule FlowConfig originalFlowConfig = getFlowConfig(flowId); originalFlowConfig.setSchedule(NEVER_RUN_CRON_SCHEDULE); flowConfig = originalFlowConfig; } this.flowCatalog.put(createFlowSpecForConfig(flowConfig), triggerListener); return new UpdateResponse(HttpStatus.S_200_OK); }
[ "public", "UpdateResponse", "updateFlowConfig", "(", "FlowId", "flowId", ",", "FlowConfig", "flowConfig", ",", "boolean", "triggerListener", ")", "{", "log", ".", "info", "(", "\"[GAAS-REST] Update called with flowGroup {} flowName {}\"", ",", "flowId", ".", "getFlowGroup", "(", ")", ",", "flowId", ".", "getFlowName", "(", ")", ")", ";", "if", "(", "!", "flowId", ".", "getFlowGroup", "(", ")", ".", "equals", "(", "flowConfig", ".", "getId", "(", ")", ".", "getFlowGroup", "(", ")", ")", "||", "!", "flowId", ".", "getFlowName", "(", ")", ".", "equals", "(", "flowConfig", ".", "getId", "(", ")", ".", "getFlowName", "(", ")", ")", ")", "{", "throw", "new", "FlowConfigLoggedException", "(", "HttpStatus", ".", "S_400_BAD_REQUEST", ",", "\"flowName and flowGroup cannot be changed in update\"", ",", "null", ")", ";", "}", "if", "(", "isUnscheduleRequest", "(", "flowConfig", ")", ")", "{", "// flow config is not changed if it is just a request to un-schedule", "FlowConfig", "originalFlowConfig", "=", "getFlowConfig", "(", "flowId", ")", ";", "originalFlowConfig", ".", "setSchedule", "(", "NEVER_RUN_CRON_SCHEDULE", ")", ";", "flowConfig", "=", "originalFlowConfig", ";", "}", "this", ".", "flowCatalog", ".", "put", "(", "createFlowSpecForConfig", "(", "flowConfig", ")", ",", "triggerListener", ")", ";", "return", "new", "UpdateResponse", "(", "HttpStatus", ".", "S_200_OK", ")", ";", "}" ]
Update flowConfig locally and trigger all listeners iff @param triggerListener is set to true
[ "Update", "flowConfig", "locally", "and", "trigger", "all", "listeners", "iff" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L139-L155
26,063
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.updateFlowConfig
public UpdateResponse updateFlowConfig(FlowId flowId, FlowConfig flowConfig) throws FlowConfigLoggedException { return updateFlowConfig(flowId, flowConfig, true); }
java
public UpdateResponse updateFlowConfig(FlowId flowId, FlowConfig flowConfig) throws FlowConfigLoggedException { return updateFlowConfig(flowId, flowConfig, true); }
[ "public", "UpdateResponse", "updateFlowConfig", "(", "FlowId", "flowId", ",", "FlowConfig", "flowConfig", ")", "throws", "FlowConfigLoggedException", "{", "return", "updateFlowConfig", "(", "flowId", ",", "flowConfig", ",", "true", ")", ";", "}" ]
Update flowConfig locally and trigger all listeners
[ "Update", "flowConfig", "locally", "and", "trigger", "all", "listeners" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L164-L166
26,064
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.deleteFlowConfig
public UpdateResponse deleteFlowConfig(FlowId flowId, Properties header, boolean triggerListener) throws FlowConfigLoggedException { log.info("[GAAS-REST] Delete called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); URI flowUri = null; try { flowUri = FlowUriUtils.createFlowSpecUri(flowId); this.flowCatalog.remove(flowUri, header, triggerListener); return new UpdateResponse(HttpStatus.S_200_OK); } catch (URISyntaxException e) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowUri, e); } }
java
public UpdateResponse deleteFlowConfig(FlowId flowId, Properties header, boolean triggerListener) throws FlowConfigLoggedException { log.info("[GAAS-REST] Delete called with flowGroup {} flowName {}", flowId.getFlowGroup(), flowId.getFlowName()); URI flowUri = null; try { flowUri = FlowUriUtils.createFlowSpecUri(flowId); this.flowCatalog.remove(flowUri, header, triggerListener); return new UpdateResponse(HttpStatus.S_200_OK); } catch (URISyntaxException e) { throw new FlowConfigLoggedException(HttpStatus.S_400_BAD_REQUEST, "bad URI " + flowUri, e); } }
[ "public", "UpdateResponse", "deleteFlowConfig", "(", "FlowId", "flowId", ",", "Properties", "header", ",", "boolean", "triggerListener", ")", "throws", "FlowConfigLoggedException", "{", "log", ".", "info", "(", "\"[GAAS-REST] Delete called with flowGroup {} flowName {}\"", ",", "flowId", ".", "getFlowGroup", "(", ")", ",", "flowId", ".", "getFlowName", "(", ")", ")", ";", "URI", "flowUri", "=", "null", ";", "try", "{", "flowUri", "=", "FlowUriUtils", ".", "createFlowSpecUri", "(", "flowId", ")", ";", "this", ".", "flowCatalog", ".", "remove", "(", "flowUri", ",", "header", ",", "triggerListener", ")", ";", "return", "new", "UpdateResponse", "(", "HttpStatus", ".", "S_200_OK", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "new", "FlowConfigLoggedException", "(", "HttpStatus", ".", "S_400_BAD_REQUEST", ",", "\"bad URI \"", "+", "flowUri", ",", "e", ")", ";", "}", "}" ]
Delete flowConfig locally and trigger all listeners iff @param triggerListener is set to true
[ "Delete", "flowConfig", "locally", "and", "trigger", "all", "listeners", "iff" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L171-L183
26,065
apache/incubator-gobblin
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java
FlowConfigResourceLocalHandler.deleteFlowConfig
public UpdateResponse deleteFlowConfig(FlowId flowId, Properties header) throws FlowConfigLoggedException { return deleteFlowConfig(flowId, header, true); }
java
public UpdateResponse deleteFlowConfig(FlowId flowId, Properties header) throws FlowConfigLoggedException { return deleteFlowConfig(flowId, header, true); }
[ "public", "UpdateResponse", "deleteFlowConfig", "(", "FlowId", "flowId", ",", "Properties", "header", ")", "throws", "FlowConfigLoggedException", "{", "return", "deleteFlowConfig", "(", "flowId", ",", "header", ",", "true", ")", ";", "}" ]
Delete flowConfig locally and trigger all listeners
[ "Delete", "flowConfig", "locally", "and", "trigger", "all", "listeners" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowConfigResourceLocalHandler.java#L188-L190
26,066
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.createWorkUnits
protected void createWorkUnits(SourceState state) throws IOException { createWorkunitsFromPreviousState(state); if (this.datasets.isEmpty()) { return; } for (HivePartitionDataset dataset : this.datasets) { Optional<String> owner = dataset.getOwner(); if (workUnitsExceeded()) { log.info("Workunits exceeded"); setJobWatermark(state, dataset.datasetURN()); return; } if (!this.policy.shouldPurge(dataset)) { continue; } WorkUnit workUnit = createNewWorkUnit(dataset); log.info("Created new work unit with partition " + workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME)); this.workUnitMap.put(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), workUnit); this.workUnitsCreatedCount++; } if (!state.contains(ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK)) { this.setJobWatermark(state, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK); } }
java
protected void createWorkUnits(SourceState state) throws IOException { createWorkunitsFromPreviousState(state); if (this.datasets.isEmpty()) { return; } for (HivePartitionDataset dataset : this.datasets) { Optional<String> owner = dataset.getOwner(); if (workUnitsExceeded()) { log.info("Workunits exceeded"); setJobWatermark(state, dataset.datasetURN()); return; } if (!this.policy.shouldPurge(dataset)) { continue; } WorkUnit workUnit = createNewWorkUnit(dataset); log.info("Created new work unit with partition " + workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME)); this.workUnitMap.put(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), workUnit); this.workUnitsCreatedCount++; } if (!state.contains(ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK)) { this.setJobWatermark(state, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK); } }
[ "protected", "void", "createWorkUnits", "(", "SourceState", "state", ")", "throws", "IOException", "{", "createWorkunitsFromPreviousState", "(", "state", ")", ";", "if", "(", "this", ".", "datasets", ".", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "for", "(", "HivePartitionDataset", "dataset", ":", "this", ".", "datasets", ")", "{", "Optional", "<", "String", ">", "owner", "=", "dataset", ".", "getOwner", "(", ")", ";", "if", "(", "workUnitsExceeded", "(", ")", ")", "{", "log", ".", "info", "(", "\"Workunits exceeded\"", ")", ";", "setJobWatermark", "(", "state", ",", "dataset", ".", "datasetURN", "(", ")", ")", ";", "return", ";", "}", "if", "(", "!", "this", ".", "policy", ".", "shouldPurge", "(", "dataset", ")", ")", "{", "continue", ";", "}", "WorkUnit", "workUnit", "=", "createNewWorkUnit", "(", "dataset", ")", ";", "log", ".", "info", "(", "\"Created new work unit with partition \"", "+", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", ")", ";", "this", ".", "workUnitMap", ".", "put", "(", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", ",", "workUnit", ")", ";", "this", ".", "workUnitsCreatedCount", "++", ";", "}", "if", "(", "!", "state", ".", "contains", "(", "ComplianceConfigurationKeys", ".", "HIVE_PURGER_WATERMARK", ")", ")", "{", "this", ".", "setJobWatermark", "(", "state", ",", "ComplianceConfigurationKeys", ".", "NO_PREVIOUS_WATERMARK", ")", ";", "}", "}" ]
This method creates the list of all work units needed for the current execution. Fresh work units are created for each partition starting from watermark and failed work units from the previous run will be added to the list.
[ "This", "method", "creates", "the", "list", "of", "all", "work", "units", "needed", "for", "the", "current", "execution", ".", "Fresh", "work", "units", "are", "created", "for", "each", "partition", "starting", "from", "watermark", "and", "failed", "work", "units", "from", "the", "previous", "run", "will", "be", "added", "to", "the", "list", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L178-L202
26,067
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.sortHiveDatasets
protected List<HivePartitionDataset> sortHiveDatasets(List<HivePartitionDataset> datasets) { Collections.sort(datasets, new Comparator<HivePartitionDataset>() { @Override public int compare(HivePartitionDataset o1, HivePartitionDataset o2) { return o1.datasetURN().compareTo(o2.datasetURN()); } }); return datasets; }
java
protected List<HivePartitionDataset> sortHiveDatasets(List<HivePartitionDataset> datasets) { Collections.sort(datasets, new Comparator<HivePartitionDataset>() { @Override public int compare(HivePartitionDataset o1, HivePartitionDataset o2) { return o1.datasetURN().compareTo(o2.datasetURN()); } }); return datasets; }
[ "protected", "List", "<", "HivePartitionDataset", ">", "sortHiveDatasets", "(", "List", "<", "HivePartitionDataset", ">", "datasets", ")", "{", "Collections", ".", "sort", "(", "datasets", ",", "new", "Comparator", "<", "HivePartitionDataset", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "HivePartitionDataset", "o1", ",", "HivePartitionDataset", "o2", ")", "{", "return", "o1", ".", "datasetURN", "(", ")", ".", "compareTo", "(", "o2", ".", "datasetURN", "(", ")", ")", ";", "}", "}", ")", ";", "return", "datasets", ";", "}" ]
Sort all HiveDatasets on the basis of complete name ie dbName.tableName
[ "Sort", "all", "HiveDatasets", "on", "the", "basis", "of", "complete", "name", "ie", "dbName", ".", "tableName" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L220-L228
26,068
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.createWorkunitsFromPreviousState
protected void createWorkunitsFromPreviousState(SourceState state) { if (this.lowWatermark.equalsIgnoreCase(ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK)) { return; } if (Iterables.isEmpty(state.getPreviousWorkUnitStates())) { return; } for (WorkUnitState workUnitState : state.getPreviousWorkUnitStates()) { if (workUnitState.getWorkingState() == WorkUnitState.WorkingState.COMMITTED) { continue; } WorkUnit workUnit = workUnitState.getWorkunit(); Preconditions.checkArgument(workUnit.contains(ComplianceConfigurationKeys.PARTITION_NAME), "Older WorkUnit doesn't contain property partition name."); int executionAttempts = workUnit.getPropAsInt(ComplianceConfigurationKeys.EXECUTION_ATTEMPTS, ComplianceConfigurationKeys.DEFAULT_EXECUTION_ATTEMPTS); if (executionAttempts < this.maxWorkUnitExecutionAttempts) { Optional<WorkUnit> workUnitOptional = createNewWorkUnit(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), ++executionAttempts); if (!workUnitOptional.isPresent()) { continue; } workUnit = workUnitOptional.get(); log.info("Revived old Work Unit for partiton " + workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME) + " having execution attempt " + workUnit.getProp(ComplianceConfigurationKeys.EXECUTION_ATTEMPTS)); workUnitMap.put(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), workUnit); } } }
java
protected void createWorkunitsFromPreviousState(SourceState state) { if (this.lowWatermark.equalsIgnoreCase(ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK)) { return; } if (Iterables.isEmpty(state.getPreviousWorkUnitStates())) { return; } for (WorkUnitState workUnitState : state.getPreviousWorkUnitStates()) { if (workUnitState.getWorkingState() == WorkUnitState.WorkingState.COMMITTED) { continue; } WorkUnit workUnit = workUnitState.getWorkunit(); Preconditions.checkArgument(workUnit.contains(ComplianceConfigurationKeys.PARTITION_NAME), "Older WorkUnit doesn't contain property partition name."); int executionAttempts = workUnit.getPropAsInt(ComplianceConfigurationKeys.EXECUTION_ATTEMPTS, ComplianceConfigurationKeys.DEFAULT_EXECUTION_ATTEMPTS); if (executionAttempts < this.maxWorkUnitExecutionAttempts) { Optional<WorkUnit> workUnitOptional = createNewWorkUnit(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), ++executionAttempts); if (!workUnitOptional.isPresent()) { continue; } workUnit = workUnitOptional.get(); log.info("Revived old Work Unit for partiton " + workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME) + " having execution attempt " + workUnit.getProp(ComplianceConfigurationKeys.EXECUTION_ATTEMPTS)); workUnitMap.put(workUnit.getProp(ComplianceConfigurationKeys.PARTITION_NAME), workUnit); } } }
[ "protected", "void", "createWorkunitsFromPreviousState", "(", "SourceState", "state", ")", "{", "if", "(", "this", ".", "lowWatermark", ".", "equalsIgnoreCase", "(", "ComplianceConfigurationKeys", ".", "NO_PREVIOUS_WATERMARK", ")", ")", "{", "return", ";", "}", "if", "(", "Iterables", ".", "isEmpty", "(", "state", ".", "getPreviousWorkUnitStates", "(", ")", ")", ")", "{", "return", ";", "}", "for", "(", "WorkUnitState", "workUnitState", ":", "state", ".", "getPreviousWorkUnitStates", "(", ")", ")", "{", "if", "(", "workUnitState", ".", "getWorkingState", "(", ")", "==", "WorkUnitState", ".", "WorkingState", ".", "COMMITTED", ")", "{", "continue", ";", "}", "WorkUnit", "workUnit", "=", "workUnitState", ".", "getWorkunit", "(", ")", ";", "Preconditions", ".", "checkArgument", "(", "workUnit", ".", "contains", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", ",", "\"Older WorkUnit doesn't contain property partition name.\"", ")", ";", "int", "executionAttempts", "=", "workUnit", ".", "getPropAsInt", "(", "ComplianceConfigurationKeys", ".", "EXECUTION_ATTEMPTS", ",", "ComplianceConfigurationKeys", ".", "DEFAULT_EXECUTION_ATTEMPTS", ")", ";", "if", "(", "executionAttempts", "<", "this", ".", "maxWorkUnitExecutionAttempts", ")", "{", "Optional", "<", "WorkUnit", ">", "workUnitOptional", "=", "createNewWorkUnit", "(", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", ",", "++", "executionAttempts", ")", ";", "if", "(", "!", "workUnitOptional", ".", "isPresent", "(", ")", ")", "{", "continue", ";", "}", "workUnit", "=", "workUnitOptional", ".", "get", "(", ")", ";", "log", ".", "info", "(", "\"Revived old Work Unit for partiton \"", "+", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", "+", "\" having execution attempt \"", "+", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "EXECUTION_ATTEMPTS", ")", ")", ";", "workUnitMap", ".", "put", "(", "workUnit", ".", "getProp", "(", "ComplianceConfigurationKeys", ".", "PARTITION_NAME", ")", ",", "workUnit", ")", ";", "}", "}", "}" ]
Add failed work units in a workUnitMap with partition name as Key. New work units are created using required configuration from the old work unit.
[ "Add", "failed", "work", "units", "in", "a", "workUnitMap", "with", "partition", "name", "as", "Key", ".", "New", "work", "units", "are", "created", "using", "required", "configuration", "from", "the", "old", "work", "unit", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L234-L262
26,069
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.setLowWatermark
protected void setLowWatermark(SourceState state) { this.lowWatermark = getWatermarkFromPreviousWorkUnits(state, ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK); log.info("Setting low watermark for the job: " + this.lowWatermark); }
java
protected void setLowWatermark(SourceState state) { this.lowWatermark = getWatermarkFromPreviousWorkUnits(state, ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK); log.info("Setting low watermark for the job: " + this.lowWatermark); }
[ "protected", "void", "setLowWatermark", "(", "SourceState", "state", ")", "{", "this", ".", "lowWatermark", "=", "getWatermarkFromPreviousWorkUnits", "(", "state", ",", "ComplianceConfigurationKeys", ".", "HIVE_PURGER_WATERMARK", ")", ";", "log", ".", "info", "(", "\"Setting low watermark for the job: \"", "+", "this", ".", "lowWatermark", ")", ";", "}" ]
Sets the local watermark, which is a class variable. Local watermark is a complete partition name which act as the starting point for the creation of fresh work units.
[ "Sets", "the", "local", "watermark", "which", "is", "a", "class", "variable", ".", "Local", "watermark", "is", "a", "complete", "partition", "name", "which", "act", "as", "the", "starting", "point", "for", "the", "creation", "of", "fresh", "work", "units", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L281-L284
26,070
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.submitCycleCompletionEvent
protected void submitCycleCompletionEvent() { if (!this.lowWatermark.equalsIgnoreCase(ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK)) { return; } if (this.executionCount > 1) { // Cycle completed Map<String, String> metadata = new HashMap<>(); metadata.put(ComplianceConfigurationKeys.TOTAL_EXECUTIONS, Integer.toString((this.executionCount - 1))); this.eventSubmitter.submit(ComplianceEvents.Purger.CYCLE_COMPLETED, metadata); this.executionCount = ComplianceConfigurationKeys.DEFAULT_EXECUTION_COUNT; } }
java
protected void submitCycleCompletionEvent() { if (!this.lowWatermark.equalsIgnoreCase(ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK)) { return; } if (this.executionCount > 1) { // Cycle completed Map<String, String> metadata = new HashMap<>(); metadata.put(ComplianceConfigurationKeys.TOTAL_EXECUTIONS, Integer.toString((this.executionCount - 1))); this.eventSubmitter.submit(ComplianceEvents.Purger.CYCLE_COMPLETED, metadata); this.executionCount = ComplianceConfigurationKeys.DEFAULT_EXECUTION_COUNT; } }
[ "protected", "void", "submitCycleCompletionEvent", "(", ")", "{", "if", "(", "!", "this", ".", "lowWatermark", ".", "equalsIgnoreCase", "(", "ComplianceConfigurationKeys", ".", "NO_PREVIOUS_WATERMARK", ")", ")", "{", "return", ";", "}", "if", "(", "this", ".", "executionCount", ">", "1", ")", "{", "// Cycle completed", "Map", "<", "String", ",", "String", ">", "metadata", "=", "new", "HashMap", "<>", "(", ")", ";", "metadata", ".", "put", "(", "ComplianceConfigurationKeys", ".", "TOTAL_EXECUTIONS", ",", "Integer", ".", "toString", "(", "(", "this", ".", "executionCount", "-", "1", ")", ")", ")", ";", "this", ".", "eventSubmitter", ".", "submit", "(", "ComplianceEvents", ".", "Purger", ".", "CYCLE_COMPLETED", ",", "metadata", ")", ";", "this", ".", "executionCount", "=", "ComplianceConfigurationKeys", ".", "DEFAULT_EXECUTION_COUNT", ";", "}", "}" ]
If low watermark is at the reset point, then either cycle is completed or starting for the first time If executionCount is greater than 1, then cycle is completed If cycle is completed, executionCount will be reset and cycle completion event will be submitted
[ "If", "low", "watermark", "is", "at", "the", "reset", "point", "then", "either", "cycle", "is", "completed", "or", "starting", "for", "the", "first", "time", "If", "executionCount", "is", "greater", "than", "1", "then", "cycle", "is", "completed", "If", "cycle", "is", "completed", "executionCount", "will", "be", "reset", "and", "cycle", "completion", "event", "will", "be", "submitted" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L306-L317
26,071
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.setJobWatermark
protected void setJobWatermark(SourceState state, String watermark) { state.setProp(ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK, watermark); log.info("Setting job watermark for the job: " + watermark); }
java
protected void setJobWatermark(SourceState state, String watermark) { state.setProp(ComplianceConfigurationKeys.HIVE_PURGER_WATERMARK, watermark); log.info("Setting job watermark for the job: " + watermark); }
[ "protected", "void", "setJobWatermark", "(", "SourceState", "state", ",", "String", "watermark", ")", "{", "state", ".", "setProp", "(", "ComplianceConfigurationKeys", ".", "HIVE_PURGER_WATERMARK", ",", "watermark", ")", ";", "log", ".", "info", "(", "\"Setting job watermark for the job: \"", "+", "watermark", ")", ";", "}" ]
Sets Job Watermark in the SourceState which will be copied to all WorkUnitStates. Job Watermark is a complete partition name. During next run of this job, fresh work units will be created starting from this partition.
[ "Sets", "Job", "Watermark", "in", "the", "SourceState", "which", "will", "be", "copied", "to", "all", "WorkUnitStates", ".", "Job", "Watermark", "is", "a", "complete", "partition", "name", ".", "During", "next", "run", "of", "this", "job", "fresh", "work", "units", "will", "be", "created", "starting", "from", "this", "partition", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L327-L330
26,072
apache/incubator-gobblin
gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java
HivePurgerSource.getWatermarkFromPreviousWorkUnits
protected static String getWatermarkFromPreviousWorkUnits(SourceState state, String watermark) { if (state.getPreviousWorkUnitStates().isEmpty()) { return ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK; } return state.getPreviousWorkUnitStates().get(0) .getProp(watermark, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK); }
java
protected static String getWatermarkFromPreviousWorkUnits(SourceState state, String watermark) { if (state.getPreviousWorkUnitStates().isEmpty()) { return ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK; } return state.getPreviousWorkUnitStates().get(0) .getProp(watermark, ComplianceConfigurationKeys.NO_PREVIOUS_WATERMARK); }
[ "protected", "static", "String", "getWatermarkFromPreviousWorkUnits", "(", "SourceState", "state", ",", "String", "watermark", ")", "{", "if", "(", "state", ".", "getPreviousWorkUnitStates", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "return", "ComplianceConfigurationKeys", ".", "NO_PREVIOUS_WATERMARK", ";", "}", "return", "state", ".", "getPreviousWorkUnitStates", "(", ")", ".", "get", "(", "0", ")", ".", "getProp", "(", "watermark", ",", "ComplianceConfigurationKeys", ".", "NO_PREVIOUS_WATERMARK", ")", ";", "}" ]
Fetches the value of a watermark given its key from the previous run.
[ "Fetches", "the", "value", "of", "a", "watermark", "given", "its", "key", "from", "the", "previous", "run", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-compliance/src/main/java/org/apache/gobblin/compliance/purger/HivePurgerSource.java#L335-L341
26,073
apache/incubator-gobblin
gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java
SharedRestClientFactory.resolveUriPrefix
public static String resolveUriPrefix(Config config, SharedRestClientKey key) throws URISyntaxException, NotConfiguredException { List<String> connectionPrefixes = parseConnectionPrefixes(config, key); Preconditions.checkArgument(connectionPrefixes.size() > 0, "No uris found for service " + key.serviceName); return connectionPrefixes.get(new Random().nextInt(connectionPrefixes.size())); }
java
public static String resolveUriPrefix(Config config, SharedRestClientKey key) throws URISyntaxException, NotConfiguredException { List<String> connectionPrefixes = parseConnectionPrefixes(config, key); Preconditions.checkArgument(connectionPrefixes.size() > 0, "No uris found for service " + key.serviceName); return connectionPrefixes.get(new Random().nextInt(connectionPrefixes.size())); }
[ "public", "static", "String", "resolveUriPrefix", "(", "Config", "config", ",", "SharedRestClientKey", "key", ")", "throws", "URISyntaxException", ",", "NotConfiguredException", "{", "List", "<", "String", ">", "connectionPrefixes", "=", "parseConnectionPrefixes", "(", "config", ",", "key", ")", ";", "Preconditions", ".", "checkArgument", "(", "connectionPrefixes", ".", "size", "(", ")", ">", "0", ",", "\"No uris found for service \"", "+", "key", ".", "serviceName", ")", ";", "return", "connectionPrefixes", ".", "get", "(", "new", "Random", "(", ")", ".", "nextInt", "(", "connectionPrefixes", ".", "size", "(", ")", ")", ")", ";", "}" ]
Get a uri prefix from the input configuration.
[ "Get", "a", "uri", "prefix", "from", "the", "input", "configuration", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java#L108-L114
26,074
apache/incubator-gobblin
gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java
SharedRestClientFactory.parseConnectionPrefixes
public static List<String> parseConnectionPrefixes(Config config, SharedRestClientKey key) throws URISyntaxException, NotConfiguredException { if (key instanceof UriRestClientKey) { return Lists.newArrayList(((UriRestClientKey) key).getUri()); } if (!config.hasPath(SERVER_URI_KEY)) { throw new NotConfiguredException("Missing key " + SERVER_URI_KEY); } List<String> uris = Lists.newArrayList(); for (String uri : Splitter.on(",").omitEmptyStrings().trimResults().splitToList(config.getString(SERVER_URI_KEY))) { uris.add(resolveUriPrefix(new URI(uri))); } return uris; }
java
public static List<String> parseConnectionPrefixes(Config config, SharedRestClientKey key) throws URISyntaxException, NotConfiguredException { if (key instanceof UriRestClientKey) { return Lists.newArrayList(((UriRestClientKey) key).getUri()); } if (!config.hasPath(SERVER_URI_KEY)) { throw new NotConfiguredException("Missing key " + SERVER_URI_KEY); } List<String> uris = Lists.newArrayList(); for (String uri : Splitter.on(",").omitEmptyStrings().trimResults().splitToList(config.getString(SERVER_URI_KEY))) { uris.add(resolveUriPrefix(new URI(uri))); } return uris; }
[ "public", "static", "List", "<", "String", ">", "parseConnectionPrefixes", "(", "Config", "config", ",", "SharedRestClientKey", "key", ")", "throws", "URISyntaxException", ",", "NotConfiguredException", "{", "if", "(", "key", "instanceof", "UriRestClientKey", ")", "{", "return", "Lists", ".", "newArrayList", "(", "(", "(", "UriRestClientKey", ")", "key", ")", ".", "getUri", "(", ")", ")", ";", "}", "if", "(", "!", "config", ".", "hasPath", "(", "SERVER_URI_KEY", ")", ")", "{", "throw", "new", "NotConfiguredException", "(", "\"Missing key \"", "+", "SERVER_URI_KEY", ")", ";", "}", "List", "<", "String", ">", "uris", "=", "Lists", ".", "newArrayList", "(", ")", ";", "for", "(", "String", "uri", ":", "Splitter", ".", "on", "(", "\",\"", ")", ".", "omitEmptyStrings", "(", ")", ".", "trimResults", "(", ")", ".", "splitToList", "(", "config", ".", "getString", "(", "SERVER_URI_KEY", ")", ")", ")", "{", "uris", ".", "add", "(", "resolveUriPrefix", "(", "new", "URI", "(", "uri", ")", ")", ")", ";", "}", "return", "uris", ";", "}" ]
Parse the list of available input prefixes from the input configuration.
[ "Parse", "the", "list", "of", "available", "input", "prefixes", "from", "the", "input", "configuration", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java#L119-L133
26,075
apache/incubator-gobblin
gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java
SharedRestClientFactory.resolveUriPrefix
public static String resolveUriPrefix(URI serverURI) throws URISyntaxException { if (RESTLI_SCHEMES.contains(serverURI.getScheme())) { return new URI(serverURI.getScheme(), serverURI.getAuthority(), null, null, null).toString() + "/"; } throw new RuntimeException("Unrecognized scheme for URI " + serverURI); }
java
public static String resolveUriPrefix(URI serverURI) throws URISyntaxException { if (RESTLI_SCHEMES.contains(serverURI.getScheme())) { return new URI(serverURI.getScheme(), serverURI.getAuthority(), null, null, null).toString() + "/"; } throw new RuntimeException("Unrecognized scheme for URI " + serverURI); }
[ "public", "static", "String", "resolveUriPrefix", "(", "URI", "serverURI", ")", "throws", "URISyntaxException", "{", "if", "(", "RESTLI_SCHEMES", ".", "contains", "(", "serverURI", ".", "getScheme", "(", ")", ")", ")", "{", "return", "new", "URI", "(", "serverURI", ".", "getScheme", "(", ")", ",", "serverURI", ".", "getAuthority", "(", ")", ",", "null", ",", "null", ",", "null", ")", ".", "toString", "(", ")", "+", "\"/\"", ";", "}", "throw", "new", "RuntimeException", "(", "\"Unrecognized scheme for URI \"", "+", "serverURI", ")", ";", "}" ]
Convert the input URI into a correctly formatted uri prefix. In the future, may also resolve d2 uris.
[ "Convert", "the", "input", "URI", "into", "a", "correctly", "formatted", "uri", "prefix", ".", "In", "the", "future", "may", "also", "resolve", "d2", "uris", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-restli/gobblin-restli-utils/src/main/java/org/apache/gobblin/restli/SharedRestClientFactory.java#L138-L145
26,076
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.addAll
public void addAll(GlobalMetadata other) { throwIfImmutable(); datasetLevel.putAll(other.datasetLevel); for (Map.Entry<String, Map<String, Object>> e : other.fileLevel.entrySet()) { Map<String, Object> val = new ConcurrentHashMap<>(); val.putAll(e.getValue()); fileLevel.put(e.getKey(), val); } cachedId = null; }
java
public void addAll(GlobalMetadata other) { throwIfImmutable(); datasetLevel.putAll(other.datasetLevel); for (Map.Entry<String, Map<String, Object>> e : other.fileLevel.entrySet()) { Map<String, Object> val = new ConcurrentHashMap<>(); val.putAll(e.getValue()); fileLevel.put(e.getKey(), val); } cachedId = null; }
[ "public", "void", "addAll", "(", "GlobalMetadata", "other", ")", "{", "throwIfImmutable", "(", ")", ";", "datasetLevel", ".", "putAll", "(", "other", ".", "datasetLevel", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Map", "<", "String", ",", "Object", ">", ">", "e", ":", "other", ".", "fileLevel", ".", "entrySet", "(", ")", ")", "{", "Map", "<", "String", ",", "Object", ">", "val", "=", "new", "ConcurrentHashMap", "<>", "(", ")", ";", "val", ".", "putAll", "(", "e", ".", "getValue", "(", ")", ")", ";", "fileLevel", ".", "put", "(", "e", ".", "getKey", "(", ")", ",", "val", ")", ";", "}", "cachedId", "=", "null", ";", "}" ]
Merge another GlobalMetadata object into this one. All keys from 'other' will be placed into this object, replacing any already existing keys. @param other Metadata object to add
[ "Merge", "another", "GlobalMetadata", "object", "into", "this", "one", ".", "All", "keys", "from", "other", "will", "be", "placed", "into", "this", "object", "replacing", "any", "already", "existing", "keys", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L104-L115
26,077
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.toJsonUtf8
public byte[] toJsonUtf8() { try { ByteArrayOutputStream bOs = new ByteArrayOutputStream(512); try (JsonGenerator generator = jsonFactory.createJsonGenerator(bOs, JsonEncoding.UTF8) .setCodec(objectMapper)) { toJsonUtf8(generator); } return bOs.toByteArray(); } catch (IOException e) { throw new RuntimeException("Unexpected IOException serializing to ByteArray", e); } }
java
public byte[] toJsonUtf8() { try { ByteArrayOutputStream bOs = new ByteArrayOutputStream(512); try (JsonGenerator generator = jsonFactory.createJsonGenerator(bOs, JsonEncoding.UTF8) .setCodec(objectMapper)) { toJsonUtf8(generator); } return bOs.toByteArray(); } catch (IOException e) { throw new RuntimeException("Unexpected IOException serializing to ByteArray", e); } }
[ "public", "byte", "[", "]", "toJsonUtf8", "(", ")", "{", "try", "{", "ByteArrayOutputStream", "bOs", "=", "new", "ByteArrayOutputStream", "(", "512", ")", ";", "try", "(", "JsonGenerator", "generator", "=", "jsonFactory", ".", "createJsonGenerator", "(", "bOs", ",", "JsonEncoding", ".", "UTF8", ")", ".", "setCodec", "(", "objectMapper", ")", ")", "{", "toJsonUtf8", "(", "generator", ")", ";", "}", "return", "bOs", ".", "toByteArray", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unexpected IOException serializing to ByteArray\"", ",", "e", ")", ";", "}", "}" ]
Serialize as a UTF8 encoded JSON string.
[ "Serialize", "as", "a", "UTF8", "encoded", "JSON", "string", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L148-L161
26,078
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.bodyToJsonUtf8
protected void bodyToJsonUtf8(JsonGenerator generator) throws IOException { generator.writeObjectField("dataset", datasetLevel); generator.writeObjectFieldStart("file"); for (Map.Entry<String, Map<String, Object>> entry : fileLevel.entrySet()) { generator.writeObjectField(entry.getKey(), entry.getValue()); } generator.writeEndObject(); }
java
protected void bodyToJsonUtf8(JsonGenerator generator) throws IOException { generator.writeObjectField("dataset", datasetLevel); generator.writeObjectFieldStart("file"); for (Map.Entry<String, Map<String, Object>> entry : fileLevel.entrySet()) { generator.writeObjectField(entry.getKey(), entry.getValue()); } generator.writeEndObject(); }
[ "protected", "void", "bodyToJsonUtf8", "(", "JsonGenerator", "generator", ")", "throws", "IOException", "{", "generator", ".", "writeObjectField", "(", "\"dataset\"", ",", "datasetLevel", ")", ";", "generator", ".", "writeObjectFieldStart", "(", "\"file\"", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Map", "<", "String", ",", "Object", ">", ">", "entry", ":", "fileLevel", ".", "entrySet", "(", ")", ")", "{", "generator", ".", "writeObjectField", "(", "entry", ".", "getKey", "(", ")", ",", "entry", ".", "getValue", "(", ")", ")", ";", "}", "generator", ".", "writeEndObject", "(", ")", ";", "}" ]
Write this object out to an existing JSON stream
[ "Write", "this", "object", "out", "to", "an", "existing", "JSON", "stream" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L187-L197
26,079
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.setDatasetMetadata
public void setDatasetMetadata(String key, Object val) { throwIfImmutable(); datasetLevel.put(key, val); cachedId = null; }
java
public void setDatasetMetadata(String key, Object val) { throwIfImmutable(); datasetLevel.put(key, val); cachedId = null; }
[ "public", "void", "setDatasetMetadata", "(", "String", "key", ",", "Object", "val", ")", "{", "throwIfImmutable", "(", ")", ";", "datasetLevel", ".", "put", "(", "key", ",", "val", ")", ";", "cachedId", "=", "null", ";", "}" ]
Set an arbitrary dataset-level metadata key
[ "Set", "an", "arbitrary", "dataset", "-", "level", "metadata", "key" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L268-L272
26,080
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.addTransferEncoding
public synchronized void addTransferEncoding(String encoding) { throwIfImmutable(); List<String> encodings = getTransferEncoding(); if (encodings == null) { encodings = new ArrayList<>(); } encodings.add(encoding); setDatasetMetadata(TRANSFER_ENCODING_KEY, encodings); }
java
public synchronized void addTransferEncoding(String encoding) { throwIfImmutable(); List<String> encodings = getTransferEncoding(); if (encodings == null) { encodings = new ArrayList<>(); } encodings.add(encoding); setDatasetMetadata(TRANSFER_ENCODING_KEY, encodings); }
[ "public", "synchronized", "void", "addTransferEncoding", "(", "String", "encoding", ")", "{", "throwIfImmutable", "(", ")", ";", "List", "<", "String", ">", "encodings", "=", "getTransferEncoding", "(", ")", ";", "if", "(", "encodings", "==", "null", ")", "{", "encodings", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "encodings", ".", "add", "(", "encoding", ")", ";", "setDatasetMetadata", "(", "TRANSFER_ENCODING_KEY", ",", "encodings", ")", ";", "}" ]
Convenience method to add a new transfer-encoding to a dataset
[ "Convenience", "method", "to", "add", "a", "new", "transfer", "-", "encoding", "to", "a", "dataset" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L285-L295
26,081
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.getFileMetadata
public Object getFileMetadata(String file, String key) { Map<String, Object> fileKeys = fileLevel.get(file); if (fileKeys == null) { return null; } return fileKeys.get(key); }
java
public Object getFileMetadata(String file, String key) { Map<String, Object> fileKeys = fileLevel.get(file); if (fileKeys == null) { return null; } return fileKeys.get(key); }
[ "public", "Object", "getFileMetadata", "(", "String", "file", ",", "String", "key", ")", "{", "Map", "<", "String", ",", "Object", ">", "fileKeys", "=", "fileLevel", ".", "get", "(", "file", ")", ";", "if", "(", "fileKeys", "==", "null", ")", "{", "return", "null", ";", "}", "return", "fileKeys", ".", "get", "(", "key", ")", ";", "}" ]
Get an arbitrary file-level metadata key
[ "Get", "an", "arbitrary", "file", "-", "level", "metadata", "key" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L313-L320
26,082
apache/incubator-gobblin
gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java
GlobalMetadata.setFileMetadata
public void setFileMetadata(String file, String key, Object val) { throwIfImmutable(); Map<String, Object> fileKeys = fileLevel.get(file); if (fileKeys == null) { fileKeys = new ConcurrentHashMap<>(); fileLevel.put(file, fileKeys); } fileKeys.put(key, val); cachedId = null; }
java
public void setFileMetadata(String file, String key, Object val) { throwIfImmutable(); Map<String, Object> fileKeys = fileLevel.get(file); if (fileKeys == null) { fileKeys = new ConcurrentHashMap<>(); fileLevel.put(file, fileKeys); } fileKeys.put(key, val); cachedId = null; }
[ "public", "void", "setFileMetadata", "(", "String", "file", ",", "String", "key", ",", "Object", "val", ")", "{", "throwIfImmutable", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "fileKeys", "=", "fileLevel", ".", "get", "(", "file", ")", ";", "if", "(", "fileKeys", "==", "null", ")", "{", "fileKeys", "=", "new", "ConcurrentHashMap", "<>", "(", ")", ";", "fileLevel", ".", "put", "(", "file", ",", "fileKeys", ")", ";", "}", "fileKeys", ".", "put", "(", "key", ",", "val", ")", ";", "cachedId", "=", "null", ";", "}" ]
Set an arbitrary file-level metadata key
[ "Set", "an", "arbitrary", "file", "-", "level", "metadata", "key" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-modules/gobblin-metadata/src/main/java/org/apache/gobblin/metadata/types/GlobalMetadata.java#L325-L335
26,083
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java
ExponentialBackoff.awaitNextRetry
public void awaitNextRetry() throws InterruptedException, NoMoreRetriesException { this.retryNumber++; if (this.retryNumber > this.maxRetries) { throw new NoMoreRetriesException("Reached maximum number of retries: " + this.maxRetries); } else if (this.totalWait > this.maxWait) { throw new NoMoreRetriesException("Reached maximum time to wait: " + this.maxWait); } Thread.sleep(this.nextDelay); this.totalWait += this.nextDelay; this.nextDelay = Math.min((long) (this.alpha * this.nextDelay) + 1, this.maxDelay); }
java
public void awaitNextRetry() throws InterruptedException, NoMoreRetriesException { this.retryNumber++; if (this.retryNumber > this.maxRetries) { throw new NoMoreRetriesException("Reached maximum number of retries: " + this.maxRetries); } else if (this.totalWait > this.maxWait) { throw new NoMoreRetriesException("Reached maximum time to wait: " + this.maxWait); } Thread.sleep(this.nextDelay); this.totalWait += this.nextDelay; this.nextDelay = Math.min((long) (this.alpha * this.nextDelay) + 1, this.maxDelay); }
[ "public", "void", "awaitNextRetry", "(", ")", "throws", "InterruptedException", ",", "NoMoreRetriesException", "{", "this", ".", "retryNumber", "++", ";", "if", "(", "this", ".", "retryNumber", ">", "this", ".", "maxRetries", ")", "{", "throw", "new", "NoMoreRetriesException", "(", "\"Reached maximum number of retries: \"", "+", "this", ".", "maxRetries", ")", ";", "}", "else", "if", "(", "this", ".", "totalWait", ">", "this", ".", "maxWait", ")", "{", "throw", "new", "NoMoreRetriesException", "(", "\"Reached maximum time to wait: \"", "+", "this", ".", "maxWait", ")", ";", "}", "Thread", ".", "sleep", "(", "this", ".", "nextDelay", ")", ";", "this", ".", "totalWait", "+=", "this", ".", "nextDelay", ";", "this", ".", "nextDelay", "=", "Math", ".", "min", "(", "(", "long", ")", "(", "this", ".", "alpha", "*", "this", ".", "nextDelay", ")", "+", "1", ",", "this", ".", "maxDelay", ")", ";", "}" ]
Block until next retry can be executed. This method throws an exception if the max number of retries has been reached. For an alternative see {@link #awaitNextRetryIfAvailable()}. @throws NoMoreRetriesException If maximum number of retries has been reached.
[ "Block", "until", "next", "retry", "can", "be", "executed", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java#L68-L78
26,084
apache/incubator-gobblin
gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java
ExponentialBackoff.evaluateConditionUntilTrue
@Builder(builderMethodName = "awaitCondition", buildMethodName = "await") private static boolean evaluateConditionUntilTrue(Callable<Boolean> callable, Double alpha, Integer maxRetries, Long maxWait, Long maxDelay, Long initialDelay) throws ExecutionException, InterruptedException { ExponentialBackoff exponentialBackoff = new ExponentialBackoff(alpha, maxRetries, maxWait, maxDelay, initialDelay); while (true) { try { if (callable.call()) { return true; } } catch (Throwable t) { throw new ExecutionException(t); } if (!exponentialBackoff.awaitNextRetryIfAvailable()) { return false; } } }
java
@Builder(builderMethodName = "awaitCondition", buildMethodName = "await") private static boolean evaluateConditionUntilTrue(Callable<Boolean> callable, Double alpha, Integer maxRetries, Long maxWait, Long maxDelay, Long initialDelay) throws ExecutionException, InterruptedException { ExponentialBackoff exponentialBackoff = new ExponentialBackoff(alpha, maxRetries, maxWait, maxDelay, initialDelay); while (true) { try { if (callable.call()) { return true; } } catch (Throwable t) { throw new ExecutionException(t); } if (!exponentialBackoff.awaitNextRetryIfAvailable()) { return false; } } }
[ "@", "Builder", "(", "builderMethodName", "=", "\"awaitCondition\"", ",", "buildMethodName", "=", "\"await\"", ")", "private", "static", "boolean", "evaluateConditionUntilTrue", "(", "Callable", "<", "Boolean", ">", "callable", ",", "Double", "alpha", ",", "Integer", "maxRetries", ",", "Long", "maxWait", ",", "Long", "maxDelay", ",", "Long", "initialDelay", ")", "throws", "ExecutionException", ",", "InterruptedException", "{", "ExponentialBackoff", "exponentialBackoff", "=", "new", "ExponentialBackoff", "(", "alpha", ",", "maxRetries", ",", "maxWait", ",", "maxDelay", ",", "initialDelay", ")", ";", "while", "(", "true", ")", "{", "try", "{", "if", "(", "callable", ".", "call", "(", ")", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "throw", "new", "ExecutionException", "(", "t", ")", ";", "}", "if", "(", "!", "exponentialBackoff", ".", "awaitNextRetryIfAvailable", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}" ]
Evaluate a condition until true with exponential backoff. @param callable Condition. @return true if the condition returned true. @throws ExecutionException if the condition throws an exception.
[ "Evaluate", "a", "condition", "until", "true", "with", "exponential", "backoff", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-utility/src/main/java/org/apache/gobblin/util/ExponentialBackoff.java#L112-L128
26,085
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/avro/MRCompactorAvroKeyDedupJobRunner.java
MRCompactorAvroKeyDedupJobRunner.isKeySchemaValid
public static boolean isKeySchemaValid(Schema keySchema, Schema topicSchema) { return SchemaCompatibility.checkReaderWriterCompatibility(keySchema, topicSchema).getType() .equals(SchemaCompatibilityType.COMPATIBLE); }
java
public static boolean isKeySchemaValid(Schema keySchema, Schema topicSchema) { return SchemaCompatibility.checkReaderWriterCompatibility(keySchema, topicSchema).getType() .equals(SchemaCompatibilityType.COMPATIBLE); }
[ "public", "static", "boolean", "isKeySchemaValid", "(", "Schema", "keySchema", ",", "Schema", "topicSchema", ")", "{", "return", "SchemaCompatibility", ".", "checkReaderWriterCompatibility", "(", "keySchema", ",", "topicSchema", ")", ".", "getType", "(", ")", ".", "equals", "(", "SchemaCompatibilityType", ".", "COMPATIBLE", ")", ";", "}" ]
keySchema is valid if a record with newestSchema can be converted to a record with keySchema.
[ "keySchema", "is", "valid", "if", "a", "record", "with", "newestSchema", "can", "be", "converted", "to", "a", "record", "with", "keySchema", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/avro/MRCompactorAvroKeyDedupJobRunner.java#L215-L218
26,086
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/async/AsyncRequest.java
AsyncRequest.markRecord
public void markRecord(BufferedRecord<D> record, int bytesWritten) { synchronized (this) { thunks.add(new Thunk<>(record, bytesWritten)); byteSize += bytesWritten; } }
java
public void markRecord(BufferedRecord<D> record, int bytesWritten) { synchronized (this) { thunks.add(new Thunk<>(record, bytesWritten)); byteSize += bytesWritten; } }
[ "public", "void", "markRecord", "(", "BufferedRecord", "<", "D", ">", "record", ",", "int", "bytesWritten", ")", "{", "synchronized", "(", "this", ")", "{", "thunks", ".", "add", "(", "new", "Thunk", "<>", "(", "record", ",", "bytesWritten", ")", ")", ";", "byteSize", "+=", "bytesWritten", ";", "}", "}" ]
Mark the record associated with this request @param record buffered record @param bytesWritten bytes of the record written into the request
[ "Mark", "the", "record", "associated", "with", "this", "request" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/async/AsyncRequest.java#L71-L76
26,087
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.interruptGracefully
private void interruptGracefully() throws IOException { LOG.info("Attempting graceful interruption of job " + this.jobContext.getJobId()); this.fs.createNewFile(this.interruptPath); long waitTimeStart = System.currentTimeMillis(); while (!this.job.isComplete() && System.currentTimeMillis() < waitTimeStart + 30 * 1000) { try { Thread.sleep(1000); } catch (InterruptedException ie) { break; } } if (!this.job.isComplete()) { LOG.info("Interrupted job did not shut itself down after timeout. Killing job."); this.job.killJob(); } }
java
private void interruptGracefully() throws IOException { LOG.info("Attempting graceful interruption of job " + this.jobContext.getJobId()); this.fs.createNewFile(this.interruptPath); long waitTimeStart = System.currentTimeMillis(); while (!this.job.isComplete() && System.currentTimeMillis() < waitTimeStart + 30 * 1000) { try { Thread.sleep(1000); } catch (InterruptedException ie) { break; } } if (!this.job.isComplete()) { LOG.info("Interrupted job did not shut itself down after timeout. Killing job."); this.job.killJob(); } }
[ "private", "void", "interruptGracefully", "(", ")", "throws", "IOException", "{", "LOG", ".", "info", "(", "\"Attempting graceful interruption of job \"", "+", "this", ".", "jobContext", ".", "getJobId", "(", ")", ")", ";", "this", ".", "fs", ".", "createNewFile", "(", "this", ".", "interruptPath", ")", ";", "long", "waitTimeStart", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "while", "(", "!", "this", ".", "job", ".", "isComplete", "(", ")", "&&", "System", ".", "currentTimeMillis", "(", ")", "<", "waitTimeStart", "+", "30", "*", "1000", ")", "{", "try", "{", "Thread", ".", "sleep", "(", "1000", ")", ";", "}", "catch", "(", "InterruptedException", "ie", ")", "{", "break", ";", "}", "}", "if", "(", "!", "this", ".", "job", ".", "isComplete", "(", ")", ")", "{", "LOG", ".", "info", "(", "\"Interrupted job did not shut itself down after timeout. Killing job.\"", ")", ";", "this", ".", "job", ".", "killJob", "(", ")", ";", "}", "}" ]
Attempt a gracious interruption of the running job
[ "Attempt", "a", "gracious", "interruption", "of", "the", "running", "job" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L333-L351
26,088
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.addDependencies
private void addDependencies(Configuration conf) throws IOException { TimingEvent distributedCacheSetupTimer = this.eventSubmitter.getTimingEvent(TimingEvent.RunJobTimings.MR_DISTRIBUTED_CACHE_SETUP); Path jarFileDir = this.jarsDir; // Add framework jars to the classpath for the mappers/reducer if (this.jobProps.containsKey(ConfigurationKeys.FRAMEWORK_JAR_FILES_KEY)) { addJars(jarFileDir, this.jobProps.getProperty(ConfigurationKeys.FRAMEWORK_JAR_FILES_KEY), conf); } // Add job-specific jars to the classpath for the mappers if (this.jobProps.containsKey(ConfigurationKeys.JOB_JAR_FILES_KEY)) { addJars(jarFileDir, this.jobProps.getProperty(ConfigurationKeys.JOB_JAR_FILES_KEY), conf); } // Add other files (if any) the job depends on to DistributedCache if (this.jobProps.containsKey(ConfigurationKeys.JOB_LOCAL_FILES_KEY)) { addLocalFiles(new Path(this.mrJobDir, FILES_DIR_NAME), this.jobProps.getProperty(ConfigurationKeys.JOB_LOCAL_FILES_KEY), conf); } // Add files (if any) already on HDFS that the job depends on to DistributedCache if (this.jobProps.containsKey(ConfigurationKeys.JOB_HDFS_FILES_KEY)) { addHDFSFiles(this.jobProps.getProperty(ConfigurationKeys.JOB_HDFS_FILES_KEY), conf); } // Add job-specific jars existing in HDFS to the classpath for the mappers if (this.jobProps.containsKey(ConfigurationKeys.JOB_JAR_HDFS_FILES_KEY)) { addHdfsJars(this.jobProps.getProperty(ConfigurationKeys.JOB_JAR_HDFS_FILES_KEY), conf); } distributedCacheSetupTimer.stop(); }
java
private void addDependencies(Configuration conf) throws IOException { TimingEvent distributedCacheSetupTimer = this.eventSubmitter.getTimingEvent(TimingEvent.RunJobTimings.MR_DISTRIBUTED_CACHE_SETUP); Path jarFileDir = this.jarsDir; // Add framework jars to the classpath for the mappers/reducer if (this.jobProps.containsKey(ConfigurationKeys.FRAMEWORK_JAR_FILES_KEY)) { addJars(jarFileDir, this.jobProps.getProperty(ConfigurationKeys.FRAMEWORK_JAR_FILES_KEY), conf); } // Add job-specific jars to the classpath for the mappers if (this.jobProps.containsKey(ConfigurationKeys.JOB_JAR_FILES_KEY)) { addJars(jarFileDir, this.jobProps.getProperty(ConfigurationKeys.JOB_JAR_FILES_KEY), conf); } // Add other files (if any) the job depends on to DistributedCache if (this.jobProps.containsKey(ConfigurationKeys.JOB_LOCAL_FILES_KEY)) { addLocalFiles(new Path(this.mrJobDir, FILES_DIR_NAME), this.jobProps.getProperty(ConfigurationKeys.JOB_LOCAL_FILES_KEY), conf); } // Add files (if any) already on HDFS that the job depends on to DistributedCache if (this.jobProps.containsKey(ConfigurationKeys.JOB_HDFS_FILES_KEY)) { addHDFSFiles(this.jobProps.getProperty(ConfigurationKeys.JOB_HDFS_FILES_KEY), conf); } // Add job-specific jars existing in HDFS to the classpath for the mappers if (this.jobProps.containsKey(ConfigurationKeys.JOB_JAR_HDFS_FILES_KEY)) { addHdfsJars(this.jobProps.getProperty(ConfigurationKeys.JOB_JAR_HDFS_FILES_KEY), conf); } distributedCacheSetupTimer.stop(); }
[ "private", "void", "addDependencies", "(", "Configuration", "conf", ")", "throws", "IOException", "{", "TimingEvent", "distributedCacheSetupTimer", "=", "this", ".", "eventSubmitter", ".", "getTimingEvent", "(", "TimingEvent", ".", "RunJobTimings", ".", "MR_DISTRIBUTED_CACHE_SETUP", ")", ";", "Path", "jarFileDir", "=", "this", ".", "jarsDir", ";", "// Add framework jars to the classpath for the mappers/reducer", "if", "(", "this", ".", "jobProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "FRAMEWORK_JAR_FILES_KEY", ")", ")", "{", "addJars", "(", "jarFileDir", ",", "this", ".", "jobProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "FRAMEWORK_JAR_FILES_KEY", ")", ",", "conf", ")", ";", "}", "// Add job-specific jars to the classpath for the mappers", "if", "(", "this", ".", "jobProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_JAR_FILES_KEY", ")", ")", "{", "addJars", "(", "jarFileDir", ",", "this", ".", "jobProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_JAR_FILES_KEY", ")", ",", "conf", ")", ";", "}", "// Add other files (if any) the job depends on to DistributedCache", "if", "(", "this", ".", "jobProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_LOCAL_FILES_KEY", ")", ")", "{", "addLocalFiles", "(", "new", "Path", "(", "this", ".", "mrJobDir", ",", "FILES_DIR_NAME", ")", ",", "this", ".", "jobProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_LOCAL_FILES_KEY", ")", ",", "conf", ")", ";", "}", "// Add files (if any) already on HDFS that the job depends on to DistributedCache", "if", "(", "this", ".", "jobProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_HDFS_FILES_KEY", ")", ")", "{", "addHDFSFiles", "(", "this", ".", "jobProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_HDFS_FILES_KEY", ")", ",", "conf", ")", ";", "}", "// Add job-specific jars existing in HDFS to the classpath for the mappers", "if", "(", "this", ".", "jobProps", ".", "containsKey", "(", "ConfigurationKeys", ".", "JOB_JAR_HDFS_FILES_KEY", ")", ")", "{", "addHdfsJars", "(", "this", ".", "jobProps", ".", "getProperty", "(", "ConfigurationKeys", ".", "JOB_JAR_HDFS_FILES_KEY", ")", ",", "conf", ")", ";", "}", "distributedCacheSetupTimer", ".", "stop", "(", ")", ";", "}" ]
Add dependent jars and files.
[ "Add", "dependent", "jars", "and", "files", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L363-L396
26,089
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.addJars
@SuppressWarnings("deprecation") private void addJars(Path jarFileDir, String jarFileList, Configuration conf) throws IOException { LocalFileSystem lfs = FileSystem.getLocal(conf); for (String jarFile : SPLITTER.split(jarFileList)) { Path srcJarFile = new Path(jarFile); FileStatus[] fileStatusList = lfs.globStatus(srcJarFile); for (FileStatus status : fileStatusList) { // For each FileStatus there are chances it could fail in copying at the first attempt, due to file-existence // or file-copy is ongoing by other job instance since all Gobblin jobs share the same jar file directory. // the retryCount is to avoid cases (if any) where retry is going too far and causes job hanging. int retryCount = 0; boolean shouldFileBeAddedIntoDC = true; Path destJarFile = calculateDestJarFile(status, jarFileDir); // Adding destJarFile into HDFS until it exists and the size of file on targetPath matches the one on local path. while (!this.fs.exists(destJarFile) || fs.getFileStatus(destJarFile).getLen() != status.getLen()) { try { if (this.fs.exists(destJarFile) && fs.getFileStatus(destJarFile).getLen() != status.getLen()) { Thread.sleep(WAITING_TIME_ON_IMCOMPLETE_UPLOAD); throw new IOException("Waiting for file to complete on uploading ... "); } // Set the first parameter as false for not deleting sourceFile // Set the second parameter as false for not overwriting existing file on the target, by default it is true. // If the file is preExisted but overwrite flag set to false, then an IOException if thrown. this.fs.copyFromLocalFile(false, false, status.getPath(), destJarFile); } catch (IOException | InterruptedException e) { LOG.warn("Path:" + destJarFile + " is not copied successfully. Will require retry."); retryCount += 1; if (retryCount >= this.jarFileMaximumRetry) { LOG.error("The jar file:" + destJarFile + "failed in being copied into hdfs", e); // If retry reaches upper limit, skip copying this file. shouldFileBeAddedIntoDC = false; break; } } } if (shouldFileBeAddedIntoDC) { // Then add the jar file on HDFS to the classpath LOG.info(String.format("Adding %s to classpath", destJarFile)); DistributedCache.addFileToClassPath(destJarFile, conf, this.fs); } } } }
java
@SuppressWarnings("deprecation") private void addJars(Path jarFileDir, String jarFileList, Configuration conf) throws IOException { LocalFileSystem lfs = FileSystem.getLocal(conf); for (String jarFile : SPLITTER.split(jarFileList)) { Path srcJarFile = new Path(jarFile); FileStatus[] fileStatusList = lfs.globStatus(srcJarFile); for (FileStatus status : fileStatusList) { // For each FileStatus there are chances it could fail in copying at the first attempt, due to file-existence // or file-copy is ongoing by other job instance since all Gobblin jobs share the same jar file directory. // the retryCount is to avoid cases (if any) where retry is going too far and causes job hanging. int retryCount = 0; boolean shouldFileBeAddedIntoDC = true; Path destJarFile = calculateDestJarFile(status, jarFileDir); // Adding destJarFile into HDFS until it exists and the size of file on targetPath matches the one on local path. while (!this.fs.exists(destJarFile) || fs.getFileStatus(destJarFile).getLen() != status.getLen()) { try { if (this.fs.exists(destJarFile) && fs.getFileStatus(destJarFile).getLen() != status.getLen()) { Thread.sleep(WAITING_TIME_ON_IMCOMPLETE_UPLOAD); throw new IOException("Waiting for file to complete on uploading ... "); } // Set the first parameter as false for not deleting sourceFile // Set the second parameter as false for not overwriting existing file on the target, by default it is true. // If the file is preExisted but overwrite flag set to false, then an IOException if thrown. this.fs.copyFromLocalFile(false, false, status.getPath(), destJarFile); } catch (IOException | InterruptedException e) { LOG.warn("Path:" + destJarFile + " is not copied successfully. Will require retry."); retryCount += 1; if (retryCount >= this.jarFileMaximumRetry) { LOG.error("The jar file:" + destJarFile + "failed in being copied into hdfs", e); // If retry reaches upper limit, skip copying this file. shouldFileBeAddedIntoDC = false; break; } } } if (shouldFileBeAddedIntoDC) { // Then add the jar file on HDFS to the classpath LOG.info(String.format("Adding %s to classpath", destJarFile)); DistributedCache.addFileToClassPath(destJarFile, conf, this.fs); } } } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "private", "void", "addJars", "(", "Path", "jarFileDir", ",", "String", "jarFileList", ",", "Configuration", "conf", ")", "throws", "IOException", "{", "LocalFileSystem", "lfs", "=", "FileSystem", ".", "getLocal", "(", "conf", ")", ";", "for", "(", "String", "jarFile", ":", "SPLITTER", ".", "split", "(", "jarFileList", ")", ")", "{", "Path", "srcJarFile", "=", "new", "Path", "(", "jarFile", ")", ";", "FileStatus", "[", "]", "fileStatusList", "=", "lfs", ".", "globStatus", "(", "srcJarFile", ")", ";", "for", "(", "FileStatus", "status", ":", "fileStatusList", ")", "{", "// For each FileStatus there are chances it could fail in copying at the first attempt, due to file-existence", "// or file-copy is ongoing by other job instance since all Gobblin jobs share the same jar file directory.", "// the retryCount is to avoid cases (if any) where retry is going too far and causes job hanging.", "int", "retryCount", "=", "0", ";", "boolean", "shouldFileBeAddedIntoDC", "=", "true", ";", "Path", "destJarFile", "=", "calculateDestJarFile", "(", "status", ",", "jarFileDir", ")", ";", "// Adding destJarFile into HDFS until it exists and the size of file on targetPath matches the one on local path.", "while", "(", "!", "this", ".", "fs", ".", "exists", "(", "destJarFile", ")", "||", "fs", ".", "getFileStatus", "(", "destJarFile", ")", ".", "getLen", "(", ")", "!=", "status", ".", "getLen", "(", ")", ")", "{", "try", "{", "if", "(", "this", ".", "fs", ".", "exists", "(", "destJarFile", ")", "&&", "fs", ".", "getFileStatus", "(", "destJarFile", ")", ".", "getLen", "(", ")", "!=", "status", ".", "getLen", "(", ")", ")", "{", "Thread", ".", "sleep", "(", "WAITING_TIME_ON_IMCOMPLETE_UPLOAD", ")", ";", "throw", "new", "IOException", "(", "\"Waiting for file to complete on uploading ... \"", ")", ";", "}", "// Set the first parameter as false for not deleting sourceFile", "// Set the second parameter as false for not overwriting existing file on the target, by default it is true.", "// If the file is preExisted but overwrite flag set to false, then an IOException if thrown.", "this", ".", "fs", ".", "copyFromLocalFile", "(", "false", ",", "false", ",", "status", ".", "getPath", "(", ")", ",", "destJarFile", ")", ";", "}", "catch", "(", "IOException", "|", "InterruptedException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Path:\"", "+", "destJarFile", "+", "\" is not copied successfully. Will require retry.\"", ")", ";", "retryCount", "+=", "1", ";", "if", "(", "retryCount", ">=", "this", ".", "jarFileMaximumRetry", ")", "{", "LOG", ".", "error", "(", "\"The jar file:\"", "+", "destJarFile", "+", "\"failed in being copied into hdfs\"", ",", "e", ")", ";", "// If retry reaches upper limit, skip copying this file.", "shouldFileBeAddedIntoDC", "=", "false", ";", "break", ";", "}", "}", "}", "if", "(", "shouldFileBeAddedIntoDC", ")", "{", "// Then add the jar file on HDFS to the classpath", "LOG", ".", "info", "(", "String", ".", "format", "(", "\"Adding %s to classpath\"", ",", "destJarFile", ")", ")", ";", "DistributedCache", ".", "addFileToClassPath", "(", "destJarFile", ",", "conf", ",", "this", ".", "fs", ")", ";", "}", "}", "}", "}" ]
Add framework or job-specific jars to the classpath through DistributedCache so the mappers can use them.
[ "Add", "framework", "or", "job", "-", "specific", "jars", "to", "the", "classpath", "through", "DistributedCache", "so", "the", "mappers", "can", "use", "them", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L471-L514
26,090
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.addLocalFiles
@SuppressWarnings("deprecation") private void addLocalFiles(Path jobFileDir, String jobFileList, Configuration conf) throws IOException { DistributedCache.createSymlink(conf); for (String jobFile : SPLITTER.split(jobFileList)) { Path srcJobFile = new Path(jobFile); // DistributedCache requires absolute path, so we need to use makeQualified. Path destJobFile = new Path(this.fs.makeQualified(jobFileDir), srcJobFile.getName()); // Copy the file from local file system to HDFS this.fs.copyFromLocalFile(srcJobFile, destJobFile); // Create a URI that is in the form path#symlink URI destFileUri = URI.create(destJobFile.toUri().getPath() + "#" + destJobFile.getName()); LOG.info(String.format("Adding %s to DistributedCache", destFileUri)); // Finally add the file to DistributedCache with a symlink named after the file name DistributedCache.addCacheFile(destFileUri, conf); } }
java
@SuppressWarnings("deprecation") private void addLocalFiles(Path jobFileDir, String jobFileList, Configuration conf) throws IOException { DistributedCache.createSymlink(conf); for (String jobFile : SPLITTER.split(jobFileList)) { Path srcJobFile = new Path(jobFile); // DistributedCache requires absolute path, so we need to use makeQualified. Path destJobFile = new Path(this.fs.makeQualified(jobFileDir), srcJobFile.getName()); // Copy the file from local file system to HDFS this.fs.copyFromLocalFile(srcJobFile, destJobFile); // Create a URI that is in the form path#symlink URI destFileUri = URI.create(destJobFile.toUri().getPath() + "#" + destJobFile.getName()); LOG.info(String.format("Adding %s to DistributedCache", destFileUri)); // Finally add the file to DistributedCache with a symlink named after the file name DistributedCache.addCacheFile(destFileUri, conf); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "private", "void", "addLocalFiles", "(", "Path", "jobFileDir", ",", "String", "jobFileList", ",", "Configuration", "conf", ")", "throws", "IOException", "{", "DistributedCache", ".", "createSymlink", "(", "conf", ")", ";", "for", "(", "String", "jobFile", ":", "SPLITTER", ".", "split", "(", "jobFileList", ")", ")", "{", "Path", "srcJobFile", "=", "new", "Path", "(", "jobFile", ")", ";", "// DistributedCache requires absolute path, so we need to use makeQualified.", "Path", "destJobFile", "=", "new", "Path", "(", "this", ".", "fs", ".", "makeQualified", "(", "jobFileDir", ")", ",", "srcJobFile", ".", "getName", "(", ")", ")", ";", "// Copy the file from local file system to HDFS", "this", ".", "fs", ".", "copyFromLocalFile", "(", "srcJobFile", ",", "destJobFile", ")", ";", "// Create a URI that is in the form path#symlink", "URI", "destFileUri", "=", "URI", ".", "create", "(", "destJobFile", ".", "toUri", "(", ")", ".", "getPath", "(", ")", "+", "\"#\"", "+", "destJobFile", ".", "getName", "(", ")", ")", ";", "LOG", ".", "info", "(", "String", ".", "format", "(", "\"Adding %s to DistributedCache\"", ",", "destFileUri", ")", ")", ";", "// Finally add the file to DistributedCache with a symlink named after the file name", "DistributedCache", ".", "addCacheFile", "(", "destFileUri", ",", "conf", ")", ";", "}", "}" ]
Add local non-jar files the job depends on to DistributedCache.
[ "Add", "local", "non", "-", "jar", "files", "the", "job", "depends", "on", "to", "DistributedCache", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L530-L545
26,091
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.addHDFSFiles
@SuppressWarnings("deprecation") private void addHDFSFiles(String jobFileList, Configuration conf) { DistributedCache.createSymlink(conf); jobFileList = PasswordManager.getInstance(this.jobProps).readPassword(jobFileList); for (String jobFile : SPLITTER.split(jobFileList)) { Path srcJobFile = new Path(jobFile); // Create a URI that is in the form path#symlink URI srcFileUri = URI.create(srcJobFile.toUri().getPath() + "#" + srcJobFile.getName()); LOG.info(String.format("Adding %s to DistributedCache", srcFileUri)); // Finally add the file to DistributedCache with a symlink named after the file name DistributedCache.addCacheFile(srcFileUri, conf); } }
java
@SuppressWarnings("deprecation") private void addHDFSFiles(String jobFileList, Configuration conf) { DistributedCache.createSymlink(conf); jobFileList = PasswordManager.getInstance(this.jobProps).readPassword(jobFileList); for (String jobFile : SPLITTER.split(jobFileList)) { Path srcJobFile = new Path(jobFile); // Create a URI that is in the form path#symlink URI srcFileUri = URI.create(srcJobFile.toUri().getPath() + "#" + srcJobFile.getName()); LOG.info(String.format("Adding %s to DistributedCache", srcFileUri)); // Finally add the file to DistributedCache with a symlink named after the file name DistributedCache.addCacheFile(srcFileUri, conf); } }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "private", "void", "addHDFSFiles", "(", "String", "jobFileList", ",", "Configuration", "conf", ")", "{", "DistributedCache", ".", "createSymlink", "(", "conf", ")", ";", "jobFileList", "=", "PasswordManager", ".", "getInstance", "(", "this", ".", "jobProps", ")", ".", "readPassword", "(", "jobFileList", ")", ";", "for", "(", "String", "jobFile", ":", "SPLITTER", ".", "split", "(", "jobFileList", ")", ")", "{", "Path", "srcJobFile", "=", "new", "Path", "(", "jobFile", ")", ";", "// Create a URI that is in the form path#symlink", "URI", "srcFileUri", "=", "URI", ".", "create", "(", "srcJobFile", ".", "toUri", "(", ")", ".", "getPath", "(", ")", "+", "\"#\"", "+", "srcJobFile", ".", "getName", "(", ")", ")", ";", "LOG", ".", "info", "(", "String", ".", "format", "(", "\"Adding %s to DistributedCache\"", ",", "srcFileUri", ")", ")", ";", "// Finally add the file to DistributedCache with a symlink named after the file name", "DistributedCache", ".", "addCacheFile", "(", "srcFileUri", ",", "conf", ")", ";", "}", "}" ]
Add non-jar files already on HDFS that the job depends on to DistributedCache.
[ "Add", "non", "-", "jar", "files", "already", "on", "HDFS", "that", "the", "job", "depends", "on", "to", "DistributedCache", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L550-L562
26,092
apache/incubator-gobblin
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java
MRJobLauncher.prepareJobInput
private void prepareJobInput(List<WorkUnit> workUnits) throws IOException { Closer closer = Closer.create(); try { ParallelRunner parallelRunner = closer.register(new ParallelRunner(this.parallelRunnerThreads, this.fs)); int multiTaskIdSequence = 0; // Serialize each work unit into a file named after the task ID for (WorkUnit workUnit : workUnits) { String workUnitFileName; if (workUnit instanceof MultiWorkUnit) { workUnitFileName = JobLauncherUtils.newMultiTaskId(this.jobContext.getJobId(), multiTaskIdSequence++) + MULTI_WORK_UNIT_FILE_EXTENSION; } else { workUnitFileName = workUnit.getProp(ConfigurationKeys.TASK_ID_KEY) + WORK_UNIT_FILE_EXTENSION; } Path workUnitFile = new Path(this.jobInputPath, workUnitFileName); LOG.debug("Writing work unit file " + workUnitFileName); parallelRunner.serializeToFile(workUnit, workUnitFile); // Append the work unit file path to the job input file } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
java
private void prepareJobInput(List<WorkUnit> workUnits) throws IOException { Closer closer = Closer.create(); try { ParallelRunner parallelRunner = closer.register(new ParallelRunner(this.parallelRunnerThreads, this.fs)); int multiTaskIdSequence = 0; // Serialize each work unit into a file named after the task ID for (WorkUnit workUnit : workUnits) { String workUnitFileName; if (workUnit instanceof MultiWorkUnit) { workUnitFileName = JobLauncherUtils.newMultiTaskId(this.jobContext.getJobId(), multiTaskIdSequence++) + MULTI_WORK_UNIT_FILE_EXTENSION; } else { workUnitFileName = workUnit.getProp(ConfigurationKeys.TASK_ID_KEY) + WORK_UNIT_FILE_EXTENSION; } Path workUnitFile = new Path(this.jobInputPath, workUnitFileName); LOG.debug("Writing work unit file " + workUnitFileName); parallelRunner.serializeToFile(workUnit, workUnitFile); // Append the work unit file path to the job input file } } catch (Throwable t) { throw closer.rethrow(t); } finally { closer.close(); } }
[ "private", "void", "prepareJobInput", "(", "List", "<", "WorkUnit", ">", "workUnits", ")", "throws", "IOException", "{", "Closer", "closer", "=", "Closer", ".", "create", "(", ")", ";", "try", "{", "ParallelRunner", "parallelRunner", "=", "closer", ".", "register", "(", "new", "ParallelRunner", "(", "this", ".", "parallelRunnerThreads", ",", "this", ".", "fs", ")", ")", ";", "int", "multiTaskIdSequence", "=", "0", ";", "// Serialize each work unit into a file named after the task ID", "for", "(", "WorkUnit", "workUnit", ":", "workUnits", ")", "{", "String", "workUnitFileName", ";", "if", "(", "workUnit", "instanceof", "MultiWorkUnit", ")", "{", "workUnitFileName", "=", "JobLauncherUtils", ".", "newMultiTaskId", "(", "this", ".", "jobContext", ".", "getJobId", "(", ")", ",", "multiTaskIdSequence", "++", ")", "+", "MULTI_WORK_UNIT_FILE_EXTENSION", ";", "}", "else", "{", "workUnitFileName", "=", "workUnit", ".", "getProp", "(", "ConfigurationKeys", ".", "TASK_ID_KEY", ")", "+", "WORK_UNIT_FILE_EXTENSION", ";", "}", "Path", "workUnitFile", "=", "new", "Path", "(", "this", ".", "jobInputPath", ",", "workUnitFileName", ")", ";", "LOG", ".", "debug", "(", "\"Writing work unit file \"", "+", "workUnitFileName", ")", ";", "parallelRunner", ".", "serializeToFile", "(", "workUnit", ",", "workUnitFile", ")", ";", "// Append the work unit file path to the job input file", "}", "}", "catch", "(", "Throwable", "t", ")", "{", "throw", "closer", ".", "rethrow", "(", "t", ")", ";", "}", "finally", "{", "closer", ".", "close", "(", ")", ";", "}", "}" ]
Prepare the job input. @throws IOException
[ "Prepare", "the", "job", "input", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-runtime/src/main/java/org/apache/gobblin/runtime/mapreduce/MRJobLauncher.java#L581-L609
26,093
apache/incubator-gobblin
gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/avro/AvroKeyMapper.java
AvroKeyMapper.populateComparableKeyRecord
private void populateComparableKeyRecord(GenericRecord source, GenericRecord target) { for (Field field : target.getSchema().getFields()) { if (field.schema().getType() == Schema.Type.UNION) { // Since a UNION has multiple types, we need to use induce() to get the actual type in the record. Object fieldData = source.get(field.name()); Schema actualFieldSchema = GenericData.get().induce(fieldData); if (actualFieldSchema.getType() == Schema.Type.RECORD) { // If the actual type is RECORD (which may contain another UNION), we need to recursively // populate it. for (Schema candidateType : field.schema().getTypes()) { if (candidateType.getFullName().equals(actualFieldSchema.getFullName())) { GenericRecord record = new GenericData.Record(candidateType); target.put(field.name(), record); populateComparableKeyRecord((GenericRecord) fieldData, record); break; } } } else { target.put(field.name(), source.get(field.name())); } } else if (field.schema().getType() == Schema.Type.RECORD) { GenericRecord record = (GenericRecord) target.get(field.name()); if (record == null) { record = new GenericData.Record(field.schema()); target.put(field.name(), record); } populateComparableKeyRecord((GenericRecord) source.get(field.name()), record); } else { target.put(field.name(), source.get(field.name())); } } }
java
private void populateComparableKeyRecord(GenericRecord source, GenericRecord target) { for (Field field : target.getSchema().getFields()) { if (field.schema().getType() == Schema.Type.UNION) { // Since a UNION has multiple types, we need to use induce() to get the actual type in the record. Object fieldData = source.get(field.name()); Schema actualFieldSchema = GenericData.get().induce(fieldData); if (actualFieldSchema.getType() == Schema.Type.RECORD) { // If the actual type is RECORD (which may contain another UNION), we need to recursively // populate it. for (Schema candidateType : field.schema().getTypes()) { if (candidateType.getFullName().equals(actualFieldSchema.getFullName())) { GenericRecord record = new GenericData.Record(candidateType); target.put(field.name(), record); populateComparableKeyRecord((GenericRecord) fieldData, record); break; } } } else { target.put(field.name(), source.get(field.name())); } } else if (field.schema().getType() == Schema.Type.RECORD) { GenericRecord record = (GenericRecord) target.get(field.name()); if (record == null) { record = new GenericData.Record(field.schema()); target.put(field.name(), record); } populateComparableKeyRecord((GenericRecord) source.get(field.name()), record); } else { target.put(field.name(), source.get(field.name())); } } }
[ "private", "void", "populateComparableKeyRecord", "(", "GenericRecord", "source", ",", "GenericRecord", "target", ")", "{", "for", "(", "Field", "field", ":", "target", ".", "getSchema", "(", ")", ".", "getFields", "(", ")", ")", "{", "if", "(", "field", ".", "schema", "(", ")", ".", "getType", "(", ")", "==", "Schema", ".", "Type", ".", "UNION", ")", "{", "// Since a UNION has multiple types, we need to use induce() to get the actual type in the record.", "Object", "fieldData", "=", "source", ".", "get", "(", "field", ".", "name", "(", ")", ")", ";", "Schema", "actualFieldSchema", "=", "GenericData", ".", "get", "(", ")", ".", "induce", "(", "fieldData", ")", ";", "if", "(", "actualFieldSchema", ".", "getType", "(", ")", "==", "Schema", ".", "Type", ".", "RECORD", ")", "{", "// If the actual type is RECORD (which may contain another UNION), we need to recursively", "// populate it.", "for", "(", "Schema", "candidateType", ":", "field", ".", "schema", "(", ")", ".", "getTypes", "(", ")", ")", "{", "if", "(", "candidateType", ".", "getFullName", "(", ")", ".", "equals", "(", "actualFieldSchema", ".", "getFullName", "(", ")", ")", ")", "{", "GenericRecord", "record", "=", "new", "GenericData", ".", "Record", "(", "candidateType", ")", ";", "target", ".", "put", "(", "field", ".", "name", "(", ")", ",", "record", ")", ";", "populateComparableKeyRecord", "(", "(", "GenericRecord", ")", "fieldData", ",", "record", ")", ";", "break", ";", "}", "}", "}", "else", "{", "target", ".", "put", "(", "field", ".", "name", "(", ")", ",", "source", ".", "get", "(", "field", ".", "name", "(", ")", ")", ")", ";", "}", "}", "else", "if", "(", "field", ".", "schema", "(", ")", ".", "getType", "(", ")", "==", "Schema", ".", "Type", ".", "RECORD", ")", "{", "GenericRecord", "record", "=", "(", "GenericRecord", ")", "target", ".", "get", "(", "field", ".", "name", "(", ")", ")", ";", "if", "(", "record", "==", "null", ")", "{", "record", "=", "new", "GenericData", ".", "Record", "(", "field", ".", "schema", "(", ")", ")", ";", "target", ".", "put", "(", "field", ".", "name", "(", ")", ",", "record", ")", ";", "}", "populateComparableKeyRecord", "(", "(", "GenericRecord", ")", "source", ".", "get", "(", "field", ".", "name", "(", ")", ")", ",", "record", ")", ";", "}", "else", "{", "target", ".", "put", "(", "field", ".", "name", "(", ")", ",", "source", ".", "get", "(", "field", ".", "name", "(", ")", ")", ")", ";", "}", "}", "}" ]
Populate the target record, based on the field values in the source record. Target record's schema should be a subset of source record's schema. Target record's schema cannot have MAP, ARRAY or ENUM fields, or UNION fields that contain these fields.
[ "Populate", "the", "target", "record", "based", "on", "the", "field", "values", "in", "the", "source", "record", ".", "Target", "record", "s", "schema", "should", "be", "a", "subset", "of", "source", "record", "s", "schema", ".", "Target", "record", "s", "schema", "cannot", "have", "MAP", "ARRAY", "or", "ENUM", "fields", "or", "UNION", "fields", "that", "contain", "these", "fields", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-compaction/src/main/java/org/apache/gobblin/compaction/mapreduce/avro/AvroKeyMapper.java#L86-L119
26,094
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/converter/csv/CsvToJsonConverterV2.java
CsvToJsonConverterV2.convertValue
private JsonElement convertValue(String value, JsonObject dataType) { if (dataType == null || !dataType.has(TYPE)) { return new JsonPrimitive(value); } String type = dataType.get(TYPE).getAsString().toUpperCase(); ValueType valueType = ValueType.valueOf(type); return valueType.convert(value); }
java
private JsonElement convertValue(String value, JsonObject dataType) { if (dataType == null || !dataType.has(TYPE)) { return new JsonPrimitive(value); } String type = dataType.get(TYPE).getAsString().toUpperCase(); ValueType valueType = ValueType.valueOf(type); return valueType.convert(value); }
[ "private", "JsonElement", "convertValue", "(", "String", "value", ",", "JsonObject", "dataType", ")", "{", "if", "(", "dataType", "==", "null", "||", "!", "dataType", ".", "has", "(", "TYPE", ")", ")", "{", "return", "new", "JsonPrimitive", "(", "value", ")", ";", "}", "String", "type", "=", "dataType", ".", "get", "(", "TYPE", ")", ".", "getAsString", "(", ")", ".", "toUpperCase", "(", ")", ";", "ValueType", "valueType", "=", "ValueType", ".", "valueOf", "(", "type", ")", ";", "return", "valueType", ".", "convert", "(", "value", ")", ";", "}" ]
Convert string value to the expected type
[ "Convert", "string", "value", "to", "the", "expected", "type" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/converter/csv/CsvToJsonConverterV2.java#L219-L227
26,095
apache/incubator-gobblin
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/writer/HiveQueryExecutionWriter.java
HiveQueryExecutionWriter.addPropsForPublisher
private void addPropsForPublisher(QueryBasedHiveConversionEntity hiveConversionEntity) { if (!hiveConversionEntity.getPartition().isPresent()) { return; } ConvertibleHiveDataset convertibleHiveDataset = hiveConversionEntity.getConvertibleHiveDataset(); for (String format : convertibleHiveDataset.getDestFormats()) { Optional<ConvertibleHiveDataset.ConversionConfig> conversionConfigForFormat = convertibleHiveDataset.getConversionConfigForFormat(format); if (!conversionConfigForFormat.isPresent()) { continue; } SchemaAwareHivePartition sourcePartition = hiveConversionEntity.getHivePartition().get(); // Get complete source partition name dbName@tableName@partitionName String completeSourcePartitionName = StringUtils.join(Arrays .asList(sourcePartition.getTable().getDbName(), sourcePartition.getTable().getTableName(), sourcePartition.getName()), AT_CHAR); ConvertibleHiveDataset.ConversionConfig config = conversionConfigForFormat.get(); // Get complete destination partition name dbName@tableName@partitionName String completeDestPartitionName = StringUtils.join( Arrays.asList(config.getDestinationDbName(), config.getDestinationTableName(), sourcePartition.getName()), AT_CHAR); workUnit.setProp(HiveConvertPublisher.COMPLETE_SOURCE_PARTITION_NAME, completeSourcePartitionName); workUnit.setProp(HiveConvertPublisher.COMPLETE_DEST_PARTITION_NAME, completeDestPartitionName); } }
java
private void addPropsForPublisher(QueryBasedHiveConversionEntity hiveConversionEntity) { if (!hiveConversionEntity.getPartition().isPresent()) { return; } ConvertibleHiveDataset convertibleHiveDataset = hiveConversionEntity.getConvertibleHiveDataset(); for (String format : convertibleHiveDataset.getDestFormats()) { Optional<ConvertibleHiveDataset.ConversionConfig> conversionConfigForFormat = convertibleHiveDataset.getConversionConfigForFormat(format); if (!conversionConfigForFormat.isPresent()) { continue; } SchemaAwareHivePartition sourcePartition = hiveConversionEntity.getHivePartition().get(); // Get complete source partition name dbName@tableName@partitionName String completeSourcePartitionName = StringUtils.join(Arrays .asList(sourcePartition.getTable().getDbName(), sourcePartition.getTable().getTableName(), sourcePartition.getName()), AT_CHAR); ConvertibleHiveDataset.ConversionConfig config = conversionConfigForFormat.get(); // Get complete destination partition name dbName@tableName@partitionName String completeDestPartitionName = StringUtils.join( Arrays.asList(config.getDestinationDbName(), config.getDestinationTableName(), sourcePartition.getName()), AT_CHAR); workUnit.setProp(HiveConvertPublisher.COMPLETE_SOURCE_PARTITION_NAME, completeSourcePartitionName); workUnit.setProp(HiveConvertPublisher.COMPLETE_DEST_PARTITION_NAME, completeDestPartitionName); } }
[ "private", "void", "addPropsForPublisher", "(", "QueryBasedHiveConversionEntity", "hiveConversionEntity", ")", "{", "if", "(", "!", "hiveConversionEntity", ".", "getPartition", "(", ")", ".", "isPresent", "(", ")", ")", "{", "return", ";", "}", "ConvertibleHiveDataset", "convertibleHiveDataset", "=", "hiveConversionEntity", ".", "getConvertibleHiveDataset", "(", ")", ";", "for", "(", "String", "format", ":", "convertibleHiveDataset", ".", "getDestFormats", "(", ")", ")", "{", "Optional", "<", "ConvertibleHiveDataset", ".", "ConversionConfig", ">", "conversionConfigForFormat", "=", "convertibleHiveDataset", ".", "getConversionConfigForFormat", "(", "format", ")", ";", "if", "(", "!", "conversionConfigForFormat", ".", "isPresent", "(", ")", ")", "{", "continue", ";", "}", "SchemaAwareHivePartition", "sourcePartition", "=", "hiveConversionEntity", ".", "getHivePartition", "(", ")", ".", "get", "(", ")", ";", "// Get complete source partition name dbName@tableName@partitionName", "String", "completeSourcePartitionName", "=", "StringUtils", ".", "join", "(", "Arrays", ".", "asList", "(", "sourcePartition", ".", "getTable", "(", ")", ".", "getDbName", "(", ")", ",", "sourcePartition", ".", "getTable", "(", ")", ".", "getTableName", "(", ")", ",", "sourcePartition", ".", "getName", "(", ")", ")", ",", "AT_CHAR", ")", ";", "ConvertibleHiveDataset", ".", "ConversionConfig", "config", "=", "conversionConfigForFormat", ".", "get", "(", ")", ";", "// Get complete destination partition name dbName@tableName@partitionName", "String", "completeDestPartitionName", "=", "StringUtils", ".", "join", "(", "Arrays", ".", "asList", "(", "config", ".", "getDestinationDbName", "(", ")", ",", "config", ".", "getDestinationTableName", "(", ")", ",", "sourcePartition", ".", "getName", "(", ")", ")", ",", "AT_CHAR", ")", ";", "workUnit", ".", "setProp", "(", "HiveConvertPublisher", ".", "COMPLETE_SOURCE_PARTITION_NAME", ",", "completeSourcePartitionName", ")", ";", "workUnit", ".", "setProp", "(", "HiveConvertPublisher", ".", "COMPLETE_DEST_PARTITION_NAME", ",", "completeDestPartitionName", ")", ";", "}", "}" ]
Method to add properties needed by publisher to preserve partition params
[ "Method", "to", "add", "properties", "needed", "by", "publisher", "to", "preserve", "partition", "params" ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-data-management/src/main/java/org/apache/gobblin/data/management/conversion/hive/writer/HiveQueryExecutionWriter.java#L81-L108
26,096
apache/incubator-gobblin
gobblin-core/src/main/java/org/apache/gobblin/publisher/NoopPublisher.java
NoopPublisher.publishData
@Override public void publishData(Collection<? extends WorkUnitState> states) throws IOException { for (WorkUnitState state: states) { if (state.getWorkingState() == WorkUnitState.WorkingState.SUCCESSFUL) { state.setWorkingState(WorkUnitState.WorkingState.COMMITTED); log.info("Marking state committed"); } } }
java
@Override public void publishData(Collection<? extends WorkUnitState> states) throws IOException { for (WorkUnitState state: states) { if (state.getWorkingState() == WorkUnitState.WorkingState.SUCCESSFUL) { state.setWorkingState(WorkUnitState.WorkingState.COMMITTED); log.info("Marking state committed"); } } }
[ "@", "Override", "public", "void", "publishData", "(", "Collection", "<", "?", "extends", "WorkUnitState", ">", "states", ")", "throws", "IOException", "{", "for", "(", "WorkUnitState", "state", ":", "states", ")", "{", "if", "(", "state", ".", "getWorkingState", "(", ")", "==", "WorkUnitState", ".", "WorkingState", ".", "SUCCESSFUL", ")", "{", "state", ".", "setWorkingState", "(", "WorkUnitState", ".", "WorkingState", ".", "COMMITTED", ")", ";", "log", ".", "info", "(", "\"Marking state committed\"", ")", ";", "}", "}", "}" ]
Publish the data for the given tasks. @param states
[ "Publish", "the", "data", "for", "the", "given", "tasks", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-core/src/main/java/org/apache/gobblin/publisher/NoopPublisher.java#L53-L64
26,097
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java
Extract.setFullTrue
@Deprecated public void setFullTrue(long extractFullRunTime) { setProp(ConfigurationKeys.EXTRACT_IS_FULL_KEY, true); setProp(ConfigurationKeys.EXTRACT_FULL_RUN_TIME_KEY, extractFullRunTime); }
java
@Deprecated public void setFullTrue(long extractFullRunTime) { setProp(ConfigurationKeys.EXTRACT_IS_FULL_KEY, true); setProp(ConfigurationKeys.EXTRACT_FULL_RUN_TIME_KEY, extractFullRunTime); }
[ "@", "Deprecated", "public", "void", "setFullTrue", "(", "long", "extractFullRunTime", ")", "{", "setProp", "(", "ConfigurationKeys", ".", "EXTRACT_IS_FULL_KEY", ",", "true", ")", ";", "setProp", "(", "ConfigurationKeys", ".", "EXTRACT_FULL_RUN_TIME_KEY", ",", "extractFullRunTime", ")", ";", "}" ]
Set full drop date from the given time. @param extractFullRunTime full extract time @deprecated It is recommend to set this information in {@code WorkUnit} instead of {@code Extract}.
[ "Set", "full", "drop", "date", "from", "the", "given", "time", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java#L220-L224
26,098
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java
Extract.setPrimaryKeys
@Deprecated public void setPrimaryKeys(String... primaryKeyFieldName) { setProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, Joiner.on(",").join(primaryKeyFieldName)); }
java
@Deprecated public void setPrimaryKeys(String... primaryKeyFieldName) { setProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, Joiner.on(",").join(primaryKeyFieldName)); }
[ "@", "Deprecated", "public", "void", "setPrimaryKeys", "(", "String", "...", "primaryKeyFieldName", ")", "{", "setProp", "(", "ConfigurationKeys", ".", "EXTRACT_PRIMARY_KEY_FIELDS_KEY", ",", "Joiner", ".", "on", "(", "\",\"", ")", ".", "join", "(", "primaryKeyFieldName", ")", ")", ";", "}" ]
Set primary keys. <p> The order of primary keys does not matter. </p> @param primaryKeyFieldName primary key names @deprecated It is recommended to set primary keys in {@code WorkUnit} instead of {@code Extract}.
[ "Set", "primary", "keys", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java#L236-L239
26,099
apache/incubator-gobblin
gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java
Extract.addPrimaryKey
@Deprecated public void addPrimaryKey(String... primaryKeyFieldName) { StringBuilder sb = new StringBuilder(getProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, "")); Joiner.on(",").appendTo(sb, primaryKeyFieldName); setProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, sb.toString()); }
java
@Deprecated public void addPrimaryKey(String... primaryKeyFieldName) { StringBuilder sb = new StringBuilder(getProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, "")); Joiner.on(",").appendTo(sb, primaryKeyFieldName); setProp(ConfigurationKeys.EXTRACT_PRIMARY_KEY_FIELDS_KEY, sb.toString()); }
[ "@", "Deprecated", "public", "void", "addPrimaryKey", "(", "String", "...", "primaryKeyFieldName", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "getProp", "(", "ConfigurationKeys", ".", "EXTRACT_PRIMARY_KEY_FIELDS_KEY", ",", "\"\"", ")", ")", ";", "Joiner", ".", "on", "(", "\",\"", ")", ".", "appendTo", "(", "sb", ",", "primaryKeyFieldName", ")", ";", "setProp", "(", "ConfigurationKeys", ".", "EXTRACT_PRIMARY_KEY_FIELDS_KEY", ",", "sb", ".", "toString", "(", ")", ")", ";", "}" ]
Add more primary keys to the existing set of primary keys. @param primaryKeyFieldName primary key names @deprecated @deprecated It is recommended to add primary keys in {@code WorkUnit} instead of {@code Extract}.
[ "Add", "more", "primary", "keys", "to", "the", "existing", "set", "of", "primary", "keys", "." ]
f029b4c0fea0fe4aa62f36dda2512344ff708bae
https://github.com/apache/incubator-gobblin/blob/f029b4c0fea0fe4aa62f36dda2512344ff708bae/gobblin-api/src/main/java/org/apache/gobblin/source/workunit/Extract.java#L247-L252