本文整理了Java中org.apache.brooklyn.core.entity.Entities.descendantsAndSelf()
方法的一些代码示例,展示了Entities.descendantsAndSelf()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entities.descendantsAndSelf()
方法的具体详情如下:
包路径:org.apache.brooklyn.core.entity.Entities
类名称:Entities
方法名:descendantsAndSelf
[英]Returns the entity, its children, and all its children, and so on.
[中]返回实体、其子对象及其所有子对象,依此类推。
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* @deprecated since 0.10.0; see {@link #descendantsAndSelf(Entity, Predicate)}
*/
@Deprecated
public static Iterable<Entity> descendants(Entity root, Predicate<? super Entity> matching) {
return descendantsAndSelf(root, matching);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* Returns the entities matching the given predicate.
*
* @see #descendants(Entity, Predicate, boolean)
*/
public static Iterable<Entity> descendantsAndSelf(Entity root, Predicate<? super Entity> matching) {
return Iterables.filter(descendantsAndSelf(root), matching);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* @deprecated since 0.10.0; see {@link #descendantsAndSelf(Entity)}
*/
@Deprecated
public static Iterable<Entity> descendants(Entity root) {
return descendantsAndSelf(root);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* @deprecated since 0.10.0; see {@link #descendantsAndSelf(Entity)}
*/
@Deprecated
public static <T extends Entity> Iterable<T> descendants(Entity root, Class<T> ofType) {
return descendantsAndSelf(root, ofType);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* Return all descendants of given entity of the given type, potentially including the given root.
*
* @see #descendants(Entity)
* @see Iterables#filter(Iterable, Class)
*/
public static <T extends Entity> Iterable<T> descendantsAndSelf(Entity root, Class<T> ofType) {
return Iterables.filter(descendantsAndSelf(root), ofType);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
private enum ValueMarkers {
UNCHANGED,
REMOVE;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
@Test
public void testTargetGroupCanBeSetInYaml() throws Exception {
final String resourceName = "classpath:/" + getClass().getPackage().getName().replace('.', '/') + "/geodns.yaml";
final String blueprint = loadYaml(resourceName);
Application app = EntityManagementUtils.createUnstarted(mgmt(), blueprint);
GeoscalingDnsService geodns = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, GeoscalingDnsService.class));
DynamicFabric fabric = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, DynamicFabric.class));
assertEquals(geodns.config().get(AbstractGeoDnsService.ENTITY_PROVIDER), fabric);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
protected void deployAndAssertDisplayName(String yaml, String expectedName) throws Exception {
Entity app = createAndStartApplication(yaml);
Entity entity = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, TestEntity.class));
assertEquals(entity.getDisplayName(), expectedName);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
@SuppressWarnings("deprecation")
public void testDescendantsFilteredByType() throws Exception {
Asserts.assertEqualsIgnoringOrder(Entities.descendantsAndSelf(app, TestEntity.class), ImmutableList.of(entity, entity2));
Asserts.assertEqualsIgnoringOrder(Entities.descendants(app, TestEntity.class), ImmutableList.of(entity, entity2));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
@SuppressWarnings("deprecation")
public void testDescendants() throws Exception {
Asserts.assertEqualsIgnoringOrder(Entities.descendantsAndSelf(app), ImmutableList.of(app, entity, entity2));
Asserts.assertEqualsIgnoringOrder(Entities.descendants(app), ImmutableList.of(app, entity, entity2));
Asserts.assertEqualsIgnoringOrder(Entities.descendantsAndSelf(entity), ImmutableList.of(entity));
Asserts.assertEqualsIgnoringOrder(Entities.descendants(entity), ImmutableList.of(entity));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-launcher
@Override
public void run() {
for (Entity entity : Entities.descendantsAndSelf(app)) {
assertNotEquals(entity.getAttribute(Attributes.SERVICE_STATE_ACTUAL), Lifecycle.ON_FIRE);
assertNotEquals(entity.getAttribute(Attributes.SERVICE_UP), false);
if (entity instanceof SoftwareProcess) {
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
EntityAsserts.assertAttributeEquals(entity, Attributes.SERVICE_UP, Boolean.TRUE);
}
}
}});
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
@SuppressWarnings("deprecation")
public void testDescendantsFilteredByPredicate() throws Exception {
Asserts.assertEqualsIgnoringOrder(Entities.descendantsAndSelf(app, Predicates.instanceOf(TestEntity.class)), ImmutableList.of(entity, entity2));
Asserts.assertEqualsIgnoringOrder(Entities.descendants(app, Predicates.instanceOf(TestEntity.class)), ImmutableList.of(entity, entity2));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testEntityCreatingItsEnricherDoesNotReCreateItUnlessUniqueTagDifferent() throws Exception {
TestEntity e1 = origApp.createAndManageChild(EntitySpec.create(TestEntity.class, MyTestEntityWithEnricher.class));
Collection<Enricher> e1e = e1.getEnrichers();
log.info("enrichers1: "+e1e);
Entities.dumpInfo(e1);
assertEquals(e1e.size(), 5);
newApp = rebind();
Entity e2 = Iterables.getOnlyElement( Entities.descendantsAndSelf(newApp, EntityPredicates.idEqualTo(e1.getId())) );
Collection<Enricher> e2e = e2.getEnrichers();
log.info("enrichers2: "+e2e);
Entities.dumpInfo(e2);
assertEquals(e2e.size(), e1e.size()+1);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testNoWinrm() throws Exception {
Entity app = createAndStartApplication(
"location: byon:(hosts=\"1.2.3.4\",osFamily=windows)",
"services:",
"- type: "+EmptyWindowsProcess.class.getName(),
" brooklyn.config:",
" winrmMonitoring.enabled: false",
" onbox.base.dir.skipResolution: true");
waitForApplicationTasks(app);
EmptyWindowsProcess entity = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, EmptyWindowsProcess.class));
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true);
EntityAsserts.assertAttributeEqualsContinually(entity, Attributes.SERVICE_UP, true);
Iterables.find(entity.getLocations(), Predicates.instanceOf(WinRmMachineLocation.class));
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test(groups="Integration")
public void testNoSshing() throws Exception {
Entity app = createAndStartApplication(
"location: byon:(hosts=\"1.2.3.4\")",
"services:",
"- type: "+EmptySoftwareProcess.class.getName(),
" brooklyn.config:",
" sshMonitoring.enabled: false",
" "+BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION.getName()+": true");
waitForApplicationTasks(app);
EmptySoftwareProcess entity = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, EmptySoftwareProcess.class));
EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true);
EntityAsserts.assertAttributeEqualsContinually(entity, Attributes.SERVICE_UP, true);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-launcher
@Override public boolean apply(Application app) {
VanillaWindowsProcess entity = Iterables.getOnlyElement(Entities.descendantsAndSelf(app, VanillaWindowsProcess.class));
String winRMAddress = entity.getAttribute(AdvertiseWinrmLoginPolicy.VM_USER_CREDENTIALS);
String ipPort = Strings.getFirstWordAfter(winRMAddress, "@");
String user = Strings.getFirstWord(winRMAddress);
String password = Strings.getFirstWordAfter(winRMAddress, ":");
WinRmTool winRmTool = WinRmTool.Builder.builder(ipPort, user, password).build();
WinRmToolResponse winRmResponse = winRmTool.executePs(ImmutableList.of("(Get-Item \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\").name"));
LOG.info("winRmResponse: code="+winRmResponse.getStatusCode()+"; out="+winRmResponse.getStdOut()+"; err="+winRmResponse.getStdErr());
return "7z.exe\r\n".equals(winRmResponse.getStdOut());
}
};
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
@Test
public void testCanDisableFilterForRunningEntities() throws Exception {
geoDns.config().set(AbstractGeoDnsService.FILTER_FOR_RUNNING, false);
app.start(ImmutableList.of(westChildWithLocation, eastChildWithLocationAndWithPrivateHostname));
publishSensors(2, true, true, true);
assertAttributeEventually(geoDns, AbstractGeoDnsService.TARGETS, CollectionFunctionals.<String>mapSizeEquals(2));
final Map<String, String> targets = ImmutableMap.copyOf(geoDns.sensors().get(AbstractGeoDnsService.TARGETS));
TestEntity problemChild = Iterables.get(Entities.descendantsAndSelf(app, TestEntity.class), 0);
problemChild.sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
assertAttributeEqualsContinually(geoDns, AbstractGeoDnsService.TARGETS, targets);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
@Test(groups={"Broken"})
public void testFiltersForRunningEntities() {
app.start(ImmutableList.of(westChildWithLocation, eastChildWithLocationAndWithPrivateHostname));
publishSensors(2, true, true, true);
TestEntity problemChild = Iterables.get(Entities.descendantsAndSelf(app, TestEntity.class), 0);
assertAttributeEventually(geoDns, AbstractGeoDnsService.TARGETS, CollectionFunctionals.<String>mapSizeEquals(2));
problemChild.sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE);
assertAttributeEventually(geoDns, AbstractGeoDnsService.TARGETS, CollectionFunctionals.<String>mapSizeEquals(1));
problemChild.sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
assertAttributeEventually(geoDns, AbstractGeoDnsService.TARGETS, CollectionFunctionals.<String>mapSizeEquals(2));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testEntityTags() throws Exception {
MyEntity origE = origApp.createAndManageChild(EntitySpec.create(MyEntity.class));
origE.tags().addTag("foo");
origE.tags().addTag(origApp);
newApp = rebind();
MyEntity newE = Iterables.getOnlyElement( Entities.descendantsAndSelf(newApp, MyEntity.class) );
assertTrue(newE.tags().containsTag("foo"), "tags are "+newE.tags().getTags());
assertFalse(newE.tags().containsTag("bar"));
assertTrue(newE.tags().containsTag(newE.getParent()));
assertTrue(newE.tags().containsTag(origApp));
assertEquals(newE.tags().getTags(), MutableSet.of("foo", newE.getParent()));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
@Test(groups = "Integration")
public void testResizeAfterRebind() throws Exception {
DynamicCluster cluster = app().createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure(DynamicCluster.INITIAL_SIZE, 3)
.configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
app().start(ImmutableList.of(app().newLocalhostProvisioningLocation()));
EntityAsserts.assertAttributeEquals(cluster, DynamicCluster.GROUP_SIZE, 3);
rebind(RebindOptions.create().terminateOrigManagementContext(true));
cluster = Iterables.getOnlyElement(Entities.descendantsAndSelf(newApp, DynamicCluster.class));
cluster.resize(5);
EntityAsserts.assertAttributeEquals(cluster, DynamicCluster.GROUP_SIZE, 5);
EntityAsserts.assertAttributeEquals(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
}
}
内容来源于网络,如有侵权,请联系作者删除!