Skip to content

Commit fd669ae

Browse files
committed
Merge pull request #96 from aledsage/fix/port-mapper-enricher-for-marathon
Fix port-mapping enricher for marathon
2 parents 60c2ddd + db5932a commit fd669ae

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

portforwarding/src/main/java/brooklyn/networking/subnet/SubnetEnrichers.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222

2323
import org.apache.brooklyn.api.entity.Entity;
2424
import org.apache.brooklyn.api.entity.EntityLocal;
25+
import org.apache.brooklyn.api.location.Location;
2526
import org.apache.brooklyn.api.location.MachineLocation;
2627
import org.apache.brooklyn.api.sensor.AttributeSensor;
2728
import org.apache.brooklyn.api.sensor.EnricherSpec;
2829
import org.apache.brooklyn.api.sensor.SensorEvent;
30+
import org.apache.brooklyn.api.sensor.SensorEventListener;
2931
import org.apache.brooklyn.config.ConfigKey;
3032
import org.apache.brooklyn.core.config.ConfigKeys;
33+
import org.apache.brooklyn.core.entity.AbstractEntity;
3134
import org.apache.brooklyn.core.entity.EntityAndAttribute;
3235
import org.apache.brooklyn.core.location.Machines;
3336
import org.apache.brooklyn.core.location.access.PortForwardManager;
@@ -124,6 +127,15 @@ public void onAssociationDeleted(PortForwardManager.AssociationMetadata metadata
124127
}
125128
};
126129
getConfig(SUBNET_TIER).getPortForwardManager().addAssociationListener(listener, Predicates.alwaysTrue());
130+
131+
subscriptions().subscribe(producer, AbstractEntity.LOCATION_ADDED, new SensorEventListener<Location>() {
132+
@Override public void onEvent(SensorEvent<Location> event) {
133+
T sensorVal = producer.getAttribute((AttributeSensor<T>)sourceSensor);
134+
if (sensorVal != null) {
135+
log.debug("Simulating sensor-event on new location-added {}, to trigger transformation by {}", new Object[] {event.getValue(), AbstractNatTransformingEnricher.this});
136+
AbstractNatTransformingEnricher.this.onEvent(new BasicSensorEvent<T>(sourceSensor, producer, sensorVal));
137+
}
138+
}});
127139
}
128140

129141
@Override

0 commit comments

Comments
 (0)