id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
sequence | docstring
stringlengths 3
16k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 105
339
|
---|---|---|---|---|---|---|---|---|---|---|---|
162,100 | 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",
",",
"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",
";",
"}"
] | 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 |
162,101 | 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 |
162,102 | 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",
"!=",
"null",
"&&",
"obj1",
".",
"equals",
"(",
"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 |
162,103 | 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",
".",
"isDelayedQueue",
"(",
"jedis",
",",
"key",
")",
")",
"{",
"// If delayed queue, use ZCARD",
"size",
"=",
"jedis",
".",
"zcard",
"(",
"key",
")",
";",
"}",
"else",
"{",
"// Else, use LLEN",
"size",
"=",
"jedis",
".",
"llen",
"(",
"key",
")",
";",
"}",
"return",
"size",
";",
"}"
] | 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 |
162,104 | 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",
"(",
"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",
";",
"}"
] | 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 |
162,105 | 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",
">",
")",
"vars",
";",
"}"
] | 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 |
162,106 | 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 |
162,107 | 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",
"(",
"unknownFields",
")",
";",
"}"
] | 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 |
162,108 | 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 |
162,109 | 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",
".",
"values",
"(",
")",
".",
"remove",
"(",
"jobType",
")",
";",
"}"
] | 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 |
162,110 | 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",
".",
"jobTypes",
".",
"putAll",
"(",
"jobTypes",
")",
";",
"}"
] | 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 |
162,111 | 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 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",
")",
";",
"}",
"}",
"}"
] | 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 |
162,112 | 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\"",
")",
";",
"}",
"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",
")",
";",
"}",
"}"
] | 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 |
162,113 | 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",
"(",
"namespace",
",",
"CHANNEL",
",",
"channel",
")",
",",
"jobJson",
")",
";",
"}"
] | 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 |
162,114 | 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",
"{",
"return",
"findConstructor",
"(",
"clazz",
",",
"args",
")",
".",
"newInstance",
"(",
"args",
")",
";",
"}"
] | 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 |
162,115 | 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",
",",
"AmbiguousConstructorException",
",",
"ReflectiveOperationException",
"{",
"return",
"invokeSetters",
"(",
"findConstructor",
"(",
"clazz",
",",
"args",
")",
".",
"newInstance",
"(",
"args",
")",
",",
"vars",
")",
";",
"}"
] | 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 |
162,116 | 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",
"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",
";",
"}"
] | 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 |
162,117 | 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",
"!=",
"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",
";",
"}"
] | 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 |
162,118 | 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",
"(",
"final",
"String",
"queue",
":",
"queues",
")",
"{",
"if",
"(",
"queue",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"queue",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"queues' members must not be null: \"",
"+",
"queues",
")",
";",
"}",
"}",
"}"
] | 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 |
162,119 | 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",
".",
"setFailedAt",
"(",
"new",
"Date",
"(",
")",
")",
";",
"failure",
".",
"setWorker",
"(",
"this",
".",
"name",
")",
";",
"failure",
".",
"setQueue",
"(",
"queue",
")",
";",
"failure",
".",
"setPayload",
"(",
"job",
")",
";",
"failure",
".",
"setThrowable",
"(",
"thrwbl",
")",
";",
"return",
"ObjectMapperFactory",
".",
"get",
"(",
")",
".",
"writeValueAsString",
"(",
"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 |
162,120 | 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",
"(",
")",
")",
";",
"status",
".",
"setQueue",
"(",
"queue",
")",
";",
"status",
".",
"setPayload",
"(",
"job",
")",
";",
"return",
"ObjectMapperFactory",
".",
"get",
"(",
")",
".",
"writeValueAsString",
"(",
"status",
")",
";",
"}"
] | 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 |
162,121 | 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",
"(",
"isPaused",
"(",
")",
")",
";",
"return",
"ObjectMapperFactory",
".",
"get",
"(",
")",
".",
"writeValueAsString",
"(",
"status",
")",
";",
"}"
] | 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 |
162,122 | 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",
"(",
")",
")",
".",
"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",
"(",
")",
";",
"}"
] | 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 |
162,123 | 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 |
162,124 | 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\"",
")",
";",
"}",
"for",
"(",
"final",
"String",
"channel",
":",
"channels",
")",
"{",
"if",
"(",
"channel",
"==",
"null",
"||",
"\"\"",
".",
"equals",
"(",
"channel",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"channels' members must not be null: \"",
"+",
"channels",
")",
";",
"}",
"}",
"}"
] | 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 |
162,125 | 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",
")",
"{",
"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",
";",
"}"
] | 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 |
162,126 | 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",
"=",
"doWorkInPool",
"(",
"pool",
",",
"work",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"re",
")",
"{",
"throw",
"re",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"result",
";",
"}"
] | 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 |
162,127 | 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",
"(",
"\"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",
"(",
")",
")",
";",
"}",
"}"
] | 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 |
162,128 | 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",
"(",
"namespace",
",",
"QUEUES",
")",
",",
"queue",
")",
";",
"jedis",
".",
"rpush",
"(",
"JesqueUtils",
".",
"createKey",
"(",
"namespace",
",",
"QUEUE",
",",
"queue",
")",
",",
"jobJson",
")",
";",
"}"
] | 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 |
162,129 | 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",
".",
"pipelined",
"(",
")",
";",
"pipelined",
".",
"sadd",
"(",
"JesqueUtils",
".",
"createKey",
"(",
"namespace",
",",
"QUEUES",
")",
",",
"queue",
")",
";",
"for",
"(",
"String",
"jobJson",
":",
"jobJsons",
")",
"{",
"pipelined",
".",
"rpush",
"(",
"JesqueUtils",
".",
"createKey",
"(",
"namespace",
",",
"QUEUE",
",",
"queue",
")",
",",
"jobJson",
")",
";",
"}",
"pipelined",
".",
"sync",
"(",
")",
";",
"}"
] | 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 |
162,130 | 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",
"(",
"namespace",
",",
"QUEUES",
")",
",",
"queue",
")",
";",
"jedis",
".",
"lpush",
"(",
"JesqueUtils",
".",
"createKey",
"(",
"namespace",
",",
"QUEUE",
",",
"queue",
")",
",",
"jobJson",
")",
";",
"}"
] | 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 |
162,131 | 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",
"=",
"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",
";",
"}"
] | 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 |
162,132 | 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: \"",
"+",
"host",
")",
";",
"}",
"this",
".",
"host",
"=",
"host",
";",
"return",
"this",
";",
"}"
] | 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 |
162,133 | 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",
"(",
"\"sentinels is null or empty: \"",
"+",
"sentinels",
")",
";",
"}",
"this",
".",
"sentinels",
"=",
"sentinels",
";",
"return",
"this",
";",
"}"
] | 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 |
162,134 | 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 null or empty: \"",
"+",
"masterName",
")",
";",
"}",
"this",
".",
"masterName",
"=",
"masterName",
";",
"return",
"this",
";",
"}"
] | 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 |
162,135 | 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",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"// Ignore",
"try",
"{",
"jedis",
".",
"disconnect",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"// Ignore",
"jedis",
".",
"connect",
"(",
")",
";",
"}",
"return",
"jedisOK",
";",
"}"
] | 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 |
162,136 | 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",
"(",
")",
";",
"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",
")",
";",
"}"
] | 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 |
162,137 | 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 |
162,138 | 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 |
162,139 | 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 |
162,140 | 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",
"(",
"type",
")",
"||",
"NONE",
".",
"equalsIgnoreCase",
"(",
"type",
")",
")",
";",
"}"
] | 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 |
162,141 | 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",
"(",
"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.\"",
")",
";",
"}",
"}"
] | 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 |
162,142 | 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",
"=",
"(",
"Port",
")",
"q",
";",
"if",
"(",
"port",
".",
"value",
"(",
")",
">",
"0",
")",
"{",
"return",
"port",
".",
"value",
"(",
")",
";",
"}",
"}",
"}",
"ServicePort",
"servicePort",
"=",
"findQualifiedServicePort",
"(",
"service",
",",
"qualifiers",
")",
";",
"if",
"(",
"servicePort",
"!=",
"null",
")",
"{",
"return",
"servicePort",
".",
"getPort",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] | 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 |
162,143 | 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",
"=",
"(",
"Port",
")",
"q",
";",
"if",
"(",
"port",
".",
"value",
"(",
")",
">",
"0",
")",
"{",
"return",
"port",
".",
"value",
"(",
")",
";",
"}",
"}",
"}",
"ServicePort",
"servicePort",
"=",
"findQualifiedServicePort",
"(",
"service",
",",
"qualifiers",
")",
";",
"if",
"(",
"servicePort",
"!=",
"null",
")",
"{",
"return",
"servicePort",
".",
"getTargetPort",
"(",
")",
".",
"getIntVal",
"(",
")",
";",
"}",
"return",
"0",
";",
"}"
] | 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 |
162,144 | 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",
"(",
"(",
"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",
";",
"}"
] | 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 |
162,145 | 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",
"(",
"(",
"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",
";",
"}"
] | 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 |
162,146 | 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",
")",
".",
"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",
"(",
")",
";",
"}",
"}"
] | 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 |
162,147 | 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",
"=",
"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",
";",
"}"
] | 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 |
162,148 | 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",
"++",
")",
"{",
"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",
"}",
"}"
] | 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 |
162,149 | 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",
"=",
"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",
";",
"}"
] | 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 |
162,150 | 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",
"(",
"containerId",
",",
"commands",
")",
";",
"CubeOutput",
"output",
"=",
"execStartOutput",
"(",
"id",
")",
";",
"return",
"new",
"ExecInspection",
"(",
"output",
",",
"inspectExec",
"(",
"id",
")",
")",
";",
"}",
"finally",
"{",
"this",
".",
"readWriteLock",
".",
"readLock",
"(",
")",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] | 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 |
162,151 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java | OpenShiftResourceFactory.createImageStreamRequest | private static String createImageStreamRequest(String name, String version, String image, boolean insecure) {
JSONObject imageStream = new JSONObject();
JSONObject metadata = new JSONObject();
JSONObject annotations = new JSONObject();
metadata.put("name", name);
annotations.put("openshift.io/image.insecureRepository", insecure);
metadata.put("annotations", annotations);
// Definition of the image
JSONObject from = new JSONObject();
from.put("kind", "DockerImage");
from.put("name", image);
JSONObject importPolicy = new JSONObject();
importPolicy.put("insecure", insecure);
JSONObject tag = new JSONObject();
tag.put("name", version);
tag.put("from", from);
tag.put("importPolicy", importPolicy);
JSONObject tagAnnotations = new JSONObject();
tagAnnotations.put("version", version);
tag.put("annotations", tagAnnotations);
JSONArray tags = new JSONArray();
tags.add(tag);
// Add image definition to image stream
JSONObject spec = new JSONObject();
spec.put("tags", tags);
imageStream.put("kind", "ImageStream");
imageStream.put("apiVersion", "v1");
imageStream.put("metadata", metadata);
imageStream.put("spec", spec);
return imageStream.toJSONString();
} | java | private static String createImageStreamRequest(String name, String version, String image, boolean insecure) {
JSONObject imageStream = new JSONObject();
JSONObject metadata = new JSONObject();
JSONObject annotations = new JSONObject();
metadata.put("name", name);
annotations.put("openshift.io/image.insecureRepository", insecure);
metadata.put("annotations", annotations);
// Definition of the image
JSONObject from = new JSONObject();
from.put("kind", "DockerImage");
from.put("name", image);
JSONObject importPolicy = new JSONObject();
importPolicy.put("insecure", insecure);
JSONObject tag = new JSONObject();
tag.put("name", version);
tag.put("from", from);
tag.put("importPolicy", importPolicy);
JSONObject tagAnnotations = new JSONObject();
tagAnnotations.put("version", version);
tag.put("annotations", tagAnnotations);
JSONArray tags = new JSONArray();
tags.add(tag);
// Add image definition to image stream
JSONObject spec = new JSONObject();
spec.put("tags", tags);
imageStream.put("kind", "ImageStream");
imageStream.put("apiVersion", "v1");
imageStream.put("metadata", metadata);
imageStream.put("spec", spec);
return imageStream.toJSONString();
} | [
"private",
"static",
"String",
"createImageStreamRequest",
"(",
"String",
"name",
",",
"String",
"version",
",",
"String",
"image",
",",
"boolean",
"insecure",
")",
"{",
"JSONObject",
"imageStream",
"=",
"new",
"JSONObject",
"(",
")",
";",
"JSONObject",
"metadata",
"=",
"new",
"JSONObject",
"(",
")",
";",
"JSONObject",
"annotations",
"=",
"new",
"JSONObject",
"(",
")",
";",
"metadata",
".",
"put",
"(",
"\"name\"",
",",
"name",
")",
";",
"annotations",
".",
"put",
"(",
"\"openshift.io/image.insecureRepository\"",
",",
"insecure",
")",
";",
"metadata",
".",
"put",
"(",
"\"annotations\"",
",",
"annotations",
")",
";",
"// Definition of the image",
"JSONObject",
"from",
"=",
"new",
"JSONObject",
"(",
")",
";",
"from",
".",
"put",
"(",
"\"kind\"",
",",
"\"DockerImage\"",
")",
";",
"from",
".",
"put",
"(",
"\"name\"",
",",
"image",
")",
";",
"JSONObject",
"importPolicy",
"=",
"new",
"JSONObject",
"(",
")",
";",
"importPolicy",
".",
"put",
"(",
"\"insecure\"",
",",
"insecure",
")",
";",
"JSONObject",
"tag",
"=",
"new",
"JSONObject",
"(",
")",
";",
"tag",
".",
"put",
"(",
"\"name\"",
",",
"version",
")",
";",
"tag",
".",
"put",
"(",
"\"from\"",
",",
"from",
")",
";",
"tag",
".",
"put",
"(",
"\"importPolicy\"",
",",
"importPolicy",
")",
";",
"JSONObject",
"tagAnnotations",
"=",
"new",
"JSONObject",
"(",
")",
";",
"tagAnnotations",
".",
"put",
"(",
"\"version\"",
",",
"version",
")",
";",
"tag",
".",
"put",
"(",
"\"annotations\"",
",",
"tagAnnotations",
")",
";",
"JSONArray",
"tags",
"=",
"new",
"JSONArray",
"(",
")",
";",
"tags",
".",
"add",
"(",
"tag",
")",
";",
"// Add image definition to image stream",
"JSONObject",
"spec",
"=",
"new",
"JSONObject",
"(",
")",
";",
"spec",
".",
"put",
"(",
"\"tags\"",
",",
"tags",
")",
";",
"imageStream",
".",
"put",
"(",
"\"kind\"",
",",
"\"ImageStream\"",
")",
";",
"imageStream",
".",
"put",
"(",
"\"apiVersion\"",
",",
"\"v1\"",
")",
";",
"imageStream",
".",
"put",
"(",
"\"metadata\"",
",",
"metadata",
")",
";",
"imageStream",
".",
"put",
"(",
"\"spec\"",
",",
"spec",
")",
";",
"return",
"imageStream",
".",
"toJSONString",
"(",
")",
";",
"}"
] | Creates image stream request and returns it in JSON formatted string.
@param name Name of the image stream
@param insecure If the registry where the image is stored is insecure
@param image Image name, includes registry information and tag
@param version Image stream version.
@return JSON formatted string | [
"Creates",
"image",
"stream",
"request",
"and",
"returns",
"it",
"in",
"JSON",
"formatted",
"string",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java#L159-L198 |
162,152 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java | OpenShiftResourceFactory.getTemplates | static <T> List<Template> getTemplates(T objectType) {
try {
List<Template> templates = new ArrayList<>();
TEMP_FINDER.findAnnotations(templates, objectType);
return templates;
} catch (Exception e) {
throw new IllegalStateException(e);
}
} | java | static <T> List<Template> getTemplates(T objectType) {
try {
List<Template> templates = new ArrayList<>();
TEMP_FINDER.findAnnotations(templates, objectType);
return templates;
} catch (Exception e) {
throw new IllegalStateException(e);
}
} | [
"static",
"<",
"T",
">",
"List",
"<",
"Template",
">",
"getTemplates",
"(",
"T",
"objectType",
")",
"{",
"try",
"{",
"List",
"<",
"Template",
">",
"templates",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"TEMP_FINDER",
".",
"findAnnotations",
"(",
"templates",
",",
"objectType",
")",
";",
"return",
"templates",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"}"
] | Aggregates a list of templates specified by @Template | [
"Aggregates",
"a",
"list",
"of",
"templates",
"specified",
"by"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java#L203-L211 |
162,153 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java | OpenShiftResourceFactory.syncInstantiation | static <T> boolean syncInstantiation(T objectType) {
List<Template> templates = new ArrayList<>();
Templates tr = TEMP_FINDER.findAnnotations(templates, objectType);
if (tr == null) {
/* Default to synchronous instantiation */
return true;
} else {
return tr.syncInstantiation();
}
} | java | static <T> boolean syncInstantiation(T objectType) {
List<Template> templates = new ArrayList<>();
Templates tr = TEMP_FINDER.findAnnotations(templates, objectType);
if (tr == null) {
/* Default to synchronous instantiation */
return true;
} else {
return tr.syncInstantiation();
}
} | [
"static",
"<",
"T",
">",
"boolean",
"syncInstantiation",
"(",
"T",
"objectType",
")",
"{",
"List",
"<",
"Template",
">",
"templates",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Templates",
"tr",
"=",
"TEMP_FINDER",
".",
"findAnnotations",
"(",
"templates",
",",
"objectType",
")",
";",
"if",
"(",
"tr",
"==",
"null",
")",
"{",
"/* Default to synchronous instantiation */",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"tr",
".",
"syncInstantiation",
"(",
")",
";",
"}",
"}"
] | Returns true if templates are to be instantiated synchronously and false if
asynchronously. | [
"Returns",
"true",
"if",
"templates",
"are",
"to",
"be",
"instantiated",
"synchronously",
"and",
"false",
"if",
"asynchronously",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/resources/OpenShiftResourceFactory.java#L217-L226 |
162,154 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.deployApplication | public void deployApplication(String applicationName, String... classpathLocations) throws IOException {
final List<URL> classpathElements = Arrays.stream(classpathLocations)
.map(classpath -> Thread.currentThread().getContextClassLoader().getResource(classpath))
.collect(Collectors.toList());
deployApplication(applicationName, classpathElements.toArray(new URL[classpathElements.size()]));
} | java | public void deployApplication(String applicationName, String... classpathLocations) throws IOException {
final List<URL> classpathElements = Arrays.stream(classpathLocations)
.map(classpath -> Thread.currentThread().getContextClassLoader().getResource(classpath))
.collect(Collectors.toList());
deployApplication(applicationName, classpathElements.toArray(new URL[classpathElements.size()]));
} | [
"public",
"void",
"deployApplication",
"(",
"String",
"applicationName",
",",
"String",
"...",
"classpathLocations",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"URL",
">",
"classpathElements",
"=",
"Arrays",
".",
"stream",
"(",
"classpathLocations",
")",
".",
"map",
"(",
"classpath",
"->",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
".",
"getResource",
"(",
"classpath",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"deployApplication",
"(",
"applicationName",
",",
"classpathElements",
".",
"toArray",
"(",
"new",
"URL",
"[",
"classpathElements",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}"
] | Deploys application reading resources from specified classpath location
@param applicationName to configure in cluster
@param classpathLocations where resources are read
@throws IOException | [
"Deploys",
"application",
"reading",
"resources",
"from",
"specified",
"classpath",
"location"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L107-L114 |
162,155 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.deployApplication | public void deployApplication(String applicationName, URL... urls) throws IOException {
this.applicationName = applicationName;
for (URL url : urls) {
try (InputStream inputStream = url.openStream()) {
deploy(inputStream);
}
}
} | java | public void deployApplication(String applicationName, URL... urls) throws IOException {
this.applicationName = applicationName;
for (URL url : urls) {
try (InputStream inputStream = url.openStream()) {
deploy(inputStream);
}
}
} | [
"public",
"void",
"deployApplication",
"(",
"String",
"applicationName",
",",
"URL",
"...",
"urls",
")",
"throws",
"IOException",
"{",
"this",
".",
"applicationName",
"=",
"applicationName",
";",
"for",
"(",
"URL",
"url",
":",
"urls",
")",
"{",
"try",
"(",
"InputStream",
"inputStream",
"=",
"url",
".",
"openStream",
"(",
")",
")",
"{",
"deploy",
"(",
"inputStream",
")",
";",
"}",
"}",
"}"
] | Deploys application reading resources from specified URLs
@param applicationName to configure in cluster
@param urls where resources are read
@return the name of the application
@throws IOException | [
"Deploys",
"application",
"reading",
"resources",
"from",
"specified",
"URLs"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L136-L144 |
162,156 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.deploy | public void deploy(InputStream inputStream) throws IOException {
final List<? extends HasMetadata> entities = deploy("application", inputStream);
if (this.applicationName == null) {
Optional<String> deployment = entities.stream()
.filter(hm -> hm instanceof Deployment)
.map(hm -> (Deployment) hm)
.map(rc -> rc.getMetadata().getName()).findFirst();
deployment.ifPresent(name -> this.applicationName = name);
}
} | java | public void deploy(InputStream inputStream) throws IOException {
final List<? extends HasMetadata> entities = deploy("application", inputStream);
if (this.applicationName == null) {
Optional<String> deployment = entities.stream()
.filter(hm -> hm instanceof Deployment)
.map(hm -> (Deployment) hm)
.map(rc -> rc.getMetadata().getName()).findFirst();
deployment.ifPresent(name -> this.applicationName = name);
}
} | [
"public",
"void",
"deploy",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"?",
"extends",
"HasMetadata",
">",
"entities",
"=",
"deploy",
"(",
"\"application\"",
",",
"inputStream",
")",
";",
"if",
"(",
"this",
".",
"applicationName",
"==",
"null",
")",
"{",
"Optional",
"<",
"String",
">",
"deployment",
"=",
"entities",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"hm",
"->",
"hm",
"instanceof",
"Deployment",
")",
".",
"map",
"(",
"hm",
"->",
"(",
"Deployment",
")",
"hm",
")",
".",
"map",
"(",
"rc",
"->",
"rc",
".",
"getMetadata",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"findFirst",
"(",
")",
";",
"deployment",
".",
"ifPresent",
"(",
"name",
"->",
"this",
".",
"applicationName",
"=",
"name",
")",
";",
"}",
"}"
] | Deploys application reading resources from specified InputStream
@param inputStream where resources are read
@throws IOException | [
"Deploys",
"application",
"reading",
"resources",
"from",
"specified",
"InputStream"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L231-L243 |
162,157 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.getServiceUrl | public Optional<URL> getServiceUrl(String name) {
Service service = client.services().inNamespace(namespace).withName(name).get();
return service != null ? createUrlForService(service) : Optional.empty();
} | java | public Optional<URL> getServiceUrl(String name) {
Service service = client.services().inNamespace(namespace).withName(name).get();
return service != null ? createUrlForService(service) : Optional.empty();
} | [
"public",
"Optional",
"<",
"URL",
">",
"getServiceUrl",
"(",
"String",
"name",
")",
"{",
"Service",
"service",
"=",
"client",
".",
"services",
"(",
")",
".",
"inNamespace",
"(",
"namespace",
")",
".",
"withName",
"(",
"name",
")",
".",
"get",
"(",
")",
";",
"return",
"service",
"!=",
"null",
"?",
"createUrlForService",
"(",
"service",
")",
":",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] | Gets the URL of the service with the given name that has been created during the current session.
@param name to return its URL
@return URL of the service. | [
"Gets",
"the",
"URL",
"of",
"the",
"service",
"with",
"the",
"given",
"name",
"that",
"has",
"been",
"created",
"during",
"the",
"current",
"session",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L263-L266 |
162,158 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.getServiceUrl | public Optional<URL> getServiceUrl() {
Optional<Service> optionalService = client.services().inNamespace(namespace)
.list().getItems()
.stream()
.findFirst();
return optionalService
.map(this::createUrlForService)
.orElse(Optional.empty());
} | java | public Optional<URL> getServiceUrl() {
Optional<Service> optionalService = client.services().inNamespace(namespace)
.list().getItems()
.stream()
.findFirst();
return optionalService
.map(this::createUrlForService)
.orElse(Optional.empty());
} | [
"public",
"Optional",
"<",
"URL",
">",
"getServiceUrl",
"(",
")",
"{",
"Optional",
"<",
"Service",
">",
"optionalService",
"=",
"client",
".",
"services",
"(",
")",
".",
"inNamespace",
"(",
"namespace",
")",
".",
"list",
"(",
")",
".",
"getItems",
"(",
")",
".",
"stream",
"(",
")",
".",
"findFirst",
"(",
")",
";",
"return",
"optionalService",
".",
"map",
"(",
"this",
"::",
"createUrlForService",
")",
".",
"orElse",
"(",
"Optional",
".",
"empty",
"(",
")",
")",
";",
"}"
] | Gets the URL of the first service that have been created during the current session.
@return URL of the first service. | [
"Gets",
"the",
"URL",
"of",
"the",
"first",
"service",
"that",
"have",
"been",
"created",
"during",
"the",
"current",
"session",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L273-L282 |
162,159 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.cleanup | public void cleanup() {
List<String> keys = new ArrayList<>(created.keySet());
keys.sort(String::compareTo);
for (String key : keys) {
created.remove(key)
.stream()
.sorted(Comparator.comparing(HasMetadata::getKind))
.forEach(metadata -> {
log.info(String.format("Deleting %s : %s", key, metadata.getKind()));
deleteWithRetries(metadata);
});
}
} | java | public void cleanup() {
List<String> keys = new ArrayList<>(created.keySet());
keys.sort(String::compareTo);
for (String key : keys) {
created.remove(key)
.stream()
.sorted(Comparator.comparing(HasMetadata::getKind))
.forEach(metadata -> {
log.info(String.format("Deleting %s : %s", key, metadata.getKind()));
deleteWithRetries(metadata);
});
}
} | [
"public",
"void",
"cleanup",
"(",
")",
"{",
"List",
"<",
"String",
">",
"keys",
"=",
"new",
"ArrayList",
"<>",
"(",
"created",
".",
"keySet",
"(",
")",
")",
";",
"keys",
".",
"sort",
"(",
"String",
"::",
"compareTo",
")",
";",
"for",
"(",
"String",
"key",
":",
"keys",
")",
"{",
"created",
".",
"remove",
"(",
"key",
")",
".",
"stream",
"(",
")",
".",
"sorted",
"(",
"Comparator",
".",
"comparing",
"(",
"HasMetadata",
"::",
"getKind",
")",
")",
".",
"forEach",
"(",
"metadata",
"->",
"{",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Deleting %s : %s\"",
",",
"key",
",",
"metadata",
".",
"getKind",
"(",
")",
")",
")",
";",
"deleteWithRetries",
"(",
"metadata",
")",
";",
"}",
")",
";",
"}",
"}"
] | Removes all resources deployed using this class. | [
"Removes",
"all",
"resources",
"deployed",
"using",
"this",
"class",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L361-L373 |
162,160 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java | KubernetesAssistant.awaitPodReadinessOrFail | public void awaitPodReadinessOrFail(Predicate<Pod> filter) {
await().atMost(5, TimeUnit.MINUTES).until(() -> {
List<Pod> list = client.pods().inNamespace(namespace).list().getItems();
return list.stream()
.filter(filter)
.filter(Readiness::isPodReady)
.collect(Collectors.toList()).size() >= 1;
}
);
} | java | public void awaitPodReadinessOrFail(Predicate<Pod> filter) {
await().atMost(5, TimeUnit.MINUTES).until(() -> {
List<Pod> list = client.pods().inNamespace(namespace).list().getItems();
return list.stream()
.filter(filter)
.filter(Readiness::isPodReady)
.collect(Collectors.toList()).size() >= 1;
}
);
} | [
"public",
"void",
"awaitPodReadinessOrFail",
"(",
"Predicate",
"<",
"Pod",
">",
"filter",
")",
"{",
"await",
"(",
")",
".",
"atMost",
"(",
"5",
",",
"TimeUnit",
".",
"MINUTES",
")",
".",
"until",
"(",
"(",
")",
"->",
"{",
"List",
"<",
"Pod",
">",
"list",
"=",
"client",
".",
"pods",
"(",
")",
".",
"inNamespace",
"(",
"namespace",
")",
".",
"list",
"(",
")",
".",
"getItems",
"(",
")",
";",
"return",
"list",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"filter",
")",
".",
"filter",
"(",
"Readiness",
"::",
"isPodReady",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
".",
"size",
"(",
")",
">=",
"1",
";",
"}",
")",
";",
"}"
] | Awaits at most 5 minutes until all pods meets the given predicate.
@param filter used to wait to detect that a pod is up and running. | [
"Awaits",
"at",
"most",
"5",
"minutes",
"until",
"all",
"pods",
"meets",
"the",
"given",
"predicate",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/KubernetesAssistant.java#L430-L439 |
162,161 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/requirement/DockerRequirement.java | DockerRequirement.getDockerVersion | private static Version getDockerVersion(String serverUrl) {
try {
DockerClient client = DockerClientBuilder.getInstance(serverUrl).build();
return client.versionCmd().exec();
} catch (Exception e) {
return null;
}
} | java | private static Version getDockerVersion(String serverUrl) {
try {
DockerClient client = DockerClientBuilder.getInstance(serverUrl).build();
return client.versionCmd().exec();
} catch (Exception e) {
return null;
}
} | [
"private",
"static",
"Version",
"getDockerVersion",
"(",
"String",
"serverUrl",
")",
"{",
"try",
"{",
"DockerClient",
"client",
"=",
"DockerClientBuilder",
".",
"getInstance",
"(",
"serverUrl",
")",
".",
"build",
"(",
")",
";",
"return",
"client",
".",
"versionCmd",
"(",
")",
".",
"exec",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the docker version.
@param serverUrl
The serverUrl to use. | [
"Returns",
"the",
"docker",
"version",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/requirement/DockerRequirement.java#L59-L66 |
162,162 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/client/CubeConfigurator.java | CubeConfigurator.configure | public void configure(@Observes(precedence = -10) ArquillianDescriptor arquillianDescriptor) {
Map<String, String> config = arquillianDescriptor.extension(EXTENSION_NAME).getExtensionProperties();
CubeConfiguration cubeConfiguration = CubeConfiguration.fromMap(config);
configurationProducer.set(cubeConfiguration);
} | java | public void configure(@Observes(precedence = -10) ArquillianDescriptor arquillianDescriptor) {
Map<String, String> config = arquillianDescriptor.extension(EXTENSION_NAME).getExtensionProperties();
CubeConfiguration cubeConfiguration = CubeConfiguration.fromMap(config);
configurationProducer.set(cubeConfiguration);
} | [
"public",
"void",
"configure",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"-",
"10",
")",
"ArquillianDescriptor",
"arquillianDescriptor",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"config",
"=",
"arquillianDescriptor",
".",
"extension",
"(",
"EXTENSION_NAME",
")",
".",
"getExtensionProperties",
"(",
")",
";",
"CubeConfiguration",
"cubeConfiguration",
"=",
"CubeConfiguration",
".",
"fromMap",
"(",
"config",
")",
";",
"configurationProducer",
".",
"set",
"(",
"cubeConfiguration",
")",
";",
"}"
] | Add precedence -10 because we need that ContainerRegistry is available in the Arquillian scope. | [
"Add",
"precedence",
"-",
"10",
"because",
"we",
"need",
"that",
"ContainerRegistry",
"is",
"available",
"in",
"the",
"Arquillian",
"scope",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/client/CubeConfigurator.java#L20-L24 |
162,163 | arquillian/arquillian-cube | openshift/openshift-restassured/src/main/java/org/arquillian/cube/openshift/restassured/RestAssuredConfigurator.java | RestAssuredConfigurator.configure | public void configure(@Observes(precedence = -200) ArquillianDescriptor arquillianDescriptor) {
restAssuredConfigurationInstanceProducer.set(
RestAssuredConfiguration.fromMap(arquillianDescriptor
.extension("restassured")
.getExtensionProperties()));
} | java | public void configure(@Observes(precedence = -200) ArquillianDescriptor arquillianDescriptor) {
restAssuredConfigurationInstanceProducer.set(
RestAssuredConfiguration.fromMap(arquillianDescriptor
.extension("restassured")
.getExtensionProperties()));
} | [
"public",
"void",
"configure",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"-",
"200",
")",
"ArquillianDescriptor",
"arquillianDescriptor",
")",
"{",
"restAssuredConfigurationInstanceProducer",
".",
"set",
"(",
"RestAssuredConfiguration",
".",
"fromMap",
"(",
"arquillianDescriptor",
".",
"extension",
"(",
"\"restassured\"",
")",
".",
"getExtensionProperties",
"(",
")",
")",
")",
";",
"}"
] | required for rest assured base URI configuration. | [
"required",
"for",
"rest",
"assured",
"base",
"URI",
"configuration",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift-restassured/src/main/java/org/arquillian/cube/openshift/restassured/RestAssuredConfigurator.java#L17-L22 |
162,164 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/CubeDockerConfigurationResolver.java | CubeDockerConfigurationResolver.resolve | public Map<String, String> resolve(Map<String, String> config) {
config = resolveSystemEnvironmentVariables(config);
config = resolveSystemDefaultSetup(config);
config = resolveDockerInsideDocker(config);
config = resolveDownloadDockerMachine(config);
config = resolveAutoStartDockerMachine(config);
config = resolveDefaultDockerMachine(config);
config = resolveServerUriByOperativeSystem(config);
config = resolveServerIp(config);
config = resolveTlsVerification(config);
return config;
} | java | public Map<String, String> resolve(Map<String, String> config) {
config = resolveSystemEnvironmentVariables(config);
config = resolveSystemDefaultSetup(config);
config = resolveDockerInsideDocker(config);
config = resolveDownloadDockerMachine(config);
config = resolveAutoStartDockerMachine(config);
config = resolveDefaultDockerMachine(config);
config = resolveServerUriByOperativeSystem(config);
config = resolveServerIp(config);
config = resolveTlsVerification(config);
return config;
} | [
"public",
"Map",
"<",
"String",
",",
"String",
">",
"resolve",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"config",
")",
"{",
"config",
"=",
"resolveSystemEnvironmentVariables",
"(",
"config",
")",
";",
"config",
"=",
"resolveSystemDefaultSetup",
"(",
"config",
")",
";",
"config",
"=",
"resolveDockerInsideDocker",
"(",
"config",
")",
";",
"config",
"=",
"resolveDownloadDockerMachine",
"(",
"config",
")",
";",
"config",
"=",
"resolveAutoStartDockerMachine",
"(",
"config",
")",
";",
"config",
"=",
"resolveDefaultDockerMachine",
"(",
"config",
")",
";",
"config",
"=",
"resolveServerUriByOperativeSystem",
"(",
"config",
")",
";",
"config",
"=",
"resolveServerIp",
"(",
"config",
")",
";",
"config",
"=",
"resolveTlsVerification",
"(",
"config",
")",
";",
"return",
"config",
";",
"}"
] | Resolves the configuration.
@param config The specified configuration.
@return The resolved configuration. | [
"Resolves",
"the",
"configuration",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/CubeDockerConfigurationResolver.java#L68-L79 |
162,165 | arquillian/arquillian-cube | docker/drone/src/main/java/org/arquillian/cube/docker/drone/util/SeleniumVersionExtractor.java | SeleniumVersionExtractor.fromClassPath | public static String fromClassPath() {
Set<String> versions = new HashSet<>();
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Enumeration<URL> manifests = classLoader.getResources("META-INF/MANIFEST.MF");
while (manifests.hasMoreElements()) {
URL manifestURL = manifests.nextElement();
try (InputStream is = manifestURL.openStream()) {
Manifest manifest = new Manifest();
manifest.read(is);
Attributes buildInfo = manifest.getAttributes("Build-Info");
if (buildInfo != null) {
if (buildInfo.getValue("Selenium-Version") != null) {
versions.add(buildInfo.getValue("Selenium-Version"));
} else {
// might be in build-info part
if (manifest.getEntries() != null) {
if (manifest.getEntries().containsKey("Build-Info")) {
final Attributes attributes = manifest.getEntries().get("Build-Info");
if (attributes.getValue("Selenium-Version") != null) {
versions.add(attributes.getValue("Selenium-Version"));
}
}
}
}
}
}
}
} catch (Exception e) {
logger.log(Level.WARNING,
"Exception {0} occurred while resolving selenium version and latest image is going to be used.",
e.getMessage());
return SELENIUM_VERSION;
}
if (versions.isEmpty()) {
logger.log(Level.INFO, "No version of Selenium found in classpath. Using latest image.");
return SELENIUM_VERSION;
}
String foundVersion = versions.iterator().next();
if (versions.size() > 1) {
logger.log(Level.WARNING, "Multiple versions of Selenium found in classpath. Using the first one found {0}.",
foundVersion);
}
return foundVersion;
} | java | public static String fromClassPath() {
Set<String> versions = new HashSet<>();
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Enumeration<URL> manifests = classLoader.getResources("META-INF/MANIFEST.MF");
while (manifests.hasMoreElements()) {
URL manifestURL = manifests.nextElement();
try (InputStream is = manifestURL.openStream()) {
Manifest manifest = new Manifest();
manifest.read(is);
Attributes buildInfo = manifest.getAttributes("Build-Info");
if (buildInfo != null) {
if (buildInfo.getValue("Selenium-Version") != null) {
versions.add(buildInfo.getValue("Selenium-Version"));
} else {
// might be in build-info part
if (manifest.getEntries() != null) {
if (manifest.getEntries().containsKey("Build-Info")) {
final Attributes attributes = manifest.getEntries().get("Build-Info");
if (attributes.getValue("Selenium-Version") != null) {
versions.add(attributes.getValue("Selenium-Version"));
}
}
}
}
}
}
}
} catch (Exception e) {
logger.log(Level.WARNING,
"Exception {0} occurred while resolving selenium version and latest image is going to be used.",
e.getMessage());
return SELENIUM_VERSION;
}
if (versions.isEmpty()) {
logger.log(Level.INFO, "No version of Selenium found in classpath. Using latest image.");
return SELENIUM_VERSION;
}
String foundVersion = versions.iterator().next();
if (versions.size() > 1) {
logger.log(Level.WARNING, "Multiple versions of Selenium found in classpath. Using the first one found {0}.",
foundVersion);
}
return foundVersion;
} | [
"public",
"static",
"String",
"fromClassPath",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"versions",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"try",
"{",
"ClassLoader",
"classLoader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"Enumeration",
"<",
"URL",
">",
"manifests",
"=",
"classLoader",
".",
"getResources",
"(",
"\"META-INF/MANIFEST.MF\"",
")",
";",
"while",
"(",
"manifests",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"URL",
"manifestURL",
"=",
"manifests",
".",
"nextElement",
"(",
")",
";",
"try",
"(",
"InputStream",
"is",
"=",
"manifestURL",
".",
"openStream",
"(",
")",
")",
"{",
"Manifest",
"manifest",
"=",
"new",
"Manifest",
"(",
")",
";",
"manifest",
".",
"read",
"(",
"is",
")",
";",
"Attributes",
"buildInfo",
"=",
"manifest",
".",
"getAttributes",
"(",
"\"Build-Info\"",
")",
";",
"if",
"(",
"buildInfo",
"!=",
"null",
")",
"{",
"if",
"(",
"buildInfo",
".",
"getValue",
"(",
"\"Selenium-Version\"",
")",
"!=",
"null",
")",
"{",
"versions",
".",
"add",
"(",
"buildInfo",
".",
"getValue",
"(",
"\"Selenium-Version\"",
")",
")",
";",
"}",
"else",
"{",
"// might be in build-info part",
"if",
"(",
"manifest",
".",
"getEntries",
"(",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"manifest",
".",
"getEntries",
"(",
")",
".",
"containsKey",
"(",
"\"Build-Info\"",
")",
")",
"{",
"final",
"Attributes",
"attributes",
"=",
"manifest",
".",
"getEntries",
"(",
")",
".",
"get",
"(",
"\"Build-Info\"",
")",
";",
"if",
"(",
"attributes",
".",
"getValue",
"(",
"\"Selenium-Version\"",
")",
"!=",
"null",
")",
"{",
"versions",
".",
"add",
"(",
"attributes",
".",
"getValue",
"(",
"\"Selenium-Version\"",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Exception {0} occurred while resolving selenium version and latest image is going to be used.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"SELENIUM_VERSION",
";",
"}",
"if",
"(",
"versions",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"No version of Selenium found in classpath. Using latest image.\"",
")",
";",
"return",
"SELENIUM_VERSION",
";",
"}",
"String",
"foundVersion",
"=",
"versions",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"if",
"(",
"versions",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"logger",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"Multiple versions of Selenium found in classpath. Using the first one found {0}.\"",
",",
"foundVersion",
")",
";",
"}",
"return",
"foundVersion",
";",
"}"
] | Returns current selenium version from JAR set in classpath.
@return Version of Selenium. | [
"Returns",
"current",
"selenium",
"version",
"from",
"JAR",
"set",
"in",
"classpath",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/drone/src/main/java/org/arquillian/cube/docker/drone/util/SeleniumVersionExtractor.java#L26-L76 |
162,166 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java | DefaultConfiguration.getKubernetesConfigurationUrl | public static URL getKubernetesConfigurationUrl(Map<String, String> map) throws MalformedURLException {
if (Strings.isNotNullOrEmpty(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_URL, ""))) {
return new URL(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_URL, ""));
} else if (Strings.isNotNullOrEmpty(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_RESOURCE_NAME, ""))) {
String resourceName = Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_RESOURCE_NAME, "");
return findConfigResource(resourceName);
} else if (map.containsKey(ENVIRONMENT_CONFIG_URL)) {
return new URL(map.get(ENVIRONMENT_CONFIG_URL));
} else if (map.containsKey(ENVIRONMENT_CONFIG_RESOURCE_NAME)) {
String resourceName = map.get(ENVIRONMENT_CONFIG_RESOURCE_NAME);
return findConfigResource(resourceName);
} else {
// Let the resource locator find the resource
return null;
}
} | java | public static URL getKubernetesConfigurationUrl(Map<String, String> map) throws MalformedURLException {
if (Strings.isNotNullOrEmpty(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_URL, ""))) {
return new URL(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_URL, ""));
} else if (Strings.isNotNullOrEmpty(Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_RESOURCE_NAME, ""))) {
String resourceName = Utils.getSystemPropertyOrEnvVar(ENVIRONMENT_CONFIG_RESOURCE_NAME, "");
return findConfigResource(resourceName);
} else if (map.containsKey(ENVIRONMENT_CONFIG_URL)) {
return new URL(map.get(ENVIRONMENT_CONFIG_URL));
} else if (map.containsKey(ENVIRONMENT_CONFIG_RESOURCE_NAME)) {
String resourceName = map.get(ENVIRONMENT_CONFIG_RESOURCE_NAME);
return findConfigResource(resourceName);
} else {
// Let the resource locator find the resource
return null;
}
} | [
"public",
"static",
"URL",
"getKubernetesConfigurationUrl",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"map",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"Strings",
".",
"isNotNullOrEmpty",
"(",
"Utils",
".",
"getSystemPropertyOrEnvVar",
"(",
"ENVIRONMENT_CONFIG_URL",
",",
"\"\"",
")",
")",
")",
"{",
"return",
"new",
"URL",
"(",
"Utils",
".",
"getSystemPropertyOrEnvVar",
"(",
"ENVIRONMENT_CONFIG_URL",
",",
"\"\"",
")",
")",
";",
"}",
"else",
"if",
"(",
"Strings",
".",
"isNotNullOrEmpty",
"(",
"Utils",
".",
"getSystemPropertyOrEnvVar",
"(",
"ENVIRONMENT_CONFIG_RESOURCE_NAME",
",",
"\"\"",
")",
")",
")",
"{",
"String",
"resourceName",
"=",
"Utils",
".",
"getSystemPropertyOrEnvVar",
"(",
"ENVIRONMENT_CONFIG_RESOURCE_NAME",
",",
"\"\"",
")",
";",
"return",
"findConfigResource",
"(",
"resourceName",
")",
";",
"}",
"else",
"if",
"(",
"map",
".",
"containsKey",
"(",
"ENVIRONMENT_CONFIG_URL",
")",
")",
"{",
"return",
"new",
"URL",
"(",
"map",
".",
"get",
"(",
"ENVIRONMENT_CONFIG_URL",
")",
")",
";",
"}",
"else",
"if",
"(",
"map",
".",
"containsKey",
"(",
"ENVIRONMENT_CONFIG_RESOURCE_NAME",
")",
")",
"{",
"String",
"resourceName",
"=",
"map",
".",
"get",
"(",
"ENVIRONMENT_CONFIG_RESOURCE_NAME",
")",
";",
"return",
"findConfigResource",
"(",
"resourceName",
")",
";",
"}",
"else",
"{",
"// Let the resource locator find the resource",
"return",
"null",
";",
"}",
"}"
] | Applies the kubernetes json url to the configuration.
@param map
The arquillian configuration. | [
"Applies",
"the",
"kubernetes",
"json",
"url",
"to",
"the",
"configuration",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java#L237-L252 |
162,167 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java | DefaultConfiguration.findConfigResource | public static URL findConfigResource(String resourceName) {
if (Strings.isNullOrEmpty(resourceName)) {
return null;
}
final URL url = resourceName.startsWith(ROOT) ? DefaultConfiguration.class.getResource(resourceName)
: DefaultConfiguration.class.getResource(ROOT + resourceName);
if (url != null) {
return url;
}
// This is useful to get resource under META-INF directory
String[] resourceNamePrefix = new String[] {"META-INF/fabric8/", "META-INF/fabric8/"};
for (String resource : resourceNamePrefix) {
String fullResourceName = resource + resourceName;
URL candidate = KubernetesResourceLocator.class.getResource(fullResourceName.startsWith(ROOT) ? fullResourceName : ROOT + fullResourceName);
if (candidate != null) {
return candidate;
}
}
return null;
} | java | public static URL findConfigResource(String resourceName) {
if (Strings.isNullOrEmpty(resourceName)) {
return null;
}
final URL url = resourceName.startsWith(ROOT) ? DefaultConfiguration.class.getResource(resourceName)
: DefaultConfiguration.class.getResource(ROOT + resourceName);
if (url != null) {
return url;
}
// This is useful to get resource under META-INF directory
String[] resourceNamePrefix = new String[] {"META-INF/fabric8/", "META-INF/fabric8/"};
for (String resource : resourceNamePrefix) {
String fullResourceName = resource + resourceName;
URL candidate = KubernetesResourceLocator.class.getResource(fullResourceName.startsWith(ROOT) ? fullResourceName : ROOT + fullResourceName);
if (candidate != null) {
return candidate;
}
}
return null;
} | [
"public",
"static",
"URL",
"findConfigResource",
"(",
"String",
"resourceName",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"resourceName",
")",
")",
"{",
"return",
"null",
";",
"}",
"final",
"URL",
"url",
"=",
"resourceName",
".",
"startsWith",
"(",
"ROOT",
")",
"?",
"DefaultConfiguration",
".",
"class",
".",
"getResource",
"(",
"resourceName",
")",
":",
"DefaultConfiguration",
".",
"class",
".",
"getResource",
"(",
"ROOT",
"+",
"resourceName",
")",
";",
"if",
"(",
"url",
"!=",
"null",
")",
"{",
"return",
"url",
";",
"}",
"// This is useful to get resource under META-INF directory",
"String",
"[",
"]",
"resourceNamePrefix",
"=",
"new",
"String",
"[",
"]",
"{",
"\"META-INF/fabric8/\"",
",",
"\"META-INF/fabric8/\"",
"}",
";",
"for",
"(",
"String",
"resource",
":",
"resourceNamePrefix",
")",
"{",
"String",
"fullResourceName",
"=",
"resource",
"+",
"resourceName",
";",
"URL",
"candidate",
"=",
"KubernetesResourceLocator",
".",
"class",
".",
"getResource",
"(",
"fullResourceName",
".",
"startsWith",
"(",
"ROOT",
")",
"?",
"fullResourceName",
":",
"ROOT",
"+",
"fullResourceName",
")",
";",
"if",
"(",
"candidate",
"!=",
"null",
")",
"{",
"return",
"candidate",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the URL of a classpath resource.
@param resourceName
The name of the resource.
@return The URL. | [
"Returns",
"the",
"URL",
"of",
"a",
"classpath",
"resource",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java#L262-L287 |
162,168 | arquillian/arquillian-cube | kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java | DefaultConfiguration.asUrlOrResource | public static URL asUrlOrResource(String s) {
if (Strings.isNullOrEmpty(s)) {
return null;
}
try {
return new URL(s);
} catch (MalformedURLException e) {
//If its not a valid URL try to treat it as a local resource.
return findConfigResource(s);
}
} | java | public static URL asUrlOrResource(String s) {
if (Strings.isNullOrEmpty(s)) {
return null;
}
try {
return new URL(s);
} catch (MalformedURLException e) {
//If its not a valid URL try to treat it as a local resource.
return findConfigResource(s);
}
} | [
"public",
"static",
"URL",
"asUrlOrResource",
"(",
"String",
"s",
")",
"{",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"s",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"new",
"URL",
"(",
"s",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"//If its not a valid URL try to treat it as a local resource.",
"return",
"findConfigResource",
"(",
"s",
")",
";",
"}",
"}"
] | Convert a string to a URL and fallback to classpath resource, if not convertible.
@param s
The string to convert.
@return The URL. | [
"Convert",
"a",
"string",
"to",
"a",
"URL",
"and",
"fallback",
"to",
"classpath",
"resource",
"if",
"not",
"convertible",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/kubernetes/kubernetes/src/main/java/org/arquillian/cube/kubernetes/impl/DefaultConfiguration.java#L297-L308 |
162,169 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java | OpenShiftAssistant.deploy | @Override
public void deploy(InputStream inputStream) throws IOException {
final List<? extends HasMetadata> entities = deploy("application", inputStream);
if (this.applicationName == null) {
Optional<String> deploymentConfig = entities.stream()
.filter(hm -> hm instanceof DeploymentConfig)
.map(hm -> (DeploymentConfig) hm)
.map(dc -> dc.getMetadata().getName()).findFirst();
deploymentConfig.ifPresent(name -> this.applicationName = name);
}
} | java | @Override
public void deploy(InputStream inputStream) throws IOException {
final List<? extends HasMetadata> entities = deploy("application", inputStream);
if (this.applicationName == null) {
Optional<String> deploymentConfig = entities.stream()
.filter(hm -> hm instanceof DeploymentConfig)
.map(hm -> (DeploymentConfig) hm)
.map(dc -> dc.getMetadata().getName()).findFirst();
deploymentConfig.ifPresent(name -> this.applicationName = name);
}
} | [
"@",
"Override",
"public",
"void",
"deploy",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"final",
"List",
"<",
"?",
"extends",
"HasMetadata",
">",
"entities",
"=",
"deploy",
"(",
"\"application\"",
",",
"inputStream",
")",
";",
"if",
"(",
"this",
".",
"applicationName",
"==",
"null",
")",
"{",
"Optional",
"<",
"String",
">",
"deploymentConfig",
"=",
"entities",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"hm",
"->",
"hm",
"instanceof",
"DeploymentConfig",
")",
".",
"map",
"(",
"hm",
"->",
"(",
"DeploymentConfig",
")",
"hm",
")",
".",
"map",
"(",
"dc",
"->",
"dc",
".",
"getMetadata",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"findFirst",
"(",
")",
";",
"deploymentConfig",
".",
"ifPresent",
"(",
"name",
"->",
"this",
".",
"applicationName",
"=",
"name",
")",
";",
"}",
"}"
] | Deploys application reading resources from specified InputStream.
@param inputStream where resources are read
@throws IOException | [
"Deploys",
"application",
"reading",
"resources",
"from",
"specified",
"InputStream",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java#L69-L82 |
162,170 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java | OpenShiftAssistant.getRoute | public Optional<URL> getRoute(String routeName) {
Route route = getClient().routes()
.inNamespace(namespace).withName(routeName).get();
return route != null ? Optional.ofNullable(createUrlFromRoute(route)) : Optional.empty();
} | java | public Optional<URL> getRoute(String routeName) {
Route route = getClient().routes()
.inNamespace(namespace).withName(routeName).get();
return route != null ? Optional.ofNullable(createUrlFromRoute(route)) : Optional.empty();
} | [
"public",
"Optional",
"<",
"URL",
">",
"getRoute",
"(",
"String",
"routeName",
")",
"{",
"Route",
"route",
"=",
"getClient",
"(",
")",
".",
"routes",
"(",
")",
".",
"inNamespace",
"(",
"namespace",
")",
".",
"withName",
"(",
"routeName",
")",
".",
"get",
"(",
")",
";",
"return",
"route",
"!=",
"null",
"?",
"Optional",
".",
"ofNullable",
"(",
"createUrlFromRoute",
"(",
"route",
")",
")",
":",
"Optional",
".",
"empty",
"(",
")",
";",
"}"
] | Gets the URL of the route with given name.
@param routeName to return its URL
@return URL backed by the route with given name. | [
"Gets",
"the",
"URL",
"of",
"the",
"route",
"with",
"given",
"name",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java#L89-L94 |
162,171 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java | OpenShiftAssistant.getRoute | public Optional<URL> getRoute() {
Optional<Route> optionalRoute = getClient().routes().inNamespace(namespace)
.list().getItems()
.stream()
.findFirst();
return optionalRoute
.map(OpenShiftRouteLocator::createUrlFromRoute);
} | java | public Optional<URL> getRoute() {
Optional<Route> optionalRoute = getClient().routes().inNamespace(namespace)
.list().getItems()
.stream()
.findFirst();
return optionalRoute
.map(OpenShiftRouteLocator::createUrlFromRoute);
} | [
"public",
"Optional",
"<",
"URL",
">",
"getRoute",
"(",
")",
"{",
"Optional",
"<",
"Route",
">",
"optionalRoute",
"=",
"getClient",
"(",
")",
".",
"routes",
"(",
")",
".",
"inNamespace",
"(",
"namespace",
")",
".",
"list",
"(",
")",
".",
"getItems",
"(",
")",
".",
"stream",
"(",
")",
".",
"findFirst",
"(",
")",
";",
"return",
"optionalRoute",
".",
"map",
"(",
"OpenShiftRouteLocator",
"::",
"createUrlFromRoute",
")",
";",
"}"
] | Returns the URL of the first route.
@return URL backed by the first route. | [
"Returns",
"the",
"URL",
"of",
"the",
"first",
"route",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java#L100-L108 |
162,172 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java | OpenShiftAssistant.projectExists | public boolean projectExists(String name) throws IllegalArgumentException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Project name cannot be empty");
}
return listProjects().stream()
.map(p -> p.getMetadata().getName())
.anyMatch(Predicate.isEqual(name));
} | java | public boolean projectExists(String name) throws IllegalArgumentException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Project name cannot be empty");
}
return listProjects().stream()
.map(p -> p.getMetadata().getName())
.anyMatch(Predicate.isEqual(name));
} | [
"public",
"boolean",
"projectExists",
"(",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Project name cannot be empty\"",
")",
";",
"}",
"return",
"listProjects",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"p",
"->",
"p",
".",
"getMetadata",
"(",
")",
".",
"getName",
"(",
")",
")",
".",
"anyMatch",
"(",
"Predicate",
".",
"isEqual",
"(",
"name",
")",
")",
";",
"}"
] | Checks if the given project exists or not.
@param name project name
@return true/false
@throws IllegalArgumentException | [
"Checks",
"if",
"the",
"given",
"project",
"exists",
"or",
"not",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java#L230-L237 |
162,173 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java | OpenShiftAssistant.findProject | public Optional<Project> findProject(String name) throws IllegalArgumentException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Project name cannot be empty");
}
return getProject(name);
} | java | public Optional<Project> findProject(String name) throws IllegalArgumentException {
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Project name cannot be empty");
}
return getProject(name);
} | [
"public",
"Optional",
"<",
"Project",
">",
"findProject",
"(",
"String",
"name",
")",
"throws",
"IllegalArgumentException",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Project name cannot be empty\"",
")",
";",
"}",
"return",
"getProject",
"(",
"name",
")",
";",
"}"
] | Finds for the given project.
@param name project name
@return given project or an empty {@code Optional} if project does not exist
@throws IllegalArgumentException | [
"Finds",
"for",
"the",
"given",
"project",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistant.java#L246-L251 |
162,174 | arquillian/arquillian-cube | requirement/src/main/java/org/arquillian/cube/requirement/Constraints.java | Constraints.loadConstraint | private static Constraint loadConstraint(Annotation context) {
Constraint constraint = null;
final ServiceLoader<Constraint> constraints = ServiceLoader.load(Constraint.class);
for (Constraint aConstraint : constraints) {
try {
aConstraint.getClass().getDeclaredMethod("check", context.annotationType());
constraint = aConstraint;
break;
} catch (NoSuchMethodException e) {
// Look for next implementation if method not found with required signature.
}
}
if (constraint == null) {
throw new IllegalStateException("Couldn't found any implementation of " + Constraint.class.getName());
}
return constraint;
} | java | private static Constraint loadConstraint(Annotation context) {
Constraint constraint = null;
final ServiceLoader<Constraint> constraints = ServiceLoader.load(Constraint.class);
for (Constraint aConstraint : constraints) {
try {
aConstraint.getClass().getDeclaredMethod("check", context.annotationType());
constraint = aConstraint;
break;
} catch (NoSuchMethodException e) {
// Look for next implementation if method not found with required signature.
}
}
if (constraint == null) {
throw new IllegalStateException("Couldn't found any implementation of " + Constraint.class.getName());
}
return constraint;
} | [
"private",
"static",
"Constraint",
"loadConstraint",
"(",
"Annotation",
"context",
")",
"{",
"Constraint",
"constraint",
"=",
"null",
";",
"final",
"ServiceLoader",
"<",
"Constraint",
">",
"constraints",
"=",
"ServiceLoader",
".",
"load",
"(",
"Constraint",
".",
"class",
")",
";",
"for",
"(",
"Constraint",
"aConstraint",
":",
"constraints",
")",
"{",
"try",
"{",
"aConstraint",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"check\"",
",",
"context",
".",
"annotationType",
"(",
")",
")",
";",
"constraint",
"=",
"aConstraint",
";",
"break",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"// Look for next implementation if method not found with required signature.",
"}",
"}",
"if",
"(",
"constraint",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Couldn't found any implementation of \"",
"+",
"Constraint",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"}",
"return",
"constraint",
";",
"}"
] | we have only one implementation on classpath. | [
"we",
"have",
"only",
"one",
"implementation",
"on",
"classpath",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/requirement/src/main/java/org/arquillian/cube/requirement/Constraints.java#L38-L56 |
162,175 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/CEEnvironmentProcessor.java | CEEnvironmentProcessor.createEnvironment | public void createEnvironment(@Observes(precedence = 10) BeforeClass event, OpenShiftAdapter client,
CubeOpenShiftConfiguration cubeOpenShiftConfiguration) {
final TestClass testClass = event.getTestClass();
log.info(String.format("Creating environment for %s", testClass.getName()));
OpenShiftResourceFactory.createResources(testClass.getName(), client, testClass.getJavaClass(),
cubeOpenShiftConfiguration.getProperties());
classTemplateProcessor = new ClassTemplateProcessor(client, cubeOpenShiftConfiguration, testClass);
final List<? extends OpenShiftResource> templateResources = classTemplateProcessor.processTemplateResources();
templateDetailsProducer.set(() -> templateResources);
} | java | public void createEnvironment(@Observes(precedence = 10) BeforeClass event, OpenShiftAdapter client,
CubeOpenShiftConfiguration cubeOpenShiftConfiguration) {
final TestClass testClass = event.getTestClass();
log.info(String.format("Creating environment for %s", testClass.getName()));
OpenShiftResourceFactory.createResources(testClass.getName(), client, testClass.getJavaClass(),
cubeOpenShiftConfiguration.getProperties());
classTemplateProcessor = new ClassTemplateProcessor(client, cubeOpenShiftConfiguration, testClass);
final List<? extends OpenShiftResource> templateResources = classTemplateProcessor.processTemplateResources();
templateDetailsProducer.set(() -> templateResources);
} | [
"public",
"void",
"createEnvironment",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"10",
")",
"BeforeClass",
"event",
",",
"OpenShiftAdapter",
"client",
",",
"CubeOpenShiftConfiguration",
"cubeOpenShiftConfiguration",
")",
"{",
"final",
"TestClass",
"testClass",
"=",
"event",
".",
"getTestClass",
"(",
")",
";",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Creating environment for %s\"",
",",
"testClass",
".",
"getName",
"(",
")",
")",
")",
";",
"OpenShiftResourceFactory",
".",
"createResources",
"(",
"testClass",
".",
"getName",
"(",
")",
",",
"client",
",",
"testClass",
".",
"getJavaClass",
"(",
")",
",",
"cubeOpenShiftConfiguration",
".",
"getProperties",
"(",
")",
")",
";",
"classTemplateProcessor",
"=",
"new",
"ClassTemplateProcessor",
"(",
"client",
",",
"cubeOpenShiftConfiguration",
",",
"testClass",
")",
";",
"final",
"List",
"<",
"?",
"extends",
"OpenShiftResource",
">",
"templateResources",
"=",
"classTemplateProcessor",
".",
"processTemplateResources",
"(",
")",
";",
"templateDetailsProducer",
".",
"set",
"(",
"(",
")",
"->",
"templateResources",
")",
";",
"}"
] | Create the environment as specified by @Template or
arq.extension.ce-cube.openshift.template.* properties.
<p>
In the future, this might be handled by starting application Cube
objects, e.g. CreateCube(application), StartCube(application)
<p>
Needs to fire before the containers are started. | [
"Create",
"the",
"environment",
"as",
"specified",
"by"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/CEEnvironmentProcessor.java#L87-L96 |
162,176 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java | DockerContainerObjectBuilder.withContainerObjectClass | public DockerContainerObjectBuilder<T> withContainerObjectClass(Class<T> containerObjectClass) {
if (containerObjectClass == null) {
throw new IllegalArgumentException("container object class cannot be null");
}
this.containerObjectClass = containerObjectClass;
//First we check if this ContainerObject is defining a @CubeDockerFile in static method
final List<Method> methodsWithCubeDockerFile =
ReflectionUtil.getMethodsWithAnnotation(containerObjectClass, CubeDockerFile.class);
if (methodsWithCubeDockerFile.size() > 1) {
throw new IllegalArgumentException(
String.format(
"More than one %s annotation found and only one was expected. Methods where annotation was found are: %s",
CubeDockerFile.class.getSimpleName(), methodsWithCubeDockerFile));
}
classHasMethodWithCubeDockerFile = !methodsWithCubeDockerFile.isEmpty();
classDefinesCubeDockerFile = containerObjectClass.isAnnotationPresent(CubeDockerFile.class);
classDefinesImage = containerObjectClass.isAnnotationPresent(Image.class);
if (classHasMethodWithCubeDockerFile) {
methodWithCubeDockerFile = methodsWithCubeDockerFile.get(0);
boolean isMethodStatic = Modifier.isStatic(methodWithCubeDockerFile.getModifiers());
boolean methodHasNoArguments = methodWithCubeDockerFile.getParameterCount() == 0;
boolean methodReturnsAnArchive = Archive.class.isAssignableFrom(methodWithCubeDockerFile.getReturnType());
if (!isMethodStatic || !methodHasNoArguments || !methodReturnsAnArchive) {
throw new IllegalArgumentException(
String.format("Method %s annotated with %s is expected to be static, no args and return %s.",
methodWithCubeDockerFile, CubeDockerFile.class.getSimpleName(), Archive.class.getSimpleName()));
}
}
// User has defined @CubeDockerfile on the class and a method
if (classHasMethodWithCubeDockerFile && classDefinesCubeDockerFile) {
throw new IllegalArgumentException(
String.format(
"More than one %s annotation found and only one was expected. Both class and method %s has the annotation.",
CubeDockerFile.class.getSimpleName(), methodWithCubeDockerFile));
}
// User has defined @CubeDockerfile and @Image
if ((classHasMethodWithCubeDockerFile || classDefinesCubeDockerFile) && classDefinesImage) {
throw new IllegalArgumentException(
String.format("Container Object %s has defined %s annotation and %s annotation together.",
containerObjectClass.getSimpleName(), Image.class.getSimpleName(),
CubeDockerFile.class.getSimpleName()));
}
// User has not defined either @CubeDockerfile or @Image
if (!classDefinesCubeDockerFile && !classDefinesImage && !classHasMethodWithCubeDockerFile) {
throw new IllegalArgumentException(
String.format("Container Object %s is not annotated with either %s or %s annotations.",
containerObjectClass.getName(), CubeDockerFile.class.getSimpleName(), Image.class.getSimpleName()));
}
return this;
} | java | public DockerContainerObjectBuilder<T> withContainerObjectClass(Class<T> containerObjectClass) {
if (containerObjectClass == null) {
throw new IllegalArgumentException("container object class cannot be null");
}
this.containerObjectClass = containerObjectClass;
//First we check if this ContainerObject is defining a @CubeDockerFile in static method
final List<Method> methodsWithCubeDockerFile =
ReflectionUtil.getMethodsWithAnnotation(containerObjectClass, CubeDockerFile.class);
if (methodsWithCubeDockerFile.size() > 1) {
throw new IllegalArgumentException(
String.format(
"More than one %s annotation found and only one was expected. Methods where annotation was found are: %s",
CubeDockerFile.class.getSimpleName(), methodsWithCubeDockerFile));
}
classHasMethodWithCubeDockerFile = !methodsWithCubeDockerFile.isEmpty();
classDefinesCubeDockerFile = containerObjectClass.isAnnotationPresent(CubeDockerFile.class);
classDefinesImage = containerObjectClass.isAnnotationPresent(Image.class);
if (classHasMethodWithCubeDockerFile) {
methodWithCubeDockerFile = methodsWithCubeDockerFile.get(0);
boolean isMethodStatic = Modifier.isStatic(methodWithCubeDockerFile.getModifiers());
boolean methodHasNoArguments = methodWithCubeDockerFile.getParameterCount() == 0;
boolean methodReturnsAnArchive = Archive.class.isAssignableFrom(methodWithCubeDockerFile.getReturnType());
if (!isMethodStatic || !methodHasNoArguments || !methodReturnsAnArchive) {
throw new IllegalArgumentException(
String.format("Method %s annotated with %s is expected to be static, no args and return %s.",
methodWithCubeDockerFile, CubeDockerFile.class.getSimpleName(), Archive.class.getSimpleName()));
}
}
// User has defined @CubeDockerfile on the class and a method
if (classHasMethodWithCubeDockerFile && classDefinesCubeDockerFile) {
throw new IllegalArgumentException(
String.format(
"More than one %s annotation found and only one was expected. Both class and method %s has the annotation.",
CubeDockerFile.class.getSimpleName(), methodWithCubeDockerFile));
}
// User has defined @CubeDockerfile and @Image
if ((classHasMethodWithCubeDockerFile || classDefinesCubeDockerFile) && classDefinesImage) {
throw new IllegalArgumentException(
String.format("Container Object %s has defined %s annotation and %s annotation together.",
containerObjectClass.getSimpleName(), Image.class.getSimpleName(),
CubeDockerFile.class.getSimpleName()));
}
// User has not defined either @CubeDockerfile or @Image
if (!classDefinesCubeDockerFile && !classDefinesImage && !classHasMethodWithCubeDockerFile) {
throw new IllegalArgumentException(
String.format("Container Object %s is not annotated with either %s or %s annotations.",
containerObjectClass.getName(), CubeDockerFile.class.getSimpleName(), Image.class.getSimpleName()));
}
return this;
} | [
"public",
"DockerContainerObjectBuilder",
"<",
"T",
">",
"withContainerObjectClass",
"(",
"Class",
"<",
"T",
">",
"containerObjectClass",
")",
"{",
"if",
"(",
"containerObjectClass",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"container object class cannot be null\"",
")",
";",
"}",
"this",
".",
"containerObjectClass",
"=",
"containerObjectClass",
";",
"//First we check if this ContainerObject is defining a @CubeDockerFile in static method",
"final",
"List",
"<",
"Method",
">",
"methodsWithCubeDockerFile",
"=",
"ReflectionUtil",
".",
"getMethodsWithAnnotation",
"(",
"containerObjectClass",
",",
"CubeDockerFile",
".",
"class",
")",
";",
"if",
"(",
"methodsWithCubeDockerFile",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"More than one %s annotation found and only one was expected. Methods where annotation was found are: %s\"",
",",
"CubeDockerFile",
".",
"class",
".",
"getSimpleName",
"(",
")",
",",
"methodsWithCubeDockerFile",
")",
")",
";",
"}",
"classHasMethodWithCubeDockerFile",
"=",
"!",
"methodsWithCubeDockerFile",
".",
"isEmpty",
"(",
")",
";",
"classDefinesCubeDockerFile",
"=",
"containerObjectClass",
".",
"isAnnotationPresent",
"(",
"CubeDockerFile",
".",
"class",
")",
";",
"classDefinesImage",
"=",
"containerObjectClass",
".",
"isAnnotationPresent",
"(",
"Image",
".",
"class",
")",
";",
"if",
"(",
"classHasMethodWithCubeDockerFile",
")",
"{",
"methodWithCubeDockerFile",
"=",
"methodsWithCubeDockerFile",
".",
"get",
"(",
"0",
")",
";",
"boolean",
"isMethodStatic",
"=",
"Modifier",
".",
"isStatic",
"(",
"methodWithCubeDockerFile",
".",
"getModifiers",
"(",
")",
")",
";",
"boolean",
"methodHasNoArguments",
"=",
"methodWithCubeDockerFile",
".",
"getParameterCount",
"(",
")",
"==",
"0",
";",
"boolean",
"methodReturnsAnArchive",
"=",
"Archive",
".",
"class",
".",
"isAssignableFrom",
"(",
"methodWithCubeDockerFile",
".",
"getReturnType",
"(",
")",
")",
";",
"if",
"(",
"!",
"isMethodStatic",
"||",
"!",
"methodHasNoArguments",
"||",
"!",
"methodReturnsAnArchive",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Method %s annotated with %s is expected to be static, no args and return %s.\"",
",",
"methodWithCubeDockerFile",
",",
"CubeDockerFile",
".",
"class",
".",
"getSimpleName",
"(",
")",
",",
"Archive",
".",
"class",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"}",
"// User has defined @CubeDockerfile on the class and a method",
"if",
"(",
"classHasMethodWithCubeDockerFile",
"&&",
"classDefinesCubeDockerFile",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"More than one %s annotation found and only one was expected. Both class and method %s has the annotation.\"",
",",
"CubeDockerFile",
".",
"class",
".",
"getSimpleName",
"(",
")",
",",
"methodWithCubeDockerFile",
")",
")",
";",
"}",
"// User has defined @CubeDockerfile and @Image",
"if",
"(",
"(",
"classHasMethodWithCubeDockerFile",
"||",
"classDefinesCubeDockerFile",
")",
"&&",
"classDefinesImage",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Container Object %s has defined %s annotation and %s annotation together.\"",
",",
"containerObjectClass",
".",
"getSimpleName",
"(",
")",
",",
"Image",
".",
"class",
".",
"getSimpleName",
"(",
")",
",",
"CubeDockerFile",
".",
"class",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"// User has not defined either @CubeDockerfile or @Image",
"if",
"(",
"!",
"classDefinesCubeDockerFile",
"&&",
"!",
"classDefinesImage",
"&&",
"!",
"classHasMethodWithCubeDockerFile",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Container Object %s is not annotated with either %s or %s annotations.\"",
",",
"containerObjectClass",
".",
"getName",
"(",
")",
",",
"CubeDockerFile",
".",
"class",
".",
"getSimpleName",
"(",
")",
",",
"Image",
".",
"class",
".",
"getSimpleName",
"(",
")",
")",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Specifies the container object class to be instantiated
@param containerObjectClass
container object class to be instantiated
@return the current builder instance | [
"Specifies",
"the",
"container",
"object",
"class",
"to",
"be",
"instantiated"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java#L184-L241 |
162,177 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java | DockerContainerObjectBuilder.withEnrichers | public DockerContainerObjectBuilder<T> withEnrichers(Collection<TestEnricher> enrichers) {
if (enrichers == null) {
throw new IllegalArgumentException("enrichers cannot be null");
}
this.enrichers = enrichers;
return this;
} | java | public DockerContainerObjectBuilder<T> withEnrichers(Collection<TestEnricher> enrichers) {
if (enrichers == null) {
throw new IllegalArgumentException("enrichers cannot be null");
}
this.enrichers = enrichers;
return this;
} | [
"public",
"DockerContainerObjectBuilder",
"<",
"T",
">",
"withEnrichers",
"(",
"Collection",
"<",
"TestEnricher",
">",
"enrichers",
")",
"{",
"if",
"(",
"enrichers",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"enrichers cannot be null\"",
")",
";",
"}",
"this",
".",
"enrichers",
"=",
"enrichers",
";",
"return",
"this",
";",
"}"
] | Specifies the list of enrichers that will be used to enrich the container object.
@param enrichers
list of enrichers that will be used to enrich the container object
@return the current builder instance | [
"Specifies",
"the",
"list",
"of",
"enrichers",
"that",
"will",
"be",
"used",
"to",
"enrich",
"the",
"container",
"object",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java#L282-L288 |
162,178 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java | DockerContainerObjectBuilder.build | public T build() throws IllegalAccessException, IOException, InvocationTargetException {
generatedConfigutation = new CubeContainer();
findContainerName();
// if needed, prepare prepare resources required to build a docker image
prepareImageBuild();
// instantiate container object
instantiateContainerObject();
// enrich container object (without cube instance)
enrichContainerObjectBeforeCube();
// extract configuration from container object class
extractConfigurationFromContainerObject();
// merge received configuration with extracted configuration
mergeContainerObjectConfiguration();
// create/start/register associated cube
initializeCube();
// enrich container object (with cube instance)
enrichContainerObjectWithCube();
// return created container object
return containerObjectInstance;
} | java | public T build() throws IllegalAccessException, IOException, InvocationTargetException {
generatedConfigutation = new CubeContainer();
findContainerName();
// if needed, prepare prepare resources required to build a docker image
prepareImageBuild();
// instantiate container object
instantiateContainerObject();
// enrich container object (without cube instance)
enrichContainerObjectBeforeCube();
// extract configuration from container object class
extractConfigurationFromContainerObject();
// merge received configuration with extracted configuration
mergeContainerObjectConfiguration();
// create/start/register associated cube
initializeCube();
// enrich container object (with cube instance)
enrichContainerObjectWithCube();
// return created container object
return containerObjectInstance;
} | [
"public",
"T",
"build",
"(",
")",
"throws",
"IllegalAccessException",
",",
"IOException",
",",
"InvocationTargetException",
"{",
"generatedConfigutation",
"=",
"new",
"CubeContainer",
"(",
")",
";",
"findContainerName",
"(",
")",
";",
"// if needed, prepare prepare resources required to build a docker image",
"prepareImageBuild",
"(",
")",
";",
"// instantiate container object",
"instantiateContainerObject",
"(",
")",
";",
"// enrich container object (without cube instance)",
"enrichContainerObjectBeforeCube",
"(",
")",
";",
"// extract configuration from container object class",
"extractConfigurationFromContainerObject",
"(",
")",
";",
"// merge received configuration with extracted configuration",
"mergeContainerObjectConfiguration",
"(",
")",
";",
"// create/start/register associated cube",
"initializeCube",
"(",
")",
";",
"// enrich container object (with cube instance)",
"enrichContainerObjectWithCube",
"(",
")",
";",
"// return created container object",
"return",
"containerObjectInstance",
";",
"}"
] | Triggers the building process, builds, creates and starts the docker container associated with the requested
container object, creates the container object and returns it
@return the created container object
@throws IllegalAccessException
if there is an error accessing the container object fields
@throws IOException
if there is an I/O error while preparing the docker build
@throws InvocationTargetException
if there is an error while calling the DockerFile archive creation | [
"Triggers",
"the",
"building",
"process",
"builds",
"creates",
"and",
"starts",
"the",
"docker",
"container",
"associated",
"with",
"the",
"requested",
"container",
"object",
"creates",
"the",
"container",
"object",
"and",
"returns",
"it"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/containerobject/DockerContainerObjectBuilder.java#L318-L338 |
162,179 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/DockerContainerDefinitionParser.java | DockerContainerDefinitionParser.resolveDockerDefinition | private static Path resolveDockerDefinition(Path fullpath) {
final Path ymlPath = fullpath.resolveSibling(fullpath.getFileName() + ".yml");
if (Files.exists(ymlPath)) {
return ymlPath;
} else {
final Path yamlPath = fullpath.resolveSibling(fullpath.getFileName() + ".yaml");
if (Files.exists(yamlPath)) {
return yamlPath;
}
}
return null;
} | java | private static Path resolveDockerDefinition(Path fullpath) {
final Path ymlPath = fullpath.resolveSibling(fullpath.getFileName() + ".yml");
if (Files.exists(ymlPath)) {
return ymlPath;
} else {
final Path yamlPath = fullpath.resolveSibling(fullpath.getFileName() + ".yaml");
if (Files.exists(yamlPath)) {
return yamlPath;
}
}
return null;
} | [
"private",
"static",
"Path",
"resolveDockerDefinition",
"(",
"Path",
"fullpath",
")",
"{",
"final",
"Path",
"ymlPath",
"=",
"fullpath",
".",
"resolveSibling",
"(",
"fullpath",
".",
"getFileName",
"(",
")",
"+",
"\".yml\"",
")",
";",
"if",
"(",
"Files",
".",
"exists",
"(",
"ymlPath",
")",
")",
"{",
"return",
"ymlPath",
";",
"}",
"else",
"{",
"final",
"Path",
"yamlPath",
"=",
"fullpath",
".",
"resolveSibling",
"(",
"fullpath",
".",
"getFileName",
"(",
")",
"+",
"\".yaml\"",
")",
";",
"if",
"(",
"Files",
".",
"exists",
"(",
"yamlPath",
")",
")",
"{",
"return",
"yamlPath",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Resolves current full path with .yml and .yaml extensions
@param fullpath
without extension.
@return Path of existing definition or null | [
"Resolves",
"current",
"full",
"path",
"with",
".",
"yml",
"and",
".",
"yaml",
"extensions"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/DockerContainerDefinitionParser.java#L206-L218 |
162,180 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/ResourceUtil.java | ResourceUtil.awaitRoute | public static void awaitRoute(URL routeUrl, int timeout, TimeUnit timeoutUnit, int repetitions, int... statusCodes) {
AtomicInteger successfulAwaitsInARow = new AtomicInteger(0);
await().atMost(timeout, timeoutUnit).until(() -> {
if (tryConnect(routeUrl, statusCodes)) {
successfulAwaitsInARow.incrementAndGet();
} else {
successfulAwaitsInARow.set(0);
}
return successfulAwaitsInARow.get() >= repetitions;
});
} | java | public static void awaitRoute(URL routeUrl, int timeout, TimeUnit timeoutUnit, int repetitions, int... statusCodes) {
AtomicInteger successfulAwaitsInARow = new AtomicInteger(0);
await().atMost(timeout, timeoutUnit).until(() -> {
if (tryConnect(routeUrl, statusCodes)) {
successfulAwaitsInARow.incrementAndGet();
} else {
successfulAwaitsInARow.set(0);
}
return successfulAwaitsInARow.get() >= repetitions;
});
} | [
"public",
"static",
"void",
"awaitRoute",
"(",
"URL",
"routeUrl",
",",
"int",
"timeout",
",",
"TimeUnit",
"timeoutUnit",
",",
"int",
"repetitions",
",",
"int",
"...",
"statusCodes",
")",
"{",
"AtomicInteger",
"successfulAwaitsInARow",
"=",
"new",
"AtomicInteger",
"(",
"0",
")",
";",
"await",
"(",
")",
".",
"atMost",
"(",
"timeout",
",",
"timeoutUnit",
")",
".",
"until",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"tryConnect",
"(",
"routeUrl",
",",
"statusCodes",
")",
")",
"{",
"successfulAwaitsInARow",
".",
"incrementAndGet",
"(",
")",
";",
"}",
"else",
"{",
"successfulAwaitsInARow",
".",
"set",
"(",
"0",
")",
";",
"}",
"return",
"successfulAwaitsInARow",
".",
"get",
"(",
")",
">=",
"repetitions",
";",
"}",
")",
";",
"}"
] | Waits for the timeout duration until the url responds with correct status code
@param routeUrl URL to check (usually a route one)
@param timeout Max timeout value to await for route readiness.
If not set, default timeout value is set to 5.
@param timeoutUnit TimeUnit used for timeout duration.
If not set, Minutes is used as default TimeUnit.
@param repetitions How many times in a row the route must respond successfully to be considered available.
@param statusCodes list of status code that might return that service is up and running.
It is used as OR, so if one returns true, then the route is considered valid.
If not set, then only 200 status code is used. | [
"Waits",
"for",
"the",
"timeout",
"duration",
"until",
"the",
"url",
"responds",
"with",
"correct",
"status",
"code"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/ResourceUtil.java#L190-L200 |
162,181 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/ReflectionUtil.java | ReflectionUtil.getConstructor | public static Constructor<?> getConstructor(final Class<?> clazz,
final Class<?>... argumentTypes) throws NoSuchMethodException {
try {
return AccessController
.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
public Constructor<?> run()
throws NoSuchMethodException {
return clazz.getConstructor(argumentTypes);
}
});
}
// Unwrap
catch (final PrivilegedActionException pae) {
final Throwable t = pae.getCause();
// Rethrow
if (t instanceof NoSuchMethodException) {
throw (NoSuchMethodException) t;
} else {
// No other checked Exception thrown by Class.getConstructor
try {
throw (RuntimeException) t;
}
// Just in case we've really messed up
catch (final ClassCastException cce) {
throw new RuntimeException(
"Obtained unchecked Exception; this code should never be reached",
t);
}
}
}
} | java | public static Constructor<?> getConstructor(final Class<?> clazz,
final Class<?>... argumentTypes) throws NoSuchMethodException {
try {
return AccessController
.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
public Constructor<?> run()
throws NoSuchMethodException {
return clazz.getConstructor(argumentTypes);
}
});
}
// Unwrap
catch (final PrivilegedActionException pae) {
final Throwable t = pae.getCause();
// Rethrow
if (t instanceof NoSuchMethodException) {
throw (NoSuchMethodException) t;
} else {
// No other checked Exception thrown by Class.getConstructor
try {
throw (RuntimeException) t;
}
// Just in case we've really messed up
catch (final ClassCastException cce) {
throw new RuntimeException(
"Obtained unchecked Exception; this code should never be reached",
t);
}
}
}
} | [
"public",
"static",
"Constructor",
"<",
"?",
">",
"getConstructor",
"(",
"final",
"Class",
"<",
"?",
">",
"clazz",
",",
"final",
"Class",
"<",
"?",
">",
"...",
"argumentTypes",
")",
"throws",
"NoSuchMethodException",
"{",
"try",
"{",
"return",
"AccessController",
".",
"doPrivileged",
"(",
"new",
"PrivilegedExceptionAction",
"<",
"Constructor",
"<",
"?",
">",
">",
"(",
")",
"{",
"public",
"Constructor",
"<",
"?",
">",
"run",
"(",
")",
"throws",
"NoSuchMethodException",
"{",
"return",
"clazz",
".",
"getConstructor",
"(",
"argumentTypes",
")",
";",
"}",
"}",
")",
";",
"}",
"// Unwrap",
"catch",
"(",
"final",
"PrivilegedActionException",
"pae",
")",
"{",
"final",
"Throwable",
"t",
"=",
"pae",
".",
"getCause",
"(",
")",
";",
"// Rethrow",
"if",
"(",
"t",
"instanceof",
"NoSuchMethodException",
")",
"{",
"throw",
"(",
"NoSuchMethodException",
")",
"t",
";",
"}",
"else",
"{",
"// No other checked Exception thrown by Class.getConstructor",
"try",
"{",
"throw",
"(",
"RuntimeException",
")",
"t",
";",
"}",
"// Just in case we've really messed up",
"catch",
"(",
"final",
"ClassCastException",
"cce",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Obtained unchecked Exception; this code should never be reached\"",
",",
"t",
")",
";",
"}",
"}",
"}",
"}"
] | Obtains the Constructor specified from the given Class and argument types
@throws NoSuchMethodException | [
"Obtains",
"the",
"Constructor",
"specified",
"from",
"the",
"given",
"Class",
"and",
"argument",
"types"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/ReflectionUtil.java#L53-L83 |
162,182 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/ConfigUtil.java | ConfigUtil.getStringProperty | public static String getStringProperty(String name, Map<String, String> map, String defaultValue) {
if (map.containsKey(name) && Strings.isNotNullOrEmpty(map.get(name))) {
defaultValue = map.get(name);
}
return getPropertyOrEnvironmentVariable(name, defaultValue);
} | java | public static String getStringProperty(String name, Map<String, String> map, String defaultValue) {
if (map.containsKey(name) && Strings.isNotNullOrEmpty(map.get(name))) {
defaultValue = map.get(name);
}
return getPropertyOrEnvironmentVariable(name, defaultValue);
} | [
"public",
"static",
"String",
"getStringProperty",
"(",
"String",
"name",
",",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"String",
"defaultValue",
")",
"{",
"if",
"(",
"map",
".",
"containsKey",
"(",
"name",
")",
"&&",
"Strings",
".",
"isNotNullOrEmpty",
"(",
"map",
".",
"get",
"(",
"name",
")",
")",
")",
"{",
"defaultValue",
"=",
"map",
".",
"get",
"(",
"name",
")",
";",
"}",
"return",
"getPropertyOrEnvironmentVariable",
"(",
"name",
",",
"defaultValue",
")",
";",
"}"
] | Gets a property from system, environment or an external map.
The lookup order is system > env > map > defaultValue.
@param name
The name of the property.
@param map
The external map.
@param defaultValue
The value that should be used if property is not found. | [
"Gets",
"a",
"property",
"from",
"system",
"environment",
"or",
"an",
"external",
"map",
".",
"The",
"lookup",
"order",
"is",
"system",
">",
"env",
">",
"map",
">",
"defaultValue",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/ConfigUtil.java#L25-L30 |
162,183 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistantTemplate.java | OpenShiftAssistantTemplate.parameter | public OpenShiftAssistantTemplate parameter(String name, String value) {
parameterValues.put(name, value);
return this;
} | java | public OpenShiftAssistantTemplate parameter(String name, String value) {
parameterValues.put(name, value);
return this;
} | [
"public",
"OpenShiftAssistantTemplate",
"parameter",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"parameterValues",
".",
"put",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Stores template parameters for OpenShiftAssistantTemplate.
@param name template parameter name
@param value template parameter value | [
"Stores",
"template",
"parameters",
"for",
"OpenShiftAssistantTemplate",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/client/OpenShiftAssistantTemplate.java#L37-L40 |
162,184 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/Timespan.java | Timespan.create | public static Timespan create(Timespan... timespans) {
if (timespans == null) {
return null;
}
if (timespans.length == 0) {
return ZERO_MILLISECONDS;
}
Timespan res = timespans[0];
for (int i = 1; i < timespans.length; i++) {
Timespan timespan = timespans[i];
res = res.add(timespan);
}
return res;
} | java | public static Timespan create(Timespan... timespans) {
if (timespans == null) {
return null;
}
if (timespans.length == 0) {
return ZERO_MILLISECONDS;
}
Timespan res = timespans[0];
for (int i = 1; i < timespans.length; i++) {
Timespan timespan = timespans[i];
res = res.add(timespan);
}
return res;
} | [
"public",
"static",
"Timespan",
"create",
"(",
"Timespan",
"...",
"timespans",
")",
"{",
"if",
"(",
"timespans",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"timespans",
".",
"length",
"==",
"0",
")",
"{",
"return",
"ZERO_MILLISECONDS",
";",
"}",
"Timespan",
"res",
"=",
"timespans",
"[",
"0",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"timespans",
".",
"length",
";",
"i",
"++",
")",
"{",
"Timespan",
"timespan",
"=",
"timespans",
"[",
"i",
"]",
";",
"res",
"=",
"res",
".",
"add",
"(",
"timespan",
")",
";",
"}",
"return",
"res",
";",
"}"
] | Creates a timespan from a list of other timespans.
@return a timespan representing the sum of all the timespans provided | [
"Creates",
"a",
"timespan",
"from",
"a",
"list",
"of",
"other",
"timespans",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Timespan.java#L470-L487 |
162,185 | arquillian/arquillian-cube | docker/drone/src/main/java/org/arquillian/cube/docker/drone/InstallSeleniumCube.java | InstallSeleniumCube.install | public void install(@Observes(precedence = 90) CubeDockerConfiguration configuration,
ArquillianDescriptor arquillianDescriptor) {
DockerCompositions cubes = configuration.getDockerContainersContent();
final SeleniumContainers seleniumContainers =
SeleniumContainers.create(getBrowser(arquillianDescriptor), cubeDroneConfigurationInstance.get());
cubes.add(seleniumContainers.getSeleniumContainerName(), seleniumContainers.getSeleniumContainer());
final boolean recording = cubeDroneConfigurationInstance.get().isRecording();
if (recording) {
cubes.add(seleniumContainers.getVncContainerName(), seleniumContainers.getVncContainer());
cubes.add(seleniumContainers.getVideoConverterContainerName(),
seleniumContainers.getVideoConverterContainer());
}
seleniumContainersInstanceProducer.set(seleniumContainers);
System.out.println("SELENIUM INSTALLED");
System.out.println(ConfigUtil.dump(cubes));
} | java | public void install(@Observes(precedence = 90) CubeDockerConfiguration configuration,
ArquillianDescriptor arquillianDescriptor) {
DockerCompositions cubes = configuration.getDockerContainersContent();
final SeleniumContainers seleniumContainers =
SeleniumContainers.create(getBrowser(arquillianDescriptor), cubeDroneConfigurationInstance.get());
cubes.add(seleniumContainers.getSeleniumContainerName(), seleniumContainers.getSeleniumContainer());
final boolean recording = cubeDroneConfigurationInstance.get().isRecording();
if (recording) {
cubes.add(seleniumContainers.getVncContainerName(), seleniumContainers.getVncContainer());
cubes.add(seleniumContainers.getVideoConverterContainerName(),
seleniumContainers.getVideoConverterContainer());
}
seleniumContainersInstanceProducer.set(seleniumContainers);
System.out.println("SELENIUM INSTALLED");
System.out.println(ConfigUtil.dump(cubes));
} | [
"public",
"void",
"install",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"90",
")",
"CubeDockerConfiguration",
"configuration",
",",
"ArquillianDescriptor",
"arquillianDescriptor",
")",
"{",
"DockerCompositions",
"cubes",
"=",
"configuration",
".",
"getDockerContainersContent",
"(",
")",
";",
"final",
"SeleniumContainers",
"seleniumContainers",
"=",
"SeleniumContainers",
".",
"create",
"(",
"getBrowser",
"(",
"arquillianDescriptor",
")",
",",
"cubeDroneConfigurationInstance",
".",
"get",
"(",
")",
")",
";",
"cubes",
".",
"add",
"(",
"seleniumContainers",
".",
"getSeleniumContainerName",
"(",
")",
",",
"seleniumContainers",
".",
"getSeleniumContainer",
"(",
")",
")",
";",
"final",
"boolean",
"recording",
"=",
"cubeDroneConfigurationInstance",
".",
"get",
"(",
")",
".",
"isRecording",
"(",
")",
";",
"if",
"(",
"recording",
")",
"{",
"cubes",
".",
"add",
"(",
"seleniumContainers",
".",
"getVncContainerName",
"(",
")",
",",
"seleniumContainers",
".",
"getVncContainer",
"(",
")",
")",
";",
"cubes",
".",
"add",
"(",
"seleniumContainers",
".",
"getVideoConverterContainerName",
"(",
")",
",",
"seleniumContainers",
".",
"getVideoConverterContainer",
"(",
")",
")",
";",
"}",
"seleniumContainersInstanceProducer",
".",
"set",
"(",
"seleniumContainers",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"SELENIUM INSTALLED\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"ConfigUtil",
".",
"dump",
"(",
"cubes",
")",
")",
";",
"}"
] | ten less than Cube Q | [
"ten",
"less",
"than",
"Cube",
"Q"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/drone/src/main/java/org/arquillian/cube/docker/drone/InstallSeleniumCube.java#L31-L51 |
162,186 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/util/DockerMachine.java | DockerMachine.startDockerMachine | public void startDockerMachine(String cliPathExec, String machineName) {
commandLineExecutor.execCommand(createDockerMachineCommand(cliPathExec), "start", machineName);
this.manuallyStarted = true;
} | java | public void startDockerMachine(String cliPathExec, String machineName) {
commandLineExecutor.execCommand(createDockerMachineCommand(cliPathExec), "start", machineName);
this.manuallyStarted = true;
} | [
"public",
"void",
"startDockerMachine",
"(",
"String",
"cliPathExec",
",",
"String",
"machineName",
")",
"{",
"commandLineExecutor",
".",
"execCommand",
"(",
"createDockerMachineCommand",
"(",
"cliPathExec",
")",
",",
"\"start\"",
",",
"machineName",
")",
";",
"this",
".",
"manuallyStarted",
"=",
"true",
";",
"}"
] | Starts given docker machine.
@param cliPathExec
location of docker-machine or null if it is on PATH.
@param machineName
to be started. | [
"Starts",
"given",
"docker",
"machine",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/util/DockerMachine.java#L53-L56 |
162,187 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/util/DockerMachine.java | DockerMachine.isDockerMachineInstalled | public boolean isDockerMachineInstalled(String cliPathExec) {
try {
commandLineExecutor.execCommand(createDockerMachineCommand(cliPathExec));
return true;
} catch (Exception e) {
return false;
}
} | java | public boolean isDockerMachineInstalled(String cliPathExec) {
try {
commandLineExecutor.execCommand(createDockerMachineCommand(cliPathExec));
return true;
} catch (Exception e) {
return false;
}
} | [
"public",
"boolean",
"isDockerMachineInstalled",
"(",
"String",
"cliPathExec",
")",
"{",
"try",
"{",
"commandLineExecutor",
".",
"execCommand",
"(",
"createDockerMachineCommand",
"(",
"cliPathExec",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Checks if Docker Machine is installed by running docker-machine and inspect the result.
@param cliPathExec
location of docker-machine or null if it is on PATH.
@return true if it is installed, false otherwise. | [
"Checks",
"if",
"Docker",
"Machine",
"is",
"installed",
"by",
"running",
"docker",
"-",
"machine",
"and",
"inspect",
"the",
"result",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/util/DockerMachine.java#L85-L92 |
162,188 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/config/DockerCompositions.java | DockerCompositions.overrideCubeProperties | public void overrideCubeProperties(DockerCompositions overrideDockerCompositions) {
final Set<String> containerIds = overrideDockerCompositions.getContainerIds();
for (String containerId : containerIds) {
// main definition of containers contains a container that must be overrode
if (containers.containsKey(containerId)) {
final CubeContainer cubeContainer = containers.get(containerId);
final CubeContainer overrideCubeContainer = overrideDockerCompositions.get(containerId);
cubeContainer.setRemoveVolumes(overrideCubeContainer.getRemoveVolumes());
cubeContainer.setAlwaysPull(overrideCubeContainer.getAlwaysPull());
if (overrideCubeContainer.hasAwait()) {
cubeContainer.setAwait(overrideCubeContainer.getAwait());
}
if (overrideCubeContainer.hasBeforeStop()) {
cubeContainer.setBeforeStop(overrideCubeContainer.getBeforeStop());
}
if (overrideCubeContainer.isManual()) {
cubeContainer.setManual(overrideCubeContainer.isManual());
}
if (overrideCubeContainer.isKillContainer()) {
cubeContainer.setKillContainer(overrideCubeContainer.isKillContainer());
}
} else {
logger.warning(String.format("Overriding Container %s are not defined in main definition of containers.",
containerId));
}
}
} | java | public void overrideCubeProperties(DockerCompositions overrideDockerCompositions) {
final Set<String> containerIds = overrideDockerCompositions.getContainerIds();
for (String containerId : containerIds) {
// main definition of containers contains a container that must be overrode
if (containers.containsKey(containerId)) {
final CubeContainer cubeContainer = containers.get(containerId);
final CubeContainer overrideCubeContainer = overrideDockerCompositions.get(containerId);
cubeContainer.setRemoveVolumes(overrideCubeContainer.getRemoveVolumes());
cubeContainer.setAlwaysPull(overrideCubeContainer.getAlwaysPull());
if (overrideCubeContainer.hasAwait()) {
cubeContainer.setAwait(overrideCubeContainer.getAwait());
}
if (overrideCubeContainer.hasBeforeStop()) {
cubeContainer.setBeforeStop(overrideCubeContainer.getBeforeStop());
}
if (overrideCubeContainer.isManual()) {
cubeContainer.setManual(overrideCubeContainer.isManual());
}
if (overrideCubeContainer.isKillContainer()) {
cubeContainer.setKillContainer(overrideCubeContainer.isKillContainer());
}
} else {
logger.warning(String.format("Overriding Container %s are not defined in main definition of containers.",
containerId));
}
}
} | [
"public",
"void",
"overrideCubeProperties",
"(",
"DockerCompositions",
"overrideDockerCompositions",
")",
"{",
"final",
"Set",
"<",
"String",
">",
"containerIds",
"=",
"overrideDockerCompositions",
".",
"getContainerIds",
"(",
")",
";",
"for",
"(",
"String",
"containerId",
":",
"containerIds",
")",
"{",
"// main definition of containers contains a container that must be overrode",
"if",
"(",
"containers",
".",
"containsKey",
"(",
"containerId",
")",
")",
"{",
"final",
"CubeContainer",
"cubeContainer",
"=",
"containers",
".",
"get",
"(",
"containerId",
")",
";",
"final",
"CubeContainer",
"overrideCubeContainer",
"=",
"overrideDockerCompositions",
".",
"get",
"(",
"containerId",
")",
";",
"cubeContainer",
".",
"setRemoveVolumes",
"(",
"overrideCubeContainer",
".",
"getRemoveVolumes",
"(",
")",
")",
";",
"cubeContainer",
".",
"setAlwaysPull",
"(",
"overrideCubeContainer",
".",
"getAlwaysPull",
"(",
")",
")",
";",
"if",
"(",
"overrideCubeContainer",
".",
"hasAwait",
"(",
")",
")",
"{",
"cubeContainer",
".",
"setAwait",
"(",
"overrideCubeContainer",
".",
"getAwait",
"(",
")",
")",
";",
"}",
"if",
"(",
"overrideCubeContainer",
".",
"hasBeforeStop",
"(",
")",
")",
"{",
"cubeContainer",
".",
"setBeforeStop",
"(",
"overrideCubeContainer",
".",
"getBeforeStop",
"(",
")",
")",
";",
"}",
"if",
"(",
"overrideCubeContainer",
".",
"isManual",
"(",
")",
")",
"{",
"cubeContainer",
".",
"setManual",
"(",
"overrideCubeContainer",
".",
"isManual",
"(",
")",
")",
";",
"}",
"if",
"(",
"overrideCubeContainer",
".",
"isKillContainer",
"(",
")",
")",
"{",
"cubeContainer",
".",
"setKillContainer",
"(",
"overrideCubeContainer",
".",
"isKillContainer",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"logger",
".",
"warning",
"(",
"String",
".",
"format",
"(",
"\"Overriding Container %s are not defined in main definition of containers.\"",
",",
"containerId",
")",
")",
";",
"}",
"}",
"}"
] | This method only overrides properties that are specific from Cube like await strategy or before stop events.
@param overrideDockerCompositions
that contains information to override. | [
"This",
"method",
"only",
"overrides",
"properties",
"that",
"are",
"specific",
"from",
"Cube",
"like",
"await",
"strategy",
"or",
"before",
"stop",
"events",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/client/config/DockerCompositions.java#L109-L142 |
162,189 | arquillian/arquillian-cube | docker/docker/src/main/java/org/arquillian/cube/docker/impl/docker/compose/DockerComposeEnvironmentVarResolver.java | DockerComposeEnvironmentVarResolver.replaceParameters | public static String replaceParameters(final InputStream stream) {
String content = IOUtil.asStringPreservingNewLines(stream);
return resolvePlaceholders(content);
} | java | public static String replaceParameters(final InputStream stream) {
String content = IOUtil.asStringPreservingNewLines(stream);
return resolvePlaceholders(content);
} | [
"public",
"static",
"String",
"replaceParameters",
"(",
"final",
"InputStream",
"stream",
")",
"{",
"String",
"content",
"=",
"IOUtil",
".",
"asStringPreservingNewLines",
"(",
"stream",
")",
";",
"return",
"resolvePlaceholders",
"(",
"content",
")",
";",
"}"
] | Method that takes an inputstream, read it preserving the end lines, and subtitute using commons-lang-3 calls
the variables, first searching as system properties vars and then in environment var list.
In case of missing the property is replaced by white space.
@param stream
@return | [
"Method",
"that",
"takes",
"an",
"inputstream",
"read",
"it",
"preserving",
"the",
"end",
"lines",
"and",
"subtitute",
"using",
"commons",
"-",
"lang",
"-",
"3",
"calls",
"the",
"variables",
"first",
"searching",
"as",
"system",
"properties",
"vars",
"and",
"then",
"in",
"environment",
"var",
"list",
".",
"In",
"case",
"of",
"missing",
"the",
"property",
"is",
"replaced",
"by",
"white",
"space",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/docker/src/main/java/org/arquillian/cube/docker/impl/docker/compose/DockerComposeEnvironmentVarResolver.java#L22-L25 |
162,190 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/Strings.java | Strings.join | public static String join(final Collection<?> collection, final String separator) {
StringBuffer buffer = new StringBuffer();
boolean first = true;
Iterator<?> iter = collection.iterator();
while (iter.hasNext()) {
Object next = iter.next();
if (first) {
first = false;
} else {
buffer.append(separator);
}
buffer.append(next);
}
return buffer.toString();
} | java | public static String join(final Collection<?> collection, final String separator) {
StringBuffer buffer = new StringBuffer();
boolean first = true;
Iterator<?> iter = collection.iterator();
while (iter.hasNext()) {
Object next = iter.next();
if (first) {
first = false;
} else {
buffer.append(separator);
}
buffer.append(next);
}
return buffer.toString();
} | [
"public",
"static",
"String",
"join",
"(",
"final",
"Collection",
"<",
"?",
">",
"collection",
",",
"final",
"String",
"separator",
")",
"{",
"StringBuffer",
"buffer",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"boolean",
"first",
"=",
"true",
";",
"Iterator",
"<",
"?",
">",
"iter",
"=",
"collection",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"Object",
"next",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"first",
")",
"{",
"first",
"=",
"false",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"separator",
")",
";",
"}",
"buffer",
".",
"append",
"(",
"next",
")",
";",
"}",
"return",
"buffer",
".",
"toString",
"(",
")",
";",
"}"
] | joins a collection of objects together as a String using a separator | [
"joins",
"a",
"collection",
"of",
"objects",
"together",
"as",
"a",
"String",
"using",
"a",
"separator"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Strings.java#L26-L40 |
162,191 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/Strings.java | Strings.splitAsList | public static List<String> splitAsList(String text, String delimiter) {
List<String> answer = new ArrayList<String>();
if (text != null && text.length() > 0) {
answer.addAll(Arrays.asList(text.split(delimiter)));
}
return answer;
} | java | public static List<String> splitAsList(String text, String delimiter) {
List<String> answer = new ArrayList<String>();
if (text != null && text.length() > 0) {
answer.addAll(Arrays.asList(text.split(delimiter)));
}
return answer;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"splitAsList",
"(",
"String",
"text",
",",
"String",
"delimiter",
")",
"{",
"List",
"<",
"String",
">",
"answer",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"answer",
".",
"addAll",
"(",
"Arrays",
".",
"asList",
"(",
"text",
".",
"split",
"(",
"delimiter",
")",
")",
")",
";",
"}",
"return",
"answer",
";",
"}"
] | splits a string into a list of strings, ignoring the empty string | [
"splits",
"a",
"string",
"into",
"a",
"list",
"of",
"strings",
"ignoring",
"the",
"empty",
"string"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Strings.java#L45-L51 |
162,192 | arquillian/arquillian-cube | core/src/main/java/org/arquillian/cube/impl/util/Strings.java | Strings.splitAndTrimAsList | public static List<String> splitAndTrimAsList(String text, String sep) {
ArrayList<String> answer = new ArrayList<>();
if (text != null && text.length() > 0) {
for (String v : text.split(sep)) {
String trim = v.trim();
if (trim.length() > 0) {
answer.add(trim);
}
}
}
return answer;
} | java | public static List<String> splitAndTrimAsList(String text, String sep) {
ArrayList<String> answer = new ArrayList<>();
if (text != null && text.length() > 0) {
for (String v : text.split(sep)) {
String trim = v.trim();
if (trim.length() > 0) {
answer.add(trim);
}
}
}
return answer;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"splitAndTrimAsList",
"(",
"String",
"text",
",",
"String",
"sep",
")",
"{",
"ArrayList",
"<",
"String",
">",
"answer",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"text",
"!=",
"null",
"&&",
"text",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"String",
"v",
":",
"text",
".",
"split",
"(",
"sep",
")",
")",
"{",
"String",
"trim",
"=",
"v",
".",
"trim",
"(",
")",
";",
"if",
"(",
"trim",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"answer",
".",
"add",
"(",
"trim",
")",
";",
"}",
"}",
"}",
"return",
"answer",
";",
"}"
] | splits a string into a list of strings. Trims the results and ignores empty strings | [
"splits",
"a",
"string",
"into",
"a",
"list",
"of",
"strings",
".",
"Trims",
"the",
"results",
"and",
"ignores",
"empty",
"strings"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/core/src/main/java/org/arquillian/cube/impl/util/Strings.java#L56-L67 |
162,193 | arquillian/arquillian-cube | openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/ext/TemplateContainerStarter.java | TemplateContainerStarter.waitForDeployments | public void waitForDeployments(@Observes(precedence = -100) AfterStart event, OpenShiftAdapter client,
CEEnvironmentProcessor.TemplateDetails details, TestClass testClass, CubeOpenShiftConfiguration configuration, OpenShiftClient openshiftClient)
throws Exception {
if (testClass == null) {
// nothing to do, since we're not in ClassScoped context
return;
}
if (details == null) {
log.warning(String.format("No environment for %s", testClass.getName()));
return;
}
log.info(String.format("Waiting for environment for %s", testClass.getName()));
try {
delay(client, details.getResources());
} catch (Throwable t) {
throw new IllegalArgumentException("Error waiting for template resources to deploy: " + testClass.getName(), t);
}
} | java | public void waitForDeployments(@Observes(precedence = -100) AfterStart event, OpenShiftAdapter client,
CEEnvironmentProcessor.TemplateDetails details, TestClass testClass, CubeOpenShiftConfiguration configuration, OpenShiftClient openshiftClient)
throws Exception {
if (testClass == null) {
// nothing to do, since we're not in ClassScoped context
return;
}
if (details == null) {
log.warning(String.format("No environment for %s", testClass.getName()));
return;
}
log.info(String.format("Waiting for environment for %s", testClass.getName()));
try {
delay(client, details.getResources());
} catch (Throwable t) {
throw new IllegalArgumentException("Error waiting for template resources to deploy: " + testClass.getName(), t);
}
} | [
"public",
"void",
"waitForDeployments",
"(",
"@",
"Observes",
"(",
"precedence",
"=",
"-",
"100",
")",
"AfterStart",
"event",
",",
"OpenShiftAdapter",
"client",
",",
"CEEnvironmentProcessor",
".",
"TemplateDetails",
"details",
",",
"TestClass",
"testClass",
",",
"CubeOpenShiftConfiguration",
"configuration",
",",
"OpenShiftClient",
"openshiftClient",
")",
"throws",
"Exception",
"{",
"if",
"(",
"testClass",
"==",
"null",
")",
"{",
"// nothing to do, since we're not in ClassScoped context",
"return",
";",
"}",
"if",
"(",
"details",
"==",
"null",
")",
"{",
"log",
".",
"warning",
"(",
"String",
".",
"format",
"(",
"\"No environment for %s\"",
",",
"testClass",
".",
"getName",
"(",
")",
")",
")",
";",
"return",
";",
"}",
"log",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"Waiting for environment for %s\"",
",",
"testClass",
".",
"getName",
"(",
")",
")",
")",
";",
"try",
"{",
"delay",
"(",
"client",
",",
"details",
".",
"getResources",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Error waiting for template resources to deploy: \"",
"+",
"testClass",
".",
"getName",
"(",
")",
",",
"t",
")",
";",
"}",
"}"
] | Wait for the template resources to come up after the test container has
been started. This allows the test container and the template resources
to come up in parallel. | [
"Wait",
"for",
"the",
"template",
"resources",
"to",
"come",
"up",
"after",
"the",
"test",
"container",
"has",
"been",
"started",
".",
"This",
"allows",
"the",
"test",
"container",
"and",
"the",
"template",
"resources",
"to",
"come",
"up",
"in",
"parallel",
"."
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/openshift/openshift/src/main/java/org/arquillian/cube/openshift/impl/ext/TemplateContainerStarter.java#L25-L42 |
162,194 | arquillian/arquillian-cube | docker/drone/src/main/java/org/arquillian/cube/docker/drone/util/IpAddressValidator.java | IpAddressValidator.validate | public static boolean validate(final String ip) {
Matcher matcher = pattern.matcher(ip);
return matcher.matches();
} | java | public static boolean validate(final String ip) {
Matcher matcher = pattern.matcher(ip);
return matcher.matches();
} | [
"public",
"static",
"boolean",
"validate",
"(",
"final",
"String",
"ip",
")",
"{",
"Matcher",
"matcher",
"=",
"pattern",
".",
"matcher",
"(",
"ip",
")",
";",
"return",
"matcher",
".",
"matches",
"(",
")",
";",
"}"
] | Validate ipv4 address with regular expression
@param ip
address for validation
@return true valid ip address, false invalid ip address | [
"Validate",
"ipv4",
"address",
"with",
"regular",
"expression"
] | ce6b08062cc6ba2a68ecc29606bbae9acda5be13 | https://github.com/arquillian/arquillian-cube/blob/ce6b08062cc6ba2a68ecc29606bbae9acda5be13/docker/drone/src/main/java/org/arquillian/cube/docker/drone/util/IpAddressValidator.java#L27-L30 |
162,195 | spacecowboy/NoNonsense-FilePicker | examples/src/main/java/com/nononsenseapps/filepicker/examples/backbutton/BackHandlingFilePickerActivity.java | BackHandlingFilePickerActivity.getFragment | @Override
protected AbstractFilePickerFragment<File> getFragment(
final String startPath, final int mode, final boolean allowMultiple,
final boolean allowDirCreate, final boolean allowExistingFile,
final boolean singleClick) {
// startPath is allowed to be null.
// In that case, default folder should be SD-card and not "/"
String path = (startPath != null ? startPath
: Environment.getExternalStorageDirectory().getPath());
currentFragment = new BackHandlingFilePickerFragment();
currentFragment.setArgs(path, mode, allowMultiple, allowDirCreate,
allowExistingFile, singleClick);
return currentFragment;
} | java | @Override
protected AbstractFilePickerFragment<File> getFragment(
final String startPath, final int mode, final boolean allowMultiple,
final boolean allowDirCreate, final boolean allowExistingFile,
final boolean singleClick) {
// startPath is allowed to be null.
// In that case, default folder should be SD-card and not "/"
String path = (startPath != null ? startPath
: Environment.getExternalStorageDirectory().getPath());
currentFragment = new BackHandlingFilePickerFragment();
currentFragment.setArgs(path, mode, allowMultiple, allowDirCreate,
allowExistingFile, singleClick);
return currentFragment;
} | [
"@",
"Override",
"protected",
"AbstractFilePickerFragment",
"<",
"File",
">",
"getFragment",
"(",
"final",
"String",
"startPath",
",",
"final",
"int",
"mode",
",",
"final",
"boolean",
"allowMultiple",
",",
"final",
"boolean",
"allowDirCreate",
",",
"final",
"boolean",
"allowExistingFile",
",",
"final",
"boolean",
"singleClick",
")",
"{",
"// startPath is allowed to be null.",
"// In that case, default folder should be SD-card and not \"/\"",
"String",
"path",
"=",
"(",
"startPath",
"!=",
"null",
"?",
"startPath",
":",
"Environment",
".",
"getExternalStorageDirectory",
"(",
")",
".",
"getPath",
"(",
")",
")",
";",
"currentFragment",
"=",
"new",
"BackHandlingFilePickerFragment",
"(",
")",
";",
"currentFragment",
".",
"setArgs",
"(",
"path",
",",
"mode",
",",
"allowMultiple",
",",
"allowDirCreate",
",",
"allowExistingFile",
",",
"singleClick",
")",
";",
"return",
"currentFragment",
";",
"}"
] | Return a copy of the new fragment and set the variable above. | [
"Return",
"a",
"copy",
"of",
"the",
"new",
"fragment",
"and",
"set",
"the",
"variable",
"above",
"."
] | 396ef7fa5e87791170791f9d94c78f6e42a7679a | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/examples/src/main/java/com/nononsenseapps/filepicker/examples/backbutton/BackHandlingFilePickerActivity.java#L20-L35 |
162,196 | spacecowboy/NoNonsense-FilePicker | library/src/main/java/com/nononsenseapps/filepicker/FilePickerFragment.java | FilePickerFragment.getParent | @NonNull
@Override
public File getParent(@NonNull final File from) {
if (from.getPath().equals(getRoot().getPath())) {
// Already at root, we can't go higher
return from;
} else if (from.getParentFile() != null) {
return from.getParentFile();
} else {
return from;
}
} | java | @NonNull
@Override
public File getParent(@NonNull final File from) {
if (from.getPath().equals(getRoot().getPath())) {
// Already at root, we can't go higher
return from;
} else if (from.getParentFile() != null) {
return from.getParentFile();
} else {
return from;
}
} | [
"@",
"NonNull",
"@",
"Override",
"public",
"File",
"getParent",
"(",
"@",
"NonNull",
"final",
"File",
"from",
")",
"{",
"if",
"(",
"from",
".",
"getPath",
"(",
")",
".",
"equals",
"(",
"getRoot",
"(",
")",
".",
"getPath",
"(",
")",
")",
")",
"{",
"// Already at root, we can't go higher",
"return",
"from",
";",
"}",
"else",
"if",
"(",
"from",
".",
"getParentFile",
"(",
")",
"!=",
"null",
")",
"{",
"return",
"from",
".",
"getParentFile",
"(",
")",
";",
"}",
"else",
"{",
"return",
"from",
";",
"}",
"}"
] | Return the path to the parent directory. Should return the root if
from is root.
@param from either a file or directory
@return the parent directory | [
"Return",
"the",
"path",
"to",
"the",
"parent",
"directory",
".",
"Should",
"return",
"the",
"root",
"if",
"from",
"is",
"root",
"."
] | 396ef7fa5e87791170791f9d94c78f6e42a7679a | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/library/src/main/java/com/nononsenseapps/filepicker/FilePickerFragment.java#L145-L156 |
162,197 | spacecowboy/NoNonsense-FilePicker | library/src/main/java/com/nononsenseapps/filepicker/FilePickerFragment.java | FilePickerFragment.getLoader | @NonNull
@Override
public Loader<SortedList<File>> getLoader() {
return new AsyncTaskLoader<SortedList<File>>(getActivity()) {
FileObserver fileObserver;
@Override
public SortedList<File> loadInBackground() {
File[] listFiles = mCurrentPath.listFiles();
final int initCap = listFiles == null ? 0 : listFiles.length;
SortedList<File> files = new SortedList<>(File.class, new SortedListAdapterCallback<File>(getDummyAdapter()) {
@Override
public int compare(File lhs, File rhs) {
return compareFiles(lhs, rhs);
}
@Override
public boolean areContentsTheSame(File file, File file2) {
return file.getAbsolutePath().equals(file2.getAbsolutePath()) && (file.isFile() == file2.isFile());
}
@Override
public boolean areItemsTheSame(File file, File file2) {
return areContentsTheSame(file, file2);
}
}, initCap);
files.beginBatchedUpdates();
if (listFiles != null) {
for (java.io.File f : listFiles) {
if (isItemVisible(f)) {
files.add(f);
}
}
}
files.endBatchedUpdates();
return files;
}
/**
* Handles a request to start the Loader.
*/
@Override
protected void onStartLoading() {
super.onStartLoading();
// handle if directory does not exist. Fall back to root.
if (mCurrentPath == null || !mCurrentPath.isDirectory()) {
mCurrentPath = getRoot();
}
// Start watching for changes
fileObserver = new FileObserver(mCurrentPath.getPath(),
FileObserver.CREATE |
FileObserver.DELETE
| FileObserver.MOVED_FROM | FileObserver.MOVED_TO
) {
@Override
public void onEvent(int event, String path) {
// Reload
onContentChanged();
}
};
fileObserver.startWatching();
forceLoad();
}
/**
* Handles a request to completely reset the Loader.
*/
@Override
protected void onReset() {
super.onReset();
// Stop watching
if (fileObserver != null) {
fileObserver.stopWatching();
fileObserver = null;
}
}
};
} | java | @NonNull
@Override
public Loader<SortedList<File>> getLoader() {
return new AsyncTaskLoader<SortedList<File>>(getActivity()) {
FileObserver fileObserver;
@Override
public SortedList<File> loadInBackground() {
File[] listFiles = mCurrentPath.listFiles();
final int initCap = listFiles == null ? 0 : listFiles.length;
SortedList<File> files = new SortedList<>(File.class, new SortedListAdapterCallback<File>(getDummyAdapter()) {
@Override
public int compare(File lhs, File rhs) {
return compareFiles(lhs, rhs);
}
@Override
public boolean areContentsTheSame(File file, File file2) {
return file.getAbsolutePath().equals(file2.getAbsolutePath()) && (file.isFile() == file2.isFile());
}
@Override
public boolean areItemsTheSame(File file, File file2) {
return areContentsTheSame(file, file2);
}
}, initCap);
files.beginBatchedUpdates();
if (listFiles != null) {
for (java.io.File f : listFiles) {
if (isItemVisible(f)) {
files.add(f);
}
}
}
files.endBatchedUpdates();
return files;
}
/**
* Handles a request to start the Loader.
*/
@Override
protected void onStartLoading() {
super.onStartLoading();
// handle if directory does not exist. Fall back to root.
if (mCurrentPath == null || !mCurrentPath.isDirectory()) {
mCurrentPath = getRoot();
}
// Start watching for changes
fileObserver = new FileObserver(mCurrentPath.getPath(),
FileObserver.CREATE |
FileObserver.DELETE
| FileObserver.MOVED_FROM | FileObserver.MOVED_TO
) {
@Override
public void onEvent(int event, String path) {
// Reload
onContentChanged();
}
};
fileObserver.startWatching();
forceLoad();
}
/**
* Handles a request to completely reset the Loader.
*/
@Override
protected void onReset() {
super.onReset();
// Stop watching
if (fileObserver != null) {
fileObserver.stopWatching();
fileObserver = null;
}
}
};
} | [
"@",
"NonNull",
"@",
"Override",
"public",
"Loader",
"<",
"SortedList",
"<",
"File",
">",
">",
"getLoader",
"(",
")",
"{",
"return",
"new",
"AsyncTaskLoader",
"<",
"SortedList",
"<",
"File",
">",
">",
"(",
"getActivity",
"(",
")",
")",
"{",
"FileObserver",
"fileObserver",
";",
"@",
"Override",
"public",
"SortedList",
"<",
"File",
">",
"loadInBackground",
"(",
")",
"{",
"File",
"[",
"]",
"listFiles",
"=",
"mCurrentPath",
".",
"listFiles",
"(",
")",
";",
"final",
"int",
"initCap",
"=",
"listFiles",
"==",
"null",
"?",
"0",
":",
"listFiles",
".",
"length",
";",
"SortedList",
"<",
"File",
">",
"files",
"=",
"new",
"SortedList",
"<>",
"(",
"File",
".",
"class",
",",
"new",
"SortedListAdapterCallback",
"<",
"File",
">",
"(",
"getDummyAdapter",
"(",
")",
")",
"{",
"@",
"Override",
"public",
"int",
"compare",
"(",
"File",
"lhs",
",",
"File",
"rhs",
")",
"{",
"return",
"compareFiles",
"(",
"lhs",
",",
"rhs",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"areContentsTheSame",
"(",
"File",
"file",
",",
"File",
"file2",
")",
"{",
"return",
"file",
".",
"getAbsolutePath",
"(",
")",
".",
"equals",
"(",
"file2",
".",
"getAbsolutePath",
"(",
")",
")",
"&&",
"(",
"file",
".",
"isFile",
"(",
")",
"==",
"file2",
".",
"isFile",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"areItemsTheSame",
"(",
"File",
"file",
",",
"File",
"file2",
")",
"{",
"return",
"areContentsTheSame",
"(",
"file",
",",
"file2",
")",
";",
"}",
"}",
",",
"initCap",
")",
";",
"files",
".",
"beginBatchedUpdates",
"(",
")",
";",
"if",
"(",
"listFiles",
"!=",
"null",
")",
"{",
"for",
"(",
"java",
".",
"io",
".",
"File",
"f",
":",
"listFiles",
")",
"{",
"if",
"(",
"isItemVisible",
"(",
"f",
")",
")",
"{",
"files",
".",
"add",
"(",
"f",
")",
";",
"}",
"}",
"}",
"files",
".",
"endBatchedUpdates",
"(",
")",
";",
"return",
"files",
";",
"}",
"/**\n * Handles a request to start the Loader.\n */",
"@",
"Override",
"protected",
"void",
"onStartLoading",
"(",
")",
"{",
"super",
".",
"onStartLoading",
"(",
")",
";",
"// handle if directory does not exist. Fall back to root.",
"if",
"(",
"mCurrentPath",
"==",
"null",
"||",
"!",
"mCurrentPath",
".",
"isDirectory",
"(",
")",
")",
"{",
"mCurrentPath",
"=",
"getRoot",
"(",
")",
";",
"}",
"// Start watching for changes",
"fileObserver",
"=",
"new",
"FileObserver",
"(",
"mCurrentPath",
".",
"getPath",
"(",
")",
",",
"FileObserver",
".",
"CREATE",
"|",
"FileObserver",
".",
"DELETE",
"|",
"FileObserver",
".",
"MOVED_FROM",
"|",
"FileObserver",
".",
"MOVED_TO",
")",
"{",
"@",
"Override",
"public",
"void",
"onEvent",
"(",
"int",
"event",
",",
"String",
"path",
")",
"{",
"// Reload",
"onContentChanged",
"(",
")",
";",
"}",
"}",
";",
"fileObserver",
".",
"startWatching",
"(",
")",
";",
"forceLoad",
"(",
")",
";",
"}",
"/**\n * Handles a request to completely reset the Loader.\n */",
"@",
"Override",
"protected",
"void",
"onReset",
"(",
")",
"{",
"super",
".",
"onReset",
"(",
")",
";",
"// Stop watching",
"if",
"(",
"fileObserver",
"!=",
"null",
")",
"{",
"fileObserver",
".",
"stopWatching",
"(",
")",
";",
"fileObserver",
"=",
"null",
";",
"}",
"}",
"}",
";",
"}"
] | Get a loader that lists the Files in the current path,
and monitors changes. | [
"Get",
"a",
"loader",
"that",
"lists",
"the",
"Files",
"in",
"the",
"current",
"path",
"and",
"monitors",
"changes",
"."
] | 396ef7fa5e87791170791f9d94c78f6e42a7679a | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/library/src/main/java/com/nononsenseapps/filepicker/FilePickerFragment.java#L210-L297 |
162,198 | spacecowboy/NoNonsense-FilePicker | library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java | AbstractFilePickerFragment.onLoadFinished | @Override
public void onLoadFinished(final Loader<SortedList<T>> loader,
final SortedList<T> data) {
isLoading = false;
mCheckedItems.clear();
mCheckedVisibleViewHolders.clear();
mFiles = data;
mAdapter.setList(data);
if (mCurrentDirView != null) {
mCurrentDirView.setText(getFullPath(mCurrentPath));
}
// Stop loading now to avoid a refresh clearing the user's selections
getLoaderManager().destroyLoader( 0 );
} | java | @Override
public void onLoadFinished(final Loader<SortedList<T>> loader,
final SortedList<T> data) {
isLoading = false;
mCheckedItems.clear();
mCheckedVisibleViewHolders.clear();
mFiles = data;
mAdapter.setList(data);
if (mCurrentDirView != null) {
mCurrentDirView.setText(getFullPath(mCurrentPath));
}
// Stop loading now to avoid a refresh clearing the user's selections
getLoaderManager().destroyLoader( 0 );
} | [
"@",
"Override",
"public",
"void",
"onLoadFinished",
"(",
"final",
"Loader",
"<",
"SortedList",
"<",
"T",
">",
">",
"loader",
",",
"final",
"SortedList",
"<",
"T",
">",
"data",
")",
"{",
"isLoading",
"=",
"false",
";",
"mCheckedItems",
".",
"clear",
"(",
")",
";",
"mCheckedVisibleViewHolders",
".",
"clear",
"(",
")",
";",
"mFiles",
"=",
"data",
";",
"mAdapter",
".",
"setList",
"(",
"data",
")",
";",
"if",
"(",
"mCurrentDirView",
"!=",
"null",
")",
"{",
"mCurrentDirView",
".",
"setText",
"(",
"getFullPath",
"(",
"mCurrentPath",
")",
")",
";",
"}",
"// Stop loading now to avoid a refresh clearing the user's selections",
"getLoaderManager",
"(",
")",
".",
"destroyLoader",
"(",
"0",
")",
";",
"}"
] | Called when a previously created loader has finished its load.
@param loader The Loader that has finished.
@param data The data generated by the Loader. | [
"Called",
"when",
"a",
"previously",
"created",
"loader",
"has",
"finished",
"its",
"load",
"."
] | 396ef7fa5e87791170791f9d94c78f6e42a7679a | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java#L575-L588 |
162,199 | spacecowboy/NoNonsense-FilePicker | library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java | AbstractFilePickerFragment.clearSelections | public void clearSelections() {
for (CheckableViewHolder vh : mCheckedVisibleViewHolders) {
vh.checkbox.setChecked(false);
}
mCheckedVisibleViewHolders.clear();
mCheckedItems.clear();
} | java | public void clearSelections() {
for (CheckableViewHolder vh : mCheckedVisibleViewHolders) {
vh.checkbox.setChecked(false);
}
mCheckedVisibleViewHolders.clear();
mCheckedItems.clear();
} | [
"public",
"void",
"clearSelections",
"(",
")",
"{",
"for",
"(",
"CheckableViewHolder",
"vh",
":",
"mCheckedVisibleViewHolders",
")",
"{",
"vh",
".",
"checkbox",
".",
"setChecked",
"(",
"false",
")",
";",
"}",
"mCheckedVisibleViewHolders",
".",
"clear",
"(",
")",
";",
"mCheckedItems",
".",
"clear",
"(",
")",
";",
"}"
] | Animate de-selection of visible views and clear
selected set. | [
"Animate",
"de",
"-",
"selection",
"of",
"visible",
"views",
"and",
"clear",
"selected",
"set",
"."
] | 396ef7fa5e87791170791f9d94c78f6e42a7679a | https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/library/src/main/java/com/nononsenseapps/filepicker/AbstractFilePickerFragment.java#L674-L680 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.