use of java.util.Collection in project cas by apereo.
the class AbstractServicesManager method load.
/**
* For the duration of the read, the cache store should not remain empty.
* Otherwise, lookup operations during that loading time window might produce
* unauthorized failure errors. Invalidation attempts must happen after the load
* to minimize chances of failures.
*/
@Override
public synchronized Collection<RegisteredService> load() {
LOGGER.trace("Loading services from [{}]", configurationContext.getServiceRegistry().getName());
val servicesMap = configurationContext.getServiceRegistry().load().stream().filter(this::supports).filter(this::validateAndFilterServiceByEnvironment).peek(this::loadInternal).collect(Collectors.toMap(r -> {
LOGGER.trace("Adding registered service [{}] with name [{}] and internal identifier [{}]", r.getServiceId(), r.getName(), r.getId());
return r.getId();
}, Function.identity(), (r, s) -> s));
configurationContext.getServicesCache().invalidateAll();
configurationContext.getServicesCache().putAll(servicesMap);
loadInternal();
publishEvent(new CasRegisteredServicesLoadedEvent(this, getAllServices()));
evaluateExpiredServiceDefinitions();
LOGGER.info("Loaded [{}] service(s) from [{}].", configurationContext.getServicesCache().asMap().size(), configurationContext.getServiceRegistry().getName());
return configurationContext.getServicesCache().asMap().values();
}
use of java.util.Collection in project buck by facebook.
the class ApkBuilderStep method getDescription.
@Override
public String getDescription(ExecutionContext context) {
ImmutableList.Builder<String> args = ImmutableList.builder();
args.add(javaRuntimeLauncher.getCommand(), "-classpath", // accessible via an AndroidPlatformTarget and insert that here in place of "$ANDROID_HOME".
"$ANDROID_HOME/tools/lib/sdklib.jar", "com.android.sdklib.build.ApkBuilderMain");
args.add(String.valueOf(pathToOutputApkFile));
args.add("-v");
if (debugMode) {
args.add("-d");
}
// Unfortunately, ApkBuilderMain does not have CLI args to set the keystore,
// so these member variables are left out of the command:
// pathToKeystore, pathToKeystorePropertiesFile
Multimap<String, Collection<Path>> groups = ImmutableMultimap.<String, Collection<Path>>builder().put("-z", ImmutableList.of(resourceApk)).put("-f", ImmutableList.of(dexFile)).put("-rf", assetDirectories).put("-nf", nativeLibraryDirectories).put("-z", zipFiles).put("-rj", jarFilesThatMayContainResources).build();
for (Map.Entry<String, Collection<Path>> group : groups.entries()) {
String prefix = group.getKey();
for (Path path : group.getValue()) {
args.add(prefix, String.valueOf(path));
}
}
return Joiner.on(' ').join(args.build());
}
use of java.util.Collection in project deeplearning4j by deeplearning4j.
the class TestRecordReaders method testClassIndexOutsideOfRangeRRMDSI_MultipleReaders.
@Test
public void testClassIndexOutsideOfRangeRRMDSI_MultipleReaders() {
Collection<Collection<Collection<Writable>>> c1 = new ArrayList<>();
Collection<Collection<Writable>> seq1 = new ArrayList<>();
seq1.add(Arrays.<Writable>asList(new DoubleWritable(0.0)));
seq1.add(Arrays.<Writable>asList(new DoubleWritable(0.0)));
c1.add(seq1);
Collection<Collection<Writable>> seq2 = new ArrayList<>();
seq2.add(Arrays.<Writable>asList(new DoubleWritable(0.0)));
seq2.add(Arrays.<Writable>asList(new DoubleWritable(0.0)));
c1.add(seq2);
Collection<Collection<Collection<Writable>>> c2 = new ArrayList<>();
Collection<Collection<Writable>> seq1a = new ArrayList<>();
seq1a.add(Arrays.<Writable>asList(new IntWritable(0)));
seq1a.add(Arrays.<Writable>asList(new IntWritable(1)));
c2.add(seq1a);
Collection<Collection<Writable>> seq2a = new ArrayList<>();
seq2a.add(Arrays.<Writable>asList(new IntWritable(0)));
seq2a.add(Arrays.<Writable>asList(new IntWritable(2)));
c2.add(seq2a);
CollectionSequenceRecordReader csrr = new CollectionSequenceRecordReader(c1);
CollectionSequenceRecordReader csrrLabels = new CollectionSequenceRecordReader(c2);
DataSetIterator dsi = new SequenceRecordReaderDataSetIterator(csrr, csrrLabels, 2, 2);
try {
DataSet ds = dsi.next();
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testClassIndexOutsideOfRangeRRMDSI_MultipleReaders(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of java.util.Collection in project deeplearning4j by deeplearning4j.
the class TestRecordReaders method testClassIndexOutsideOfRangeRRDSI.
@Test
public void testClassIndexOutsideOfRangeRRDSI() {
Collection<Collection<Writable>> c = new ArrayList<>();
c.add(Arrays.<Writable>asList(new DoubleWritable(0.0), new IntWritable(0)));
c.add(Arrays.<Writable>asList(new DoubleWritable(0.0), new IntWritable(2)));
CollectionRecordReader crr = new CollectionRecordReader(c);
RecordReaderDataSetIterator iter = new RecordReaderDataSetIterator(crr, 2, 1, 2);
try {
DataSet ds = iter.next();
fail("Expected exception");
} catch (DL4JException e) {
System.out.println("testClassIndexOutsideOfRange(): " + e.getMessage());
} catch (Exception e) {
e.printStackTrace();
fail();
}
}
use of java.util.Collection in project elasticsearch by elastic.
the class ScriptFieldsFetchSubPhase method hitExecute.
@Override
public void hitExecute(SearchContext context, HitContext hitContext) {
if (context.hasScriptFields() == false) {
return;
}
for (ScriptFieldsContext.ScriptField scriptField : context.scriptFields().fields()) {
/* Because this is called once per document we end up creating new ScriptDocValues for every document which is important because
* the values inside ScriptDocValues might be reused for different documents (Dates do this). */
LeafSearchScript leafScript;
try {
leafScript = scriptField.script().getLeafSearchScript(hitContext.readerContext());
} catch (IOException e1) {
throw new IllegalStateException("Failed to load script", e1);
}
leafScript.setDocument(hitContext.docId());
final Object value;
try {
value = leafScript.unwrap(leafScript.run());
} catch (RuntimeException e) {
if (scriptField.ignoreException()) {
continue;
}
throw e;
}
if (hitContext.hit().fieldsOrNull() == null) {
hitContext.hit().fields(new HashMap<>(2));
}
SearchHitField hitField = hitContext.hit().getFields().get(scriptField.name());
if (hitField == null) {
final List<Object> values;
if (value instanceof Collection) {
// TODO: use diamond operator once JI-9019884 is fixed
values = new ArrayList<>((Collection<?>) value);
} else {
values = Collections.singletonList(value);
}
hitField = new SearchHitField(scriptField.name(), values);
hitContext.hit().getFields().put(scriptField.name(), hitField);
}
}
}
Aggregations