Java Code Examples for com.google.common.collect.FluentIterable#isEmpty()
The following examples show how to use
com.google.common.collect.FluentIterable#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NovaLauncher.java From karamel with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: AccelerationStoragePlugin.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * 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; }
Example 3
Source File: MaterializationStore.java From dremio-oss with Apache License 2.0 | 5 votes |
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; }
Example 4
Source File: CassandraCluster.java From cassandra-mesos-deprecated with Apache License 2.0 | 5 votes |
@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(); } }
Example 5
Source File: JobStatusCommand.java From helios with Apache License 2.0 | 4 votes |
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; }