本文整理了Java中org.apache.brooklyn.core.entity.Entities.start()
方法的一些代码示例,展示了Entities.start()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entities.start()
方法的具体详情如下:
包路径:org.apache.brooklyn.core.entity.Entities
类名称:Entities
方法名:start
[英]convenience for starting an entity, esp a new Startable instance which has been created dynamically (after the application is started)
[中]启动实体的便利性(尤指动态创建的新Startable实例)(在应用程序启动后)
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
@Override
protected void doStart(Collection<? extends Location> locations) {
Optional<Location> dockerLocation = Iterables.tryFind(getLocations(), Predicates.instanceOf(DockerLocation.class));
if (!dockerLocation.isPresent()) {
String locationName = DOCKER_LOCATION_PREFIX + getId();
DockerInfrastructure dockerInfrastructure = addChild(EntitySpec.create(DockerInfrastructure.class)
.configure(DockerInfrastructure.DOCKER_HOST_CLUSTER_MIN_SIZE, 1)
.configure(DockerInfrastructure.SDN_ENABLE, false)
.configure(DockerInfrastructure.LOCATION_NAME, locationName)
.displayName("Docker Infrastructure"));
Entities.start(dockerInfrastructure, locations);
dockerLocation = Optional.of(getManagementContext().getLocationRegistry().resolve(locationName));
}
Entities.start(vanillaDockerApplication, dockerLocation.asSet());
}
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
@Override
protected void doStart(Collection<? extends Location> locations) {
Optional<Location> dockerLocation = Iterables.tryFind(getLocations(), Predicates.instanceOf(DockerLocation.class));
if (!dockerLocation.isPresent()) {
String locationName = DOCKER_LOCATION_PREFIX + getId();
DockerInfrastructure dockerInfrastructure = addChild(EntitySpec.create(DockerInfrastructure.class)
.configure(DockerInfrastructure.DOCKER_HOST_CLUSTER_MIN_SIZE, 1)
.configure(DockerInfrastructure.SDN_ENABLE, false)
.configure(DockerInfrastructure.LOCATION_NAME, locationName)
.displayName("Docker Infrastructure"));
Entities.start(dockerInfrastructure, locations);
dockerLocation = Optional.of(getManagementContext().getLocationRegistry().resolve(locationName));
}
Entities.start(vanillaDockerApplication, dockerLocation.asSet());
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
@Test(groups = "Integration", dataProvider = "entitiesWithWarAndURL")
public void initialNamedWarDeployments(final SoftwareProcess entity, final String war,
final String urlSubPathToWebApp, final String urlSubPathToPageToQuery) {
this.entity = entity;
log.info("test=initialNamedWarDeployments; entity="+entity+"; app="+entity.getApplication());
URL resource = getClass().getClassLoader().getResource(war);
assertNotNull(resource);
entity.config().set(JavaWebAppService.NAMED_WARS, ImmutableList.of(resource.toString()));
Entities.start(entity.getApplication(), ImmutableList.of(loc));
Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
@Override
public void run() {
// TODO get this URL from a WAR file entity
HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToWebApp, urlSubPathToPageToQuery), 200);
}});
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Checks an entity can start, set SERVICE_UP to true and shutdown again.
*/
@Test(groups = "Integration", dataProvider = "basicEntities")
public void canStartAndStop(final SoftwareProcess entity) {
this.entity = entity;
log.info("test=canStartAndStop; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
EntityAsserts.assertAttributeEqualsEventually(
MutableMap.of("timeout", 120*1000), entity, Startable.SERVICE_UP, Boolean.TRUE);
entity.stop();
assertFalse(entity.getAttribute(Startable.SERVICE_UP));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Checks an entity can start, set SERVICE_UP to true and shutdown again.
*/
@Test(groups = "Integration", dataProvider = "basicEntities")
public void testReportsServiceDownWhenKilled(final SoftwareProcess entity) throws Exception {
this.entity = entity;
log.info("test=testReportsServiceDownWithKilled; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
EntityAsserts.assertAttributeEqualsEventually(MutableMap.of("timeout", 120*1000), entity, Startable.SERVICE_UP, true);
// Stop the underlying entity, but without our entity instance being told!
killEntityBehindBack(entity);
log.info("Killed {} behind mgmt's back, waiting for service up false in mgmt context", entity);
EntityAsserts.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, false);
log.info("success getting service up false in primary mgmt universe");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
@Test(groups = {"Integration","Broken"})
public void testInitialNamedDeployments() {
final String urlSubPathToWebApp = APP_NAME;
final String urlSubPathToPageToQuery = "";
LOG.info("test=testInitialNamedDeployments; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
Asserts.succeedsEventually(MutableMap.of("timeout", Duration.minutes(1)), new Runnable() {
@Override
public void run() {
// TODO get this URL from a web-app entity of some kind?
String url = Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToWebApp, urlSubPathToPageToQuery);
HttpTestUtils.assertHttpStatusCodeEquals(url, 200);
}});
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Tests given entity can deploy the given war. Checks given httpURL to confirm success.
*/
@Test(groups = "Integration", dataProvider = "entitiesWithWarAndURL")
public void initialRootWarDeployments(final SoftwareProcess entity, final String war,
final String urlSubPathToWebApp, final String urlSubPathToPageToQuery) {
this.entity = entity;
log.info("test=initialRootWarDeployments; entity="+entity+"; app="+entity.getApplication());
URL resource = getClass().getClassLoader().getResource(war);
assertNotNull(resource);
entity.config().set(JavaWebAppService.ROOT_WAR, resource.toString());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
//tomcat may need a while to unpack everything
Asserts.succeedsEventually(MutableMap.of("timeout", 60*1000), new Runnable() {
@Override
public void run() {
// TODO get this URL from a WAR file entity
HttpTestUtils.assertHttpStatusCodeEquals(Urls.mergePaths(entity.getAttribute(WebAppService.ROOT_URL), urlSubPathToPageToQuery), 200);
assertEquals(entity.getAttribute(JavaWebAppSoftwareProcess.DEPLOYED_WARS), ImmutableSet.of("/"));
}});
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Checks an entity can start, set SERVICE_UP to true and shutdown again.
*/
// Broken on Ubuntu 15.04 Vivid, no packages from ppa:chris-lea/node.js available
@Test(groups = {"Integration","Broken"})
public void testCanStartAndStop() {
LOG.info("test=canStartAndStop; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
Asserts.succeedsEventually(MutableMap.of("timeout", 120*1000), new Runnable() {
@Override
public void run() {
assertTrue(entity.getAttribute(Startable.SERVICE_UP));
}});
entity.stop();
assertFalse(entity.getAttribute(Startable.SERVICE_UP));
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Checks an entity can start, set SERVICE_UP to true and shutdown again.
*/
// Broken on Ubuntu 15.04 Vivid, no packages from ppa:chris-lea/node.js available
@Test(groups = {"Integration","Broken"})
public void testReportsServiceDownWhenKilled() throws Exception {
LOG.info("test=testReportsServiceDownWithKilled; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
EntityAsserts.assertAttributeEqualsEventually(MutableMap.of("timeout", Duration.minutes(2)), entity, Startable.SERVICE_UP, true);
// Stop the underlying entity, but without our entity instance being told!
killEntityBehindBack(entity);
LOG.info("Killed {} behind mgmt's back, waiting for service up false in mgmt context", entity);
EntityAsserts.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, false);
LOG.info("success getting service up false in primary mgmt universe");
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
assertNotNull(resource);
Entities.start(entity.getApplication(), ImmutableList.of(loc));
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
log.info("test=publishesRequestAndErrorCountMetrics; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
EntityAsserts.assertAttributeEqualsEventually(
MutableMap.of("timeout", 120 * 1000), entity, Startable.SERVICE_UP, Boolean.TRUE);
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
/**
* Tests that we get consecutive events with zero workrate, and with suitably small timestamps between them.
*/
@Test(groups = "Integration", dataProvider = "basicEntities")
@SuppressWarnings("rawtypes")
public void publishesZeroRequestsPerSecondMetricRepeatedly(final SoftwareProcess entity) {
this.entity = entity;
log.info("test=publishesZeroRequestsPerSecondMetricRepeatedly; entity="+entity+"; app="+entity.getApplication());
final int maxIntervalBetweenEvents = 4000; // TomcatServerImpl publishes events every 3000ms so this should be enough overhead
final int consecutiveEvents = 3;
Entities.start(entity.getApplication(), ImmutableList.of(loc));
SubscriptionHandle subscriptionHandle = null;
final CopyOnWriteArrayList<SensorEvent<Double>> events = new CopyOnWriteArrayList<>();
try {
subscriptionHandle = recordEvents(entity, WebAppService.REQUESTS_PER_SECOND_IN_WINDOW, events);
Asserts.succeedsEventually(assertConsecutiveSensorEventsEqual(
events, WebAppService.REQUESTS_PER_SECOND_IN_WINDOW, 0.0d, consecutiveEvents, maxIntervalBetweenEvents));
} finally {
if (subscriptionHandle != null) entity.subscriptions().unsubscribe(subscriptionHandle);
entity.stop();
}
}
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
@Override
public void postStart(Collection<? extends Location> locations) {
if (config().get(DOCKER_SHOULD_START_REGISTRY)) {
DockerHost firstEntity = (DockerHost) sensors().get(DOCKER_HOST_CLUSTER).sensors().get(DynamicCluster.FIRST);
EntitySpec<DockerRegistry> spec = EntitySpec.create(DockerRegistry.class)
.configure(DockerRegistry.DOCKER_HOST, firstEntity)
.configure(DockerRegistry.DOCKER_REGISTRY_PORT, config().get(DOCKER_REGISTRY_PORT));
// TODO Mount volume with images stored on it
DockerRegistry registry = addChild(spec);
LOG.debug("Starting a new Docker Registry with spec {}", spec);
Entities.start(registry, ImmutableList.of(firstEntity.getDynamicLocation()));
String registryUrl = HostAndPort.fromParts(firstEntity.sensors().get(Attributes.ADDRESS), config().get(DOCKER_REGISTRY_PORT)).toString();
sensors().set(DOCKER_IMAGE_REGISTRY_URL, registryUrl);
sensors().set(DOCKER_IMAGE_REGISTRY, registry);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
log.info("test=publishesRequestsPerSecondMetric; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-mesos
.configure(SubnetTier.PORT_FORWARDER, portForwarder)
.configure(SubnetTier.SUBNET_CIDR, Cidr.UNIVERSAL));
Entities.start(subnetTier, ImmutableList.of(machine));
added.sensors().set(MesosSlave.SUBNET_TIER, subnetTier);
代码示例来源:origin: org.apache.brooklyn/brooklyn-software-webapp
log.info("test=testRequestCountContinuallyPublishedWhenEntityKilled; entity="+entity+"; app="+entity.getApplication());
Entities.start(entity.getApplication(), ImmutableList.of(loc));
EntityAsserts.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, Boolean.TRUE);
String url = entity.getAttribute(WebAppService.ROOT_URL) + "does_not_exist";
代码示例来源:origin: io.brooklyn.clocker/brooklyn-clocker-docker
public static final VirtualNetwork createNetwork(final SdnProvider provider, final String networkId) {
boolean createNetwork = false;
Cidr subnetCidr = null;
VirtualNetwork network = null;
synchronized (provider.getNetworkMutex()) {
subnetCidr = provider.getSubnetCidr(networkId);
if (subnetCidr == null) {
subnetCidr = provider.getNextSubnetCidr(networkId);
createNetwork = true;
}
}
if (createNetwork) {
// Get a CIDR for the subnet from the availabkle pool and create a virtual network
EntitySpec<VirtualNetwork> networkSpec = EntitySpec.create(VirtualNetwork.class)
.configure(SdnAttributes.SDN_PROVIDER, provider)
.configure(VirtualNetwork.NETWORK_ID, networkId)
.configure(VirtualNetwork.NETWORK_CIDR, subnetCidr);
// Start and then add this virtual network as a child of SDN_NETWORKS
network = provider.sensors().get(SdnProvider.SDN_NETWORKS).addChild(networkSpec);
Entities.start(network, provider.getLocations());
Entities.waitForServiceUp(network);
} else {
network = lookupNetwork(provider, networkId);
}
return network;
}
内容来源于网络,如有侵权,请联系作者删除!