org.apache.brooklyn.util.text.Strings.s()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(13.0k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.apache.brooklyn.util.text.Strings.s()方法的一些代码示例,展示了Strings.s()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.s()方法的具体详情如下:
包路径:org.apache.brooklyn.util.text.Strings
类名称:Strings
方法名:s

Strings.s介绍

[英]returns "s" if the argument is not 1, empty string otherwise; useful when constructing plurals
[中]如果参数不是1,则返回“s”,否则返回空字符串;在构造复数时很有用

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** as {@link #s(int)} based on size of argument */
public static String s(Iterable<?> x) {
  if (x==null) return s(0);
  return s(x.iterator());
}
/** as {@link #s(int)} based on size of argument */

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** 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 */

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

/** 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);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** 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()]));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** 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()]));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

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();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-cm-chef

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();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

} 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));

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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);

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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());
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

wrapped = null;
throw new NoMachinesAvailableException("No machines available in any of the "+sublocsList.size()+" location"+Strings.s(sublocsList.size())+
  " configured here: "+msg, wrapped);

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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+")");
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@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;
  }
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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)");

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

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});

代码示例来源:origin: org.apache.brooklyn/brooklyn-locations-jclouds

@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));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

Task<List<?>> parallel = Tasks.parallel("starting "+tasks.size()+" node"+Strings.s(tasks.size())+" (parallel)", tasks.values());
TaskTags.markInessential(parallel);
DynamicTasks.queueIfPossible(parallel).orSubmitAsync(this);

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

count+" item"+Strings.s(count)+" ("+countApps+" app"+Strings.s(countApps)+") in "+Time.makeTimeStringRounded(timer));

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

+ managementContext.getApplications().size()+" application"+Strings.s(managementContext.getApplications().size())+" loaded");
} else {

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

message += "Catalog was empty anyway.";
} else {
  message += "Deleting "+catalogItems.size()+" persisted catalog item"+Strings.s(catalogItems)+": "+catalogItems;
  if (shouldLogRebinding()) {
    LOG.info(message);

相关文章