本文整理了Java中org.apache.brooklyn.api.entity.Entity.getChildren()
方法的一些代码示例,展示了Entity.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getChildren()
方法的具体详情如下:
包路径:org.apache.brooklyn.api.entity.Entity
类名称:Entity
方法名:getChildren
[英]Return the entities that are children of (i.e. "owned by") this entity
[中]返回该实体的子实体(即“拥有者”)
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
protected void setEntityAfterSubscribingProducerChildrenEvents() {
for (Entity child : Iterables.filter(producer.getChildren(), entityFilter)) {
addProducerChild(child);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
private static void gatherAllDescendants(Entity e, List<Entity> result) {
if (result.add(e)) {
for (Entity ee: e.getChildren())
gatherAllDescendants(ee, result);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-rest-resources
/** walks the hierarchy (depth-first) at root (often an Application) looking for
* an entity matching the given ID or name; returns the first such entity, or null if none found
**/
public Entity searchForEntityNamed(Entity root, String entity) {
if (root.getId().equals(entity) || entity.equals(root.getDisplayName())) return root;
for (Entity child: root.getChildren()) {
Entity result = searchForEntityNamed(child, entity);
if (result!=null) return result;
}
return null;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base
private void addRequiredOpenPortsRecursively(Entity entity, Set<Integer> ports) {
ports.addAll(entity.getConfig(SameServerEntity.REQUIRED_OPEN_LOGIN_PORTS));
Boolean portsAutoInfer = entity.getConfig(SameServerEntity.INBOUND_PORTS_AUTO_INFER);
String portsRegex = entity.getConfig(SameServerEntity.INBOUND_PORTS_CONFIG_REGEX);
ports.addAll(InboundPortsUtils.getRequiredOpenPorts(entity, portsAutoInfer, portsRegex));
LOG.debug("getRequiredOpenPorts detected default {} for {}", ports, entity);
for (Entity child : entity.getChildren()) {
addRequiredOpenPortsRecursively(child, ports);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/** unsubmitted task for restarting children of the given entity */
public static TaskAdaptable<?> restartingChildren(Entity entity, ConfigBag parameters) {
return Effectors.invocation(Startable.RESTART, parameters.getAllConfig(), filterStartableManagedEntities(entity.getChildren()));
}
/** as {@link #restartingChildren(Entity, ConfigBag)} with no parameters */
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
private void checkGrandchildEntitySpec(Entity createAndStartApplication, String entityName) {
Collection<Entity> children = createAndStartApplication.getChildren();
Assert.assertEquals(children.size(), 1);
Entity child = Iterables.getOnlyElement(children);
Collection<Entity> grandChildren = child.getChildren();
Assert.assertEquals(grandChildren.size(), 1);
Entity grandChild = Iterables.getOnlyElement(grandChildren);
Assert.assertEquals(grandChild.getDisplayName(), entityName);
Assert.assertEquals(grandChild.getEntityType().getName(), BasicEntity.class.getName());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testDslParent() throws Exception {
final Entity app = createAndStartApplication(
"services:",
"- type: " + BasicApplication.class.getName(),
" brooklyn.children:",
" - type: " + BasicEntity.class.getName(),
" brooklyn.config:",
" dest: $brooklyn:parent()");
final Entity child = Iterables.getOnlyElement(app.getChildren());
assertEquals(getConfigEventually(child, DEST), app);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testFlagAtRootEntityImpl() throws Exception {
Entity app = createAndStartApplication(
"services:",
"- serviceType: " + TestEntityImpl.class.getName(),
" confName: Foo Bar");
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_NAME), "Foo Bar");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testExplicitFlagsEntityImpl() throws Exception {
Entity app = createAndStartApplication(
"services:",
"- serviceType: " + TestEntityImpl.class.getName(),
" brooklyn.flags:",
" confName: Foo Bar");
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_NAME), "Foo Bar");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testWrapsAppIfNameAtTopLevelAndOnApp() throws Exception {
String yaml = Joiner.on("\n").join(
"name: myTopLevelName",
"services:",
"- serviceType: org.apache.brooklyn.core.test.entity.TestApplication",
" name: myEntityName");
Entity app = createStartWaitAndLogApplication(yaml);
assertNull(app.getConfig(EntityManagementUtils.WRAPPER_APP_MARKER));
assertEquals(app.getDisplayName(), "myTopLevelName");
assertEquals(app.getChildren().size(), 0);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
private void checkChildEntitySpec(Entity app, String entityName) {
Collection<Entity> children = app.getChildren();
Assert.assertEquals(children.size(), 1);
Entity child = Iterables.getOnlyElement(children);
Assert.assertEquals(child.getDisplayName(), entityName);
Assert.assertEquals(child.getEntityType().getName(), BasicEntity.class.getName());
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
private void checkChildEntitySpec(Entity app, String entityName) {
Collection<Entity> children = app.getChildren();
Assert.assertEquals(children.size(), 1);
Entity child = Iterables.getOnlyElement(children);
Assert.assertEquals(child.getDisplayName(), entityName);
Assert.assertEquals(child.getEntityType().getName(), BasicEntity.class.getName());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
protected Entity setupAndCheckTestEntityInBasicYamlWith(String ...extras) throws Exception {
Entity app = createAndStartApplication(loadYaml("test-entity-basic-template.yaml", extras));
waitForApplicationTasks(app);
Entities.dumpInfo(app);
Assert.assertEquals(app.getDisplayName(), "test-entity-basic-template");
log.info("App started:");
Entities.dumpInfo(app);
Assert.assertTrue(app.getChildren().iterator().hasNext(), "Expected app to have child entity");
Entity entity = app.getChildren().iterator().next();
Assert.assertTrue(entity instanceof TestEntity, "Expected TestEntity, found " + entity.getClass());
return entity;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testEntityTypeAsImpl() throws Exception {
String yaml =
"services:"+"\n"+
"- type: "+CustomTestEntityImpl.class.getName()+"\n";
Entity app = createStartWaitAndLogApplication(yaml);
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
assertEquals(testEntity.getEntityType().getName(), "CustomTestEntityImpl");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testReferenceAppYamlAsPlatformComponent() throws Exception {
Entity app = createAndStartApplication(
"services:",
"- name: Reference child name",
" type: classpath://yaml-ref-app.yaml");
Assert.assertEquals(app.getChildren().size(), 0);
Assert.assertEquals(app.getDisplayName(), "Reference child name");
//child is a proxy so equality test won't do
Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testConfigAppliedToCatalogItem() throws Exception {
addCatalogOSGiEntity("test", TestEntity.class.getName());
String testName = "test-applies-config-on-catalog-item";
Entity app = createAndStartApplication(
"services:",
"- type: " + ver("test"),
" brooklyn.config:",
" test.confName: " + testName);
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testExplicitFlagsAppliesToCatalogItem() throws Exception {
addCatalogOSGiEntity("test", TestEntity.class.getName());
String testName = "test-applies-config-on-catalog-item";
Entity app = createAndStartApplication(
"services:",
"- type: " + ver("test"),
" brooklyn.flags:",
" confName: " + testName);
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testExplicitFlagsAppliesToCatalogItemImpl() throws Exception {
addCatalogOSGiEntity("test", TestEntityImpl.class.getName());
String testName = "test-applies-config-on-catalog-item";
Entity app = createAndStartApplication(
"services:",
"- type: " + ver("test"),
" brooklyn.flags:",
" confName: " + testName);
Entity testEntity = Iterables.getOnlyElement(app.getChildren());
assertEquals(testEntity.config().get(TestEntity.CONF_NAME), testName);
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
@Test
public void testRefToSelf() throws Exception {
Entity app = createAndStartApplication(
"services:",
"- type: " + TestEntity.class.getName(),
" test.confObject: $brooklyn:self()",
" test.confName: $brooklyn:self().attributeWhenReady(\"mysensor\")");
Entity entity = Iterables.getOnlyElement(app.getChildren());
assertEquals(entity.getConfig(TestEntity.CONF_OBJECT), entity);
entity.sensors().set(Sensors.newStringSensor("mysensor"), "myval");
assertEquals(entity.getConfig(TestEntity.CONF_NAME), "myval");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-camp
private void registerAndLaunchAndAssertSimpleEntity(String symbolicName, String serviceType) throws Exception {
addCatalogOSGiEntity(symbolicName, serviceType);
String yaml = "name: simple-app-yaml\n" +
"location: localhost\n" +
"services: \n" +
" - serviceType: "+ver(symbolicName);
Entity app = createAndStartApplication(yaml);
Entity simpleEntity = Iterables.getOnlyElement(app.getChildren());
assertEquals(simpleEntity.getEntityType().getName(), SIMPLE_ENTITY_TYPE);
deleteCatalogEntity(symbolicName);
}
内容来源于网络,如有侵权,请联系作者删除!