@Override public Collection<Entity> findEntitiesInApplication(Application application, Predicate<? super Entity> filter) { Predicate<Entity> predicate = Predicates.and(EntityPredicates.applicationIdEqualTo(application.getId()), filter); return ImmutableList.copyOf(Iterables.filter(entityProxiesById.values(), predicate)); }
@Override public Collection<Entity> getEntitiesInApplication(Application application) { Predicate<Entity> predicate = EntityPredicates.applicationIdEqualTo(application.getId()); return ImmutableList.copyOf(Iterables.filter(entityProxiesById.values(), predicate)); }
@Override public boolean apply(DockerHostLocation input) { Iterable<Entity> deployed = Iterables.filter( Iterables.transform(input.getDockerContainerList(), EntityFunctions.config(DockerContainer.ENTITY.getConfigKey())), Predicates.notNull()); Iterable<Entity> sameApplication = Iterables.filter(deployed, EntityPredicates.applicationIdEqualTo(applicationId)); if (Iterables.isEmpty(sameApplication)) { LOG.debug("No entities with application id {} on {}", applicationId, input); return false; } else { LOG.debug("Found entities with application id {} on {}", applicationId, input); return true; } } }
Predicate<Entity> predicate = EntityPredicates.applicationIdEqualTo(application.getId()); Set<Entity> result = Sets.newLinkedHashSet();
@Test public void testApplicationIdEqualTo() throws Exception { assertTrue(EntityPredicates.applicationIdEqualTo(app.getId()).apply(entity)); assertFalse(EntityPredicates.applicationIdEqualTo("wrongid").apply(entity)); }
/** * @return * The filter configured in {@link #ENTITY_FILTER} ANDed with a check that the * entity has the same application ID. */ protected Predicate<? super Entity> getEntityFilter() { Predicate<? super Entity> entityFilter = getConfig(ENTITY_FILTER); if (entityFilter == null) { entityFilter = Predicates.alwaysFalse(); } return Predicates.and( EntityPredicates.applicationIdEqualTo(getApplicationId()), entityFilter); }
@Test public void testDisplayNameSatisfies() throws Exception { assertTrue(EntityPredicates.displayNameSatisfies(StringPredicates.matchesRegex("myd.*me")).apply(entity)); assertFalse(EntityPredicates.applicationIdEqualTo("wrongname").apply(entity)); }
predicate = EntityPredicates.idEqualTo(entity.getId()); } else if (verb.equalsIgnoreCase(APPLICATION)) { predicate = EntityPredicates.applicationIdEqualTo(entity.getApplicationId()); } else { throw new IllegalStateException("Affinity rule parameter not specified: " + rule); predicate = EntityPredicates.idEqualTo(parameter); } else if (verb.equalsIgnoreCase(APPLICATION)) { predicate = EntityPredicates.applicationIdEqualTo(parameter); } else if (verb.equalsIgnoreCase(PREDICATE)) { try {
@Test public void testWaitFor() throws Exception { entity = app.createAndManageChild(EntitySpec.create(TestEntity.class)); Duration timeout = Duration.ONE_MILLISECOND; Entities.waitFor(entity, applicationIdEqualTo(app.getApplicationId()), timeout); try { Entities.waitFor(entity, applicationIdEqualTo(app.getApplicationId() + "-wrong"), timeout); Asserts.shouldHaveFailedPreviously("Entities.waitFor() should have timed out"); } catch (Exception e) { Asserts.expectedFailureContains(e, "Timeout waiting for "); } }
Predicates.and(MesosUtils.sameCluster(this), Predicates.not(EntityPredicates.applicationIdEqualTo(getApplicationId())))); Set<Application> applications = ImmutableSet.copyOf(Iterables.transform(entities, new Function<Entity, Application>() { @Override
Predicates.and(DockerUtils.sameInfrastructure(this), Predicates.not(EntityPredicates.applicationIdEqualTo(getApplicationId())))); Set<Application> applications = ImmutableSet.copyOf(Iterables.transform(entities, new Function<Entity, Application>() { @Override
.configure(DynamicMultiGroup.ENTITY_FILTER, Predicates.and( MesosUtils.sameCluster(this), Predicates.not(EntityPredicates.applicationIdEqualTo(getApplicationId())))) .configure(DynamicMultiGroup.RESCAN_INTERVAL, 15L) .configure(DynamicMultiGroup.BUCKET_FUNCTION, new Function<Entity, String>() {