本文整理了Java中org.apache.brooklyn.core.entity.Entities.manage()
方法的一些代码示例,展示了Entities.manage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entities.manage()
方法的具体详情如下:
包路径:org.apache.brooklyn.core.entity.Entities
类名称:Entities
方法名:manage
[英]Brings this entity under management only if its ancestor is managed.
Returns true if successful, otherwise returns false in the expectation that the ancestor will become managed, or throws exception if it has no parent or a non-application root.
[中]仅当其祖先被管理时,才将此实体置于管理之下。
如果成功,则返回true,否则返回false,预期祖先将被管理,或者如果没有父级或非应用程序根,则抛出异常。
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/** convenience for starting an entity, esp a new Startable instance which has been created dynamically
* (after the application is started) */
public static void start(Entity e, Collection<? extends Location> locations) {
if (!isManaged(e) && !manage(e)) {
log.warn("Using deprecated discouraged mechanism to start management -- Entities.start(Application, Locations) -- caller should create and use the preferred management context");
startManagement(e);
}
if (e instanceof Startable) Entities.invokeEffector(e, e, Startable.START,
MutableMap.of("locations", locations)).getUnchecked();
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testManageFailsIfEntityDeleted() throws Exception {
TestEntity child = mgmt.getEntityManager().createEntity(EntitySpec.create(TestEntity.class)
.parent(app));
Entities.unmanage(child);
try {
Entities.manage(child);
fail("Managed deleted entity "+child+" in "+mgmt);
} catch (IllegalArgumentException e) {
if (!(e.toString().contains("Can't manage"))) throw e;
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
/**
* @deprecated since 0.7; support for rebinding old-style entities is deprecated
*/
@Deprecated
@Test
public void testHandlesOldStyleEntity() throws Exception {
MyOldStyleEntity origE = new MyOldStyleEntity(MutableMap.of("confName", "myval"), origApp);
Entities.manage(origE);
newApp = rebind();
MyOldStyleEntity newE = (MyOldStyleEntity) Iterables.find(newApp.getChildren(), EntityPredicates.idEqualTo(origE.getId()));
assertEquals(newE.getConfig(MyOldStyleEntity.CONF_NAME), "myval");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testManageIsNoop() throws Exception {
TestEntity child = mgmt.getEntityManager().createEntity(EntitySpec.create(TestEntity.class)
.parent(app));
Entities.manage(child);
assertTrue(Entities.isManaged(child));
listener.assertEventsEqualsEventually(ImmutableList.of(new ChangeEvent(ChangeType.ADDED, child)));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Override
public Entity addNode(@Nullable Location loc, Map<?, ?> extraFlags) {
// In case subclasses are foolish and do not call super.init() when overriding.
initialiseMemberId();
Map<?, ?> createFlags = MutableMap.builder()
.putAll(getCustomChildFlags())
.putAll(extraFlags)
.put(CLUSTER_MEMBER_ID, sensors().get(NEXT_CLUSTER_MEMBER_ID).get())
.build();
if (LOG.isTraceEnabled()) {
LOG.trace("Creating and adding a node to cluster {}({}) with properties {}", new Object[] { this, getId(), Sanitizer.sanitize(createFlags) });
}
// TODO should refactor to have a createNodeSpec; and spec should support initial sensor values
Entity entity = createNode(loc, createFlags);
entity.sensors().set(CLUSTER_MEMBER, true);
entity.sensors().set(CLUSTER, this);
// Continue to call manage(), because some uses of NodeFactory (in tests) still instantiate the
// entity via its constructor
Entities.manage(entity);
addMember(entity);
return entity;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
protected Entity addCluster(Location location) {
String locationName = elvis(location.getDisplayName(), location.getDisplayName(), null);
Map creation = Maps.newLinkedHashMap();
creation.putAll(getCustomChildFlags());
if (groovyTruth(getDisplayNamePrefix()) || groovyTruth(getDisplayNameSuffix())) {
String displayName = "" + elvis(getDisplayNamePrefix(), "") + elvis(locationName, "unnamed") + elvis(getDisplayNameSuffix(),"");
creation.put("displayName", displayName);
}
logger.info("Creating entity in fabric {} at {}{}", new Object[] {this, location,
(creation!=null && !creation.isEmpty() ? ", properties "+creation : "") });
Entity entity = createCluster(location, creation);
if (locationName != null) {
if (entity.getDisplayName()==null)
entity.setDisplayName(entity.getEntityType().getSimpleName() +" ("+locationName+")");
else if (!entity.getDisplayName().contains(locationName))
entity.setDisplayName(entity.getDisplayName() +" ("+locationName+")");
}
if (entity.getParent()==null) entity.setParent(this);
// Continue to call manage(), because some uses of NodeFactory (in tests) still instantiate the
// entity via its constructor
Entities.manage(entity);
addMember(entity);
return entity;
}
内容来源于网络,如有侵权,请联系作者删除!