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
partition
stringclasses
1 value
jbehave/jbehave-core
jbehave-guice/src/main/java/org/jbehave/core/steps/guice/GuiceStepsFactory.java
GuiceStepsFactory.addTypes
private void addTypes(Injector injector, List<Class<?>> types) { for (Binding<?> binding : injector.getBindings().values()) { Key<?> key = binding.getKey(); Type type = key.getTypeLiteral().getType(); if (hasAnnotatedMethods(type)) { types.add(((Class<?>)type)); } } if (injector.getParent() != null) { addTypes(injector.getParent(), types); } }
java
private void addTypes(Injector injector, List<Class<?>> types) { for (Binding<?> binding : injector.getBindings().values()) { Key<?> key = binding.getKey(); Type type = key.getTypeLiteral().getType(); if (hasAnnotatedMethods(type)) { types.add(((Class<?>)type)); } } if (injector.getParent() != null) { addTypes(injector.getParent(), types); } }
[ "private", "void", "addTypes", "(", "Injector", "injector", ",", "List", "<", "Class", "<", "?", ">", ">", "types", ")", "{", "for", "(", "Binding", "<", "?", ">", "binding", ":", "injector", ".", "getBindings", "(", ")", ".", "values", "(", ")", "...
Adds steps types from given injector and recursively its parent @param injector the current Inject @param types the List of steps types
[ "Adds", "steps", "types", "from", "given", "injector", "and", "recursively", "its", "parent" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-guice/src/main/java/org/jbehave/core/steps/guice/GuiceStepsFactory.java#L46-L57
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryMapper.java
StoryMapper.map
public void map(Story story, MetaFilter metaFilter) { if (metaFilter.allow(story.getMeta())) { boolean allowed = false; for (Scenario scenario : story.getScenarios()) { // scenario also inherits meta from story Meta inherited = scenario.getMeta().inheritFrom(story.getMeta()); if (metaFilter.allow(inherited)) { allowed = true; break; } } if (allowed) { add(metaFilter.asString(), story); } } }
java
public void map(Story story, MetaFilter metaFilter) { if (metaFilter.allow(story.getMeta())) { boolean allowed = false; for (Scenario scenario : story.getScenarios()) { // scenario also inherits meta from story Meta inherited = scenario.getMeta().inheritFrom(story.getMeta()); if (metaFilter.allow(inherited)) { allowed = true; break; } } if (allowed) { add(metaFilter.asString(), story); } } }
[ "public", "void", "map", "(", "Story", "story", ",", "MetaFilter", "metaFilter", ")", "{", "if", "(", "metaFilter", ".", "allow", "(", "story", ".", "getMeta", "(", ")", ")", ")", "{", "boolean", "allowed", "=", "false", ";", "for", "(", "Scenario", ...
Maps a story if it is allowed by the meta filter @param story the Story @param metaFilter the meta filter
[ "Maps", "a", "story", "if", "it", "is", "allowed", "by", "the", "meta", "filter" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryMapper.java#L33-L48
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java
MetaFilter.createMetaMatcher
protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) { for ( String key : metaMatchers.keySet() ){ if ( filterAsString.startsWith(key)){ return metaMatchers.get(key); } } if (filterAsString.startsWith(GROOVY)) { return new GroovyMetaMatcher(); } return new DefaultMetaMatcher(); }
java
protected MetaMatcher createMetaMatcher(String filterAsString, Map<String, MetaMatcher> metaMatchers) { for ( String key : metaMatchers.keySet() ){ if ( filterAsString.startsWith(key)){ return metaMatchers.get(key); } } if (filterAsString.startsWith(GROOVY)) { return new GroovyMetaMatcher(); } return new DefaultMetaMatcher(); }
[ "protected", "MetaMatcher", "createMetaMatcher", "(", "String", "filterAsString", ",", "Map", "<", "String", ",", "MetaMatcher", ">", "metaMatchers", ")", "{", "for", "(", "String", "key", ":", "metaMatchers", ".", "keySet", "(", ")", ")", "{", "if", "(", ...
Creates a MetaMatcher based on the filter content. @param filterAsString the String representation of the filter @param metaMatchers the Map of custom MetaMatchers @return A MetaMatcher used to match the filter content
[ "Creates", "a", "MetaMatcher", "based", "on", "the", "filter", "content", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/MetaFilter.java#L112-L122
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java
CodeLocations.codeLocationFromClass
public static URL codeLocationFromClass(Class<?> codeLocationClass) { String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class"; URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass); String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass); if(codeLocationPath.endsWith(".jar!/")) { codeLocationPath=removeEnd(codeLocationPath,"!/"); } return codeLocationFromPath(codeLocationPath); }
java
public static URL codeLocationFromClass(Class<?> codeLocationClass) { String pathOfClass = codeLocationClass.getName().replace(".", "/") + ".class"; URL classResource = codeLocationClass.getClassLoader().getResource(pathOfClass); String codeLocationPath = removeEnd(getPathFromURL(classResource), pathOfClass); if(codeLocationPath.endsWith(".jar!/")) { codeLocationPath=removeEnd(codeLocationPath,"!/"); } return codeLocationFromPath(codeLocationPath); }
[ "public", "static", "URL", "codeLocationFromClass", "(", "Class", "<", "?", ">", "codeLocationClass", ")", "{", "String", "pathOfClass", "=", "codeLocationClass", ".", "getName", "(", ")", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", "+", "\".class\"", "...
Creates a code location URL from a class @param codeLocationClass the class @return A URL created from Class @throws InvalidCodeLocation if URL creation fails
[ "Creates", "a", "code", "location", "URL", "from", "a", "class" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L23-L31
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java
CodeLocations.codeLocationFromPath
public static URL codeLocationFromPath(String filePath) { try { return new File(filePath).toURI().toURL(); } catch (Exception e) { throw new InvalidCodeLocation(filePath); } }
java
public static URL codeLocationFromPath(String filePath) { try { return new File(filePath).toURI().toURL(); } catch (Exception e) { throw new InvalidCodeLocation(filePath); } }
[ "public", "static", "URL", "codeLocationFromPath", "(", "String", "filePath", ")", "{", "try", "{", "return", "new", "File", "(", "filePath", ")", ".", "toURI", "(", ")", ".", "toURL", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "th...
Creates a code location URL from a file path @param filePath the file path @return A URL created from File @throws InvalidCodeLocation if URL creation fails
[ "Creates", "a", "code", "location", "URL", "from", "a", "file", "path" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L40-L46
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java
CodeLocations.codeLocationFromURL
public static URL codeLocationFromURL(String url) { try { return new URL(url); } catch (Exception e) { throw new InvalidCodeLocation(url); } }
java
public static URL codeLocationFromURL(String url) { try { return new URL(url); } catch (Exception e) { throw new InvalidCodeLocation(url); } }
[ "public", "static", "URL", "codeLocationFromURL", "(", "String", "url", ")", "{", "try", "{", "return", "new", "URL", "(", "url", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "InvalidCodeLocation", "(", "url", ")", ";", "}",...
Creates a code location URL from a URL @param url the URL external form @return A URL created from URL @throws InvalidCodeLocation if URL creation fails
[ "Creates", "a", "code", "location", "URL", "from", "a", "URL" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/CodeLocations.java#L55-L61
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.run
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story) throws Throwable { run(configuration, candidateSteps, story, MetaFilter.EMPTY); }
java
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story) throws Throwable { run(configuration, candidateSteps, story, MetaFilter.EMPTY); }
[ "public", "void", "run", "(", "Configuration", "configuration", ",", "List", "<", "CandidateSteps", ">", "candidateSteps", ",", "Story", "story", ")", "throws", "Throwable", "{", "run", "(", "configuration", ",", "candidateSteps", ",", "story", ",", "MetaFilter"...
Runs a Story with the given configuration and steps. @param configuration the Configuration used to run story @param candidateSteps the List of CandidateSteps containing the candidate steps methods @param story the Story to run @throws Throwable if failures occurred and FailureStrategy dictates it to be re-thrown.
[ "Runs", "a", "Story", "with", "the", "given", "configuration", "and", "steps", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L123-L125
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.run
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter) throws Throwable { run(configuration, candidateSteps, story, filter, null); }
java
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter) throws Throwable { run(configuration, candidateSteps, story, filter, null); }
[ "public", "void", "run", "(", "Configuration", "configuration", ",", "List", "<", "CandidateSteps", ">", "candidateSteps", ",", "Story", "story", ",", "MetaFilter", "filter", ")", "throws", "Throwable", "{", "run", "(", "configuration", ",", "candidateSteps", ",...
Runs a Story with the given configuration and steps, applying the given meta filter. @param configuration the Configuration used to run story @param candidateSteps the List of CandidateSteps containing the candidate steps methods @param story the Story to run @param filter the Filter to apply to the story Meta @throws Throwable if failures occurred and FailureStrategy dictates it to be re-thrown.
[ "Runs", "a", "Story", "with", "the", "given", "configuration", "and", "steps", "applying", "the", "given", "meta", "filter", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L139-L142
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.run
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter, State beforeStories) throws Throwable { run(configuration, new ProvidedStepsFactory(candidateSteps), story, filter, beforeStories); }
java
public void run(Configuration configuration, List<CandidateSteps> candidateSteps, Story story, MetaFilter filter, State beforeStories) throws Throwable { run(configuration, new ProvidedStepsFactory(candidateSteps), story, filter, beforeStories); }
[ "public", "void", "run", "(", "Configuration", "configuration", ",", "List", "<", "CandidateSteps", ">", "candidateSteps", ",", "Story", "story", ",", "MetaFilter", "filter", ",", "State", "beforeStories", ")", "throws", "Throwable", "{", "run", "(", "configurat...
Runs a Story with the given configuration and steps, applying the given meta filter, and staring from given state. @param configuration the Configuration used to run story @param candidateSteps the List of CandidateSteps containing the candidate steps methods @param story the Story to run @param filter the Filter to apply to the story Meta @param beforeStories the State before running any of the stories, if not <code>null</code> @throws Throwable if failures occurred and FailureStrategy dictates it to be re-thrown.
[ "Runs", "a", "Story", "with", "the", "given", "configuration", "and", "steps", "applying", "the", "given", "meta", "filter", "and", "staring", "from", "given", "state", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L158-L161
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.run
public void run(Configuration configuration, InjectableStepsFactory stepsFactory, Story story, MetaFilter filter, State beforeStories) throws Throwable { RunContext context = new RunContext(configuration, stepsFactory, story.getPath(), filter); if (beforeStories != null) { context.stateIs(beforeStories); } Map<String, String> storyParameters = new HashMap<>(); run(context, story, storyParameters); }
java
public void run(Configuration configuration, InjectableStepsFactory stepsFactory, Story story, MetaFilter filter, State beforeStories) throws Throwable { RunContext context = new RunContext(configuration, stepsFactory, story.getPath(), filter); if (beforeStories != null) { context.stateIs(beforeStories); } Map<String, String> storyParameters = new HashMap<>(); run(context, story, storyParameters); }
[ "public", "void", "run", "(", "Configuration", "configuration", ",", "InjectableStepsFactory", "stepsFactory", ",", "Story", "story", ",", "MetaFilter", "filter", ",", "State", "beforeStories", ")", "throws", "Throwable", "{", "RunContext", "context", "=", "new", ...
Runs a Story with the given steps factory, applying the given meta filter, and staring from given state. @param configuration the Configuration used to run story @param stepsFactory the InjectableStepsFactory used to created the candidate steps methods @param story the Story to run @param filter the Filter to apply to the story Meta @param beforeStories the State before running any of the stories, if not <code>null</code> @throws Throwable if failures occurred and FailureStrategy dictates it to be re-thrown.
[ "Runs", "a", "Story", "with", "the", "given", "steps", "factory", "applying", "the", "given", "meta", "filter", "and", "staring", "from", "given", "state", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L178-L186
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.storyOfPath
public Story storyOfPath(Configuration configuration, String storyPath) { String storyAsText = configuration.storyLoader().loadStoryAsText(storyPath); return configuration.storyParser().parseStory(storyAsText, storyPath); }
java
public Story storyOfPath(Configuration configuration, String storyPath) { String storyAsText = configuration.storyLoader().loadStoryAsText(storyPath); return configuration.storyParser().parseStory(storyAsText, storyPath); }
[ "public", "Story", "storyOfPath", "(", "Configuration", "configuration", ",", "String", "storyPath", ")", "{", "String", "storyAsText", "=", "configuration", ".", "storyLoader", "(", ")", ".", "loadStoryAsText", "(", "storyPath", ")", ";", "return", "configuration...
Returns the parsed story from the given path @param configuration the Configuration used to run story @param storyPath the story path @return The parsed Story
[ "Returns", "the", "parsed", "story", "from", "the", "given", "path" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L195-L198
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java
StoryRunner.storyOfText
public Story storyOfText(Configuration configuration, String storyAsText, String storyId) { return configuration.storyParser().parseStory(storyAsText, storyId); }
java
public Story storyOfText(Configuration configuration, String storyAsText, String storyId) { return configuration.storyParser().parseStory(storyAsText, storyId); }
[ "public", "Story", "storyOfText", "(", "Configuration", "configuration", ",", "String", "storyAsText", ",", "String", "storyId", ")", "{", "return", "configuration", ".", "storyParser", "(", ")", ".", "parseStory", "(", "storyAsText", ",", "storyId", ")", ";", ...
Returns the parsed story from the given text @param configuration the Configuration used to run story @param storyAsText the story text @param storyId the story Id, which will be returned as story path @return The parsed Story
[ "Returns", "the", "parsed", "story", "from", "the", "given", "text" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryRunner.java#L208-L210
train
jbehave/jbehave-core
jbehave-scala/src/main/java/org/jbehave/core/configuration/scala/ScalaContext.java
ScalaContext.newInstance
public Object newInstance(String className) { try { return classLoader.loadClass(className).newInstance(); } catch (Exception e) { throw new ScalaInstanceNotFound(className); } }
java
public Object newInstance(String className) { try { return classLoader.loadClass(className).newInstance(); } catch (Exception e) { throw new ScalaInstanceNotFound(className); } }
[ "public", "Object", "newInstance", "(", "String", "className", ")", "{", "try", "{", "return", "classLoader", ".", "loadClass", "(", "className", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "Scal...
Creates an object instance from the Scala class name @param className the Scala class name @return An Object instance
[ "Creates", "an", "object", "instance", "from", "the", "Scala", "class", "name" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-scala/src/main/java/org/jbehave/core/configuration/scala/ScalaContext.java#L43-L49
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/steps/ChainedRow.java
ChainedRow.values
@Override public Map<String, String> values() { Map<String, String> values = new LinkedHashMap<>(); for (Row each : delegates) { for (Entry<String, String> entry : each.values().entrySet()) { String name = entry.getKey(); if (!values.containsKey(name)) { values.put(name, entry.getValue()); } } } return values; }
java
@Override public Map<String, String> values() { Map<String, String> values = new LinkedHashMap<>(); for (Row each : delegates) { for (Entry<String, String> entry : each.values().entrySet()) { String name = entry.getKey(); if (!values.containsKey(name)) { values.put(name, entry.getValue()); } } } return values; }
[ "@", "Override", "public", "Map", "<", "String", ",", "String", ">", "values", "(", ")", "{", "Map", "<", "String", ",", "String", ">", "values", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", "for", "(", "Row", "each", ":", "delegates", ")", "{...
Returns values aggregated from all the delegates, without overriding values that already exist. @return The Map of aggregated values
[ "Returns", "values", "aggregated", "from", "all", "the", "delegates", "without", "overriding", "values", "that", "already", "exist", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/ChainedRow.java#L24-L36
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java
StepFinder.stepsInstances
public List<Object> stepsInstances(List<CandidateSteps> candidateSteps) { List<Object> instances = new ArrayList<>(); for (CandidateSteps steps : candidateSteps) { if (steps instanceof Steps) { instances.add(((Steps) steps).instance()); } } return instances; }
java
public List<Object> stepsInstances(List<CandidateSteps> candidateSteps) { List<Object> instances = new ArrayList<>(); for (CandidateSteps steps : candidateSteps) { if (steps instanceof Steps) { instances.add(((Steps) steps).instance()); } } return instances; }
[ "public", "List", "<", "Object", ">", "stepsInstances", "(", "List", "<", "CandidateSteps", ">", "candidateSteps", ")", "{", "List", "<", "Object", ">", "instances", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "CandidateSteps", "steps", ":", ...
Returns the steps instances associated to CandidateSteps @param candidateSteps the List of CandidateSteps @return The List of steps instances
[ "Returns", "the", "steps", "instances", "associated", "to", "CandidateSteps" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java#L90-L98
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java
StepFinder.prioritise
public List<StepCandidate> prioritise(String stepAsText, List<StepCandidate> candidates) { return prioritisingStrategy.prioritise(stepAsText, candidates); }
java
public List<StepCandidate> prioritise(String stepAsText, List<StepCandidate> candidates) { return prioritisingStrategy.prioritise(stepAsText, candidates); }
[ "public", "List", "<", "StepCandidate", ">", "prioritise", "(", "String", "stepAsText", ",", "List", "<", "StepCandidate", ">", "candidates", ")", "{", "return", "prioritisingStrategy", ".", "prioritise", "(", "stepAsText", ",", "candidates", ")", ";", "}" ]
Prioritises the list of step candidates that match a given step. @param stepAsText the textual step to match @param candidates the List of StepCandidate @return The prioritised list according to the {@link PrioritisingStrategy}.
[ "Prioritises", "the", "list", "of", "step", "candidates", "that", "match", "a", "given", "step", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/StepFinder.java#L125-L127
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java
PrintStreamOutput.format
protected String format(String key, String defaultPattern, Object... args) { String escape = escape(defaultPattern); String s = lookupPattern(key, escape); Object[] objects = escapeAll(args); return MessageFormat.format(s, objects); }
java
protected String format(String key, String defaultPattern, Object... args) { String escape = escape(defaultPattern); String s = lookupPattern(key, escape); Object[] objects = escapeAll(args); return MessageFormat.format(s, objects); }
[ "protected", "String", "format", "(", "String", "key", ",", "String", "defaultPattern", ",", "Object", "...", "args", ")", "{", "String", "escape", "=", "escape", "(", "defaultPattern", ")", ";", "String", "s", "=", "lookupPattern", "(", "key", ",", "escap...
Formats event output by key, usually equal to the method name. @param key the event key @param defaultPattern the default pattern to return if a custom pattern is not found @param args the args used to format output @return A formatted event output
[ "Formats", "event", "output", "by", "key", "usually", "equal", "to", "the", "method", "name", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L462-L467
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java
PrintStreamOutput.escape
protected Object[] escape(final Format format, Object... args) { // Transformer that escapes HTML,XML,JSON strings Transformer<Object, Object> escapingTransformer = new Transformer<Object, Object>() { @Override public Object transform(Object object) { return format.escapeValue(object); } }; List<Object> list = Arrays.asList(ArrayUtils.clone(args)); CollectionUtils.transform(list, escapingTransformer); return list.toArray(); }
java
protected Object[] escape(final Format format, Object... args) { // Transformer that escapes HTML,XML,JSON strings Transformer<Object, Object> escapingTransformer = new Transformer<Object, Object>() { @Override public Object transform(Object object) { return format.escapeValue(object); } }; List<Object> list = Arrays.asList(ArrayUtils.clone(args)); CollectionUtils.transform(list, escapingTransformer); return list.toArray(); }
[ "protected", "Object", "[", "]", "escape", "(", "final", "Format", "format", ",", "Object", "...", "args", ")", "{", "// Transformer that escapes HTML,XML,JSON strings", "Transformer", "<", "Object", ",", "Object", ">", "escapingTransformer", "=", "new", "Transforme...
Escapes args' string values according to format @param format the Format used by the PrintStream @param args the array of args to escape @return The cloned and escaped array of args
[ "Escapes", "args", "string", "values", "according", "to", "format" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L508-L519
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java
PrintStreamOutput.print
protected void print(String text) { String tableStart = format(PARAMETER_TABLE_START, PARAMETER_TABLE_START); String tableEnd = format(PARAMETER_TABLE_END, PARAMETER_TABLE_END); boolean containsTable = text.contains(tableStart) && text.contains(tableEnd); String textToPrint = containsTable ? transformPrintingTable(text, tableStart, tableEnd) : text; print(output, textToPrint .replace(format(PARAMETER_VALUE_START, PARAMETER_VALUE_START), format("parameterValueStart", EMPTY)) .replace(format(PARAMETER_VALUE_END, PARAMETER_VALUE_END), format("parameterValueEnd", EMPTY)) .replace(format(PARAMETER_VALUE_NEWLINE, PARAMETER_VALUE_NEWLINE), format("parameterValueNewline", NL))); }
java
protected void print(String text) { String tableStart = format(PARAMETER_TABLE_START, PARAMETER_TABLE_START); String tableEnd = format(PARAMETER_TABLE_END, PARAMETER_TABLE_END); boolean containsTable = text.contains(tableStart) && text.contains(tableEnd); String textToPrint = containsTable ? transformPrintingTable(text, tableStart, tableEnd) : text; print(output, textToPrint .replace(format(PARAMETER_VALUE_START, PARAMETER_VALUE_START), format("parameterValueStart", EMPTY)) .replace(format(PARAMETER_VALUE_END, PARAMETER_VALUE_END), format("parameterValueEnd", EMPTY)) .replace(format(PARAMETER_VALUE_NEWLINE, PARAMETER_VALUE_NEWLINE), format("parameterValueNewline", NL))); }
[ "protected", "void", "print", "(", "String", "text", ")", "{", "String", "tableStart", "=", "format", "(", "PARAMETER_TABLE_START", ",", "PARAMETER_TABLE_START", ")", ";", "String", "tableEnd", "=", "format", "(", "PARAMETER_TABLE_END", ",", "PARAMETER_TABLE_END", ...
Prints text to output stream, replacing parameter start and end placeholders @param text the String to print
[ "Prints", "text", "to", "output", "stream", "replacing", "parameter", "start", "and", "end", "placeholders" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/reporters/PrintStreamOutput.java#L572-L581
train
jbehave/jbehave-core
jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java
NeedleStepsFactory.methodReturningConverters
private List<ParameterConverter> methodReturningConverters(final Class<?> type) { final List<ParameterConverter> converters = new ArrayList<>(); for (final Method method : type.getMethods()) { if (method.isAnnotationPresent(AsParameterConverter.class)) { converters.add(new MethodReturningConverter(method, type, this)); } } return converters; }
java
private List<ParameterConverter> methodReturningConverters(final Class<?> type) { final List<ParameterConverter> converters = new ArrayList<>(); for (final Method method : type.getMethods()) { if (method.isAnnotationPresent(AsParameterConverter.class)) { converters.add(new MethodReturningConverter(method, type, this)); } } return converters; }
[ "private", "List", "<", "ParameterConverter", ">", "methodReturningConverters", "(", "final", "Class", "<", "?", ">", "type", ")", "{", "final", "List", "<", "ParameterConverter", ">", "converters", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", ...
Create parameter converters from methods annotated with @AsParameterConverter @see {@link AbstractStepsFactory}
[ "Create", "parameter", "converters", "from", "methods", "annotated", "with" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java#L137-L145
train
jbehave/jbehave-core
jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java
NeedleStepsFactory.toArray
static InjectionProvider<?>[] toArray(final Set<InjectionProvider<?>> injectionProviders) { return injectionProviders.toArray(new InjectionProvider<?>[injectionProviders.size()]); }
java
static InjectionProvider<?>[] toArray(final Set<InjectionProvider<?>> injectionProviders) { return injectionProviders.toArray(new InjectionProvider<?>[injectionProviders.size()]); }
[ "static", "InjectionProvider", "<", "?", ">", "[", "]", "toArray", "(", "final", "Set", "<", "InjectionProvider", "<", "?", ">", ">", "injectionProviders", ")", "{", "return", "injectionProviders", ".", "toArray", "(", "new", "InjectionProvider", "<", "?", "...
Set to array. @param injectionProviders set of providers @return array of providers
[ "Set", "to", "array", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-needle/src/main/java/org/jbehave/core/steps/needle/NeedleStepsFactory.java#L195-L197
train
jbehave/jbehave-core
examples/core/src/main/java/org/jbehave/examples/core/steps/TraderSteps.java
TraderSteps.retrieveTrader
@AsParameterConverter public Trader retrieveTrader(String name) { for (Trader trader : traders) { if (trader.getName().equals(name)) { return trader; } } return mockTradePersister().retrieveTrader(name); }
java
@AsParameterConverter public Trader retrieveTrader(String name) { for (Trader trader : traders) { if (trader.getName().equals(name)) { return trader; } } return mockTradePersister().retrieveTrader(name); }
[ "@", "AsParameterConverter", "public", "Trader", "retrieveTrader", "(", "String", "name", ")", "{", "for", "(", "Trader", "trader", ":", "traders", ")", "{", "if", "(", "trader", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "ret...
Method used as dynamical parameter converter
[ "Method", "used", "as", "dynamical", "parameter", "converter" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/examples/core/src/main/java/org/jbehave/examples/core/steps/TraderSteps.java#L219-L227
train
jbehave/jbehave-core
jbehave-spring/src/main/java/org/jbehave/core/steps/spring/SpringStepsFactory.java
SpringStepsFactory.beanType
private Class<?> beanType(String name) { Class<?> type = context.getType(name); if (ClassUtils.isCglibProxyClass(type)) { return AopProxyUtils.ultimateTargetClass(context.getBean(name)); } return type; }
java
private Class<?> beanType(String name) { Class<?> type = context.getType(name); if (ClassUtils.isCglibProxyClass(type)) { return AopProxyUtils.ultimateTargetClass(context.getBean(name)); } return type; }
[ "private", "Class", "<", "?", ">", "beanType", "(", "String", "name", ")", "{", "Class", "<", "?", ">", "type", "=", "context", ".", "getType", "(", "name", ")", ";", "if", "(", "ClassUtils", ".", "isCglibProxyClass", "(", "type", ")", ")", "{", "r...
Return the bean type, untangling the proxy if needed @param name the bean name @return The Class of the bean
[ "Return", "the", "bean", "type", "untangling", "the", "proxy", "if", "needed" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-spring/src/main/java/org/jbehave/core/steps/spring/SpringStepsFactory.java#L78-L84
train
jbehave/jbehave-core
jbehave-guice/src/main/java/org/jbehave/core/configuration/guice/GuiceAnnotationBuilder.java
GuiceAnnotationBuilder.findBinding
private boolean findBinding(Injector injector, Class<?> type) { boolean found = false; for (Key<?> key : injector.getBindings().keySet()) { if (key.getTypeLiteral().getRawType().equals(type)) { found = true; break; } } if (!found && injector.getParent() != null) { return findBinding(injector.getParent(), type); } return found; }
java
private boolean findBinding(Injector injector, Class<?> type) { boolean found = false; for (Key<?> key : injector.getBindings().keySet()) { if (key.getTypeLiteral().getRawType().equals(type)) { found = true; break; } } if (!found && injector.getParent() != null) { return findBinding(injector.getParent(), type); } return found; }
[ "private", "boolean", "findBinding", "(", "Injector", "injector", ",", "Class", "<", "?", ">", "type", ")", "{", "boolean", "found", "=", "false", ";", "for", "(", "Key", "<", "?", ">", "key", ":", "injector", ".", "getBindings", "(", ")", ".", "keyS...
Finds binding for a type in the given injector and, if not found, recurses to its parent @param injector the current Injector @param type the Class representing the type @return A boolean flag, <code>true</code> if binding found
[ "Finds", "binding", "for", "a", "type", "in", "the", "given", "injector", "and", "if", "not", "found", "recurses", "to", "its", "parent" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-guice/src/main/java/org/jbehave/core/configuration/guice/GuiceAnnotationBuilder.java#L165-L178
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/io/JarFileScanner.java
JarFileScanner.scan
public List<String> scan() { try { JarFile jar = new JarFile(jarURL.getFile()); try { List<String> result = new ArrayList<>(); Enumeration<JarEntry> en = jar.entries(); while (en.hasMoreElements()) { JarEntry entry = en.nextElement(); String path = entry.getName(); boolean match = includes.size() == 0; if (!match) { for (String pattern : includes) { if ( patternMatches(pattern, path)) { match = true; break; } } } if (match) { for (String pattern : excludes) { if ( patternMatches(pattern, path)) { match = false; break; } } } if (match) { result.add(path); } } return result; } finally { jar.close(); } } catch (IOException e) { throw new IllegalStateException(e); } }
java
public List<String> scan() { try { JarFile jar = new JarFile(jarURL.getFile()); try { List<String> result = new ArrayList<>(); Enumeration<JarEntry> en = jar.entries(); while (en.hasMoreElements()) { JarEntry entry = en.nextElement(); String path = entry.getName(); boolean match = includes.size() == 0; if (!match) { for (String pattern : includes) { if ( patternMatches(pattern, path)) { match = true; break; } } } if (match) { for (String pattern : excludes) { if ( patternMatches(pattern, path)) { match = false; break; } } } if (match) { result.add(path); } } return result; } finally { jar.close(); } } catch (IOException e) { throw new IllegalStateException(e); } }
[ "public", "List", "<", "String", ">", "scan", "(", ")", "{", "try", "{", "JarFile", "jar", "=", "new", "JarFile", "(", "jarURL", ".", "getFile", "(", ")", ")", ";", "try", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<>", ...
Scans the jar file and returns the paths that match the includes and excludes. @return A List of paths @throws An IllegalStateException when an I/O error occurs in reading the jar file.
[ "Scans", "the", "jar", "file", "and", "returns", "the", "paths", "that", "match", "the", "includes", "and", "excludes", "." ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/io/JarFileScanner.java#L52-L89
train
jbehave/jbehave-core
jbehave-core/src/main/java/org/jbehave/core/steps/Stepdoc.java
Stepdoc.getMethodSignature
public String getMethodSignature() { if (method != null) { String methodSignature = method.toString(); return methodSignature.replaceFirst("public void ", ""); } return null; }
java
public String getMethodSignature() { if (method != null) { String methodSignature = method.toString(); return methodSignature.replaceFirst("public void ", ""); } return null; }
[ "public", "String", "getMethodSignature", "(", ")", "{", "if", "(", "method", "!=", "null", ")", "{", "String", "methodSignature", "=", "method", ".", "toString", "(", ")", ";", "return", "methodSignature", ".", "replaceFirst", "(", "\"public void \"", ",", ...
Method signature without "public void" prefix @return The method signature in String format
[ "Method", "signature", "without", "public", "void", "prefix" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/jbehave-core/src/main/java/org/jbehave/core/steps/Stepdoc.java#L60-L66
train
jbehave/jbehave-core
examples/gameoflife/src/main/java/com/lunivore/gameoflife/GridStory.java
GridStory.configuration
@Override public Configuration configuration() { return new MostUsefulConfiguration() // where to find the stories .useStoryLoader(new LoadFromClasspath(this.getClass())) // CONSOLE and TXT reporting .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT)); }
java
@Override public Configuration configuration() { return new MostUsefulConfiguration() // where to find the stories .useStoryLoader(new LoadFromClasspath(this.getClass())) // CONSOLE and TXT reporting .useStoryReporterBuilder(new StoryReporterBuilder().withDefaultFormats().withFormats(Format.CONSOLE, Format.TXT)); }
[ "@", "Override", "public", "Configuration", "configuration", "(", ")", "{", "return", "new", "MostUsefulConfiguration", "(", ")", "// where to find the stories", ".", "useStoryLoader", "(", "new", "LoadFromClasspath", "(", "this", ".", "getClass", "(", ")", ")", "...
Here we specify the configuration, starting from default MostUsefulConfiguration, and changing only what is needed
[ "Here", "we", "specify", "the", "configuration", "starting", "from", "default", "MostUsefulConfiguration", "and", "changing", "only", "what", "is", "needed" ]
bdd6a6199528df3c35087e72d4644870655b23e6
https://github.com/jbehave/jbehave-core/blob/bdd6a6199528df3c35087e72d4644870655b23e6/examples/gameoflife/src/main/java/com/lunivore/gameoflife/GridStory.java#L19-L26
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/requestOptions/GetAssignmentGroupOptions.java
GetAssignmentGroupOptions.includes
public GetAssignmentGroupOptions includes(List<Include> includes) { List<Include> assignmentDependents = Arrays.asList(Include.DISCUSSION_TOPIC, Include.ASSIGNMENT_VISIBILITY, Include.SUBMISSION); if(includes.stream().anyMatch(assignmentDependents::contains) && !includes.contains(Include.ASSIGNMENTS)) { throw new IllegalArgumentException("Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions"); } addEnumList("include[]", includes); return this; }
java
public GetAssignmentGroupOptions includes(List<Include> includes) { List<Include> assignmentDependents = Arrays.asList(Include.DISCUSSION_TOPIC, Include.ASSIGNMENT_VISIBILITY, Include.SUBMISSION); if(includes.stream().anyMatch(assignmentDependents::contains) && !includes.contains(Include.ASSIGNMENTS)) { throw new IllegalArgumentException("Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions"); } addEnumList("include[]", includes); return this; }
[ "public", "GetAssignmentGroupOptions", "includes", "(", "List", "<", "Include", ">", "includes", ")", "{", "List", "<", "Include", ">", "assignmentDependents", "=", "Arrays", ".", "asList", "(", "Include", ".", "DISCUSSION_TOPIC", ",", "Include", ".", "ASSIGNMEN...
Additional objects to include with the requested group. Note that all the optional includes depend on "assignments" also being included. @param includes List of included objects to return @return this object to continue building options
[ "Additional", "objects", "to", "include", "with", "the", "requested", "group", ".", "Note", "that", "all", "the", "optional", "includes", "depend", "on", "assignments", "also", "being", "included", "." ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/GetAssignmentGroupOptions.java#L44-L51
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/impl/ExternalToolImpl.java
ExternalToolImpl.ensureToolValidForCreation
private void ensureToolValidForCreation(ExternalTool tool) { //check for the unconditionally required fields if(StringUtils.isAnyBlank(tool.getName(), tool.getPrivacyLevel(), tool.getConsumerKey(), tool.getSharedSecret())) { throw new IllegalArgumentException("External tool requires all of the following for creation: name, privacy level, consumer key, shared secret"); } //check that there is either a URL or a domain. One or the other is required if(StringUtils.isBlank(tool.getUrl()) && StringUtils.isBlank(tool.getDomain())) { throw new IllegalArgumentException("External tool requires either a URL or domain for creation"); } }
java
private void ensureToolValidForCreation(ExternalTool tool) { //check for the unconditionally required fields if(StringUtils.isAnyBlank(tool.getName(), tool.getPrivacyLevel(), tool.getConsumerKey(), tool.getSharedSecret())) { throw new IllegalArgumentException("External tool requires all of the following for creation: name, privacy level, consumer key, shared secret"); } //check that there is either a URL or a domain. One or the other is required if(StringUtils.isBlank(tool.getUrl()) && StringUtils.isBlank(tool.getDomain())) { throw new IllegalArgumentException("External tool requires either a URL or domain for creation"); } }
[ "private", "void", "ensureToolValidForCreation", "(", "ExternalTool", "tool", ")", "{", "//check for the unconditionally required fields", "if", "(", "StringUtils", ".", "isAnyBlank", "(", "tool", ".", "getName", "(", ")", ",", "tool", ".", "getPrivacyLevel", "(", "...
Ensure that a tool object is valid for creation. The API requires certain fields to be filled out. Throws an IllegalArgumentException if the conditions are not met. @param tool The external tool object we are trying to create
[ "Ensure", "that", "a", "tool", "object", "is", "valid", "for", "creation", ".", "The", "API", "requires", "certain", "fields", "to", "be", "filled", "out", ".", "Throws", "an", "IllegalArgumentException", "if", "the", "conditions", "are", "not", "met", "." ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/impl/ExternalToolImpl.java#L139-L148
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/requestOptions/GetSingleConversationOptions.java
GetSingleConversationOptions.filters
public GetSingleConversationOptions filters(List<String> filters) { if(filters.size() == 1) { //Canvas API doesn't want the [] if it is only one value addSingleItem("filter", filters.get(0)); } else { optionsMap.put("filter[]", filters); } return this; }
java
public GetSingleConversationOptions filters(List<String> filters) { if(filters.size() == 1) { //Canvas API doesn't want the [] if it is only one value addSingleItem("filter", filters.get(0)); } else { optionsMap.put("filter[]", filters); } return this; }
[ "public", "GetSingleConversationOptions", "filters", "(", "List", "<", "String", ">", "filters", ")", "{", "if", "(", "filters", ".", "size", "(", ")", "==", "1", ")", "{", "//Canvas API doesn't want the [] if it is only one value", "addSingleItem", "(", "\"filter\"...
Used when setting the "visible" field in the response. See the "List Conversations" docs for details @param filters Filter strings to be applied to the visibility of conversations @return this to continue building options
[ "Used", "when", "setting", "the", "visible", "field", "in", "the", "response", ".", "See", "the", "List", "Conversations", "docs", "for", "details" ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/GetSingleConversationOptions.java#L28-L35
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/CanvasApiFactory.java
CanvasApiFactory.getReader
public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken) { return getReader(type, oauthToken, null); }
java
public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken) { return getReader(type, oauthToken, null); }
[ "public", "<", "T", "extends", "CanvasReader", ">", "T", "getReader", "(", "Class", "<", "T", ">", "type", ",", "OauthToken", "oauthToken", ")", "{", "return", "getReader", "(", "type", ",", "oauthToken", ",", "null", ")", ";", "}" ]
Get a reader implementation class to perform API calls with. @param type Interface type you wish to get an implementation for @param oauthToken An OAuth token to use for authentication when making API calls @param <T> The reader type to request an instance of @return A reader implementation class
[ "Get", "a", "reader", "implementation", "class", "to", "perform", "API", "calls", "with", "." ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L67-L69
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/CanvasApiFactory.java
CanvasApiFactory.getReader
public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken, Integer paginationPageSize) { LOG.debug("Factory call to instantiate class: " + type.getName()); RestClient restClient = new RefreshingRestClient(); @SuppressWarnings("unchecked") Class<T> concreteClass = (Class<T>)readerMap.get(type); if (concreteClass == null) { throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName()); } LOG.debug("got class: " + concreteClass); try { Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class); return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient, connectTimeout, readTimeout, paginationPageSize, false); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e); } }
java
public <T extends CanvasReader> T getReader(Class<T> type, OauthToken oauthToken, Integer paginationPageSize) { LOG.debug("Factory call to instantiate class: " + type.getName()); RestClient restClient = new RefreshingRestClient(); @SuppressWarnings("unchecked") Class<T> concreteClass = (Class<T>)readerMap.get(type); if (concreteClass == null) { throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName()); } LOG.debug("got class: " + concreteClass); try { Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class); return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient, connectTimeout, readTimeout, paginationPageSize, false); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e); } }
[ "public", "<", "T", "extends", "CanvasReader", ">", "T", "getReader", "(", "Class", "<", "T", ">", "type", ",", "OauthToken", "oauthToken", ",", "Integer", "paginationPageSize", ")", "{", "LOG", ".", "debug", "(", "\"Factory call to instantiate class: \"", "+", ...
Get a reader implementation class to perform API calls with while specifying an explicit page size for paginated API calls. This gets translated to a per_page= parameter on API requests. Note that Canvas does not guarantee it will honor this page size request. There is an explicit maximum page size on the server side which could change. The default page size is 10 which can be limiting when, for example, trying to get all users in a 800 person course. @param type Interface type you wish to get an implementation for @param oauthToken An OAuth token to use for authentication when making API calls @param paginationPageSize Requested pagination page size @param <T> The reader type to request an instance of @return An instance of the requested reader class
[ "Get", "a", "reader", "implementation", "class", "to", "perform", "API", "calls", "with", "while", "specifying", "an", "explicit", "page", "size", "for", "paginated", "API", "calls", ".", "This", "gets", "translated", "to", "a", "per_page", "=", "parameter", ...
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L83-L103
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/CanvasApiFactory.java
CanvasApiFactory.getWriter
public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) { return getWriter(type, oauthToken, false); }
java
public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken) { return getWriter(type, oauthToken, false); }
[ "public", "<", "T", "extends", "CanvasWriter", ">", "T", "getWriter", "(", "Class", "<", "T", ">", "type", ",", "OauthToken", "oauthToken", ")", "{", "return", "getWriter", "(", "type", ",", "oauthToken", ",", "false", ")", ";", "}" ]
Get a writer implementation to push data into Canvas. @param type Interface type you wish to get an implementation for @param oauthToken An OAuth token to use for authentication when making API calls @param <T> A writer implementation @return A writer implementation class
[ "Get", "a", "writer", "implementation", "to", "push", "data", "into", "Canvas", "." ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L112-L114
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/CanvasApiFactory.java
CanvasApiFactory.getWriter
public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken, Boolean serializeNulls) { LOG.debug("Factory call to instantiate class: " + type.getName()); RestClient restClient = new RefreshingRestClient(); @SuppressWarnings("unchecked") Class<T> concreteClass = (Class<T>) writerMap.get(type); if (concreteClass == null) { throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName()); } LOG.debug("got writer class: " + concreteClass); try { Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class); return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient, connectTimeout, readTimeout, null, serializeNulls); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e); } }
java
public <T extends CanvasWriter> T getWriter(Class<T> type, OauthToken oauthToken, Boolean serializeNulls) { LOG.debug("Factory call to instantiate class: " + type.getName()); RestClient restClient = new RefreshingRestClient(); @SuppressWarnings("unchecked") Class<T> concreteClass = (Class<T>) writerMap.get(type); if (concreteClass == null) { throw new UnsupportedOperationException("No implementation for requested interface found: " + type.getName()); } LOG.debug("got writer class: " + concreteClass); try { Constructor<T> constructor = concreteClass.getConstructor(String.class, Integer.class, OauthToken.class, RestClient.class, Integer.TYPE, Integer.TYPE, Integer.class, Boolean.class); return constructor.newInstance(canvasBaseUrl, CANVAS_API_VERSION, oauthToken, restClient, connectTimeout, readTimeout, null, serializeNulls); } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException e) { throw new UnsupportedOperationException("Unknown error instantiating the concrete API class: " + type.getName(), e); } }
[ "public", "<", "T", "extends", "CanvasWriter", ">", "T", "getWriter", "(", "Class", "<", "T", ">", "type", ",", "OauthToken", "oauthToken", ",", "Boolean", "serializeNulls", ")", "{", "LOG", ".", "debug", "(", "\"Factory call to instantiate class: \"", "+", "t...
Get a writer implementation to push data into Canvas while being able to control the behavior of blank values. If the serializeNulls parameter is set to true, this writer will serialize null fields in the JSON being sent to Canvas. This is required if you want to explicitly blank out a value that is currently set to something. @param type Interface type you wish to get an implementation for @param oauthToken An OAuth token to use for authentication when making API calls @param serializeNulls Whether or not to include null fields in the serialized JSON. Defaults to false if null @param <T> A writer implementation @return An instantiated instance of the requested writer type
[ "Get", "a", "writer", "implementation", "to", "push", "data", "into", "Canvas", "while", "being", "able", "to", "control", "the", "behavior", "of", "blank", "values", ".", "If", "the", "serializeNulls", "parameter", "is", "set", "to", "true", "this", "writer...
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/CanvasApiFactory.java#L126-L146
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/requestOptions/ListActiveCoursesInAccountOptions.java
ListActiveCoursesInAccountOptions.searchTerm
public ListActiveCoursesInAccountOptions searchTerm(String searchTerm) { if(searchTerm == null || searchTerm.length() < 3) { throw new IllegalArgumentException("Search term must be at least 3 characters"); } addSingleItem("search_term", searchTerm); return this; }
java
public ListActiveCoursesInAccountOptions searchTerm(String searchTerm) { if(searchTerm == null || searchTerm.length() < 3) { throw new IllegalArgumentException("Search term must be at least 3 characters"); } addSingleItem("search_term", searchTerm); return this; }
[ "public", "ListActiveCoursesInAccountOptions", "searchTerm", "(", "String", "searchTerm", ")", "{", "if", "(", "searchTerm", "==", "null", "||", "searchTerm", ".", "length", "(", ")", "<", "3", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Search...
Filter on a search term. Can be course name, code or full ID. Must be at least 3 characters @param searchTerm Search term to filter by @return This object to allow adding more options
[ "Filter", "on", "a", "search", "term", ".", "Can", "be", "course", "name", "code", "or", "full", "ID", ".", "Must", "be", "at", "least", "3", "characters" ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/ListActiveCoursesInAccountOptions.java#L147-L153
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/requestOptions/ListExternalToolsOptions.java
ListExternalToolsOptions.searchTerm
public ListExternalToolsOptions searchTerm(String searchTerm) { if(searchTerm == null || searchTerm.length() < 3) { throw new IllegalArgumentException("Search term must be at least 3 characters"); } addSingleItem("search_term", searchTerm); return this; }
java
public ListExternalToolsOptions searchTerm(String searchTerm) { if(searchTerm == null || searchTerm.length() < 3) { throw new IllegalArgumentException("Search term must be at least 3 characters"); } addSingleItem("search_term", searchTerm); return this; }
[ "public", "ListExternalToolsOptions", "searchTerm", "(", "String", "searchTerm", ")", "{", "if", "(", "searchTerm", "==", "null", "||", "searchTerm", ".", "length", "(", ")", "<", "3", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Search term mus...
Only return tools with a name matching this partial string @param searchTerm Tool name to search for @return This object to allow adding more options
[ "Only", "return", "tools", "with", "a", "name", "matching", "this", "partial", "string" ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/ListExternalToolsOptions.java#L20-L26
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/impl/EnrollmentTermImpl.java
EnrollmentTermImpl.parseEnrollmentTermList
private List<EnrollmentTerm> parseEnrollmentTermList(final List<Response> responses) { return responses.stream(). map(this::parseEnrollmentTermList). flatMap(Collection::stream). collect(Collectors.toList()); }
java
private List<EnrollmentTerm> parseEnrollmentTermList(final List<Response> responses) { return responses.stream(). map(this::parseEnrollmentTermList). flatMap(Collection::stream). collect(Collectors.toList()); }
[ "private", "List", "<", "EnrollmentTerm", ">", "parseEnrollmentTermList", "(", "final", "List", "<", "Response", ">", "responses", ")", "{", "return", "responses", ".", "stream", "(", ")", ".", "map", "(", "this", "::", "parseEnrollmentTermList", ")", ".", "...
a useless object at the top level of the response JSON for no reason at all.
[ "a", "useless", "object", "at", "the", "top", "level", "of", "the", "response", "JSON", "for", "no", "reason", "at", "all", "." ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/impl/EnrollmentTermImpl.java#L41-L46
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/net/SimpleRestClient.java
SimpleRestClient.sendJsonPostOrPut
private Response sendJsonPostOrPut(OauthToken token, String url, String json, int connectTimeout, int readTimeout, String method) throws IOException { LOG.debug("Sending JSON " + method + " to URL: " + url); Response response = new Response(); HttpClient httpClient = createHttpClient(connectTimeout, readTimeout); HttpEntityEnclosingRequestBase action; if("POST".equals(method)) { action = new HttpPost(url); } else if("PUT".equals(method)) { action = new HttpPut(url); } else { throw new IllegalArgumentException("Method must be either POST or PUT"); } Long beginTime = System.currentTimeMillis(); action.setHeader("Authorization", "Bearer" + " " + token.getAccessToken()); StringEntity requestBody = new StringEntity(json, ContentType.APPLICATION_JSON); action.setEntity(requestBody); try { HttpResponse httpResponse = httpClient.execute(action); String content = handleResponse(httpResponse, action); response.setContent(content); response.setResponseCode(httpResponse.getStatusLine().getStatusCode()); Long endTime = System.currentTimeMillis(); LOG.debug("POST call took: " + (endTime - beginTime) + "ms"); } finally { action.releaseConnection(); } return response; }
java
private Response sendJsonPostOrPut(OauthToken token, String url, String json, int connectTimeout, int readTimeout, String method) throws IOException { LOG.debug("Sending JSON " + method + " to URL: " + url); Response response = new Response(); HttpClient httpClient = createHttpClient(connectTimeout, readTimeout); HttpEntityEnclosingRequestBase action; if("POST".equals(method)) { action = new HttpPost(url); } else if("PUT".equals(method)) { action = new HttpPut(url); } else { throw new IllegalArgumentException("Method must be either POST or PUT"); } Long beginTime = System.currentTimeMillis(); action.setHeader("Authorization", "Bearer" + " " + token.getAccessToken()); StringEntity requestBody = new StringEntity(json, ContentType.APPLICATION_JSON); action.setEntity(requestBody); try { HttpResponse httpResponse = httpClient.execute(action); String content = handleResponse(httpResponse, action); response.setContent(content); response.setResponseCode(httpResponse.getStatusLine().getStatusCode()); Long endTime = System.currentTimeMillis(); LOG.debug("POST call took: " + (endTime - beginTime) + "ms"); } finally { action.releaseConnection(); } return response; }
[ "private", "Response", "sendJsonPostOrPut", "(", "OauthToken", "token", ",", "String", "url", ",", "String", "json", ",", "int", "connectTimeout", ",", "int", "readTimeout", ",", "String", "method", ")", "throws", "IOException", "{", "LOG", ".", "debug", "(", ...
PUT and POST are identical calls except for the header specifying the method
[ "PUT", "and", "POST", "are", "identical", "calls", "except", "for", "the", "header", "specifying", "the", "method" ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/net/SimpleRestClient.java#L102-L135
train
kstateome/canvas-api
src/main/java/edu/ksu/canvas/requestOptions/BaseOptions.java
BaseOptions.addEnumList
protected void addEnumList(String key, List<? extends Enum> list) { optionsMap.put(key, list.stream().map(i -> i.toString()).collect(Collectors.toList())); }
java
protected void addEnumList(String key, List<? extends Enum> list) { optionsMap.put(key, list.stream().map(i -> i.toString()).collect(Collectors.toList())); }
[ "protected", "void", "addEnumList", "(", "String", "key", ",", "List", "<", "?", "extends", "Enum", ">", "list", ")", "{", "optionsMap", ".", "put", "(", "key", ",", "list", ".", "stream", "(", ")", ".", "map", "(", "i", "->", "i", ".", "toString",...
Add a list of enums to the options map @param key The key for the options map (ex: "include[]") @param list A list of enums
[ "Add", "a", "list", "of", "enums", "to", "the", "options", "map" ]
426bf403a8fd7aca3f170348005feda25b374e5a
https://github.com/kstateome/canvas-api/blob/426bf403a8fd7aca3f170348005feda25b374e5a/src/main/java/edu/ksu/canvas/requestOptions/BaseOptions.java#L23-L25
train
awslabs/amazon-sqs-java-extended-client-lib
src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java
ExtendedClientConfiguration.setLargePayloadSupportEnabled
public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) { if (s3 == null || s3BucketName == null) { String errorMessage = "S3 client and/or S3 bucket name cannot be null."; LOG.error(errorMessage); throw new AmazonClientException(errorMessage); } if (isLargePayloadSupportEnabled()) { LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName."); } this.s3 = s3; this.s3BucketName = s3BucketName; largePayloadSupport = true; LOG.info("Large-payload support enabled."); }
java
public void setLargePayloadSupportEnabled(AmazonS3 s3, String s3BucketName) { if (s3 == null || s3BucketName == null) { String errorMessage = "S3 client and/or S3 bucket name cannot be null."; LOG.error(errorMessage); throw new AmazonClientException(errorMessage); } if (isLargePayloadSupportEnabled()) { LOG.warn("Large-payload support is already enabled. Overwriting AmazonS3Client and S3BucketName."); } this.s3 = s3; this.s3BucketName = s3BucketName; largePayloadSupport = true; LOG.info("Large-payload support enabled."); }
[ "public", "void", "setLargePayloadSupportEnabled", "(", "AmazonS3", "s3", ",", "String", "s3BucketName", ")", "{", "if", "(", "s3", "==", "null", "||", "s3BucketName", "==", "null", ")", "{", "String", "errorMessage", "=", "\"S3 client and/or S3 bucket name cannot b...
Enables support for large-payload messages. @param s3 Amazon S3 client which is going to be used for storing large-payload messages. @param s3BucketName Name of the bucket which is going to be used for storing large-payload messages. The bucket must be already created and configured in s3.
[ "Enables", "support", "for", "large", "-", "payload", "messages", "." ]
df0c6251b99e682d6179938fe784590e662b84ea
https://github.com/awslabs/amazon-sqs-java-extended-client-lib/blob/df0c6251b99e682d6179938fe784590e662b84ea/src/main/java/com/amazon/sqs/javamessaging/ExtendedClientConfiguration.java#L64-L77
train
twitter/hbc
hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java
DelimitedStreamReader.readLine
private String readLine(boolean trim) throws IOException { boolean done = false; boolean sawCarriage = false; // bytes to trim (the \r and the \n) int removalBytes = 0; while (!done) { if (isReadBufferEmpty()) { offset = 0; end = 0; int bytesRead = inputStream.read(buffer, end, Math.min(DEFAULT_READ_COUNT, buffer.length - end)); if (bytesRead < 0) { // we failed to read anything more... throw new IOException("Reached the end of the stream"); } else { end += bytesRead; } } int originalOffset = offset; for (; !done && offset < end; offset++) { if (buffer[offset] == LF) { int cpLength = offset - originalOffset + 1; if (trim) { int length = 0; if (buffer[offset] == LF) { length ++; if (sawCarriage) { length++; } } cpLength -= length; } if (cpLength > 0) { copyToStrBuffer(buffer, originalOffset, cpLength); } else { // negative length means we need to trim a \r from strBuffer removalBytes = cpLength; } done = true; } else { // did not see newline: sawCarriage = buffer[offset] == CR; } } if (!done) { copyToStrBuffer(buffer, originalOffset, end - originalOffset); offset = end; } } int strLength = strBufferIndex + removalBytes; strBufferIndex = 0; return new String(strBuffer, 0, strLength, charset); }
java
private String readLine(boolean trim) throws IOException { boolean done = false; boolean sawCarriage = false; // bytes to trim (the \r and the \n) int removalBytes = 0; while (!done) { if (isReadBufferEmpty()) { offset = 0; end = 0; int bytesRead = inputStream.read(buffer, end, Math.min(DEFAULT_READ_COUNT, buffer.length - end)); if (bytesRead < 0) { // we failed to read anything more... throw new IOException("Reached the end of the stream"); } else { end += bytesRead; } } int originalOffset = offset; for (; !done && offset < end; offset++) { if (buffer[offset] == LF) { int cpLength = offset - originalOffset + 1; if (trim) { int length = 0; if (buffer[offset] == LF) { length ++; if (sawCarriage) { length++; } } cpLength -= length; } if (cpLength > 0) { copyToStrBuffer(buffer, originalOffset, cpLength); } else { // negative length means we need to trim a \r from strBuffer removalBytes = cpLength; } done = true; } else { // did not see newline: sawCarriage = buffer[offset] == CR; } } if (!done) { copyToStrBuffer(buffer, originalOffset, end - originalOffset); offset = end; } } int strLength = strBufferIndex + removalBytes; strBufferIndex = 0; return new String(strBuffer, 0, strLength, charset); }
[ "private", "String", "readLine", "(", "boolean", "trim", ")", "throws", "IOException", "{", "boolean", "done", "=", "false", ";", "boolean", "sawCarriage", "=", "false", ";", "// bytes to trim (the \\r and the \\n)", "int", "removalBytes", "=", "0", ";", "while", ...
Reads a line from the input stream, where a line is terminated by \r, \n, or \r\n @param trim whether to trim trailing \r and \ns
[ "Reads", "a", "line", "from", "the", "input", "stream", "where", "a", "line", "is", "terminated", "by", "\\", "r", "\\", "n", "or", "\\", "r", "\\", "n" ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L63-L117
train
twitter/hbc
hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java
DelimitedStreamReader.copyToStrBuffer
private void copyToStrBuffer(byte[] buffer, int offset, int length) { Preconditions.checkArgument(length >= 0); if (strBuffer.length - strBufferIndex < length) { // cannot fit, expanding buffer expandStrBuffer(length); } System.arraycopy( buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex)); strBufferIndex += length; }
java
private void copyToStrBuffer(byte[] buffer, int offset, int length) { Preconditions.checkArgument(length >= 0); if (strBuffer.length - strBufferIndex < length) { // cannot fit, expanding buffer expandStrBuffer(length); } System.arraycopy( buffer, offset, strBuffer, strBufferIndex, Math.min(length, MAX_ALLOWABLE_BUFFER_SIZE - strBufferIndex)); strBufferIndex += length; }
[ "private", "void", "copyToStrBuffer", "(", "byte", "[", "]", "buffer", ",", "int", "offset", ",", "int", "length", ")", "{", "Preconditions", ".", "checkArgument", "(", "length", ">=", "0", ")", ";", "if", "(", "strBuffer", ".", "length", "-", "strBuffer...
Copies from buffer to our internal strBufferIndex, expanding the internal buffer if necessary @param offset offset in the buffer to start copying from @param length length to copy
[ "Copies", "from", "buffer", "to", "our", "internal", "strBufferIndex", "expanding", "the", "internal", "buffer", "if", "necessary" ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L124-L133
train
twitter/hbc
hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java
DelimitedStreamReader.read
public String read(int numBytes) throws IOException { Preconditions.checkArgument(numBytes >= 0); Preconditions.checkArgument(numBytes <= MAX_ALLOWABLE_BUFFER_SIZE); int numBytesRemaining = numBytes; // first read whatever we need from our buffer if (!isReadBufferEmpty()) { int length = Math.min(end - offset, numBytesRemaining); copyToStrBuffer(buffer, offset, length); offset += length; numBytesRemaining -= length; } // next read the remaining chars directly into our strBuffer if (numBytesRemaining > 0) { readAmountToStrBuffer(numBytesRemaining); } if (strBufferIndex > 0 && strBuffer[strBufferIndex - 1] != LF) { // the last byte doesn't correspond to lf return readLine(false); } int strBufferLength = strBufferIndex; strBufferIndex = 0; return new String(strBuffer, 0, strBufferLength, charset); }
java
public String read(int numBytes) throws IOException { Preconditions.checkArgument(numBytes >= 0); Preconditions.checkArgument(numBytes <= MAX_ALLOWABLE_BUFFER_SIZE); int numBytesRemaining = numBytes; // first read whatever we need from our buffer if (!isReadBufferEmpty()) { int length = Math.min(end - offset, numBytesRemaining); copyToStrBuffer(buffer, offset, length); offset += length; numBytesRemaining -= length; } // next read the remaining chars directly into our strBuffer if (numBytesRemaining > 0) { readAmountToStrBuffer(numBytesRemaining); } if (strBufferIndex > 0 && strBuffer[strBufferIndex - 1] != LF) { // the last byte doesn't correspond to lf return readLine(false); } int strBufferLength = strBufferIndex; strBufferIndex = 0; return new String(strBuffer, 0, strBufferLength, charset); }
[ "public", "String", "read", "(", "int", "numBytes", ")", "throws", "IOException", "{", "Preconditions", ".", "checkArgument", "(", "numBytes", ">=", "0", ")", ";", "Preconditions", ".", "checkArgument", "(", "numBytes", "<=", "MAX_ALLOWABLE_BUFFER_SIZE", ")", ";...
Reads numBytes bytes, and returns the corresponding string
[ "Reads", "numBytes", "bytes", "and", "returns", "the", "corresponding", "string" ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/common/DelimitedStreamReader.java#L151-L176
train
twitter/hbc
hbc-core/src/main/java/com/twitter/hbc/core/endpoint/DefaultStreamingEndpoint.java
DefaultStreamingEndpoint.languages
public DefaultStreamingEndpoint languages(List<String> languages) { addPostParameter(Constants.LANGUAGE_PARAM, Joiner.on(',').join(languages)); return this; }
java
public DefaultStreamingEndpoint languages(List<String> languages) { addPostParameter(Constants.LANGUAGE_PARAM, Joiner.on(',').join(languages)); return this; }
[ "public", "DefaultStreamingEndpoint", "languages", "(", "List", "<", "String", ">", "languages", ")", "{", "addPostParameter", "(", "Constants", ".", "LANGUAGE_PARAM", ",", "Joiner", ".", "on", "(", "'", "'", ")", ".", "join", "(", "languages", ")", ")", "...
Filter for public tweets on these languages. @param languages Valid BCP 47 (http://tools.ietf.org/html/bcp47) language identifiers, and may represent any of the languages listed on Twitter's advanced search page (https://twitter.com/search-advanced), or "und" if no language could be detected. These strings should NOT be url-encoded. @return this
[ "Filter", "for", "public", "tweets", "on", "these", "languages", "." ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/core/endpoint/DefaultStreamingEndpoint.java#L89-L92
train
twitter/hbc
hbc-twitter4j/src/main/java/com/twitter/hbc/twitter4j/BaseTwitter4jClient.java
BaseTwitter4jClient.process
@Override public void process() { if (client.isDone() || executorService.isTerminated()) { throw new IllegalStateException("Client is already stopped"); } Runnable runner = new Runnable() { @Override public void run() { try { while (!client.isDone()) { String msg = messageQueue.take(); try { parseMessage(msg); } catch (Exception e) { logger.warn("Exception thrown during parsing msg " + msg, e); onException(e); } } } catch (Exception e) { onException(e); } } }; executorService.execute(runner); }
java
@Override public void process() { if (client.isDone() || executorService.isTerminated()) { throw new IllegalStateException("Client is already stopped"); } Runnable runner = new Runnable() { @Override public void run() { try { while (!client.isDone()) { String msg = messageQueue.take(); try { parseMessage(msg); } catch (Exception e) { logger.warn("Exception thrown during parsing msg " + msg, e); onException(e); } } } catch (Exception e) { onException(e); } } }; executorService.execute(runner); }
[ "@", "Override", "public", "void", "process", "(", ")", "{", "if", "(", "client", ".", "isDone", "(", ")", "||", "executorService", ".", "isTerminated", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Client is already stopped\"", ")", "...
Forks off a runnable with the executor provided. Multiple calls are allowed, but the listeners must be threadsafe.
[ "Forks", "off", "a", "runnable", "with", "the", "executor", "provided", ".", "Multiple", "calls", "are", "allowed", "but", "the", "listeners", "must", "be", "threadsafe", "." ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-twitter4j/src/main/java/com/twitter/hbc/twitter4j/BaseTwitter4jClient.java#L64-L89
train
twitter/hbc
hbc-core/src/main/java/com/twitter/hbc/httpclient/ClientBase.java
ClientBase.stop
public void stop(int waitMillis) throws InterruptedException { try { if (!isDone()) { setExitStatus(new Event(EventType.STOPPED_BY_USER, String.format("Stopped by user: waiting for %d ms", waitMillis))); } if (!waitForFinish(waitMillis)) { logger.warn("{} Client thread failed to finish in {} millis", name, waitMillis); } } finally { rateTracker.shutdown(); } }
java
public void stop(int waitMillis) throws InterruptedException { try { if (!isDone()) { setExitStatus(new Event(EventType.STOPPED_BY_USER, String.format("Stopped by user: waiting for %d ms", waitMillis))); } if (!waitForFinish(waitMillis)) { logger.warn("{} Client thread failed to finish in {} millis", name, waitMillis); } } finally { rateTracker.shutdown(); } }
[ "public", "void", "stop", "(", "int", "waitMillis", ")", "throws", "InterruptedException", "{", "try", "{", "if", "(", "!", "isDone", "(", ")", ")", "{", "setExitStatus", "(", "new", "Event", "(", "EventType", ".", "STOPPED_BY_USER", ",", "String", ".", ...
Stops the current connection. No reconnecting will occur. Kills thread + cleanup. Waits for the loop to end
[ "Stops", "the", "current", "connection", ".", "No", "reconnecting", "will", "occur", ".", "Kills", "thread", "+", "cleanup", ".", "Waits", "for", "the", "loop", "to", "end" ]
72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c
https://github.com/twitter/hbc/blob/72a8d0b44ba824a722cf4ee7ed9f9bc34d02d92c/hbc-core/src/main/java/com/twitter/hbc/httpclient/ClientBase.java#L299-L310
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerListenerDelegate.java
WorkerListenerDelegate.fireEvent
public void fireEvent(final WorkerEvent event, final Worker worker, final String queue, final Job job, final Object runner, final Object result, final Throwable t) { final ConcurrentSet<WorkerListener> listeners = this.eventListenerMap.get(event); if (listeners != null) { for (final WorkerListener listener : listeners) { if (listener != null) { try { listener.onEvent(event, worker, queue, job, runner, result, t); } catch (Exception e) { log.error("Failure executing listener " + listener + " for event " + event + " from queue " + queue + " on worker " + worker, e); } } } } }
java
public void fireEvent(final WorkerEvent event, final Worker worker, final String queue, final Job job, final Object runner, final Object result, final Throwable t) { final ConcurrentSet<WorkerListener> listeners = this.eventListenerMap.get(event); if (listeners != null) { for (final WorkerListener listener : listeners) { if (listener != null) { try { listener.onEvent(event, worker, queue, job, runner, result, t); } catch (Exception e) { log.error("Failure executing listener " + listener + " for event " + event + " from queue " + queue + " on worker " + worker, e); } } } } }
[ "public", "void", "fireEvent", "(", "final", "WorkerEvent", "event", ",", "final", "Worker", "worker", ",", "final", "String", "queue", ",", "final", "Job", "job", ",", "final", "Object", "runner", ",", "final", "Object", "result", ",", "final", "Throwable",...
Notify all WorkerListeners currently registered for the given WorkerEvent. @param event the WorkerEvent that occurred @param worker the Worker that the event occurred in @param queue the queue the Worker is processing @param job the Job related to the event (only supply for JOB_PROCESS, JOB_EXECUTE, JOB_SUCCESS, and JOB_FAILURE events) @param runner the materialized object that the Job specified (only supply for JOB_EXECUTE and JOB_SUCCESS events) @param result the result of the successful execution of the Job (only set for JOB_SUCCESS and if the Job was a Callable that returned a value) @param t the Throwable that caused the event (only supply for JOB_FAILURE and ERROR events)
[ "Notify", "all", "WorkerListeners", "currently", "registered", "for", "the", "given", "WorkerEvent", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerListenerDelegate.java#L130-L145
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JesqueUtils.java
JesqueUtils.createBacktrace
public static List<String> createBacktrace(final Throwable t) { final List<String> bTrace = new LinkedList<String>(); for (final StackTraceElement ste : t.getStackTrace()) { bTrace.add(BT_PREFIX + ste.toString()); } if (t.getCause() != null) { addCauseToBacktrace(t.getCause(), bTrace); } return bTrace; }
java
public static List<String> createBacktrace(final Throwable t) { final List<String> bTrace = new LinkedList<String>(); for (final StackTraceElement ste : t.getStackTrace()) { bTrace.add(BT_PREFIX + ste.toString()); } if (t.getCause() != null) { addCauseToBacktrace(t.getCause(), bTrace); } return bTrace; }
[ "public", "static", "List", "<", "String", ">", "createBacktrace", "(", "final", "Throwable", "t", ")", "{", "final", "List", "<", "String", ">", "bTrace", "=", "new", "LinkedList", "<", "String", ">", "(", ")", ";", "for", "(", "final", "StackTraceEleme...
Creates a Resque backtrace from a Throwable's stack trace. Includes causes. @param t the Exception to use @return a list of strings that represent how the exception's stacktrace appears.
[ "Creates", "a", "Resque", "backtrace", "from", "a", "Throwable", "s", "stack", "trace", ".", "Includes", "causes", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L131-L140
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JesqueUtils.java
JesqueUtils.addCauseToBacktrace
private static void addCauseToBacktrace(final Throwable cause, final List<String> bTrace) { if (cause.getMessage() == null) { bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName()); } else { bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName() + ": " + cause.getMessage()); } for (final StackTraceElement ste : cause.getStackTrace()) { bTrace.add(BT_PREFIX + ste.toString()); } if (cause.getCause() != null) { addCauseToBacktrace(cause.getCause(), bTrace); } }
java
private static void addCauseToBacktrace(final Throwable cause, final List<String> bTrace) { if (cause.getMessage() == null) { bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName()); } else { bTrace.add(BT_CAUSED_BY_PREFIX + cause.getClass().getName() + ": " + cause.getMessage()); } for (final StackTraceElement ste : cause.getStackTrace()) { bTrace.add(BT_PREFIX + ste.toString()); } if (cause.getCause() != null) { addCauseToBacktrace(cause.getCause(), bTrace); } }
[ "private", "static", "void", "addCauseToBacktrace", "(", "final", "Throwable", "cause", ",", "final", "List", "<", "String", ">", "bTrace", ")", "{", "if", "(", "cause", ".", "getMessage", "(", ")", "==", "null", ")", "{", "bTrace", ".", "add", "(", "B...
Add a cause to the backtrace. @param cause the cause @param bTrace the backtrace list
[ "Add", "a", "cause", "to", "the", "backtrace", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L150-L162
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JesqueUtils.java
JesqueUtils.map
@SafeVarargs public static <K, V> Map<K, V> map(final Entry<? extends K, ? extends V>... entries) { final Map<K, V> map = new LinkedHashMap<K, V>(entries.length); for (final Entry<? extends K, ? extends V> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; }
java
@SafeVarargs public static <K, V> Map<K, V> map(final Entry<? extends K, ? extends V>... entries) { final Map<K, V> map = new LinkedHashMap<K, V>(entries.length); for (final Entry<? extends K, ? extends V> entry : entries) { map.put(entry.getKey(), entry.getValue()); } return map; }
[ "@", "SafeVarargs", "public", "static", "<", "K", ",", "V", ">", "Map", "<", "K", ",", "V", ">", "map", "(", "final", "Entry", "<", "?", "extends", "K", ",", "?", "extends", "V", ">", "...", "entries", ")", "{", "final", "Map", "<", "K", ",", ...
A convenient way of creating a map on the fly. @param <K> the key type @param <V> the value type @param entries Map.Entry objects to be added to the map @return a LinkedHashMap with the supplied entries
[ "A", "convenient", "way", "of", "creating", "a", "map", "on", "the", "fly", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L319-L326
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JesqueUtils.java
JesqueUtils.set
@SafeVarargs public static <K> Set<K> set(final K... keys) { return new LinkedHashSet<K>(Arrays.asList(keys)); }
java
@SafeVarargs public static <K> Set<K> set(final K... keys) { return new LinkedHashSet<K>(Arrays.asList(keys)); }
[ "@", "SafeVarargs", "public", "static", "<", "K", ">", "Set", "<", "K", ">", "set", "(", "final", "K", "...", "keys", ")", "{", "return", "new", "LinkedHashSet", "<", "K", ">", "(", "Arrays", ".", "asList", "(", "keys", ")", ")", ";", "}" ]
Creates a Set out of the given keys @param <K> the key type @param keys the keys @return a Set containing the given keys
[ "Creates", "a", "Set", "out", "of", "the", "given", "keys" ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L352-L355
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JesqueUtils.java
JesqueUtils.nullSafeEquals
public static boolean nullSafeEquals(final Object obj1, final Object obj2) { return ((obj1 == null && obj2 == null) || (obj1 != null && obj2 != null && obj1.equals(obj2))); }
java
public static boolean nullSafeEquals(final Object obj1, final Object obj2) { return ((obj1 == null && obj2 == null) || (obj1 != null && obj2 != null && obj1.equals(obj2))); }
[ "public", "static", "boolean", "nullSafeEquals", "(", "final", "Object", "obj1", ",", "final", "Object", "obj2", ")", "{", "return", "(", "(", "obj1", "==", "null", "&&", "obj2", "==", "null", ")", "||", "(", "obj1", "!=", "null", "&&", "obj2", "!=", ...
Test for equality. @param obj1 the first object @param obj2 the second object @return true if both are null or the two objects are equal
[ "Test", "for", "equality", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JesqueUtils.java#L363-L366
train
gresrun/jesque
src/main/java/net/greghaines/jesque/meta/dao/impl/QueueInfoDAORedisImpl.java
QueueInfoDAORedisImpl.size
private long size(final Jedis jedis, final String queueName) { final String key = key(QUEUE, queueName); final long size; if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZCARD size = jedis.zcard(key); } else { // Else, use LLEN size = jedis.llen(key); } return size; }
java
private long size(final Jedis jedis, final String queueName) { final String key = key(QUEUE, queueName); final long size; if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZCARD size = jedis.zcard(key); } else { // Else, use LLEN size = jedis.llen(key); } return size; }
[ "private", "long", "size", "(", "final", "Jedis", "jedis", ",", "final", "String", "queueName", ")", "{", "final", "String", "key", "=", "key", "(", "QUEUE", ",", "queueName", ")", ";", "final", "long", "size", ";", "if", "(", "JedisUtils", ".", "isDel...
Size of a queue. @param jedis @param queueName @return
[ "Size", "of", "a", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/meta/dao/impl/QueueInfoDAORedisImpl.java#L219-L228
train
gresrun/jesque
src/main/java/net/greghaines/jesque/meta/dao/impl/QueueInfoDAORedisImpl.java
QueueInfoDAORedisImpl.getJobs
private List<Job> getJobs(final Jedis jedis, final String queueName, final long jobOffset, final long jobCount) throws Exception { final String key = key(QUEUE, queueName); final List<Job> jobs = new ArrayList<>(); if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZRANGEWITHSCORES final Set<Tuple> elements = jedis.zrangeWithScores(key, jobOffset, jobOffset + jobCount - 1); for (final Tuple elementWithScore : elements) { final Job job = ObjectMapperFactory.get().readValue(elementWithScore.getElement(), Job.class); job.setRunAt(elementWithScore.getScore()); jobs.add(job); } } else { // Else, use LRANGE final List<String> elements = jedis.lrange(key, jobOffset, jobOffset + jobCount - 1); for (final String element : elements) { jobs.add(ObjectMapperFactory.get().readValue(element, Job.class)); } } return jobs; }
java
private List<Job> getJobs(final Jedis jedis, final String queueName, final long jobOffset, final long jobCount) throws Exception { final String key = key(QUEUE, queueName); final List<Job> jobs = new ArrayList<>(); if (JedisUtils.isDelayedQueue(jedis, key)) { // If delayed queue, use ZRANGEWITHSCORES final Set<Tuple> elements = jedis.zrangeWithScores(key, jobOffset, jobOffset + jobCount - 1); for (final Tuple elementWithScore : elements) { final Job job = ObjectMapperFactory.get().readValue(elementWithScore.getElement(), Job.class); job.setRunAt(elementWithScore.getScore()); jobs.add(job); } } else { // Else, use LRANGE final List<String> elements = jedis.lrange(key, jobOffset, jobOffset + jobCount - 1); for (final String element : elements) { jobs.add(ObjectMapperFactory.get().readValue(element, Job.class)); } } return jobs; }
[ "private", "List", "<", "Job", ">", "getJobs", "(", "final", "Jedis", "jedis", ",", "final", "String", "queueName", ",", "final", "long", "jobOffset", ",", "final", "long", "jobCount", ")", "throws", "Exception", "{", "final", "String", "key", "=", "key", ...
Get list of Jobs from a queue. @param jedis @param queueName @param jobOffset @param jobCount @return
[ "Get", "list", "of", "Jobs", "from", "a", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/meta/dao/impl/QueueInfoDAORedisImpl.java#L244-L261
train
gresrun/jesque
src/main/java/net/greghaines/jesque/Job.java
Job.setVars
@SuppressWarnings("unchecked") public void setVars(final Map<String, ? extends Object> vars) { this.vars = (Map<String, Object>)vars; }
java
@SuppressWarnings("unchecked") public void setVars(final Map<String, ? extends Object> vars) { this.vars = (Map<String, Object>)vars; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "setVars", "(", "final", "Map", "<", "String", ",", "?", "extends", "Object", ">", "vars", ")", "{", "this", ".", "vars", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "...
Set the named arguments. @param vars the new named arguments
[ "Set", "the", "named", "arguments", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/Job.java#L193-L196
train
gresrun/jesque
src/main/java/net/greghaines/jesque/Job.java
Job.setUnknownField
@JsonAnySetter public void setUnknownField(final String name, final Object value) { this.unknownFields.put(name, value); }
java
@JsonAnySetter public void setUnknownField(final String name, final Object value) { this.unknownFields.put(name, value); }
[ "@", "JsonAnySetter", "public", "void", "setUnknownField", "(", "final", "String", "name", ",", "final", "Object", "value", ")", "{", "this", ".", "unknownFields", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Set an unknown field. @param name the unknown property name @param value the unknown property value
[ "Set", "an", "unknown", "field", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/Job.java#L240-L243
train
gresrun/jesque
src/main/java/net/greghaines/jesque/Job.java
Job.setUnknownFields
@JsonIgnore public void setUnknownFields(final Map<String,Object> unknownFields) { this.unknownFields.clear(); this.unknownFields.putAll(unknownFields); }
java
@JsonIgnore public void setUnknownFields(final Map<String,Object> unknownFields) { this.unknownFields.clear(); this.unknownFields.putAll(unknownFields); }
[ "@", "JsonIgnore", "public", "void", "setUnknownFields", "(", "final", "Map", "<", "String", ",", "Object", ">", "unknownFields", ")", "{", "this", ".", "unknownFields", ".", "clear", "(", ")", ";", "this", ".", "unknownFields", ".", "putAll", "(", "unknow...
Set all unknown fields @param unknownFields the new unknown fields
[ "Set", "all", "unknown", "fields" ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/Job.java#L249-L253
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java
MapBasedJobFactory.addJobType
public void addJobType(final String jobName, final Class<?> jobType) { checkJobType(jobName, jobType); this.jobTypes.put(jobName, jobType); }
java
public void addJobType(final String jobName, final Class<?> jobType) { checkJobType(jobName, jobType); this.jobTypes.put(jobName, jobType); }
[ "public", "void", "addJobType", "(", "final", "String", "jobName", ",", "final", "Class", "<", "?", ">", "jobType", ")", "{", "checkJobType", "(", "jobName", ",", "jobType", ")", ";", "this", ".", "jobTypes", ".", "put", "(", "jobName", ",", "jobType", ...
Allow the given job type to be executed. @param jobName the job name as seen @param jobType the job type to allow
[ "Allow", "the", "given", "job", "type", "to", "be", "executed", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java#L65-L68
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java
MapBasedJobFactory.removeJobType
public void removeJobType(final Class<?> jobType) { if (jobType == null) { throw new IllegalArgumentException("jobType must not be null"); } this.jobTypes.values().remove(jobType); }
java
public void removeJobType(final Class<?> jobType) { if (jobType == null) { throw new IllegalArgumentException("jobType must not be null"); } this.jobTypes.values().remove(jobType); }
[ "public", "void", "removeJobType", "(", "final", "Class", "<", "?", ">", "jobType", ")", "{", "if", "(", "jobType", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"jobType must not be null\"", ")", ";", "}", "this", ".", "jobTypes...
Disallow the job type from being executed. @param jobType the job type to disallow
[ "Disallow", "the", "job", "type", "from", "being", "executed", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java#L74-L79
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java
MapBasedJobFactory.setJobTypes
public void setJobTypes(final Map<String, ? extends Class<?>> jobTypes) { checkJobTypes(jobTypes); this.jobTypes.clear(); this.jobTypes.putAll(jobTypes); }
java
public void setJobTypes(final Map<String, ? extends Class<?>> jobTypes) { checkJobTypes(jobTypes); this.jobTypes.clear(); this.jobTypes.putAll(jobTypes); }
[ "public", "void", "setJobTypes", "(", "final", "Map", "<", "String", ",", "?", "extends", "Class", "<", "?", ">", ">", "jobTypes", ")", "{", "checkJobTypes", "(", "jobTypes", ")", ";", "this", ".", "jobTypes", ".", "clear", "(", ")", ";", "this", "."...
Clear any current allowed job types and use the given set. @param jobTypes the job types to allow
[ "Clear", "any", "current", "allowed", "job", "types", "and", "use", "the", "given", "set", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java#L96-L100
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java
MapBasedJobFactory.checkJobTypes
protected void checkJobTypes(final Map<String, ? extends Class<?>> jobTypes) { if (jobTypes == null) { throw new IllegalArgumentException("jobTypes must not be null"); } for (final Entry<String, ? extends Class<?>> entry : jobTypes.entrySet()) { try { checkJobType(entry.getKey(), entry.getValue()); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("jobTypes contained invalid value", iae); } } }
java
protected void checkJobTypes(final Map<String, ? extends Class<?>> jobTypes) { if (jobTypes == null) { throw new IllegalArgumentException("jobTypes must not be null"); } for (final Entry<String, ? extends Class<?>> entry : jobTypes.entrySet()) { try { checkJobType(entry.getKey(), entry.getValue()); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("jobTypes contained invalid value", iae); } } }
[ "protected", "void", "checkJobTypes", "(", "final", "Map", "<", "String", ",", "?", "extends", "Class", "<", "?", ">", ">", "jobTypes", ")", "{", "if", "(", "jobTypes", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"jobTypes mu...
Verify the given job types are all valid. @param jobTypes the given job types @throws IllegalArgumentException if any of the job types are invalid @see #checkJobType(String, Class)
[ "Verify", "the", "given", "job", "types", "are", "all", "valid", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java#L109-L120
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java
MapBasedJobFactory.checkJobType
protected void checkJobType(final String jobName, final Class<?> jobType) { if (jobName == null) { throw new IllegalArgumentException("jobName must not be null"); } if (jobType == null) { throw new IllegalArgumentException("jobType must not be null"); } if (!(Runnable.class.isAssignableFrom(jobType)) && !(Callable.class.isAssignableFrom(jobType))) { throw new IllegalArgumentException( "jobType must implement either Runnable or Callable: " + jobType); } }
java
protected void checkJobType(final String jobName, final Class<?> jobType) { if (jobName == null) { throw new IllegalArgumentException("jobName must not be null"); } if (jobType == null) { throw new IllegalArgumentException("jobType must not be null"); } if (!(Runnable.class.isAssignableFrom(jobType)) && !(Callable.class.isAssignableFrom(jobType))) { throw new IllegalArgumentException( "jobType must implement either Runnable or Callable: " + jobType); } }
[ "protected", "void", "checkJobType", "(", "final", "String", "jobName", ",", "final", "Class", "<", "?", ">", "jobType", ")", "{", "if", "(", "jobName", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"jobName must not be null\"", ")...
Determine if a job name and job type are valid. @param jobName the name of the job @param jobType the class of the job @throws IllegalArgumentException if the name or type are invalid
[ "Determine", "if", "a", "job", "name", "and", "job", "type", "are", "valid", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/MapBasedJobFactory.java#L128-L140
train
gresrun/jesque
src/main/java/net/greghaines/jesque/admin/AbstractAdminClient.java
AbstractAdminClient.doPublish
public static void doPublish(final Jedis jedis, final String namespace, final String channel, final String jobJson) { jedis.publish(JesqueUtils.createKey(namespace, CHANNEL, channel), jobJson); }
java
public static void doPublish(final Jedis jedis, final String namespace, final String channel, final String jobJson) { jedis.publish(JesqueUtils.createKey(namespace, CHANNEL, channel), jobJson); }
[ "public", "static", "void", "doPublish", "(", "final", "Jedis", "jedis", ",", "final", "String", "namespace", ",", "final", "String", "channel", ",", "final", "String", "jobJson", ")", "{", "jedis", ".", "publish", "(", "JesqueUtils", ".", "createKey", "(", ...
Helper method that encapsulates the minimum logic for publishing a job to a channel. @param jedis the connection to Redis @param namespace the Resque namespace @param channel the channel name @param jobJson the job serialized as JSON
[ "Helper", "method", "that", "encapsulates", "the", "minimum", "logic", "for", "publishing", "a", "job", "to", "a", "channel", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/admin/AbstractAdminClient.java#L133-L135
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java
ReflectionUtils.createObject
public static <T> T createObject(final Class<T> clazz, final Object... args) throws NoSuchConstructorException, AmbiguousConstructorException, ReflectiveOperationException { return findConstructor(clazz, args).newInstance(args); }
java
public static <T> T createObject(final Class<T> clazz, final Object... args) throws NoSuchConstructorException, AmbiguousConstructorException, ReflectiveOperationException { return findConstructor(clazz, args).newInstance(args); }
[ "public", "static", "<", "T", ">", "T", "createObject", "(", "final", "Class", "<", "T", ">", "clazz", ",", "final", "Object", "...", "args", ")", "throws", "NoSuchConstructorException", ",", "AmbiguousConstructorException", ",", "ReflectiveOperationException", "{...
Create an object of the given type using a constructor that matches the supplied arguments. @param <T> the object type @param clazz the type to create @param args the arguments to the constructor @return a new object of the given type, initialized with the given arguments @throws NoSuchConstructorException if there is not a constructor that matches the given arguments @throws AmbiguousConstructorException if there is more than one constructor that matches the given arguments @throws ReflectiveOperationException if any of the reflective operations throw an exception
[ "Create", "an", "object", "of", "the", "given", "type", "using", "a", "constructor", "that", "matches", "the", "supplied", "arguments", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java#L118-L121
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java
ReflectionUtils.createObject
public static <T> T createObject(final Class<T> clazz, final Object[] args, final Map<String,Object> vars) throws NoSuchConstructorException, AmbiguousConstructorException, ReflectiveOperationException { return invokeSetters(findConstructor(clazz, args).newInstance(args), vars); }
java
public static <T> T createObject(final Class<T> clazz, final Object[] args, final Map<String,Object> vars) throws NoSuchConstructorException, AmbiguousConstructorException, ReflectiveOperationException { return invokeSetters(findConstructor(clazz, args).newInstance(args), vars); }
[ "public", "static", "<", "T", ">", "T", "createObject", "(", "final", "Class", "<", "T", ">", "clazz", ",", "final", "Object", "[", "]", "args", ",", "final", "Map", "<", "String", ",", "Object", ">", "vars", ")", "throws", "NoSuchConstructorException", ...
Create an object of the given type using a constructor that matches the supplied arguments and invoke the setters with the supplied variables. @param <T> the object type @param clazz the type to create @param args the arguments to the constructor @param vars the named arguments for setters @return a new object of the given type, initialized with the given arguments @throws NoSuchConstructorException if there is not a constructor that matches the given arguments @throws AmbiguousConstructorException if there is more than one constructor that matches the given arguments @throws ReflectiveOperationException if any of the reflective operations throw an exception
[ "Create", "an", "object", "of", "the", "given", "type", "using", "a", "constructor", "that", "matches", "the", "supplied", "arguments", "and", "invoke", "the", "setters", "with", "the", "supplied", "variables", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java#L145-L148
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java
ReflectionUtils.findConstructor
@SuppressWarnings("rawtypes") private static <T> Constructor<T> findConstructor(final Class<T> clazz, final Object... args) throws NoSuchConstructorException, AmbiguousConstructorException { final Object[] cArgs = (args == null) ? new Object[0] : args; Constructor<T> constructorToUse = null; final Constructor<?>[] candidates = clazz.getConstructors(); Arrays.sort(candidates, ConstructorComparator.INSTANCE); int minTypeDiffWeight = Integer.MAX_VALUE; Set<Constructor<?>> ambiguousConstructors = null; for (final Constructor candidate : candidates) { final Class[] paramTypes = candidate.getParameterTypes(); if (constructorToUse != null && cArgs.length > paramTypes.length) { // Already found greedy constructor that can be satisfied. // Do not look any further, there are only less greedy // constructors left. break; } if (paramTypes.length != cArgs.length) { continue; } final int typeDiffWeight = getTypeDifferenceWeight(paramTypes, cArgs); if (typeDiffWeight < minTypeDiffWeight) { // Choose this constructor if it represents the closest match. constructorToUse = candidate; minTypeDiffWeight = typeDiffWeight; ambiguousConstructors = null; } else if (constructorToUse != null && typeDiffWeight == minTypeDiffWeight) { if (ambiguousConstructors == null) { ambiguousConstructors = new LinkedHashSet<Constructor<?>>(); ambiguousConstructors.add(constructorToUse); } ambiguousConstructors.add(candidate); } } if (ambiguousConstructors != null && !ambiguousConstructors.isEmpty()) { throw new AmbiguousConstructorException(clazz, cArgs, ambiguousConstructors); } if (constructorToUse == null) { throw new NoSuchConstructorException(clazz, cArgs); } return constructorToUse; }
java
@SuppressWarnings("rawtypes") private static <T> Constructor<T> findConstructor(final Class<T> clazz, final Object... args) throws NoSuchConstructorException, AmbiguousConstructorException { final Object[] cArgs = (args == null) ? new Object[0] : args; Constructor<T> constructorToUse = null; final Constructor<?>[] candidates = clazz.getConstructors(); Arrays.sort(candidates, ConstructorComparator.INSTANCE); int minTypeDiffWeight = Integer.MAX_VALUE; Set<Constructor<?>> ambiguousConstructors = null; for (final Constructor candidate : candidates) { final Class[] paramTypes = candidate.getParameterTypes(); if (constructorToUse != null && cArgs.length > paramTypes.length) { // Already found greedy constructor that can be satisfied. // Do not look any further, there are only less greedy // constructors left. break; } if (paramTypes.length != cArgs.length) { continue; } final int typeDiffWeight = getTypeDifferenceWeight(paramTypes, cArgs); if (typeDiffWeight < minTypeDiffWeight) { // Choose this constructor if it represents the closest match. constructorToUse = candidate; minTypeDiffWeight = typeDiffWeight; ambiguousConstructors = null; } else if (constructorToUse != null && typeDiffWeight == minTypeDiffWeight) { if (ambiguousConstructors == null) { ambiguousConstructors = new LinkedHashSet<Constructor<?>>(); ambiguousConstructors.add(constructorToUse); } ambiguousConstructors.add(candidate); } } if (ambiguousConstructors != null && !ambiguousConstructors.isEmpty()) { throw new AmbiguousConstructorException(clazz, cArgs, ambiguousConstructors); } if (constructorToUse == null) { throw new NoSuchConstructorException(clazz, cArgs); } return constructorToUse; }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "private", "static", "<", "T", ">", "Constructor", "<", "T", ">", "findConstructor", "(", "final", "Class", "<", "T", ">", "clazz", ",", "final", "Object", "...", "args", ")", "throws", "NoSuchConstructorExc...
Find a Constructor on the given type that matches the given arguments. @param <T> the object type @param clazz the type to create @param args the arguments to the constructor @return a Constructor from the given type that matches the given arguments @throws NoSuchConstructorException if there is not a constructor that matches the given arguments @throws AmbiguousConstructorException if there is more than one constructor that matches the given arguments
[ "Find", "a", "Constructor", "on", "the", "given", "type", "that", "matches", "the", "given", "arguments", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java#L167-L208
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java
ReflectionUtils.invokeSetters
public static <T> T invokeSetters(final T instance, final Map<String,Object> vars) throws ReflectiveOperationException { if (instance != null && vars != null) { final Class<?> clazz = instance.getClass(); final Method[] methods = clazz.getMethods(); for (final Entry<String,Object> entry : vars.entrySet()) { final String methodName = "set" + entry.getKey().substring(0, 1).toUpperCase(Locale.US) + entry.getKey().substring(1); boolean found = false; for (final Method method : methods) { if (methodName.equals(method.getName()) && method.getParameterTypes().length == 1) { method.invoke(instance, entry.getValue()); found = true; break; } } if (!found) { throw new NoSuchMethodException("Expected setter named '" + methodName + "' for var '" + entry.getKey() + "'"); } } } return instance; }
java
public static <T> T invokeSetters(final T instance, final Map<String,Object> vars) throws ReflectiveOperationException { if (instance != null && vars != null) { final Class<?> clazz = instance.getClass(); final Method[] methods = clazz.getMethods(); for (final Entry<String,Object> entry : vars.entrySet()) { final String methodName = "set" + entry.getKey().substring(0, 1).toUpperCase(Locale.US) + entry.getKey().substring(1); boolean found = false; for (final Method method : methods) { if (methodName.equals(method.getName()) && method.getParameterTypes().length == 1) { method.invoke(instance, entry.getValue()); found = true; break; } } if (!found) { throw new NoSuchMethodException("Expected setter named '" + methodName + "' for var '" + entry.getKey() + "'"); } } } return instance; }
[ "public", "static", "<", "T", ">", "T", "invokeSetters", "(", "final", "T", "instance", ",", "final", "Map", "<", "String", ",", "Object", ">", "vars", ")", "throws", "ReflectiveOperationException", "{", "if", "(", "instance", "!=", "null", "&&", "vars", ...
Invoke the setters for the given variables on the given instance. @param <T> the instance type @param instance the instance to inject with the variables @param vars the variables to inject @return the instance @throws ReflectiveOperationException if there was a problem finding or invoking a setter method
[ "Invoke", "the", "setters", "for", "the", "given", "variables", "on", "the", "given", "instance", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/ReflectionUtils.java#L462-L485
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerImpl.java
WorkerImpl.checkQueues
protected static void checkQueues(final Iterable<String> queues) { if (queues == null) { throw new IllegalArgumentException("queues must not be null"); } for (final String queue : queues) { if (queue == null || "".equals(queue)) { throw new IllegalArgumentException("queues' members must not be null: " + queues); } } }
java
protected static void checkQueues(final Iterable<String> queues) { if (queues == null) { throw new IllegalArgumentException("queues must not be null"); } for (final String queue : queues) { if (queue == null || "".equals(queue)) { throw new IllegalArgumentException("queues' members must not be null: " + queues); } } }
[ "protected", "static", "void", "checkQueues", "(", "final", "Iterable", "<", "String", ">", "queues", ")", "{", "if", "(", "queues", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"queues must not be null\"", ")", ";", "}", "for", ...
Verify that the given queues are all valid. @param queues the given queues
[ "Verify", "that", "the", "given", "queues", "are", "all", "valid", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java#L101-L110
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerImpl.java
WorkerImpl.failMsg
protected String failMsg(final Throwable thrwbl, final String queue, final Job job) throws IOException { final JobFailure failure = new JobFailure(); failure.setFailedAt(new Date()); failure.setWorker(this.name); failure.setQueue(queue); failure.setPayload(job); failure.setThrowable(thrwbl); return ObjectMapperFactory.get().writeValueAsString(failure); }
java
protected String failMsg(final Throwable thrwbl, final String queue, final Job job) throws IOException { final JobFailure failure = new JobFailure(); failure.setFailedAt(new Date()); failure.setWorker(this.name); failure.setQueue(queue); failure.setPayload(job); failure.setThrowable(thrwbl); return ObjectMapperFactory.get().writeValueAsString(failure); }
[ "protected", "String", "failMsg", "(", "final", "Throwable", "thrwbl", ",", "final", "String", "queue", ",", "final", "Job", "job", ")", "throws", "IOException", "{", "final", "JobFailure", "failure", "=", "new", "JobFailure", "(", ")", ";", "failure", ".", ...
Create and serialize a JobFailure. @param thrwbl the Throwable that occurred @param queue the queue the job came from @param job the Job that failed @return the JSON representation of a new JobFailure @throws IOException if there was an error serializing the JobFailure
[ "Create", "and", "serialize", "a", "JobFailure", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java#L722-L730
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerImpl.java
WorkerImpl.statusMsg
protected String statusMsg(final String queue, final Job job) throws IOException { final WorkerStatus status = new WorkerStatus(); status.setRunAt(new Date()); status.setQueue(queue); status.setPayload(job); return ObjectMapperFactory.get().writeValueAsString(status); }
java
protected String statusMsg(final String queue, final Job job) throws IOException { final WorkerStatus status = new WorkerStatus(); status.setRunAt(new Date()); status.setQueue(queue); status.setPayload(job); return ObjectMapperFactory.get().writeValueAsString(status); }
[ "protected", "String", "statusMsg", "(", "final", "String", "queue", ",", "final", "Job", "job", ")", "throws", "IOException", "{", "final", "WorkerStatus", "status", "=", "new", "WorkerStatus", "(", ")", ";", "status", ".", "setRunAt", "(", "new", "Date", ...
Create and serialize a WorkerStatus. @param queue the queue the Job came from @param job the Job currently being processed @return the JSON representation of a new WorkerStatus @throws IOException if there was an error serializing the WorkerStatus
[ "Create", "and", "serialize", "a", "WorkerStatus", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java#L740-L746
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerImpl.java
WorkerImpl.pauseMsg
protected String pauseMsg() throws IOException { final WorkerStatus status = new WorkerStatus(); status.setRunAt(new Date()); status.setPaused(isPaused()); return ObjectMapperFactory.get().writeValueAsString(status); }
java
protected String pauseMsg() throws IOException { final WorkerStatus status = new WorkerStatus(); status.setRunAt(new Date()); status.setPaused(isPaused()); return ObjectMapperFactory.get().writeValueAsString(status); }
[ "protected", "String", "pauseMsg", "(", ")", "throws", "IOException", "{", "final", "WorkerStatus", "status", "=", "new", "WorkerStatus", "(", ")", ";", "status", ".", "setRunAt", "(", "new", "Date", "(", ")", ")", ";", "status", ".", "setPaused", "(", "...
Create and serialize a WorkerStatus for a pause event. @return the JSON representation of a new WorkerStatus @throws IOException if there was an error serializing the WorkerStatus
[ "Create", "and", "serialize", "a", "WorkerStatus", "for", "a", "pause", "event", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java#L754-L759
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerImpl.java
WorkerImpl.createName
protected String createName() { final StringBuilder buf = new StringBuilder(128); try { buf.append(InetAddress.getLocalHost().getHostName()).append(COLON) .append(ManagementFactory.getRuntimeMXBean().getName().split("@")[0]) // PID .append('-').append(this.workerId).append(COLON).append(JAVA_DYNAMIC_QUEUES); for (final String queueName : this.queueNames) { buf.append(',').append(queueName); } } catch (UnknownHostException uhe) { throw new RuntimeException(uhe); } return buf.toString(); }
java
protected String createName() { final StringBuilder buf = new StringBuilder(128); try { buf.append(InetAddress.getLocalHost().getHostName()).append(COLON) .append(ManagementFactory.getRuntimeMXBean().getName().split("@")[0]) // PID .append('-').append(this.workerId).append(COLON).append(JAVA_DYNAMIC_QUEUES); for (final String queueName : this.queueNames) { buf.append(',').append(queueName); } } catch (UnknownHostException uhe) { throw new RuntimeException(uhe); } return buf.toString(); }
[ "protected", "String", "createName", "(", ")", "{", "final", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "128", ")", ";", "try", "{", "buf", ".", "append", "(", "InetAddress", ".", "getLocalHost", "(", ")", ".", "getHostName", "(", ")", ")"...
Creates a unique name, suitable for use with Resque. @return a unique name for this worker
[ "Creates", "a", "unique", "name", "suitable", "for", "use", "with", "Resque", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerImpl.java#L766-L779
train
gresrun/jesque
src/main/java/net/greghaines/jesque/worker/WorkerPool.java
WorkerPool.join
@Override public void join(final long millis) throws InterruptedException { for (final Thread thread : this.threads) { thread.join(millis); } }
java
@Override public void join(final long millis) throws InterruptedException { for (final Thread thread : this.threads) { thread.join(millis); } }
[ "@", "Override", "public", "void", "join", "(", "final", "long", "millis", ")", "throws", "InterruptedException", "{", "for", "(", "final", "Thread", "thread", ":", "this", ".", "threads", ")", "{", "thread", ".", "join", "(", "millis", ")", ";", "}", ...
Join to internal threads and wait millis time per thread or until all threads are finished if millis is 0. @param millis the time to wait in milliseconds for the threads to join; a timeout of 0 means to wait forever. @throws InterruptedException if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
[ "Join", "to", "internal", "threads", "and", "wait", "millis", "time", "per", "thread", "or", "until", "all", "threads", "are", "finished", "if", "millis", "is", "0", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/worker/WorkerPool.java#L114-L119
train
gresrun/jesque
src/main/java/net/greghaines/jesque/admin/AdminImpl.java
AdminImpl.checkChannels
protected static void checkChannels(final Iterable<String> channels) { if (channels == null) { throw new IllegalArgumentException("channels must not be null"); } for (final String channel : channels) { if (channel == null || "".equals(channel)) { throw new IllegalArgumentException("channels' members must not be null: " + channels); } } }
java
protected static void checkChannels(final Iterable<String> channels) { if (channels == null) { throw new IllegalArgumentException("channels must not be null"); } for (final String channel : channels) { if (channel == null || "".equals(channel)) { throw new IllegalArgumentException("channels' members must not be null: " + channels); } } }
[ "protected", "static", "void", "checkChannels", "(", "final", "Iterable", "<", "String", ">", "channels", ")", "{", "if", "(", "channels", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"channels must not be null\"", ")", ";", "}", ...
Verify that the given channels are all valid. @param channels the given channels
[ "Verify", "that", "the", "given", "channels", "are", "all", "valid", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/admin/AdminImpl.java#L395-L404
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/PoolUtils.java
PoolUtils.doWorkInPool
public static <V> V doWorkInPool(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) throws Exception { if (pool == null) { throw new IllegalArgumentException("pool must not be null"); } if (work == null) { throw new IllegalArgumentException("work must not be null"); } final V result; final Jedis poolResource = pool.getResource(); try { result = work.doWork(poolResource); } finally { poolResource.close(); } return result; }
java
public static <V> V doWorkInPool(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) throws Exception { if (pool == null) { throw new IllegalArgumentException("pool must not be null"); } if (work == null) { throw new IllegalArgumentException("work must not be null"); } final V result; final Jedis poolResource = pool.getResource(); try { result = work.doWork(poolResource); } finally { poolResource.close(); } return result; }
[ "public", "static", "<", "V", ">", "V", "doWorkInPool", "(", "final", "Pool", "<", "Jedis", ">", "pool", ",", "final", "PoolWork", "<", "Jedis", ",", "V", ">", "work", ")", "throws", "Exception", "{", "if", "(", "pool", "==", "null", ")", "{", "thr...
Perform the given work with a Jedis connection from the given pool. @param pool the resource pool @param work the work to perform @param <V> the result type @return the result of the given work @throws Exception if something went wrong
[ "Perform", "the", "given", "work", "with", "a", "Jedis", "connection", "from", "the", "given", "pool", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/PoolUtils.java#L42-L57
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/PoolUtils.java
PoolUtils.doWorkInPoolNicely
public static <V> V doWorkInPoolNicely(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) { final V result; try { result = doWorkInPool(pool, work); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } return result; }
java
public static <V> V doWorkInPoolNicely(final Pool<Jedis> pool, final PoolWork<Jedis, V> work) { final V result; try { result = doWorkInPool(pool, work); } catch (RuntimeException re) { throw re; } catch (Exception e) { throw new RuntimeException(e); } return result; }
[ "public", "static", "<", "V", ">", "V", "doWorkInPoolNicely", "(", "final", "Pool", "<", "Jedis", ">", "pool", ",", "final", "PoolWork", "<", "Jedis", ",", "V", ">", "work", ")", "{", "final", "V", "result", ";", "try", "{", "result", "=", "doWorkInP...
Perform the given work with a Jedis connection from the given pool. Wraps any thrown checked exceptions in a RuntimeException. @param pool the resource pool @param work the work to perform @param <V> the result type @return the result of the given work
[ "Perform", "the", "given", "work", "with", "a", "Jedis", "connection", "from", "the", "given", "pool", ".", "Wraps", "any", "thrown", "checked", "exceptions", "in", "a", "RuntimeException", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/PoolUtils.java#L68-L78
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/PoolUtils.java
PoolUtils.createJedisPool
public static Pool<Jedis> createJedisPool(final Config jesqueConfig, final GenericObjectPoolConfig poolConfig) { if (jesqueConfig == null) { throw new IllegalArgumentException("jesqueConfig must not be null"); } if (poolConfig == null) { throw new IllegalArgumentException("poolConfig must not be null"); } if (jesqueConfig.getMasterName() != null && !"".equals(jesqueConfig.getMasterName()) && jesqueConfig.getSentinels() != null && jesqueConfig.getSentinels().size() > 0) { return new JedisSentinelPool(jesqueConfig.getMasterName(), jesqueConfig.getSentinels(), poolConfig, jesqueConfig.getTimeout(), jesqueConfig.getPassword(), jesqueConfig.getDatabase()); } else { return new JedisPool(poolConfig, jesqueConfig.getHost(), jesqueConfig.getPort(), jesqueConfig.getTimeout(), jesqueConfig.getPassword(), jesqueConfig.getDatabase()); } }
java
public static Pool<Jedis> createJedisPool(final Config jesqueConfig, final GenericObjectPoolConfig poolConfig) { if (jesqueConfig == null) { throw new IllegalArgumentException("jesqueConfig must not be null"); } if (poolConfig == null) { throw new IllegalArgumentException("poolConfig must not be null"); } if (jesqueConfig.getMasterName() != null && !"".equals(jesqueConfig.getMasterName()) && jesqueConfig.getSentinels() != null && jesqueConfig.getSentinels().size() > 0) { return new JedisSentinelPool(jesqueConfig.getMasterName(), jesqueConfig.getSentinels(), poolConfig, jesqueConfig.getTimeout(), jesqueConfig.getPassword(), jesqueConfig.getDatabase()); } else { return new JedisPool(poolConfig, jesqueConfig.getHost(), jesqueConfig.getPort(), jesqueConfig.getTimeout(), jesqueConfig.getPassword(), jesqueConfig.getDatabase()); } }
[ "public", "static", "Pool", "<", "Jedis", ">", "createJedisPool", "(", "final", "Config", "jesqueConfig", ",", "final", "GenericObjectPoolConfig", "poolConfig", ")", "{", "if", "(", "jesqueConfig", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException"...
A simple helper method that creates a pool of connections to Redis using the supplied configurations. @param jesqueConfig the config used to create the pooled Jedis connections @param poolConfig the config used to create the pool @return a configured Pool of Jedis connections
[ "A", "simple", "helper", "method", "that", "creates", "a", "pool", "of", "connections", "to", "Redis", "using", "the", "supplied", "configurations", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/PoolUtils.java#L114-L129
train
gresrun/jesque
src/main/java/net/greghaines/jesque/client/AbstractClient.java
AbstractClient.doEnqueue
public static void doEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson) { jedis.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); jedis.rpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); }
java
public static void doEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson) { jedis.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); jedis.rpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); }
[ "public", "static", "void", "doEnqueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "namespace", ",", "final", "String", "queue", ",", "final", "String", "jobJson", ")", "{", "jedis", ".", "sadd", "(", "JesqueUtils", ".", "createKey", "(", "na...
Helper method that encapsulates the minimum logic for adding a job to a queue. @param jedis the connection to Redis @param namespace the Resque namespace @param queue the Resque queue name @param jobJson the job serialized as JSON
[ "Helper", "method", "that", "encapsulates", "the", "minimum", "logic", "for", "adding", "a", "job", "to", "a", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/client/AbstractClient.java#L217-L220
train
gresrun/jesque
src/main/java/net/greghaines/jesque/client/AbstractClient.java
AbstractClient.doBatchEnqueue
public static void doBatchEnqueue(final Jedis jedis, final String namespace, final String queue, final List<String> jobJsons) { Pipeline pipelined = jedis.pipelined(); pipelined.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); for (String jobJson : jobJsons) { pipelined.rpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); } pipelined.sync(); }
java
public static void doBatchEnqueue(final Jedis jedis, final String namespace, final String queue, final List<String> jobJsons) { Pipeline pipelined = jedis.pipelined(); pipelined.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); for (String jobJson : jobJsons) { pipelined.rpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); } pipelined.sync(); }
[ "public", "static", "void", "doBatchEnqueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "namespace", ",", "final", "String", "queue", ",", "final", "List", "<", "String", ">", "jobJsons", ")", "{", "Pipeline", "pipelined", "=", "jedis", ".", ...
Helper method that encapsulates the minimum logic for adding jobs to a queue. @param jedis the connection to Redis @param namespace the Resque namespace @param queue the Resque queue name @param jobJsons a list of jobs serialized as JSON
[ "Helper", "method", "that", "encapsulates", "the", "minimum", "logic", "for", "adding", "jobs", "to", "a", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/client/AbstractClient.java#L234-L241
train
gresrun/jesque
src/main/java/net/greghaines/jesque/client/AbstractClient.java
AbstractClient.doPriorityEnqueue
public static void doPriorityEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson) { jedis.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); jedis.lpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); }
java
public static void doPriorityEnqueue(final Jedis jedis, final String namespace, final String queue, final String jobJson) { jedis.sadd(JesqueUtils.createKey(namespace, QUEUES), queue); jedis.lpush(JesqueUtils.createKey(namespace, QUEUE, queue), jobJson); }
[ "public", "static", "void", "doPriorityEnqueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "namespace", ",", "final", "String", "queue", ",", "final", "String", "jobJson", ")", "{", "jedis", ".", "sadd", "(", "JesqueUtils", ".", "createKey", "(...
Helper method that encapsulates the minimum logic for adding a high priority job to a queue. @param jedis the connection to Redis @param namespace the Resque namespace @param queue the Resque queue name @param jobJson the job serialized as JSON
[ "Helper", "method", "that", "encapsulates", "the", "minimum", "logic", "for", "adding", "a", "high", "priority", "job", "to", "a", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/client/AbstractClient.java#L256-L259
train
gresrun/jesque
src/main/java/net/greghaines/jesque/client/AbstractClient.java
AbstractClient.doAcquireLock
public static boolean doAcquireLock(final Jedis jedis, final String namespace, final String lockName, final String lockHolder, final int timeout) { final String key = JesqueUtils.createKey(namespace, lockName); // If lock already exists, extend it String existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { if (jedis.expire(key, timeout) == 1) { existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } } // Check to see if the key exists and is expired for cleanup purposes if (jedis.exists(key) && (jedis.ttl(key) < 0)) { // It is expired, but it may be in the process of being created, so // sleep and check again try { Thread.sleep(2000); } catch (InterruptedException ie) { } // Ignore interruptions if (jedis.ttl(key) < 0) { existingLockHolder = jedis.get(key); // If it is our lock mark the time to live if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { if (jedis.expire(key, timeout) == 1) { existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } } else { // The key is expired, whack it! jedis.del(key); } } else { // Someone else locked it while we were sleeping return false; } } // Ignore the cleanup steps above, start with no assumptions test // creating the key if (jedis.setnx(key, lockHolder) == 1) { // Created the lock, now set the expiration if (jedis.expire(key, timeout) == 1) { // Set the timeout existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } else { // Don't know why it failed, but for now just report failed // acquisition return false; } } // Failed to create the lock return false; }
java
public static boolean doAcquireLock(final Jedis jedis, final String namespace, final String lockName, final String lockHolder, final int timeout) { final String key = JesqueUtils.createKey(namespace, lockName); // If lock already exists, extend it String existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { if (jedis.expire(key, timeout) == 1) { existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } } // Check to see if the key exists and is expired for cleanup purposes if (jedis.exists(key) && (jedis.ttl(key) < 0)) { // It is expired, but it may be in the process of being created, so // sleep and check again try { Thread.sleep(2000); } catch (InterruptedException ie) { } // Ignore interruptions if (jedis.ttl(key) < 0) { existingLockHolder = jedis.get(key); // If it is our lock mark the time to live if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { if (jedis.expire(key, timeout) == 1) { existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } } else { // The key is expired, whack it! jedis.del(key); } } else { // Someone else locked it while we were sleeping return false; } } // Ignore the cleanup steps above, start with no assumptions test // creating the key if (jedis.setnx(key, lockHolder) == 1) { // Created the lock, now set the expiration if (jedis.expire(key, timeout) == 1) { // Set the timeout existingLockHolder = jedis.get(key); if ((existingLockHolder != null) && existingLockHolder.equals(lockHolder)) { return true; } } else { // Don't know why it failed, but for now just report failed // acquisition return false; } } // Failed to create the lock return false; }
[ "public", "static", "boolean", "doAcquireLock", "(", "final", "Jedis", "jedis", ",", "final", "String", "namespace", ",", "final", "String", "lockName", ",", "final", "String", "lockHolder", ",", "final", "int", "timeout", ")", "{", "final", "String", "key", ...
Helper method that encapsulates the logic to acquire a lock. @param jedis the connection to Redis @param namespace the Resque namespace @param lockName all calls to this method will contend for a unique lock with the name of lockName @param timeout seconds until the lock will expire @param lockHolder a unique string used to tell if you are the current holder of a lock for both acquisition, and extension @return Whether or not the lock was acquired.
[ "Helper", "method", "that", "encapsulates", "the", "logic", "to", "acquire", "a", "lock", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/client/AbstractClient.java#L278-L331
train
gresrun/jesque
src/main/java/net/greghaines/jesque/ConfigBuilder.java
ConfigBuilder.withHost
public ConfigBuilder withHost(final String host) { if (host == null || "".equals(host)) { throw new IllegalArgumentException("host must not be null or empty: " + host); } this.host = host; return this; }
java
public ConfigBuilder withHost(final String host) { if (host == null || "".equals(host)) { throw new IllegalArgumentException("host must not be null or empty: " + host); } this.host = host; return this; }
[ "public", "ConfigBuilder", "withHost", "(", "final", "String", "host", ")", "{", "if", "(", "host", "==", "null", "||", "\"\"", ".", "equals", "(", "host", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"host must not be null or empty: \"", ...
Configs created by this ConfigBuilder will have the given Redis hostname. @param host the Redis hostname @return this ConfigBuilder
[ "Configs", "created", "by", "this", "ConfigBuilder", "will", "have", "the", "given", "Redis", "hostname", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/ConfigBuilder.java#L97-L103
train
gresrun/jesque
src/main/java/net/greghaines/jesque/ConfigBuilder.java
ConfigBuilder.withSentinels
public ConfigBuilder withSentinels(final Set<String> sentinels) { if (sentinels == null || sentinels.size() < 1) { throw new IllegalArgumentException("sentinels is null or empty: " + sentinels); } this.sentinels = sentinels; return this; }
java
public ConfigBuilder withSentinels(final Set<String> sentinels) { if (sentinels == null || sentinels.size() < 1) { throw new IllegalArgumentException("sentinels is null or empty: " + sentinels); } this.sentinels = sentinels; return this; }
[ "public", "ConfigBuilder", "withSentinels", "(", "final", "Set", "<", "String", ">", "sentinels", ")", "{", "if", "(", "sentinels", "==", "null", "||", "sentinels", ".", "size", "(", ")", "<", "1", ")", "{", "throw", "new", "IllegalArgumentException", "(",...
Configs created by this ConfigBuilder will use the given Redis sentinels. @param sentinels the Redis set of sentinels @return this ConfigBuilder
[ "Configs", "created", "by", "this", "ConfigBuilder", "will", "use", "the", "given", "Redis", "sentinels", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/ConfigBuilder.java#L182-L188
train
gresrun/jesque
src/main/java/net/greghaines/jesque/ConfigBuilder.java
ConfigBuilder.withMasterName
public ConfigBuilder withMasterName(final String masterName) { if (masterName == null || "".equals(masterName)) { throw new IllegalArgumentException("masterName is null or empty: " + masterName); } this.masterName = masterName; return this; }
java
public ConfigBuilder withMasterName(final String masterName) { if (masterName == null || "".equals(masterName)) { throw new IllegalArgumentException("masterName is null or empty: " + masterName); } this.masterName = masterName; return this; }
[ "public", "ConfigBuilder", "withMasterName", "(", "final", "String", "masterName", ")", "{", "if", "(", "masterName", "==", "null", "||", "\"\"", ".", "equals", "(", "masterName", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"masterName is n...
Configs created by this ConfigBuilder will use the given Redis master name. @param masterName the Redis set of sentinels @return this ConfigBuilder
[ "Configs", "created", "by", "this", "ConfigBuilder", "will", "use", "the", "given", "Redis", "master", "name", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/ConfigBuilder.java#L196-L202
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.ensureJedisConnection
public static boolean ensureJedisConnection(final Jedis jedis) { final boolean jedisOK = testJedisConnection(jedis); if (!jedisOK) { try { jedis.quit(); } catch (Exception e) { } // Ignore try { jedis.disconnect(); } catch (Exception e) { } // Ignore jedis.connect(); } return jedisOK; }
java
public static boolean ensureJedisConnection(final Jedis jedis) { final boolean jedisOK = testJedisConnection(jedis); if (!jedisOK) { try { jedis.quit(); } catch (Exception e) { } // Ignore try { jedis.disconnect(); } catch (Exception e) { } // Ignore jedis.connect(); } return jedisOK; }
[ "public", "static", "boolean", "ensureJedisConnection", "(", "final", "Jedis", "jedis", ")", "{", "final", "boolean", "jedisOK", "=", "testJedisConnection", "(", "jedis", ")", ";", "if", "(", "!", "jedisOK", ")", "{", "try", "{", "jedis", ".", "quit", "(",...
Ensure that the given connection is established. @param jedis a connection to Redis @return true if the supplied connection was already connected
[ "Ensure", "that", "the", "given", "connection", "is", "established", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L47-L61
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.reconnect
public static boolean reconnect(final Jedis jedis, final int reconAttempts, final long reconnectSleepTime) { int i = 1; do { try { jedis.disconnect(); try { Thread.sleep(reconnectSleepTime); } catch (Exception e2) { } jedis.connect(); } catch (JedisConnectionException jce) { } // Ignore bad connection attempts catch (Exception e3) { LOG.error("Unknown Exception while trying to reconnect to Redis", e3); } } while (++i <= reconAttempts && !testJedisConnection(jedis)); return testJedisConnection(jedis); }
java
public static boolean reconnect(final Jedis jedis, final int reconAttempts, final long reconnectSleepTime) { int i = 1; do { try { jedis.disconnect(); try { Thread.sleep(reconnectSleepTime); } catch (Exception e2) { } jedis.connect(); } catch (JedisConnectionException jce) { } // Ignore bad connection attempts catch (Exception e3) { LOG.error("Unknown Exception while trying to reconnect to Redis", e3); } } while (++i <= reconAttempts && !testJedisConnection(jedis)); return testJedisConnection(jedis); }
[ "public", "static", "boolean", "reconnect", "(", "final", "Jedis", "jedis", ",", "final", "int", "reconAttempts", ",", "final", "long", "reconnectSleepTime", ")", "{", "int", "i", "=", "1", ";", "do", "{", "try", "{", "jedis", ".", "disconnect", "(", ")"...
Attempt to reconnect to Redis. @param jedis the connection to Redis @param reconAttempts number of times to attempt to reconnect before giving up @param reconnectSleepTime time in milliseconds to wait between attempts @return true if reconnection was successful
[ "Attempt", "to", "reconnect", "to", "Redis", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L91-L108
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.isRegularQueue
public static boolean isRegularQueue(final Jedis jedis, final String key) { return LIST.equalsIgnoreCase(jedis.type(key)); }
java
public static boolean isRegularQueue(final Jedis jedis, final String key) { return LIST.equalsIgnoreCase(jedis.type(key)); }
[ "public", "static", "boolean", "isRegularQueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "key", ")", "{", "return", "LIST", ".", "equalsIgnoreCase", "(", "jedis", ".", "type", "(", "key", ")", ")", ";", "}" ]
Determines if the queue identified by the given key is a regular queue. @param jedis connection to Redis @param key the key that identifies a queue @return true if the key identifies a regular queue, false otherwise
[ "Determines", "if", "the", "queue", "identified", "by", "the", "given", "key", "is", "a", "regular", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L119-L121
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.isDelayedQueue
public static boolean isDelayedQueue(final Jedis jedis, final String key) { return ZSET.equalsIgnoreCase(jedis.type(key)); }
java
public static boolean isDelayedQueue(final Jedis jedis, final String key) { return ZSET.equalsIgnoreCase(jedis.type(key)); }
[ "public", "static", "boolean", "isDelayedQueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "key", ")", "{", "return", "ZSET", ".", "equalsIgnoreCase", "(", "jedis", ".", "type", "(", "key", ")", ")", ";", "}" ]
Determines if the queue identified by the given key is a delayed queue. @param jedis connection to Redis @param key the key that identifies a queue @return true if the key identifies a delayed queue, false otherwise
[ "Determines", "if", "the", "queue", "identified", "by", "the", "given", "key", "is", "a", "delayed", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L132-L134
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.isKeyUsed
public static boolean isKeyUsed(final Jedis jedis, final String key) { return !NONE.equalsIgnoreCase(jedis.type(key)); }
java
public static boolean isKeyUsed(final Jedis jedis, final String key) { return !NONE.equalsIgnoreCase(jedis.type(key)); }
[ "public", "static", "boolean", "isKeyUsed", "(", "final", "Jedis", "jedis", ",", "final", "String", "key", ")", "{", "return", "!", "NONE", ".", "equalsIgnoreCase", "(", "jedis", ".", "type", "(", "key", ")", ")", ";", "}" ]
Determines if the queue identified by the given key is used. @param jedis connection to Redis @param key the key that identifies a queue @return true if the key is used, false otherwise
[ "Determines", "if", "the", "queue", "identified", "by", "the", "given", "key", "is", "used", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L150-L152
train
gresrun/jesque
src/main/java/net/greghaines/jesque/utils/JedisUtils.java
JedisUtils.canUseAsDelayedQueue
public static boolean canUseAsDelayedQueue(final Jedis jedis, final String key) { final String type = jedis.type(key); return (ZSET.equalsIgnoreCase(type) || NONE.equalsIgnoreCase(type)); }
java
public static boolean canUseAsDelayedQueue(final Jedis jedis, final String key) { final String type = jedis.type(key); return (ZSET.equalsIgnoreCase(type) || NONE.equalsIgnoreCase(type)); }
[ "public", "static", "boolean", "canUseAsDelayedQueue", "(", "final", "Jedis", "jedis", ",", "final", "String", "key", ")", "{", "final", "String", "type", "=", "jedis", ".", "type", "(", "key", ")", ";", "return", "(", "ZSET", ".", "equalsIgnoreCase", "(",...
Determines if the queue identified by the given key can be used as a delayed queue. @param jedis connection to Redis @param key the key that identifies a queue @return true if the key already is a delayed queue or is not currently used, false otherwise
[ "Determines", "if", "the", "queue", "identified", "by", "the", "given", "key", "can", "be", "used", "as", "a", "delayed", "queue", "." ]
44749183dccc40962a94c2af547ea7d0d880b5d1
https://github.com/gresrun/jesque/blob/44749183dccc40962a94c2af547ea7d0d880b5d1/src/main/java/net/greghaines/jesque/utils/JedisUtils.java#L163-L166
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java
SessionManager.createNamespace
public void createNamespace() { Map<String, String> namespaceAnnotations = annotationProvider.create(session.getId(), Constants.RUNNING_STATUS); if (namespaceService.exists(session.getNamespace())) { //namespace exists } else if (configuration.isNamespaceLazyCreateEnabled()) { namespaceService.create(session.getNamespace(), namespaceAnnotations); } else { throw new IllegalStateException("Namespace [" + session.getNamespace() + "] doesn't exist and lazily creation of namespaces is disabled. " + "Either use an existing one, or set `namespace.lazy.enabled` to true."); } }
java
public void createNamespace() { Map<String, String> namespaceAnnotations = annotationProvider.create(session.getId(), Constants.RUNNING_STATUS); if (namespaceService.exists(session.getNamespace())) { //namespace exists } else if (configuration.isNamespaceLazyCreateEnabled()) { namespaceService.create(session.getNamespace(), namespaceAnnotations); } else { throw new IllegalStateException("Namespace [" + session.getNamespace() + "] doesn't exist and lazily creation of namespaces is disabled. " + "Either use an existing one, or set `namespace.lazy.enabled` to true."); } }
[ "public", "void", "createNamespace", "(", ")", "{", "Map", "<", "String", ",", "String", ">", "namespaceAnnotations", "=", "annotationProvider", ".", "create", "(", "session", ".", "getId", "(", ")", ",", "Constants", ".", "RUNNING_STATUS", ")", ";", "if", ...
Creates a namespace if needed.
[ "Creates", "a", "namespace", "if", "needed", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/SessionManager.java#L100-L110
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java
KuberntesServiceUrlResourceProvider.getPort
private static int getPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getPort(); } return 0; }
java
private static int getPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getPort(); } return 0; }
[ "private", "static", "int", "getPort", "(", "Service", "service", ",", "Annotation", "...", "qualifiers", ")", "{", "for", "(", "Annotation", "q", ":", "qualifiers", ")", "{", "if", "(", "q", "instanceof", "Port", ")", "{", "Port", "port", "=", "(", "P...
Find the the qualified container port of the target service Uses java annotations first or returns the container port. @param service The target service. @param qualifiers The set of qualifiers. @return Returns the resolved containerPort of '0' as a fallback.
[ "Find", "the", "the", "qualified", "container", "port", "of", "the", "target", "service", "Uses", "java", "annotations", "first", "or", "returns", "the", "container", "port", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L128-L143
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java
KuberntesServiceUrlResourceProvider.getContainerPort
private static int getContainerPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getTargetPort().getIntVal(); } return 0; }
java
private static int getContainerPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getTargetPort().getIntVal(); } return 0; }
[ "private", "static", "int", "getContainerPort", "(", "Service", "service", ",", "Annotation", "...", "qualifiers", ")", "{", "for", "(", "Annotation", "q", ":", "qualifiers", ")", "{", "if", "(", "q", "instanceof", "Port", ")", "{", "Port", "port", "=", ...
Find the the qualfied container port of the target service Uses java annotations first or returns the container port. @param service The target service. @param qualifiers The set of qualifiers. @return Returns the resolved containerPort of '0' as a fallback.
[ "Find", "the", "the", "qualfied", "container", "port", "of", "the", "target", "service", "Uses", "java", "annotations", "first", "or", "returns", "the", "container", "port", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L156-L171
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java
KuberntesServiceUrlResourceProvider.getScheme
private static String getScheme(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_SCHEME; }
java
private static String getScheme(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_SCHEME; }
[ "private", "static", "String", "getScheme", "(", "Service", "service", ",", "Annotation", "...", "qualifiers", ")", "{", "for", "(", "Annotation", "q", ":", "qualifiers", ")", "{", "if", "(", "q", "instanceof", "Scheme", ")", "{", "return", "(", "(", "Sc...
Find the scheme to use to connect to the service. Uses java annotations first and if not found, uses kubernetes annotations on the service object. @param service The target service. @param qualifiers The set of qualifiers. @return Returns the resolved scheme of 'http' as a fallback.
[ "Find", "the", "scheme", "to", "use", "to", "connect", "to", "the", "service", ".", "Uses", "java", "annotations", "first", "and", "if", "not", "found", "uses", "kubernetes", "annotations", "on", "the", "service", "object", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L184-L199
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java
KuberntesServiceUrlResourceProvider.getPath
private static String getPath(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_PATH; }
java
private static String getPath(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Scheme) { return ((Scheme) q).value(); } } if (service.getMetadata() != null && service.getMetadata().getAnnotations() != null) { String s = service.getMetadata().getAnnotations().get(SERVICE_SCHEME); if (s != null && s.isEmpty()) { return s; } } return DEFAULT_PATH; }
[ "private", "static", "String", "getPath", "(", "Service", "service", ",", "Annotation", "...", "qualifiers", ")", "{", "for", "(", "Annotation", "q", ":", "qualifiers", ")", "{", "if", "(", "q", "instanceof", "Scheme", ")", "{", "return", "(", "(", "Sche...
Find the path to use . Uses java annotations first and if not found, uses kubernetes annotations on the service object. @param service The target service. @param qualifiers The set of qualifiers. @return Returns the resolved path of '/' as a fallback.
[ "Find", "the", "path", "to", "use", ".", "Uses", "java", "annotations", "first", "and", "if", "not", "found", "uses", "kubernetes", "annotations", "on", "the", "service", "object", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L212-L226
train
arquillian/arquillian-cube
kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java
KuberntesServiceUrlResourceProvider.getRandomPod
private static Pod getRandomPod(KubernetesClient client, String name, String namespace) { Endpoints endpoints = client.endpoints().inNamespace(namespace).withName(name).get(); List<String> pods = new ArrayList<>(); if (endpoints != null) { for (EndpointSubset subset : endpoints.getSubsets()) { for (EndpointAddress address : subset.getAddresses()) { if (address.getTargetRef() != null && POD.equals(address.getTargetRef().getKind())) { String pod = address.getTargetRef().getName(); if (pod != null && !pod.isEmpty()) { pods.add(pod); } } } } } if (pods.isEmpty()) { return null; } else { String chosen = pods.get(RANDOM.nextInt(pods.size())); return client.pods().inNamespace(namespace).withName(chosen).get(); } }
java
private static Pod getRandomPod(KubernetesClient client, String name, String namespace) { Endpoints endpoints = client.endpoints().inNamespace(namespace).withName(name).get(); List<String> pods = new ArrayList<>(); if (endpoints != null) { for (EndpointSubset subset : endpoints.getSubsets()) { for (EndpointAddress address : subset.getAddresses()) { if (address.getTargetRef() != null && POD.equals(address.getTargetRef().getKind())) { String pod = address.getTargetRef().getName(); if (pod != null && !pod.isEmpty()) { pods.add(pod); } } } } } if (pods.isEmpty()) { return null; } else { String chosen = pods.get(RANDOM.nextInt(pods.size())); return client.pods().inNamespace(namespace).withName(chosen).get(); } }
[ "private", "static", "Pod", "getRandomPod", "(", "KubernetesClient", "client", ",", "String", "name", ",", "String", "namespace", ")", "{", "Endpoints", "endpoints", "=", "client", ".", "endpoints", "(", ")", ".", "inNamespace", "(", "namespace", ")", ".", "...
Get a random pod that provides the specified service in the specified namespace. @param client The client instance to use. @param name The name of the service. @param namespace The namespace of the service. @return The pod or null if no pod matches.
[ "Get", "a", "random", "pod", "that", "provides", "the", "specified", "service", "in", "the", "specified", "namespace", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/enricher/KuberntesServiceUrlResourceProvider.java#L240-L261
train
arquillian/arquillian-cube
core/src/main/java/org/arquillian/cube/impl/util/Which.java
Which.classFileUrl
public static URL classFileUrl(Class<?> clazz) throws IOException { ClassLoader cl = clazz.getClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } URL res = cl.getResource(clazz.getName().replace('.', '/') + ".class"); if (res == null) { throw new IllegalArgumentException("Unable to locate class file for " + clazz); } return res; }
java
public static URL classFileUrl(Class<?> clazz) throws IOException { ClassLoader cl = clazz.getClassLoader(); if (cl == null) { cl = ClassLoader.getSystemClassLoader(); } URL res = cl.getResource(clazz.getName().replace('.', '/') + ".class"); if (res == null) { throw new IllegalArgumentException("Unable to locate class file for " + clazz); } return res; }
[ "public", "static", "URL", "classFileUrl", "(", "Class", "<", "?", ">", "clazz", ")", "throws", "IOException", "{", "ClassLoader", "cl", "=", "clazz", ".", "getClassLoader", "(", ")", ";", "if", "(", "cl", "==", "null", ")", "{", "cl", "=", "ClassLoade...
Returns the URL of the class file where the given class has been loaded from. @throws IllegalArgumentException if failed to determine. @since 2.24
[ "Returns", "the", "URL", "of", "the", "class", "file", "where", "the", "given", "class", "has", "been", "loaded", "from", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Which.java#L56-L66
train
arquillian/arquillian-cube
core/src/main/java/org/arquillian/cube/impl/util/Which.java
Which.decode
private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '%') { baos.write(hexToInt(s.charAt(i + 1)) * 16 + hexToInt(s.charAt(i + 2))); i += 2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }
java
private static String decode(String s) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '%') { baos.write(hexToInt(s.charAt(i + 1)) * 16 + hexToInt(s.charAt(i + 2))); i += 2; continue; } baos.write(ch); } try { return new String(baos.toByteArray(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); // impossible } }
[ "private", "static", "String", "decode", "(", "String", "s", ")", "{", "ByteArrayOutputStream", "baos", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "++",...
Decode '%HH'.
[ "Decode", "%HH", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Which.java#L239-L255
train
arquillian/arquillian-cube
openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/TemplateProcessor.java
TemplateProcessor.processTemplateResources
public List<? super OpenShiftResource> processTemplateResources() { List<? extends OpenShiftResource> resources; final List<? super OpenShiftResource> processedResources = new ArrayList<>(); templates = OpenShiftResourceFactory.getTemplates(getType()); boolean sync_instantiation = OpenShiftResourceFactory.syncInstantiation(getType()); /* Instantiate templates */ for (Template template : templates) { resources = processTemplate(template); if (resources != null) { if (sync_instantiation) { /* synchronous template instantiation */ processedResources.addAll(resources); } else { /* asynchronous template instantiation */ try { delay(openShiftAdapter, resources); } catch (Throwable t) { throw new IllegalArgumentException(asynchronousDelayErrorMessage(), t); } } } } return processedResources; }
java
public List<? super OpenShiftResource> processTemplateResources() { List<? extends OpenShiftResource> resources; final List<? super OpenShiftResource> processedResources = new ArrayList<>(); templates = OpenShiftResourceFactory.getTemplates(getType()); boolean sync_instantiation = OpenShiftResourceFactory.syncInstantiation(getType()); /* Instantiate templates */ for (Template template : templates) { resources = processTemplate(template); if (resources != null) { if (sync_instantiation) { /* synchronous template instantiation */ processedResources.addAll(resources); } else { /* asynchronous template instantiation */ try { delay(openShiftAdapter, resources); } catch (Throwable t) { throw new IllegalArgumentException(asynchronousDelayErrorMessage(), t); } } } } return processedResources; }
[ "public", "List", "<", "?", "super", "OpenShiftResource", ">", "processTemplateResources", "(", ")", "{", "List", "<", "?", "extends", "OpenShiftResource", ">", "resources", ";", "final", "List", "<", "?", "super", "OpenShiftResource", ">", "processedResources", ...
Instantiates the templates specified by @Template within @Templates
[ "Instantiates", "the", "templates", "specified", "by" ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/TemplateProcessor.java#L47-L72
train
arquillian/arquillian-cube
docker/docker/src/main/java/org/arquillian/cube/docker/impl/docker/DockerClientExecutor.java
DockerClientExecutor.execStartVerbose
public ExecInspection execStartVerbose(String containerId, String... commands) { this.readWriteLock.readLock().lock(); try { String id = execCreate(containerId, commands); CubeOutput output = execStartOutput(id); return new ExecInspection(output, inspectExec(id)); } finally { this.readWriteLock.readLock().unlock(); } }
java
public ExecInspection execStartVerbose(String containerId, String... commands) { this.readWriteLock.readLock().lock(); try { String id = execCreate(containerId, commands); CubeOutput output = execStartOutput(id); return new ExecInspection(output, inspectExec(id)); } finally { this.readWriteLock.readLock().unlock(); } }
[ "public", "ExecInspection", "execStartVerbose", "(", "String", "containerId", ",", "String", "...", "commands", ")", "{", "this", ".", "readWriteLock", ".", "readLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "String", "id", "=", "execCreate", "(...
EXecutes command to given container returning the inspection object as well. This method does 3 calls to dockerhost. Create, Start and Inspect. @param containerId to execute command.
[ "EXecutes", "command", "to", "given", "container", "returning", "the", "inspection", "object", "as", "well", ".", "This", "method", "does", "3", "calls", "to", "dockerhost", ".", "Create", "Start", "and", "Inspect", "." ]
ce6b08062cc6ba2a68ecc29606bbae9acda5be13
https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/docker/DockerClientExecutor.java#L928-L938
train