Java Code Examples for org.apache.brooklyn.core.sensor.Sensors#newDoubleSensor()
The following examples show how to use
org.apache.brooklyn.core.sensor.Sensors#newDoubleSensor() .
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: WebClusterApp.java From brooklyn-library with Apache License 2.0 | 5 votes |
@Override public void initApp() { final AttributeSensor<Double> sinusoidalLoad = Sensors.newDoubleSensor("brooklyn.qa.sinusoidalLoad", "Sinusoidal server load"); AttributeSensor<Double> averageLoad = Sensors.newDoubleSensor("brooklyn.qa.averageLoad", "Average load in cluster"); NginxController nginxController = addChild(EntitySpec.create(NginxController.class) // .configure("domain", "webclusterexample.brooklyn.local") .configure("port", "8000+")); EntitySpec<JBoss7Server> jbossSpec = EntitySpec.create(JBoss7Server.class) .configure("httpPort", "8080+") .configure("war", WAR_PATH) .enricher(EnricherSpec.create(SinusoidalLoadGenerator.class) .configure(SinusoidalLoadGenerator.TARGET, sinusoidalLoad) .configure(SinusoidalLoadGenerator.PUBLISH_PERIOD_MS, 500L) .configure(SinusoidalLoadGenerator.SIN_PERIOD_MS, loadCyclePeriodMs) .configure(SinusoidalLoadGenerator.SIN_AMPLITUDE, 1d)); ControlledDynamicWebAppCluster web = addChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) .displayName("WebApp cluster") .configure("controller", nginxController) .configure("initialSize", 1) .configure("memberSpec", jbossSpec)); web.getCluster().enrichers().add(Enrichers.builder() .aggregating(sinusoidalLoad) .publishing(averageLoad) .fromMembers() .computingAverage() .build()); web.getCluster().policies().add(AutoScalerPolicy.builder() .metric(averageLoad) .sizeRange(1, 3) .metricRange(0.3, 0.7) .buildSpec()); }
Example 2
Source File: WindowsPerformanceCounterFeedTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testSendPerfCountersToSensors() { AttributeSensor<String> stringSensor = Sensors.newStringSensor("foo.bar"); AttributeSensor<Integer> integerSensor = Sensors.newIntegerSensor("bar.baz"); AttributeSensor<Double> doubleSensor = Sensors.newDoubleSensor("baz.quux"); Collection<WindowsPerformanceCounterPollConfig<?>> polls = ImmutableSet.<WindowsPerformanceCounterPollConfig<?>>of( new WindowsPerformanceCounterPollConfig<>(stringSensor).performanceCounterName("\\processor information(_total)\\% processor time"), new WindowsPerformanceCounterPollConfig<>(integerSensor).performanceCounterName("\\integer.sensor"), new WindowsPerformanceCounterPollConfig<>(doubleSensor).performanceCounterName("\\double\\sensor\\with\\multiple\\sub\\paths") ); WindowsPerformanceCounterFeed.SendPerfCountersToSensors sendPerfCountersToSensors = new WindowsPerformanceCounterFeed.SendPerfCountersToSensors(entity, polls); assertNull(entity.getAttribute(stringSensor)); StringBuilder responseBuilder = new StringBuilder(); // NOTE: This builds the response in a different order to which they are passed to the SendPerfCountersToSensors constructor // this tests that the values are applied correctly even if the (possibly non-deterministic) order in which // they are returned by the Get-Counter scriptlet is different addMockResponse(responseBuilder, "\\\\machine.name\\double\\sensor\\with\\multiple\\sub\\paths", "3.1415926"); addMockResponse(responseBuilder, "\\\\win-lge7uj2blau\\processor information(_total)\\% processor time", "99.9"); addMockResponse(responseBuilder, "\\\\machine.name\\integer.sensor", "15"); sendPerfCountersToSensors.onSuccess(new WinRmToolResponse(responseBuilder.toString(), "", 0)); EntityAsserts.assertAttributeEquals(entity, stringSensor, "99.9"); EntityAsserts.assertAttributeEquals(entity, integerSensor, 15); EntityAsserts.assertAttributeEquals(entity, doubleSensor, 3.1415926); }
Example 3
Source File: TimeFractionDeltaEnricherTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@BeforeMethod(alwaysRun=true) @Override public void setUp() throws Exception { super.setUp(); producer = app.addChild(EntitySpec.create(TestEntity.class)); intSensor = Sensors.newIntegerSensor("int sensor"); fractionSensor = Sensors.newDoubleSensor("fraction sensor"); }