.propagating(Attributes.MAIN_URI) .from(getMasterAmbariServer()) .build());
enrichers().add(Enrichers.builder().propagating(Startable.SERVICE_UP).from(child).build()); enrichers().add(ServiceStateLogic.newEnricherFromChildrenState() .suppressDuplicates(true) enrichers().add(Enrichers.builder().propagatingAllButUsualAnd().from(child).build()); } else { enrichers().add(Enrichers.builder().propagating(sensors).from(child).build());
.propagating(LoadBalancer.PROXY_HTTP_PORT, LoadBalancer.PROXY_HTTPS_PORT) .from(controller) .build());
.propagating(DOCKER_CONTAINER_COUNT, MachineAttributes.AVERAGE_CPU_USAGE) .from(hosts) .build()); enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(DynamicCluster.GROUP_SIZE, DOCKER_HOST_COUNT)) .from(hosts) .build()); .configure(ContainerHeadroomEnricher.CONTAINER_HEADROOM_PERCENTAGE, headroomPercent)); hosts.enrichers().add(Enrichers.builder() .propagating( ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_COLD, ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_HOT,
enrichers().add(Enrichers.builder().propagating(Startable.SERVICE_UP).from(child).build()); enrichers().add(ServiceStateLogic.newEnricherFromChildrenState() .suppressDuplicates(true) enrichers().add(Enrichers.builder().propagatingAllButUsualAnd().from(child).build()); } else { enrichers().add(Enrichers.builder().propagating(sensors).from(child).build());
.propagating(ImmutableMap.of(BasicGroup.GROUP_SIZE, DockerAttributes.DOCKER_CONTAINER_COUNT)) .from(containers) .build());
.propagating(Storm.STORM_UI_URL) .from(ui) .build()); enrichers().add(Enrichers.builder() .propagating(Attributes.HOSTNAME) .from(nimbus) .build());
AttributeSensor<Object> sourceSensorFromYaml = Sensors.newSensor(Object.class, TestEntity.NAME.getName()); app.enrichers().add(Enrichers.builder() .propagating(Sensors.newSensor(Object.class, TestEntity.NAME.getName())) .from(entity) .build()); app.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(sourceSensorFromYaml, targetSensor)) .from(app) .build());
@Test public void testProducerUsingDeferredSupplier() throws Exception { producer = app.createAndManageChild(EntitySpec.create(TestEntity.class) .configure(TAG, "myproducer")); target = app.createAndManageChild(EntitySpec.create(TestEntity.class)); sensor = new BasicAttributeSensor<Integer>(Integer.class, "int.sensor.a"); app.start(ImmutableList.of(new SimulatedLocation())); producer.sensors().set(sensor, 3); target.enrichers().add(Enrichers.builder() .propagating(sensor) .from(new EntityDeferredSupplier("myproducer").newTask()) .build()); EntityAsserts.assertAttributeEqualsEventually(target, sensor, 3); }
@Test public void testPropagatesSpecificSensor() { app.enrichers().add(Enrichers.builder() .propagating(TestEntity.NAME) .from(entity) .build()); // name propagated entity.sensors().set(TestEntity.NAME, "foo"); EntityAsserts.assertAttributeEqualsEventually(app, TestEntity.NAME, "foo"); // sequence not propagated entity.sensors().set(TestEntity.SEQUENCE, 2); EntityAsserts.assertAttributeEqualsContinually(MutableMap.of("timeout", 100), app, TestEntity.SEQUENCE, null); }
void connectSensors() { // FIXME no longer needed enrichers().add(Enrichers.builder() .propagatingAllButUsualAnd(Attributes.MAIN_URI, ROOT_URL, GROUP_MEMBERS, GROUP_SIZE) .from(getCluster()) .build()); enrichers().add(Enrichers.builder() // include hostname and address of controller (need both in case hostname only resolves to internal/private ip) .propagating(LoadBalancer.HOSTNAME, Attributes.ADDRESS, Attributes.MAIN_URI, ROOT_URL) .from(getController()) .build()); }
@Test public void testPropagatingAndRenaming() { entity.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(STR1, STR2)) .from(entity2) .build()); entity2.sensors().set(STR1, "myval"); EntityAsserts.assertAttributeEqualsEventually(entity, STR2, "myval"); }
@Test public void testPropagatingAsDifferentSensor() { final AttributeSensor<String> ANOTHER_ATTRIBUTE = Sensors.newStringSensor("another.attribute", ""); app.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(TestEntity.NAME, ANOTHER_ATTRIBUTE)) .from(entity) .build()); // name propagated as different attribute entity.sensors().set(TestEntity.NAME, "foo"); EntityAsserts.assertAttributeEqualsEventually(app, ANOTHER_ATTRIBUTE, "foo"); }
@Test public void testPropagatesCurrentValue() { entity.sensors().set(TestEntity.NAME, "foo"); app.enrichers().add(Enrichers.builder() .propagating(TestEntity.NAME) .from(entity) .build()); // name propagated EntityAsserts.assertAttributeEqualsEventually(app, TestEntity.NAME, "foo"); }
@Override public void init() { super.init(); ConfigToAttributes.apply(this, MESOS_SLAVE_ID); EnricherSpec<?> serviceUp = Enrichers.builder() .propagating(ImmutableMap.of(SLAVE_ACTIVE, SERVICE_UP)) .suppressDuplicates(true) .from(this) .build(); enrichers().add(serviceUp); }
void connectSensors() { enrichers().add(Enrichers.builder() .propagatingAllBut(SERVICE_UP) .from(getCluster()) .build()); enrichers().add(Enrichers.builder() .propagating(SERVICE_UP) .from(getZooKeeper()) .build()); }
@Test public void testPropagatingAsEnricher() throws Exception { origApp.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(METRIC1, METRIC2)) .from(origEntity) .build()); TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); newEntity.sensors().set(METRIC1, "myval"); EntityAsserts.assertAttributeEqualsEventually(newApp, METRIC2, "myval"); }
@Test public void testPropagating() { entity.enrichers().add(Enrichers.builder() .propagating(ImmutableList.of(STR1)) .from(entity2) .build()); entity2.sensors().set(STR1, "myval"); EntityAsserts.assertAttributeEqualsEventually(entity, STR1, "myval"); entity2.sensors().set(STR1, null); EntityAsserts.assertAttributeEqualsEventually(entity, STR1, null); }
@Test public void testPropagatingEnricher() throws Exception { origApp.enrichers().add(Enrichers.builder() .propagating(METRIC1) .from(origEntity) .build()); TestApplication newApp = rebind(); TestEntity newEntity = (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class)); newEntity.sensors().set(METRIC1, "myval"); EntityAsserts.assertAttributeEqualsEventually(newApp, METRIC1, "myval"); }
@Test public void testSensorPropagatedWhenMappingUsedSameNameButDifferentType() throws Exception { AttributeSensor<String> origSensor = Sensors.newSensor(String.class, "origSensor"); AttributeSensor<Object> sourceSensorFromYaml = Sensors.newSensor(Object.class, "origSensor"); AttributeSensor<Object> targetSensor = Sensors.newSensor(Object.class, "newSensor"); app.enrichers().add(Enrichers.builder() .propagating(ImmutableMap.of(sourceSensorFromYaml, targetSensor)) .from(entity) .build()); entity.sensors().set(origSensor, "myval"); EntityAsserts.assertAttributeEqualsEventually(app, targetSensor, "myval"); }