/** not on interface because potentially expensive */ public List<Task<?>> getAllTasks() { // not sure if synching makes any difference; have not observed CME's yet // (and so far this is only called when a CME was caught on a previous operation) synchronized (tasksById) { return MutableList.copyOf(tasksById.values()); } }
@Override protected Object compute() { synchronized (values) { // TODO Could avoid copying when filter not needed List<T> vs = MutableList.copyOf(Iterables.filter(values.values(), valueFilter)); if (transformation==null) return vs; return transformation.apply(vs); } }
protected Object compute() { synchronized (values) { // TODO Could avoid copying when filter not needed List<T> vs = MutableList.copyOf(Iterables.filter(values.values(), valueFilter)); return transformation.apply(vs); } } }
@Override public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity context) { if (locations == null || locations.isEmpty()) { return ImmutableList.of(); } List<DockerHostLocation> copy = MutableList.copyOf(locations); Collections.shuffle(copy); return ImmutableList.copyOf(copy); } }
@Override public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity context) { if (locations == null || locations.isEmpty()) { return ImmutableList.of(); } entity = context; List<DockerHostLocation> available = MutableList.copyOf(locations); Collections.sort(available, this); return ImmutableList.copyOf(Iterables.filter(available, this)); }
protected LinearRangeQuorumCheck(String name, Iterable<Point> points) { Preconditions.checkArgument(Iterables.size(points)>=2, "At least two points must be supplied for "+name+": "+points); this.name = name; this.points = MutableList.copyOf(points).asUnmodifiable(); // check valid Point last = null; for (Point p: points) { if (last!=null) { if (p.size <= last.size) throw new IllegalStateException("Points must be supplied in order of increasing totalSize (x coordinate); instead have "+last+" and "+p); } } }
/** adds the supplied policies to the spec */ public <V> EntitySpec<T> policySpecs(Iterable<? extends PolicySpec<?>> val) { checkMutable(); policySpecs.addAll(MutableList.copyOf(checkNotNull(val, "policySpecs"))); return this; }
/** adds the supplied policies to the spec * @deprecated since 0.9.0 pass a spec, using {@link #enricherSpecs(Iterable)} */ @Deprecated public <V> EntitySpec<T> enrichers(Iterable<? extends Enricher> val) { checkMutable(); enrichers.addAll(MutableList.copyOf(checkNotNull(val, "enrichers"))); return this; }
/** adds the supplied locations to the spec * @deprecated since 0.9.0 pass a spec, using {@link #locationSpecs(Iterable)} */ @Deprecated public <V> EntitySpec<T> locations(Iterable<? extends Location> val) { checkMutable(); locations.addAll(MutableList.copyOf(checkNotNull(val, "locations"))); return this; }
/** adds the supplied policies to the spec * @deprecated since 0.9.0 pass a spec, using {@link #policySpecs(Iterable)} */ @Deprecated public <V> EntitySpec<T> policies(Iterable<? extends Policy> val) { checkMutable(); policies.addAll(MutableList.copyOf(checkNotNull(val, "policies"))); return this; }
public static List<Enricher> getNonSystemEnrichers(Entity entity) { List<Enricher> result = MutableList.copyOf(entity.enrichers()); Iterator<Enricher> ri = result.iterator(); while (ri.hasNext()) { if (isSystemEnricher(ri.next())) ri.remove(); } return result; }
public synchronized Map<String,Object> asMap() { Map<String,Object> result = MutableMap.of(); result.put("count", count); result.put("lastSuccessTimeUtc", lastSuccessTime); result.put("lastSuccessTimeMillisSince", since(lastSuccessTime)); result.put("lastDuration", lastDuration); result.put("failureCount", failureCount); result.put("lastFailureTimeUtc", lastFailureTime); result.put("lastFailureTimeMillisSince", since(lastFailureTime)); result.put("errorMessages", MutableList.copyOf(errorMessages)); return result; }
@Override public String apply(List<Integer> input) { if (input == null) { return null; } else { MutableList<Integer> inputCopy = MutableList.copyOf(input); Collections.sort(inputCopy); return Joiner.on(",").join(inputCopy); } }}) .build());
@Override public List<Function<ProcessTaskWrapper<?>, Void>> getCompletionListeners() { MutableList<Function<ProcessTaskWrapper<?>, Void>> result = MutableList.copyOf(super.getCompletionListeners()); if (throwOnCommonKnifeErrors != Boolean.FALSE) insertKnifeCompletionListenerIntoCompletionListenersList(result); return result.asUnmodifiable(); }
@Override public List<Function<ProcessTaskWrapper<?>, Void>> getCompletionListeners() { MutableList<Function<ProcessTaskWrapper<?>, Void>> result = MutableList.copyOf(super.getCompletionListeners()); if (throwOnCommonKnifeErrors != Boolean.FALSE) insertKnifeCompletionListenerIntoCompletionListenersList(result); return result.asUnmodifiable(); }
private <T> List<T> getServiceStateEvents(RecordingSensorEventListener<T> listener) { if (stateListener == null) { return ImmutableList.of(); } else { return MutableList.copyOf(listener.getEventValues()).asUnmodifiable(); } }
private List<Entity> makeTwoNodes() { List<Entity> nodes = MutableList.copyOf(cluster.resizeByDelta(2)); setManagementState(nodes.get(0), ManagementNodeState.MASTER); setManagementState(nodes.get(1), ManagementNodeState.HOT_STANDBY); return nodes; }
@SuppressWarnings("unchecked") @Override public List<Object> listTags(String applicationId, String entityId) { Entity entity = brooklyn().getEntity(applicationId, entityId); return (List<Object>) resolving(MutableList.copyOf(entity.tags().getTags())).preferJson(true).resolve(); }
@Test public void testOrder() { ConfigBag bag = ConfigBag.newInstance(); bag.put(K1, "v1"); bag.put(K2, "v2"); bag.put(K3, "v3"); Assert.assertEquals(MutableList.copyOf(bag.getAllConfig().keySet()), MutableList.of(K1.getName(), K2.getName(), K3.getName())); Assert.assertEquals(MutableList.copyOf(bag.getAllConfig().values()), MutableList.of("v1", "v2", "v3")); }
@AfterMethod(alwaysRun = true) public void cleanUpButKeepMgmt() throws Exception { for (Application app: MutableList.copyOf(mgmt().getApplications())) { Entities.destroy(app); } for (Bundle b: bundlesToRemove) { ((ManagementContextInternal)mgmt()).getOsgiManager().get().uninstallUploadedBundle( ((ManagementContextInternal)mgmt()).getOsgiManager().get().getManagedBundle(new VersionedName(b))); } bundlesToRemove.clear(); }