热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.brooklyn.core.entity.Entities类的使用及代码示例

本文整理了Java中org.apache.brooklyn.core.entity.Entities类的一些代码示例,展示了Entities类

本文整理了Java中org.apache.brooklyn.core.entity.Entities类的一些代码示例,展示了Entities类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entities类的具体详情如下:
包路径:org.apache.brooklyn.core.entity.Entities
类名称:Entities

Entities介绍

[英]Convenience methods for working with entities.

Also see the various Methods classes for traits, such as StartableMethods for Startable implementations.
[中]使用实体的便捷方法。
另请参阅各种
方法类以了解特性,例如用于Startable实现的StartableMethods。

代码示例

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
if (mgmt != null) Entities.destroyAll(mgmt);
mgmt = null;
}

代码示例来源: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 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-software-base

@Override
public void run() {
Entities.unmanage(dryRunChild);
}
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** Invokes in parallel if multiple, but otherwise invokes the item directly. */
public static Task invokeEffector(Entity callingEntity, Iterable entitiesToCall,
final Effector effector, final Map parameters) {
if (Iterables.size(entitiesToCall)==1)
return invokeEffector(callingEntity, entitiesToCall.iterator().next(), effector, parameters);
else
return invokeEffectorList(callingEntity, entitiesToCall, effector, parameters);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
public void run() {
log.debug("destroying app "+app+" (managed? "+isManaged(app)+"; mgmt is "+mgmt+")");
try {
destroy(app);
log.debug("destroyed app "+app+"; mgmt now "+mgmt);
} catch (Exception e) {
log.warn("problems destroying app "+app+" (mgmt now "+mgmt+", will rethrow at least one exception): "+e);
error.compareAndSet(null, e);
}
}}));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-messaging

public String getNimbusHostname() {
String result = entity.getConfig(Storm.NIMBUS_HOSTNAME);
if (result != null) return result;
Entity nimbus = entity.getConfig(Storm.NIMBUS_ENTITY);
if (nimbus == null) {
log.warn("No nimbus hostname available; using 'localhost'");
return "localhost";
}
return Entities.submit(entity, DependentConfiguration.attributeWhenReady(nimbus, Attributes.HOSTNAME)).getUnchecked();
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** Invokes in parallel if multiple, but otherwise invokes the item directly. */
public static Task invokeEffector(Entity callingEntity, Iterable entitiesToCall,
final Effector effector) {
return invokeEffector(callingEntity, entitiesToCall, effector, Collections.emptyMap());
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-software-base

@AfterMethod(alwaysRun=true)
public void tearDown() throws Exception {
// Kills the apps before terminating the pool
for (TestApplication app : createdApps) {
Entities.destroy(app);
}
if (mgmt != null) {
Entities.destroyAll(mgmt);
mgmt = null;
}
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public static void dumpInfo(Location loc) {
try {
dumpInfo(loc, new PrintWriter(System.out), "", " ");
} catch (IOException exc) {
// system.out throwing an exception is odd, so don't have IOException on signature
throw new RuntimeException(exc);
}
}
public static void dumpInfo(Location loc, Writer out) throws IOException {

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
public boolean apply(@Nullable Entity input) {
return (input != null) && Entities.isManaged(input);
}
@Override

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/** Same as {@link #destroy(Location)} but catching all errors. */
public static void destroyCatching(Location loc) {
try {
destroy(loc);
} catch (Exception e) {
log.warn("ERROR destroying "+loc+" (ignoring): "+e, e);
Exceptions.propagateIfFatal(e);
}
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Override
public BrooklynObject apply(BrooklynObject obj) {
// entities must be deproxied
if (obj instanceof Entity) obj = Entities.deproxy((Entity)obj);
return obj;
}
}));

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

/**
* @deprecated since 0.10.0; see {@link #descendantsAndSelf(Entity, Predicate)}
*/
@Deprecated
public static Iterable descendants(Entity root, Predicate matching) {
return descendantsAndSelf(root, matching);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Test
public void testInvokeEffectorListWithEmptyUsingUnmanagedContext() throws Exception {
// Previously this threw the IllegalStateException directly, because DynamicTasks called
// ((EntityInternal)entity).getManagementSupport().getExecutionContext();
// (so it successfully called getManagementSupport, and then hit the exception.
// Now it calls ((EntityInternal)entity).getExecutionContext(), so the exception happens in
// the entity-proxy and is thus wrapped.
TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class));
Entities.unmanage(entity);
try {
Entities.invokeEffectorList(entity, ImmutableList.of(), Startable.STOP).get(Duration.THIRTY_SECONDS);
Asserts.shouldHaveFailedPreviously();
} catch (Exception e) {
IllegalStateException e2 = Exceptions.getFirstThrowableOfType(e, IllegalStateException.class);
if (e2 == null) throw e;
Asserts.expectedFailureContains(e2, "no longer managed");
}
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

public static Task> invokeEffectorListWithMap(Entity callingEntity, Iterable entitiesToCall,
final Effector effector, final Map parameters) {
return invokeEffectorList(callingEntity, entitiesToCall, effector, parameters);
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Test
public void testStartManagementOfEntityIsNoop() throws Exception {
Entity app2 = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class));
assertTrue(Entities.isManaged(app2));

Entities.startManagement(app2);
assertTrue(Entities.isManaged(app2));
listener.assertEventsEqualsEventually(ImmutableList.of(new ChangeEvent(ChangeType.ADDED, app2)));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-core

@Test
public void testStartManagementFailsIfAppDeleted() throws Exception {
TestApplication app2 = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class));
Entities.unmanage(app2);

try {
Entities.startManagement(app2, mgmt);
fail("Managed deleted app "+app2+" in "+mgmt);
} catch (IllegalStateException e) {
if (!(e.toString().contains("No concrete entity known"))) throw e;
}
}

代码示例来源: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-software-base

private void runTestGeneratesCorrectDownloadUrl(String version, String expectedUrl) throws Exception {
// TODO Using BrooklynNodeImpl directly, because want to instantiate a BroolynNodeSshDriver.
// Really want to make that easier to test, without going through "wrong" code path for creating entity.
BrooklynNode entity = app.addChild(EntitySpec.create(BrooklynNode.class)
.configure(BrooklynNode.SUGGESTED_VERSION, version));
BrooklynNodeImpl entityImpl = (BrooklynNodeImpl) Entities.deproxy(entity);
ConfigToAttributes.apply(entity);
BrooklynNodeSshDriver driver = new BrooklynNodeSshDriver(entityImpl, loc);
DownloadResolver resolver = Entities.newDownloader(driver);
List urls = resolver.getTargets();
System.out.println("urls=" + urls);
assertTrue(urls.contains(expectedUrl), "urls=" + urls);
}

代码示例来源: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));
}

推荐阅读
author-avatar
H-蔡鸿晖_515
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有