com.google.common.collect.FluentIterable#isEmpty ( )源码实例Demo

下面列出了com.google.common.collect.FluentIterable#isEmpty ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: karamel   文件: NovaLauncher.java
public boolean uploadSshPublicKey(String keyPairName, Nova nova, boolean removeOld) {
  boolean uploadSuccesful;
  FluentIterable<KeyPair> keyPairs = novaContext.getKeyPairApi().list();
  if (keyPairs.isEmpty()) {
    logger.info(String.format("New keypair '%s' is being uploaded to Nova OpenStack", keyPairName));
    novaContext.getKeyPairApi().createWithPublicKey(keyPairName, sshKeyPair.getPublicKey());
    uploadSuccesful = true;
  } else if (removeOld) {
    logger.info(String.format("Removing the old keypair '%s' and uploading the new one ...", keyPairName));
    boolean deleteSuccesful = novaContext.getKeyPairApi().delete(keyPairName);
    KeyPair pair = novaContext.getKeyPairApi().createWithPublicKey(keyPairName, sshKeyPair.getPublicKey());
    uploadSuccesful = deleteSuccesful && pair != null;
  } else {
    uploadSuccesful = false;
  }
  return uploadSuccesful;
}
 
源代码2 项目: dremio-oss   文件: AccelerationStoragePlugin.java
/**
 * Find the set of refreshes/slices associated with a particular materialization. Could be one to
 * many. If no refreshes are found, the materialization cannot be served.
 *
 * @param components
 *          The path components. First item is expected to be the Accelerator storage plugin, then
 *          we expect either two more parts: ReflectionId and MaterializationId or a single two
 *          part slashed value of ReflectionId/MaterializationId.
 * @return List of refreshes or null if there are no matching refreshes.
 */
private FluentIterable<Refresh> getSlices(List<String> components) {
  components = normalizeComponents(components);
  if (components == null) {
    return null;
  }

  ReflectionId reflectionId = new ReflectionId(components.get(1));
  MaterializationId id = new MaterializationId(components.get(2));
  Materialization materialization = materializationStore.get(id);

  if(materialization == null) {
    logger.info("Unable to find materialization id: {}", id.getId());
    return null;
  }

  // verify that the materialization has the provided reflection.
  if(!materialization.getReflectionId().equals(reflectionId)) {
    logger.info("Mismatched reflection id for materialization. Expected: {}, Actual: {}, for MaterializationId: {}", reflectionId.getId(), materialization.getReflectionId().getId(), id.getId());
    return null;
  }

  FluentIterable<Refresh> refreshes = materializationStore.getRefreshes(materialization);

  if(refreshes.isEmpty()) {
    logger.info("No slices for materialization MaterializationId: {}", id.getId());
    return null;
  }

  return refreshes;
}
 
源代码3 项目: dremio-oss   文件: MaterializationStore.java
public Iterable<Refresh> getRefreshesExclusivelyOwnedBy(final Materialization m) {
  FluentIterable<Refresh> refreshes = getRefreshes(m);
  if (refreshes.isEmpty()) {
    return refreshes;
  }

  final Materialization mostRecent = getMostRecentMaterialization(m.getReflectionId(), m.getSeriesId());
  if (mostRecent != null && !mostRecent.getId().equals(m.getId())) {
    return Collections.emptyList();
  }

  return refreshes;
}
 
@NotNull
private String getExecutorIdForOffer(@NotNull final Protos.Offer offer) {
    final FluentIterable<CassandraNode> filter =
        from(clusterState.nodes())
            .filter(cassandraNodeHasExecutor())
            .filter(cassandraNodeHostnameEq(offer.getHostname()));
    if (filter.isEmpty()) {
        return configuration.frameworkName() + ".node." + execCounter.getAndIncrement() + ".executor";
    } else {
        return filter.get(0).getCassandraNodeExecutor().getExecutorId();
    }
}
 
源代码5 项目: helios   文件: JobStatusCommand.java
private boolean showStatusesForHosts(final String hostPattern, final Set<JobId> jobIds,
                                     final Map<JobId, JobStatus> statuses,
                                     final HostStatusDisplayer statusDisplayer) {
  boolean noHostMatchedEver = true;

  for (final JobId jobId : Ordering.natural().sortedCopy(jobIds)) {
    final JobStatus jobStatus = statuses.get(jobId);

    // jobStatus will be null if the job was deleted after we first got the list of job IDs
    if (jobStatus == null) {
      continue;
    }

    final Map<String, TaskStatus> taskStatuses = new TreeMap<>(jobStatus.getTaskStatuses());

    // Add keys for jobs that were deployed to a host,
    // but for which we didn't get a reported task status.
    // This will help us see hosts where jobs aren't running correctly.
    for (final String host : jobStatus.getDeployments().keySet()) {
      if (!taskStatuses.containsKey(host)) {
        taskStatuses.put(host, null);
      }
    }

    // even though job-filtering based on host patterns is done server-side since c99364ae,
    // we still need to filter TaskStatuses by hosts here as the job's TaskStatus applies includes
    // all hosts the job is deployed to
    final FluentIterable<String> hosts = FluentIterable
        .from(taskStatuses.keySet())
        .filter(containsPattern(hostPattern));

    if (Strings.isNullOrEmpty(hostPattern)
        || !Strings.isNullOrEmpty(hostPattern) && !hosts.isEmpty()) {
      noHostMatchedEver = false;
    }

    statusDisplayer.matchedStatus(jobStatus, hosts, taskStatuses);

  }
  return noHostMatchedEver;
}