List of usage examples for com.google.common.base Predicates equalTo
public static <T> Predicate<T> equalTo(@Nullable T target)
From source file:com.google.javascript.jscomp.graph.LinkedUndirectedGraph.java
@Override public boolean isConnected(N n1, E e, N n2) { return isConnected(n1, Predicates.equalTo(e), n2); }
From source file:org.apache.brooklyn.core.location.dynamic.clocker.StubInfrastructureLocation.java
@Override public void release(MachineLocation machine) { Set<StubHostLocation> set = Multimaps.filterValues(containers, Predicates.equalTo(machine.getId())) .keySet();//from ww w. java 2 s . co m StubHostLocation hostLocation = Iterables.getOnlyElement(set); hostLocation.release((StubContainerLocation) machine); containers.remove(hostLocation, machine); }
From source file:co.cask.cdap.data.tools.HBaseQueueDebugger.java
/** * Only works for {@link co.cask.cdap.data2.transaction.queue.hbase.ShardedHBaseQueueStrategy}. *///w w w . j a v a2s . c o m public QueueStatistics scanQueue(final QueueName queueName, @Nullable Long consumerGroupId) throws Exception { HBaseConsumerStateStore stateStore; try { stateStore = queueAdmin.getConsumerStateStore(queueName); } catch (IllegalStateException e) { throw new NotFoundException(queueName); } TransactionExecutor txExecutor = Transactions.createTransactionExecutor(txExecutorFactory, stateStore); Multimap<Long, QueueBarrier> barriers = txExecutor .execute(new TransactionExecutor.Function<HBaseConsumerStateStore, Multimap<Long, QueueBarrier>>() { @Override public Multimap<Long, QueueBarrier> apply(HBaseConsumerStateStore input) throws Exception { return input.getAllBarriers(); } }, stateStore); System.out.printf("Got %d barriers\n", barriers.size()); QueueStatistics stats = new QueueStatistics(); if (consumerGroupId != null) { barriers = Multimaps.filterKeys(barriers, Predicates.equalTo(consumerGroupId)); } for (Map.Entry<Long, Collection<QueueBarrier>> entry : barriers.asMap().entrySet()) { long groupId = entry.getKey(); Collection<QueueBarrier> groupBarriers = entry.getValue(); System.out.printf("Scanning barriers for group %d\n", groupId); int currentSection = 1; PeekingIterator<QueueBarrier> barrierIterator = Iterators.peekingIterator(groupBarriers.iterator()); while (barrierIterator.hasNext()) { QueueBarrier start = barrierIterator.next(); QueueBarrier end = barrierIterator.hasNext() ? barrierIterator.peek() : null; System.out.printf("Scanning section %d/%d...\n", currentSection, groupBarriers.size()); scanQueue(txExecutor, stateStore, queueName, start, end, stats); System.out.printf("Current results: %s\n", stats.getReport()); currentSection++; } System.out.println("Scanning complete"); } System.out.printf("Total results: %s\n", stats.getReport()); return stats; }
From source file:brooklyn.entity.nosql.mongodb.MongoDBClientSshDriver.java
private AbstractMongoDBServer getServer() { AbstractMongoDBServer server = entity.getConfig(MongoDBClient.SERVER); MongoDBShardedDeployment deployment = entity.getConfig(MongoDBClient.SHARDED_DEPLOYMENT); if (server == null) { Preconditions.checkNotNull(deployment, "Either server or shardedDeployment must be specified for %s", this); server = DependentConfiguration.builder() .attributeWhenReady(deployment.getRouterCluster(), MongoDBRouterCluster.ANY_ROUTER) .blockingDetails("any available router").runNow(); DependentConfiguration.builder().attributeWhenReady(server, MongoDBRouter.SHARD_COUNT) .readiness(MathPredicates.<Integer>greaterThan(0)).runNow(); } else {/* w ww . j a v a2 s . c o m*/ if (deployment != null) { log.warn("Server and ShardedDeployment defined for {}; using server ({} instead of {})", new Object[] { this, server, deployment }); } DependentConfiguration.builder().attributeWhenReady(server, Startable.SERVICE_UP) .readiness(Predicates.equalTo(true)).runNow(); } return server; }
From source file:brooklyn.entity.basic.EntityPredicates.java
public static <T> Predicate<Entity> attributeEqualTo(final AttributeSensor<T> attribute, final T val) { return attributeSatisfies(attribute, Predicates.equalTo(val)); }
From source file:com.eucalyptus.autoscaling.common.internal.groups.TerminationPolicyType.java
private static <T> List<AutoScalingInstanceCoreView> filterByPropertyEquality( final List<AutoScalingInstanceCoreView> instances, final T target, final Function<? super AutoScalingInstanceCoreView, T> propertyFunction) { return Lists.newArrayList( Iterables.filter(instances, Predicates.compose(Predicates.equalTo(target), propertyFunction))); }
From source file:tile80.tile80.Tile80.java
public Tile80 removeBehavior(Behavior80 behavior) { return new Tile80Eager(getPos(), getId(), getTags(), FluentIterable.from(getBehavior()).filter(Predicates.not(Predicates.equalTo(behavior))), getKeyspace());/* w w w .j av a 2 s .c o m*/ }
From source file:org.jetbrains.jet.lang.resolve.TopDownAnalyzer.java
public static void processClassOrObject(@NotNull Project project, @NotNull final BindingTrace trace, @NotNull JetScope outerScope, @NotNull final DeclarationDescriptor containingDeclaration, @NotNull JetClassOrObject object) { ModuleDescriptor moduleDescriptor = new ModuleDescriptor(Name.special("<dummy for object>")); TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters( Predicates.equalTo(object.getContainingFile()), false, true, Collections.<AnalyzerScriptParameter>emptyList()); InjectorForTopDownAnalyzerBasic injector = new InjectorForTopDownAnalyzerBasic(project, topDownAnalysisParameters, new ObservableBindingTrace(trace), moduleDescriptor, ModuleConfiguration.EMPTY);/*www . j ava 2 s. c om*/ injector.getTopDownAnalyzer().doProcess(outerScope, new NamespaceLikeBuilder() { @NotNull @Override public DeclarationDescriptor getOwnerForChildren() { return containingDeclaration; } @Override public void addClassifierDescriptor(@NotNull MutableClassDescriptorLite classDescriptor) { } @Override public void addObjectDescriptor(@NotNull MutableClassDescriptorLite objectDescriptor) { } @Override public void addFunctionDescriptor(@NotNull SimpleFunctionDescriptor functionDescriptor) { throw new UnsupportedOperationException(); } @Override public void addPropertyDescriptor(@NotNull PropertyDescriptor propertyDescriptor) { } @Override public ClassObjectStatus setClassObjectDescriptor( @NotNull MutableClassDescriptorLite classObjectDescriptor) { return ClassObjectStatus.NOT_ALLOWED; } }, Collections.<PsiElement>singletonList(object)); }
From source file:com.eucalyptus.autoscaling.tags.Tags.java
private static Tag lookup(final Tag example) throws AutoScalingMetadataNotFoundException { try {//from ww w.j av a 2 s. c om final List<Tag> result = Transactions.filter(example, Predicates.compose(Predicates.equalTo(example.getResourceId()), Tags.resourceId())); if (result.size() == 1) { return result.get(0); } } catch (Exception e) { throw new AutoScalingMetadataNotFoundException( "Failed to find tag: " + example.getKey() + " for " + example.getOwner(), e); } throw new AutoScalingMetadataNotFoundException( "Failed to find unique tag: " + example.getKey() + " for " + example.getOwner()); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.elements.AbstractFrame.java
/** * Get the covered lifelines.// www. jav a 2s .co m * * @param coveredLifelines * a collection of lifelines that should be a subset of computed * lifelines (NO CHECK) * * @return the covered lifelines. */ public Collection<ISequenceEvent> computeParentEvents(Collection<Lifeline> coveredLifelines) { Collection<ISequenceEvent> parentEvents = Sets.newHashSet(); for (Lifeline lifeline : coveredLifelines) { EventFinder finder = new EventFinder(lifeline); finder.setEventsToIgnore(Predicates.equalTo((ISequenceEvent) this)); Range verticalRange = this.getVerticalRange(); ISequenceEvent localParent = finder.findMostSpecificEvent(verticalRange); if (localParent != null && localParent.getVerticalRange().includes(verticalRange)) { parentEvents.add(localParent); } } return parentEvents; }