/** as {@link #s(int)} based on size of argument */ public static String s(@Nullable Map<?,?> x) { return s(x==null ? 0 : x.size()); } /** as {@link #s(int)} based on size of argument */
/** as {@link #s(int)} based on size of argument */ public static String s(Iterator<?> x) { int count = 0; if (x==null || !x.hasNext()) {} else { x.next(); count++; if (x.hasNext()) count++; } return s(count); }
/** as {@link #invocationParallel(Effector, Map, Iterable)} but executing sequentially */ public static TaskAdaptable<List<?>> invocationSequential(Effector<?> eff, Map<?,?> params, Iterable<? extends Entity> entities) { List<TaskAdaptable<?>> tasks = new ArrayList<TaskAdaptable<?>>(); for (Entity e: entities) tasks.add(invocation(e, eff, params)); return Tasks.sequential( "invoking " + eff + " on " + tasks.size() + " node" + (Strings.s(tasks.size())), tasks.toArray(new TaskAdaptable[tasks.size()])); }
/** returns an unsubmitted task which will invoke the given effector on the given entities in parallel; * return type is Task<List<T>> (but haven't put in the blood sweat toil and tears to make the generics work) */ public static TaskAdaptable<List<?>> invocationParallel(Effector<?> eff, Map<?,?> params, Iterable<? extends Entity> entities) { List<TaskAdaptable<?>> tasks = new ArrayList<TaskAdaptable<?>>(); for (Entity e: entities) tasks.add(invocation(e, eff, params)); return Tasks.parallel( "invoking " + eff + " on " + tasks.size() + " node" + (Strings.s(tasks.size())), tasks.toArray(new TaskAdaptable[tasks.size()])); }
public static TaskFactory<?> installCookbooks(final String chefDirectory, final Map<String,String> cookbooksAndUrls, final boolean force) { return Tasks.<Void>builder().displayName("install "+(cookbooksAndUrls==null ? "0" : cookbooksAndUrls.size())+" cookbook"+Strings.s(cookbooksAndUrls)).body( new Runnable() { @Override public void run() { Entity e = EffectorTasks.findEntity(); if (cookbooksAndUrls==null) throw new IllegalStateException("No cookbooks defined to install at "+e); for (String cookbook: cookbooksAndUrls.keySet()) DynamicTasks.queue(installCookbook(chefDirectory, cookbook, cookbooksAndUrls.get(cookbook), force)); } }).buildFactory(); }
public static TaskFactory<?> installCookbooks(final String chefDirectory, final Map<String,String> cookbooksAndUrls, final boolean force) { return Tasks.<Void>builder().displayName("install "+(cookbooksAndUrls==null ? "0" : cookbooksAndUrls.size())+" cookbook"+Strings.s(cookbooksAndUrls)).body( new Runnable() { @Override public void run() { Entity e = EffectorTasks.findEntity(); if (cookbooksAndUrls==null) throw new IllegalStateException("No cookbooks defined to install at "+e); for (String cookbook: cookbooksAndUrls.keySet()) DynamicTasks.queue(installCookbook(chefDirectory, cookbook, cookbooksAndUrls.get(cookbook), force)); } }).buildFactory(); }
} else { if (!danglingRefsQuorumRequiredHealthy.isQuorate(totalFound, totalItems)) { warn("Dangling item"+Strings.s(totalDangling)+" ("+totalDangling+" of "+totalItems+") found on rebind exceeds quorum, assuming failed: "+danglingIds); allExceptions.add(new IllegalStateException("Too many dangling references: "+totalDangling+" of "+totalItems)); } else { LOG.info("Dangling item"+Strings.s(totalDangling)+" ("+totalDangling+" of "+totalItems+") found on rebind, assuming deleted: "+danglingIds); allExceptions.add(new IllegalStateException("Missing referenced location" + Strings.s(missingLocations) + ": " + missingLocations)); allExceptions.add(new IllegalStateException("Missing referenced enricher" + Strings.s(missingEnrichers) + ": " + missingEnrichers)); allExceptions.add(new IllegalStateException("Missing referenced feed" + Strings.s(missingFeeds) + ": " + missingFeeds)); allExceptions.add(new IllegalStateException("Missing referenced catalog item" + Strings.s(missingCatalogItems) + ": " + missingCatalogItems)); allExceptions.add(new IllegalStateException("Missing referenced untyped items" + Strings.s(missingUntypedItems) + ": " + missingUntypedItems));
if (result.size()==1 && exceptions.size()==1) throw Exceptions.propagate( exceptions.get(0) ); throw Exceptions.propagate(exceptions.size()+" of "+result.size()+" parallel child task"+Strings.s(result.size())+" failed", exceptions);
protected void finishingUp() { checkContinuingPhase(8); if (!isEmpty) { BrooklynLogging.log(LOG, shouldLogRebinding() ? LoggingLevel.INFO : LoggingLevel.DEBUG, "Rebind complete " + "("+mode+(readOnlyRebindCount.get()>=0 ? ", iteration "+readOnlyRebindCount : "")+")" + " in {}: {} app{}, {} entit{}, {} location{}, {} polic{}, {} enricher{}, {} feed{}, {} catalog item{}", Time.makeTimeStringRounded(timer), applications.size(), Strings.s(applications), rebindContext.getEntities().size(), Strings.ies(rebindContext.getEntities()), rebindContext.getLocations().size(), Strings.s(rebindContext.getLocations()), rebindContext.getPolicies().size(), Strings.ies(rebindContext.getPolicies()), rebindContext.getEnrichers().size(), Strings.s(rebindContext.getEnrichers()), rebindContext.getFeeds().size(), Strings.s(rebindContext.getFeeds()), rebindContext.getCatalogItems().size(), Strings.s(rebindContext.getCatalogItems()) ); } // Return the top-level applications logRebindingDebug("RebindManager complete; apps: {}", getMementoRootEntities()); }
wrapped = null; throw new NoMachinesAvailableException("No machines available in any of the "+sublocsList.size()+" location"+Strings.s(sublocsList.size())+ " configured here: "+msg, wrapped);
public PerUserEntitlementManager(BrooklynProperties properties) { this(load(properties, properties.getConfig(DEFAULT_MANAGER))); Set<ConfigKey<?>> users = properties.findKeysPresent(ConfigPredicates.nameStartsWith(PER_USER_ENTITLEMENTS_CONFIG_PREFIX+".")); for (ConfigKey<?> key: users) { if (key.getName().equals(DEFAULT_MANAGER.getName())) continue; String user = Strings.removeFromStart(key.getName(), PER_USER_ENTITLEMENTS_CONFIG_PREFIX+"."); addUser(user, load(properties, Strings.toString(properties.getConfig(key)))); } log.info(getClass().getSimpleName()+" created with "+perUserManagers.size()+" user"+Strings.s(perUserManagers)+" and " + "default "+defaultManager+" (users: "+perUserManagers+")"); }
@Override public void expungeMembers(boolean stopFirst) { Set<Entity> members = ImmutableSet.copyOf(getMembers()); RuntimeException exception = null; if (stopFirst) { Map<Entity, Task<?>> tasks = Maps.newLinkedHashMap(); for (Entity member : members) { if (member instanceof Startable) { Task<Void> task = Effectors.invocation(member, Startable.STOP, ImmutableMap.of()).asTask(); tasks.put(member, task); } } DynamicTasks.queueIfPossible(Tasks.parallel("stopping "+tasks.size()+" member"+Strings.s(tasks.size())+" (parallel)", tasks.values())).orSubmitAsync(this); try { waitForTasksOnExpungeMembers(tasks); } catch (RuntimeException e) { Exceptions.propagateIfFatal(e); exception = e; LOG.warn("Problem stopping members of quarantine group "+this+" (rethrowing after unmanaging members): "+e); } } for (Entity member : members) { removeMember(member); Entities.unmanage(member); } if (exception != null) { throw exception; } }
missing = Sets.difference(itemsToDelete, entities.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)"); missing = Sets.difference(itemsToDelete, locations.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)"); missing = Sets.difference(itemsToDelete, policies.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)"); missing = Sets.difference(itemsToDelete, enrichers.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)"); missing = Sets.difference(itemsToDelete, feeds.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)"); missing = Sets.difference(itemsToDelete, catalogItems.keySet()); if (missing.size() > 0) { LOG.warn("Unable to delete " + type + " id"+Strings.s(missing.size())+" ("+missing+"), " + "because not found in persisted state (continuing)");
Set<String> policiesToDelete = Sets.difference(input.getPolicies().keySet(), policiesToKeep.keySet()); Set<String> feedsToDelete = Sets.difference(input.getFeeds().keySet(), feedsToKeep.keySet()); LOG.info("Deleting {} orphaned location{} (of {}): {}", new Object[] {locsToDelete.size(), Strings.s(locsToDelete.size()), input.getLocations().size(), locsToDelete}); LOG.info("Deleting {} orphaned enricher{} (of {}): {}", new Object[] {enrichersToDelete.size(), Strings.s(enrichersToDelete.size()), input.getEnrichers().size(), enrichersToDelete}); LOG.info("Deleting {} orphaned polic{} (of {}): {}", new Object[] {policiesToDelete.size(), (policiesToDelete.size() == 1 ? "y" : "ies"), input.getPolicies().size(), policiesToDelete}); LOG.info("Deleting {} orphaned feed{} (of {}): {}", new Object[] {feedsToDelete.size(), Strings.s(feedsToDelete.size()), input.getFeeds().size(), feedsToDelete});
@SuppressWarnings("unchecked") private void assertCustomizers(Entity entity, int numberCustomizers) { Object object = entity.config().get(BrooklynConfigKeys.PROVISIONING_PROPERTIES.subKey( JcloudsLocationConfig.JCLOUDS_LOCATION_CUSTOMIZERS.getName())); assertNotNull(object, "expected value for customizers in " + entity.config().get(BrooklynConfigKeys.PROVISIONING_PROPERTIES)); assertTrue(object instanceof Collection, "expected collection, got " + object.getClass()); Collection<JcloudsLocationCustomizer> customizers = (Collection<JcloudsLocationCustomizer>) object; assertEquals(customizers.size(), numberCustomizers, "expected " + numberCustomizers + " customizer" + Strings.s(numberCustomizers) + " in " + Iterables.toString(customizers)); assertTrue(customizers.contains(testCustomizer), "expected to find testCustomizer in " + Iterables.toString(customizers)); }
Task<List<?>> parallel = Tasks.parallel("starting "+tasks.size()+" node"+Strings.s(tasks.size())+" (parallel)", tasks.values()); TaskTags.markInessential(parallel); DynamicTasks.queueIfPossible(parallel).orSubmitAsync(this);
+ managementContext.getApplications().size()+" application"+Strings.s(managementContext.getApplications().size())+" loaded"); } else {
message += "Catalog was empty anyway."; } else { message += "Deleting "+catalogItems.size()+" persisted catalog item"+Strings.s(catalogItems)+": "+catalogItems; if (shouldLogRebinding()) { LOG.info(message);