org.apache.brooklyn.core.entity.Attributes Java Examples
The following examples show how to use
org.apache.brooklyn.core.entity.Attributes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerPoolTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testResizingPoolUp() { TestApplication app = createAppWithChildren(getInitialPoolSize()); app.start(ImmutableList.of(pool.getDynamicLocation())); assertTrue(app.getAttribute(Attributes.SERVICE_UP)); TestApplication app2 = createAppWithChildren(1); assertNoMachinesAvailableForApp(app2); pool.resizeByDelta(1); assertAvailableCountEventuallyEquals(1); assertEquals((int) pool.getCurrentSize(), getInitialPoolSize() + 1); app2.start(ImmutableList.of(pool.getDynamicLocation())); assertTrue(app2.getAttribute(Attributes.SERVICE_UP)); }
Example #2
Source File: SolrServerEc2LiveTest.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Test(groups = {"Live"}) public void testWithOnlyPort22() throws Exception { // CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1 jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC, ImmutableMap.of( "tags", ImmutableList.of(getClass().getName()), "imageId", "us-east-1/ami-a96b01c0", "hardwareId", SMALL_HARDWARE_ID)); SolrServer server = app.createAndManageChild(EntitySpec.create(SolrServer.class) .configure(SolrServer.SOLR_CORE_CONFIG, ImmutableMap.of("example", "classpath://solr/example.tgz")) .configure(JBoss7Server.USE_HTTP_MONITORING, false) .configure(JBoss7Server.OPEN_IPTABLES, true)); app.start(ImmutableList.of(jcloudsLocation)); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); URI url = server.getAttribute(SolrServer.MAIN_URI); assertNotNull(url); assertViaSshLocalUrlListeningEventually(server, url.toString()); }
Example #3
Source File: OnSubnetNetworkEnricherTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
/** * The sensorVal must include port 1234, so that it will be converted to "+publicIp+":1234 */ @Test(dataProvider = "variants") public <T> void testSensorTransformed(Timing setUri, Timing addLocation, AttributeSensor<T> sensor, T sensorVal, String targetSensorName, String expectedVal) throws Exception { entity.sensors().set(Attributes.SUBNET_ADDRESS, privateIp); if (setUri == Timing.BEFORE) { entity.sensors().set(sensor, sensorVal); } if (addLocation == Timing.BEFORE) { entity.addLocations(ImmutableList.of(machine)); } entity.enrichers().add(EnricherSpec.create(OnSubnetNetworkEnricher.class) .configure(OnSubnetNetworkEnricher.SENSORS, ImmutableList.of(sensor))); if (setUri == Timing.AFTER) { entity.sensors().set(sensor, sensorVal); } if (addLocation == Timing.AFTER) { entity.addLocations(ImmutableList.of(machine)); } EntityAsserts.assertAttributeEqualsEventually(entity, Sensors.newStringSensor(targetSensorName), expectedVal); EntityAsserts.assertAttributeEquals(entity, sensor, sensorVal); }
Example #4
Source File: DynamicClusterRebindTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testThrottleAppliesAfterRebind() throws Exception { DynamicCluster cluster = origApp.createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure(DynamicCluster.MAX_CONCURRENT_CHILD_COMMANDS, 1) .configure(DynamicCluster.INITIAL_SIZE, 1) .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(DynamicClusterTest.ThrowOnAsyncStartEntity.class)) .configure(DynamicClusterTest.ThrowOnAsyncStartEntity.COUNTER, new AtomicInteger())); app().start(ImmutableList.of(origApp.newLocalhostProvisioningLocation())); EntityAsserts.assertAttributeEquals(cluster, DynamicCluster.GROUP_SIZE, 1); rebind(RebindOptions.create().terminateOrigManagementContext(true)); cluster = Entities.descendants(app(), DynamicCluster.class).iterator().next(); cluster.resize(10); EntityAsserts.assertAttributeEqualsEventually(cluster, DynamicCluster.GROUP_SIZE, 10); EntityAsserts.assertAttributeEquals(cluster, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); }
Example #5
Source File: AbstractGeoDnsServiceImpl.java From brooklyn-library with Apache License 2.0 | 6 votes |
/** * Start the tracker. * <p> * Subclasses should take care to synchronize on {@link #trackerLock}. */ protected void startTracker() { synchronized (trackerLock) { if (targetEntityProvider == null || !getManagementSupport().isDeployed()) { log.debug("Tracker for " + this + " not yet active: " + targetEntityProvider + " / " + getManagementContext()); return; } endTracker(); ImmutableSet.Builder<Sensor<?>> sensorsToTrack = ImmutableSet.<Sensor<?>>builder().add( HOSTNAME, ADDRESS, Attributes.MAIN_URI, WebAppService.ROOT_URL); // Don't subscribe to lifecycle events if entities will be included regardless of their status. if (Boolean.TRUE.equals(config().get(FILTER_FOR_RUNNING))) { sensorsToTrack.add(Attributes.SERVICE_STATE_ACTUAL); } log.debug("Initializing tracker for " + this + ", following " + targetEntityProvider); tracker = policies().add(PolicySpec.create(MemberTrackingPolicy.class) .displayName("GeoDNS targets tracker") .configure(AbstractMembershipTrackingPolicy.SENSORS_TO_TRACK, sensorsToTrack.build()) .configure(AbstractMembershipTrackingPolicy.GROUP, targetEntityProvider)); refreshGroupMembership(); } }
Example #6
Source File: TomcatServerEc2LiveTest.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Test(groups = {"Live"}) public void testWithOnlyPort22() throws Exception { // CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1 jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC, ImmutableMap.of( "tags", ImmutableList.of(getClass().getName()), "imageId", "us-east-1/ami-a96b01c0", "hardwareId", SMALL_HARDWARE_ID)); final TomcatServer server = app.createAndManageChild(EntitySpec.create(TomcatServer.class) .configure(TomcatServer.PROVISIONING_PROPERTIES.subKey(CloudLocationConfig.INBOUND_PORTS.getName()), ImmutableList.of(22)) .configure(TomcatServer.USE_JMX, false) .configure(TomcatServer.OPEN_IPTABLES, true) // .configure(TomcatServer.PRE_INSTALL_COMMAND, BashCommands.sudo("yum upgrade -y ca-certificates --disablerepo=epel")) .configure("war", getTestWar())); app.start(ImmutableList.of(jcloudsLocation)); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); String url = server.getAttribute(TomcatServer.ROOT_URL); assertNotNull(url); assertViaSshLocalUrlListeningEventually(server, url); }
Example #7
Source File: OnPublicNetworkEnricherTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@DataProvider(name = "variants") public Object[][] provideVariants() { AttributeSensor<HostAndPort> hostAndPortSensor = Sensors.newSensor(HostAndPort.class, "test.endpoint"); List<Object[]> result = Lists.newArrayList(); for (Timing setSensor : Timing.values()) { for (Timing createAssociation : Timing.values()) { for (Timing addLocation : Timing.values()) { result.add(new Object[] {setSensor, createAssociation, addLocation, Attributes.MAIN_URI, URI.create("http://127.0.0.1:1234/my/path"), "main.uri.mapped.public", "http://mypublichost:5678/my/path"}); result.add(new Object[] {setSensor, createAssociation, addLocation, TestEntity.NAME, "http://127.0.0.1:1234/my/path", "test.name.mapped.public", "http://mypublichost:5678/my/path"}); result.add(new Object[] {setSensor, createAssociation, addLocation, Attributes.HTTP_PORT, 1234, "http.endpoint.mapped.public", "mypublichost:5678"}); result.add(new Object[] {setSensor, createAssociation, addLocation, TestEntity.NAME, "1234", "test.name.mapped.public", "mypublichost:5678"}); result.add(new Object[] {setSensor, createAssociation, addLocation, TestEntity.NAME, "127.0.0.1:1234", "test.name.mapped.public", "mypublichost:5678"}); result.add(new Object[] {setSensor, createAssociation, addLocation, hostAndPortSensor, HostAndPort.fromString("127.0.0.1:1234"), "test.endpoint.mapped.public", "mypublichost:5678"}); } } } return result.toArray(new Object[result.size()][]); }
Example #8
Source File: PrimaryRunningEnricher.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Override public void onEvent(SensorEvent<Object> event) { Entity primary = entity.getAttribute( Sensors.newSensor(Entity.class, config().get(PRIMARY_SENSOR_NAME)) ); if (primary==null) { ServiceNotUpLogic.updateNotUpIndicator(entity, "primary.enricher", "no primary found"); ServiceProblemsLogic.updateProblemsIndicator(entity, "primary.enricher", "no primary found"); } else if (Lifecycle.RUNNING.equals(primary.getAttribute(Attributes.SERVICE_STATE_ACTUAL)) && Boolean.TRUE.equals(primary.getAttribute(Attributes.SERVICE_UP))) { if (ServiceStateLogic.getMapSensorEntry(entity, Attributes.SERVICE_PROBLEMS, "primary.enricher")!=null) { log.info("Primary "+primary+" at "+entity+" detected as healthy"); ServiceProblemsLogic.clearProblemsIndicator(entity, "primary.enricher"); ServiceNotUpLogic.clearNotUpIndicator(entity, "primary.enricher"); } } else { log.warn("Primary "+primary+" at "+entity+" detected as down or otherwise unhealthy"); ServiceProblemsLogic.updateProblemsIndicator(entity, "primary.enricher", "Primary "+primary+" not in healthy state"); } }
Example #9
Source File: FunctionSensorTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testFunction() throws Exception { AtomicReference<String> val = new AtomicReference<String>("first"); Callable<String> callable = new Callable<String>() { @Override public String call() throws Exception { return val.get(); } }; FunctionSensor<Integer> initializer = new FunctionSensor<Integer>(ConfigBag.newInstance() .configure(FunctionSensor.SENSOR_PERIOD, Duration.millis(10)) .configure(FunctionSensor.SENSOR_NAME, SENSOR_STRING.getName()) .configure(FunctionSensor.SENSOR_TYPE, STRING_TARGET_TYPE) .configure(FunctionSensor.FUNCTION, callable)); initializer.apply(entity); entity.sensors().set(Attributes.SERVICE_UP, true); initializer.apply(entity); entity.sensors().set(Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "first"); val.set("second"); EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "second"); }
Example #10
Source File: AsyncApplicationImpl.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Override public void setEntity(EntityLocal entity) { if (!(entity instanceof AsyncApplicationImpl)) { throw new IllegalArgumentException("enricher designed to work only with async-apps"); } if (!isRebinding() && Boolean.FALSE.equals(config().get(SUPPRESS_DUPLICATES))) { throw new IllegalArgumentException("Must not set "+SUPPRESS_DUPLICATES+" to false when using "+this); } super.setEntity(entity); if (suppressDuplicates==null) { // only publish on changes, unless it is configured otherwise suppressDuplicates = true; } // Need to update again, e.g. if stop() effector marks this as expected=stopped. // There'd be a risk of infinite loop if we didn't suppressDuplicates! subscriptions().subscribe(entity, Attributes.SERVICE_STATE_EXPECTED, new SensorEventListener<Lifecycle.Transition>() { @Override public void onEvent(SensorEvent<Lifecycle.Transition> event) { onUpdated(); }}); }
Example #11
Source File: MySqlClusterImpl.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override protected Entity createNode(Location loc, Map<?, ?> flags) { MySqlNode node = (MySqlNode) super.createNode(loc, flags); if (!MySqlClusterUtils.IS_MASTER.apply(node)) { ServiceNotUpLogic.updateNotUpIndicator(node, MySqlSlave.SLAVE_HEALTHY, "Replication not started"); addFeed(FunctionFeed.builder() .entity(node) .period(Duration.FIVE_SECONDS) .poll(FunctionPollConfig.forSensor(MySqlSlave.SLAVE_HEALTHY) .callable(new SlaveStateCallable(node)) .checkSuccess(StringPredicates.isNonBlank()) .onSuccess(new SlaveStateParser(node)) .setOnFailure(false) .description("Polls SHOW SLAVE STATUS")) .build()); node.enrichers().add(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS) .from(MySqlSlave.SLAVE_HEALTHY) .computing(Functionals.ifNotEquals(true).value("Slave replication status is not healthy") ) .build()); } return node; }
Example #12
Source File: LoopOverGroupMembersTestCaseImpl.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Override public void stop() { // Let everyone know we're stopping (so that the GUI shows the correct icon). sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPING); try { for (Entity child : this.getChildren()) { if (child instanceof Startable) ((Startable) child).stop(); } // Let everyone know we've stopped successfully (changes the icon in the GUI). logger.debug("Tasks successfully run. Update state of {} to STOPPED.", this); setUpAndRunState(false, Lifecycle.STOPPED); } catch (Throwable t) { logger.debug("Tasks NOT successfully run. Update state of {} to ON_FIRE.", this); setUpAndRunState(false, Lifecycle.ON_FIRE); throw Exceptions.propagate(t); } }
Example #13
Source File: RedisClusterImpl.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override public void init() { super.init(); RedisStore master = addChild(EntitySpec.create(RedisStore.class)); sensors().set(MASTER, master); DynamicCluster slaves = addChild(EntitySpec.create(DynamicCluster.class) .configure(DynamicCluster.MEMBER_SPEC, EntitySpec.create(RedisSlave.class).configure(RedisSlave.MASTER, master) .configure(SoftwareProcess.CUSTOMIZE_LATCH, DependentConfiguration.attributeWhenReady(master, Attributes.SERVICE_UP)))); sensors().set(SLAVES, slaves); enrichers().add(Enrichers.builder() .propagating(RedisStore.HOSTNAME, RedisStore.ADDRESS, RedisStore.SUBNET_HOSTNAME, RedisStore.SUBNET_ADDRESS, RedisStore.REDIS_PORT) .from(master) .build()); }
Example #14
Source File: HazelcastNodeImpl.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Override protected void connectSensors() { super.connectSensors(); if (LOG.isDebugEnabled()) { LOG.debug("Connecting sensors for node: {} ", getAttribute(Attributes.HOSTNAME)); } HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getNodePort()); String nodeUri = String.format("http://%s:%d/hazelcast/rest/cluster", hp.getHostText(), hp.getPort()); sensors().set(Attributes.MAIN_URI, URI.create(nodeUri)); if (LOG.isDebugEnabled()) { LOG.debug("Node {} is using {} as a main URI", this, nodeUri); } httpFeed = HttpFeed.builder() .entity(this) .period(3000, TimeUnit.MILLISECONDS) .baseUri(nodeUri) .poll(new HttpPollConfig<Boolean>(SERVICE_UP) .onSuccess(HttpValueFunctions.responseCodeEquals(200)) .onFailureOrException(Functions.constant(false))) .build(); }
Example #15
Source File: RelativeEntityTestCaseTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testSiblingScope() { TestEntity brother = app.createAndManageChild(EntitySpec.create(TestEntity.class) .configure(BrooklynCampConstants.PLAN_ID, "brother-plan")); TestEntity sister = app.createAndManageChild(EntitySpec.create(TestEntity.class) .configure(BrooklynCampConstants.PLAN_ID, "sister-plan")); brother.sensors().set(TestEntity.NAME, "brother"); sister.sensors().set(TestEntity.NAME, "sister"); app.start(ImmutableList.of(app.newSimulatedLocation())); TestCase testCase = app.createAndManageChild(EntitySpec.create(TestCase.class) .child(relativeEntityTestCaseEntitySpec(brother, "sister-plan", DslComponent.Scope.SIBLING, "sister")) .child(relativeEntityTestCaseEntitySpec(sister, "brother-plan", DslComponent.Scope.SIBLING, "brother"))); testCase.start(app.getLocations()); assertTrue(testCase.sensors().get(Attributes.SERVICE_UP), "Test case did not pass: " + testCase); }
Example #16
Source File: JmxAttributeSensorTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testSensor() throws Exception { GeneralisedDynamicMBean mbean = jmxService.registerMBean(ImmutableMap.of(attributeName, 42), objectName); JmxAttributeSensor<Integer> sensor = new JmxAttributeSensor<Integer>(ConfigBag.newInstance() .configure(JmxAttributeSensor.SENSOR_PERIOD, Duration.millis(10)) .configure(JmxAttributeSensor.SENSOR_NAME, SENSOR_STRING.getName()) .configure(JmxAttributeSensor.SENSOR_TYPE, STRING_TARGET_TYPE) .configure(JmxAttributeSensor.OBJECT_NAME, objectName) .configure(JmxAttributeSensor.ATTRIBUTE, attributeName)); sensor.apply(entity); entity.sensors().set(Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "42"); // Change the value and check it updates mbean.updateAttributeValue(attributeName, 64); EntityAsserts.assertAttributeEqualsEventually(entity, SENSOR_STRING, "64"); }
Example #17
Source File: VanillaWindowsProcessWinrmExitStatusLiveTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test(groups = "Live") public void testExecWithZeroExitCodes() { VanillaWindowsProcess entity = app.createAndManageChild(EntitySpec.create(VanillaWindowsProcess.class) .configure(VanillaWindowsProcess.PRE_INSTALL_COMMAND, "echo preinstall") .configure(VanillaWindowsProcess.INSTALL_COMMAND, "echo install") .configure(VanillaWindowsProcess.POST_INSTALL_COMMAND, "echo postinstall") .configure(VanillaWindowsProcess.CUSTOMIZE_COMMAND, "echo customize") .configure(VanillaWindowsProcess.PRE_LAUNCH_COMMAND, "echo prelaunch") .configure(VanillaWindowsProcess.LAUNCH_COMMAND, "echo launch") .configure(VanillaWindowsProcess.POST_LAUNCH_COMMAND, "echo postlaunch") .configure(VanillaWindowsProcess.CHECK_RUNNING_COMMAND, "echo checkrunning") .configure(VanillaWindowsProcess.STOP_COMMAND, "echo stop")); app.start(ImmutableList.of(machine)); LOG.info("app started; asserting up"); EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); entity.stop(); LOG.info("stopping entity"); EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); EntityAsserts.assertAttributeEqualsEventually(entity, Attributes.SERVICE_UP, false); }
Example #18
Source File: JBoss6ServerAwsEc2LiveTest.java From brooklyn-library with Apache License 2.0 | 6 votes |
@Test(groups = {"Live"}) public void testWithOnlyPort22() throws Exception { // CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1 jcloudsLocation = mgmt.getLocationRegistry().getLocationManaged(LOCATION_SPEC, ImmutableMap.of( "tags", ImmutableList.of(getClass().getName()), "imageId", "us-east-1/ami-a96b01c0", "hardwareId", SMALL_HARDWARE_ID)); final JBoss6Server server = app.createAndManageChild(EntitySpec.create(JBoss6Server.class) .configure(JBoss6Server.PROVISIONING_PROPERTIES.subKey(CloudLocationConfig.INBOUND_PORTS.getName()), ImmutableList.of(22)) .configure(JBoss6Server.USE_JMX, false) .configure(JBoss6Server.OPEN_IPTABLES, true) .configure("war", getTestWar())); app.start(ImmutableList.of(jcloudsLocation)); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, true); EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); String url = server.getAttribute(JBoss6Server.ROOT_URL); assertNotNull(url); assertViaSshLocalUrlListeningEventually(server, url); }
Example #19
Source File: ElasticSearchNodeIntegrationTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Test(groups = {"Integration"}) public void testDocumentCount() throws URISyntaxException { elasticSearchNode = app.createAndManageChild(EntitySpec.create(ElasticSearchNode.class)); app.start(ImmutableList.of(testLocation)); EntityAsserts.assertAttributeEqualsEventually(elasticSearchNode, Startable.SERVICE_UP, true); EntityAsserts.assertAttributeEquals(elasticSearchNode, ElasticSearchNode.DOCUMENT_COUNT, 0); String baseUri = "http://" + elasticSearchNode.getAttribute(Attributes.HOSTNAME) + ":" + elasticSearchNode.getAttribute(Attributes.HTTP_PORT); HttpToolResponse pingResponse = HttpTool.execAndConsume( HttpTool.httpClientBuilder().build(), new HttpGet(baseUri)); assertEquals(pingResponse.getResponseCode(), 200); String document = "{\"foo\" : \"bar\",\"baz\" : \"quux\"}"; HttpToolResponse putResponse = HttpTool.httpPut( HttpTool.httpClientBuilder() .port(elasticSearchNode.getAttribute(Attributes.HTTP_PORT)) .build(), new URI(baseUri + "/mydocuments/docs/1"), ImmutableMap.<String, String>of(), Strings.toByteArray(document)); assertEquals(putResponse.getResponseCode(), 201); HttpToolResponse getResponse = HttpTool.execAndConsume( HttpTool.httpClientBuilder().build(), new HttpGet(baseUri + "/mydocuments/docs/1/_source")); assertEquals(getResponse.getResponseCode(), 200); assertEquals(HttpValueFunctions.jsonContents("foo", String.class).apply(getResponse), "bar"); EntityAsserts.assertAttributeEqualsEventually(elasticSearchNode, ElasticSearchNode.DOCUMENT_COUNT, 1); }
Example #20
Source File: DynamicClusterRebindTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@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); }
Example #21
Source File: BrooklynEntityMirrorImpl.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override public void init() { super.init(); connectSensorsAsync(); //start spinning, could take some time before MIRRORED_ENTITY_URL is available for first time mirroring sensors().set(Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STARTING); }
Example #22
Source File: MachinesTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testFindSubnetOrPrivateIpFromLocation() throws Exception { TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class) .location(sshMachineSpec)); entity.sensors().set(Attributes.ADDRESS, "ignored-val"); assertEquals(Machines.findSubnetOrPrivateIp(entity).get(), privateAddr); }
Example #23
Source File: CloudFoundryYamlLiveTest.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
public void testDeployWebappWitPolicyJMMonitoringFromYaml() { SimpleYamlLauncher launcher = new SimpleYamlLauncher(); launcher.setShutdownAppsOnExit(false); Application app = launcher.launchAppYaml("cf-webchat-policy.yml").getApplication(); final CloudFoundryWebApp server = (CloudFoundryWebApp) findChildEntitySpecByPlanId(app, "webapp"); assertNotNull(server); Asserts.succeedsEventually(new Runnable() { public void run() { assertNotNull(server.getAttribute(CloudFoundryWebApp.SERVICE_PROCESS_IS_RUNNING)); assertEquals(server.getAttribute(CloudFoundryWebApp.BOUND_SERVICES).size(), 0); assertTrue(server.getAttribute(Startable.SERVICE_UP)); assertTrue(server.getAttribute(JavaCloudFoundryPaasWebApp .SERVICE_PROCESS_IS_RUNNING)); assertNotNull(server.getAttribute(Attributes.MAIN_URI)); assertNotNull(server.getAttribute(JavaCloudFoundryPaasWebApp.ROOT_URL)); assertEquals(server.getAttribute(JavaCloudFoundryPaasWebApp.DISK), PaasLocationConfig.REQUIRED_DISK.getDefaultValue()); assertEquals(server.getAttribute(JavaCloudFoundryPaasWebApp.INSTANCES_NUM), PaasLocationConfig.REQUIRED_INSTANCES.getDefaultValue()); assertEquals(server.getAttribute(JavaCloudFoundryPaasWebApp.MEMORY), PaasLocationConfig.REQUIRED_MEMORY.getDefaultValue()); assertNotNull(server.getPolicies()); assertEquals(server.getPolicies().size(), 1); assertNotNull(server.getAttribute(JavaCloudFoundryPaasWebApp.SERVER_PROCESSING_TIME)); assertNotNull(server.getAttribute(JavaCloudFoundryPaasWebApp.SERVER_REQUESTS)); } }); }
Example #24
Source File: InitdServiceInstaller.java From brooklyn-server with Apache License 2.0 | 5 votes |
private String getLogLocation() { String logFileLocation = entity.getAttribute(Attributes.LOG_FILE_LOCATION); if (logFileLocation != null) { return new File(logFileLocation).getParent(); } else { return "/tmp"; } }
Example #25
Source File: BindDnsServerIntegrationTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Test(groups = "Integration") public void testStripsInvalidCharactersFromHostname() { origApp.start(ImmutableList.of(origApp.newLocalhostProvisioningLocation())); cluster.resize(1); assertDnsEntityEventuallyHasActiveMembers(1); Entity e = Iterables.getOnlyElement(cluster.getMembers()); e.sensors().set(PrefixAndIdEnricher.SENSOR, " _-pretend.hostname.10.0.0.7.my-cloud.com"); EntityAsserts.assertAttributeEqualsEventually(dns, BindDnsServer.A_RECORDS, ImmutableMap.of("pretend-hostname-10-0-0-7-my-cloud-com", e.getAttribute(Attributes.ADDRESS))); }
Example #26
Source File: SeaCloudsMonitoringInitializationPolicies.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
@Override public void setEntity(EntityLocal entity) { super.setEntity(entity); if (!entity.getApplication().equals(entity)) { throw new RuntimeException("SeaCloudsMonitoringInitializationPolicies must be attached " + "to an application"); } LifecycleListener listener = new LifecycleListener(); entity.subscriptions().subscribe(entity, Attributes.SERVICE_STATE_ACTUAL, listener); }
Example #27
Source File: SeaCloudsMonitoringInitializationPolicies.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
private String getMainUri(Entity child) { URI mainUri = child.getAttribute(Attributes.MAIN_URI); if (mainUri != null) { return mainUri.toString(); } return Strings.EMPTY; }
Example #28
Source File: BindDnsServerIntegrationTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Test(groups = "Integration") public void testMapsSeveralEntitiesOnOneMachine() { origApp.start(ImmutableList.of(origApp.newLocalhostProvisioningLocation())); EntityAsserts.assertAttributeEqualsEventually(dns, Attributes.SERVICE_UP, true); logDnsMappings(); // One host with one A, two CNAME and one PTR record assertEquals(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).keySet().size(), 1); assertMapSizes(3, 1, 2, 1); String key = Iterables.getOnlyElement(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).keySet()); assertEquals(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).get(key).size(), 3); Entities.dumpInfo(dns); }
Example #29
Source File: BindDnsServerIntegrationTest.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Test(groups = "Integration") public void testCanConfigureToListenToChildrenOfEntityOtherThanParent() { // Ignoring origApp TestApplication app = origManagementContext.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)); EnricherSpec<PrefixAndIdEnricher> dnsEnricher = EnricherSpec.create(PrefixAndIdEnricher.class) .configure(PrefixAndIdEnricher.PREFIX, "dns-integration-test-") .configure(PrefixAndIdEnricher.MONITOR, Attributes.HOSTNAME); EntitySpec<EmptySoftwareProcess> emptySoftwareProcessSpec = EntitySpec.create(EmptySoftwareProcess.class) .enricher(dnsEnricher); // App DNS will listen to cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure(DynamicCluster.MEMBER_SPEC, emptySoftwareProcessSpec) .configure(DynamicCluster.INITIAL_SIZE, 3)); // Apps that DNS should not listen to. Appreciate that their having dnsEnricher is unrealistic! app.createAndManageChild(emptySoftwareProcessSpec); app.createAndManageChild(emptySoftwareProcessSpec); Predicate<Entity> entityFilter = Predicates.and( Predicates.instanceOf(EmptySoftwareProcess.class), EntityPredicates.isChildOf(cluster)); dns = app.createAndManageChild(EntitySpec.create(BindDnsServer.class, TestBindDnsServerImpl.class) .configure(BindDnsServer.ENTITY_FILTER, entityFilter) .configure(BindDnsServer.HOSTNAME_SENSOR, PrefixAndIdEnricher.SENSOR)); app.start(ImmutableList.of(app.newLocalhostProvisioningLocation())); logDnsMappings(); assertEquals(dns.getAttribute(BindDnsServer.ADDRESS_MAPPINGS).keySet().size(), 1); assertMapSizes(3, 1, 2, 1); cluster.resize(4); EntityAsserts.assertAttributeEqualsEventually(cluster, DynamicCluster.GROUP_SIZE, 4); assertDnsEntityEventuallyHasActiveMembers(4); assertMapSizes(4, 1, 3, 1); }
Example #30
Source File: ServerPoolImpl.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override protected void onEntityEvent(EventType type, Entity member) { Boolean isUp = member.getAttribute(Attributes.SERVICE_UP); LOG.info("{} in {}: {} service up is {}", new Object[]{type.name(), entity, member, isUp}); defaultHighlightAction(type, entity, "Update on %s %s (service "+(isUp==Boolean.TRUE ? "up" : isUp==Boolean.FALSE ? "not up" : "up value not known")+")"); if (type.equals(EventType.ENTITY_ADDED) || type.equals(EventType.ENTITY_CHANGE)) { if (Boolean.TRUE.equals(isUp)) { ((ServerPoolImpl) entity).serverAdded(member); } else if (LOG.isDebugEnabled()) { LOG.debug("{} observed event {} but {} is not up (yet) and will not be used by the pool", new Object[]{entity, type.name(), member}); } } }