Skip to content

Commit 9191874

Browse files
authored
Merge pull request #107 from aledsage/bostko-aled/make_compilable
Reflect changes from apache/brooklyn-server#355 (strike 2)
2 parents 41f7a48 + b589e9e commit 9191874

File tree

9 files changed

+29
-12
lines changed

9 files changed

+29
-12
lines changed

cloudstack/src/main/java/brooklyn/networking/cloudstack/legacy/LegacyAbstractSubnetApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public abstract class LegacyAbstractSubnetApp extends AbstractApplication implem
6767
}
6868

6969
protected <T> void setIfNotAlreadySet(ConfigKey<T> key, T value) {
70-
if (config().getRaw(key).isAbsent()) configure(key, value);
70+
if (config().getRaw(key).isAbsent()) config().set(key, value);
7171
}
7272

7373
protected void applyDefaultConfig() {
@@ -80,7 +80,7 @@ protected void applyDefaultConfig() {
8080
// FIXME not safe for persistence
8181
if (config().getRaw(LegacyJcloudsCloudstackSubnetLocation.PORT_FORWARDING_MANAGER).isAbsent()) {
8282
PortForwardManager pfm = (PortForwardManager) getManagementContext().getLocationRegistry().resolve("portForwardManager(scope=global)");
83-
configure(LegacyJcloudsCloudstackSubnetLocation.PORT_FORWARDING_MANAGER, pfm);
83+
config().set(LegacyJcloudsCloudstackSubnetLocation.PORT_FORWARDING_MANAGER, pfm);
8484
}
8585

8686
setIfNotAlreadySet(MANAGEMENT_ACCESS_CIDR, MANAGEMENT_ACCESS_CIDR.getDefaultValue());

cloudstack/src/main/java/brooklyn/networking/cloudstack/legacy/LegacyJcloudsCloudstackSubnetLocation.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.brooklyn.util.text.Strings;
5656
import org.apache.brooklyn.util.time.Duration;
5757
import org.apache.brooklyn.util.time.Time;
58+
import org.apache.commons.lang3.tuple.Pair;
5859
import org.jclouds.cloudstack.CloudStackApi;
5960
import org.jclouds.cloudstack.compute.options.CloudStackTemplateOptions;
6061
import org.jclouds.cloudstack.domain.AsyncCreateResponse;
@@ -125,6 +126,8 @@ public class LegacyJcloudsCloudstackSubnetLocation extends JcloudsLocation {
125126

126127
public LegacyJcloudsCloudstackSubnetLocation(JcloudsLocation parent, ConfigBag map) {
127128
super(MutableMap.copyOf(parent.getLocalConfigBag().getAllConfig()));
129+
// TODO
130+
// TODO NB relying on behaviour implemented in deprecated method
128131
configure(map.getAllConfig());
129132
}
130133

@@ -207,9 +210,10 @@ public JcloudsMachineLocation obtain(Map<?,?> flagsIn) throws NoMachinesAvailabl
207210
}
208211

209212
@Override
210-
protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeService computeService, NodeMetadata node, Optional<Template> template, String vmHostname1, Optional<HostAndPort> sshHostAndPort, LoginCredentials userCredentials, ConfigBag setup) throws IOException {
213+
protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeService computeService, NodeMetadata node, Optional<Template> template,
214+
LoginCredentials userCredentials, HostAndPort managementHostAndPort, ConfigBag setup) throws IOException {
211215
String subnetSpecificHostname = null;
212-
String vmHostname = vmHostname1;
216+
String vmHostname = managementHostAndPort.getHostText();
213217
String sshHost = vmHostname;
214218
Integer sshPort = null;
215219
PortForwardManager pfw = null;

cloudstack/src/main/java/brooklyn/networking/cloudstack/legacy/LegacySubnetTierImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public boolean isVpcEnabled() {
7979
return getConfig(VirtualPrivateCloud.USE_VPC);
8080
}
8181

82+
@Override
8283
public void start(Collection<? extends Location> locations) {
8384
addLocations(locations);
8485
if (isSubnetEnabled()) {
@@ -325,6 +326,7 @@ protected void openCidrAccess(Collection<Cidr> values) {
325326

326327
}
327328

329+
@Override
328330
public void propagateSensorStringReplacingWithSubnetAddress(final Entity target, final AttributeSensor<String> sensor) {
329331
SensorPropagaterWithReplacement mapper = new SensorPropagaterWithReplacement(this, sensor, new Function<String,String>() {
330332
@Override
@@ -347,6 +349,7 @@ public static String replaceIfNotNull(String string, String searchFor, String re
347349
return Strings.replaceAll(string, searchFor, replaceWith);
348350
}
349351

352+
@Override
350353
public void transformSensorStringReplacingWithPublicAddressAndPort(
351354
final Entity sensorToMapFromSource, final AttributeSensor<String> sensorToMapFromPropagating,
352355
final Entity optionalSensorOfPortToMapFromSource, final AttributeSensor<Integer> optionalSensorOfPortToMapFrom,

common/src/test/java/brooklyn/networking/PortForwarderAsyncTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public class PortForwarderAsyncTest extends BrooklynAppLiveTestSupport {
8888
private PortForwarderAsyncImpl pfa;
8989

9090
@BeforeMethod(alwaysRun=true)
91+
@Override
9192
public void setUp() throws Exception {
9293
super.setUp();
9394
loc = mgmt.getLocationRegistry().resolve("localhost");

portforwarding/src/main/java/brooklyn/networking/portforwarding/PortForwarderIptables.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void inject(Entity owner, List<Location> locations) {
103103
}
104104
}
105105

106+
@Override
106107
public PortForwardManager getPortForwardManager() {
107108
return portForwardManager;
108109
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public JcloudsMachineLocation obtain(Map<?,?> flagsIn) throws NoMachinesAvailabl
127127
// TODO Remove duplication from super's JcloudsLocation.createJcloudsSshMachineLocation
128128
// the todos/fixmes in this method are copied from there; they should be addressed in core brooklyn
129129
@Override
130-
protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeService computeService, NodeMetadata node, Optional<Template> template, String vmHostname, Optional<HostAndPort> sshHostAndPort, LoginCredentials userCredentials, ConfigBag setup) throws IOException {
130+
protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeService computeService, NodeMetadata node, Optional<Template> template,
131+
LoginCredentials userCredentials, HostAndPort managementHostAndPort, ConfigBag setup) throws IOException {
131132
Map<?,?> sshConfig = extractSshConfig(setup, node);
132133
String nodeAvailabilityZone = extractAvailabilityZone(setup, node);
133134
String nodeRegion = extractRegion(setup, node);
@@ -136,7 +137,7 @@ protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeServi
136137
nodeRegion = extractProvider(setup, node);
137138
}
138139

139-
String address = sshHostAndPort.isPresent() ? sshHostAndPort.get().getHostText() : vmHostname;
140+
String address = managementHostAndPort.getHostText();
140141
try {
141142
Networking.getInetAddressWithFixedName(address);
142143
// fine, it resolves
@@ -149,7 +150,7 @@ protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeServi
149150
// Don't want to wait for (or don't expect) VM to be ssh'able, so just check IP reachabilty;
150151
// but don't fail if can't access it at all.
151152
// TODO What is a sensible time to wait?
152-
LOG.debug("Could not resolve reported address '"+address+"' for "+vmHostname+" ("+setup.getDescription()+"/"+node+"), waitForSshable=false, so requesting reachable address");
153+
LOG.debug("Could not resolve reported address '"+address+"' for "+managementHostAndPort+" ("+setup.getDescription()+"/"+node+"), waitForSshable=false, so requesting reachable address");
153154
Iterable<String> addresses = Iterables.concat(node.getPublicAddresses(), node.getPrivateAddresses());
154155
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
155156
try {
@@ -161,7 +162,7 @@ protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeServi
161162
executor.shutdownNow();
162163
}
163164
} else {
164-
LOG.debug("Could not resolve reported address '"+address+"' for "+vmHostname+" ("+setup.getDescription()+"/"+node+"), requesting reachable socket address");
165+
LOG.debug("Could not resolve reported address '"+address+"' for "+managementHostAndPort+" ("+setup.getDescription()+"/"+node+"), requesting reachable socket address");
165166
if (computeService==null) throw Exceptions.propagate(e);
166167
// this has sometimes already been done in waitForReachable (unless skipped) but easy enough to do again
167168
address = JcloudsUtil.getFirstReachableAddress(computeService.getContext(), node);
@@ -174,7 +175,7 @@ protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeServi
174175
userCredentials.getUser(),
175176
address,
176177
Entities.sanitize(sshConfig),
177-
sshHostAndPort,
178+
managementHostAndPort,
178179
setup.getDescription(),
179180
node
180181
});
@@ -189,10 +190,10 @@ protected JcloudsSshMachineLocation createJcloudsSshMachineLocation(ComputeServi
189190
// TODO Why pass in "config"? I (Aled) am dubious that has any effect!
190191
// TODO These things need fixed in JcloudsLocation.createJcloudsSshMachineLocation, rather than just here.
191192
return getManagementContext().getLocationManager().createLocation(LocationSpec.create(JcloudsPortforwardingSubnetMachineLocation.class)
192-
.displayName(vmHostname)
193+
.displayName(address)
193194
.configure(setup.getAllConfig())
194195
.configure("address", address)
195-
.configure("port", sshHostAndPort.isPresent() ? sshHostAndPort.get().getPort() : node.getLoginPort())
196+
.configure("port", managementHostAndPort.getPort())
196197
.configure("user", userCredentials.getUser())
197198
// don't think "config" does anything
198199
.configure(sshConfig)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ protected Integer extractPrivatePort(Integer sensorVal) {
302302
return sensorVal;
303303
}
304304

305+
@Override
305306
public void init() {
306307
SubnetTier subnetTier = getConfig(SUBNET_TIER);
307308
config().set(TRANSFORMATION_FROM_EVENT, new HostAndPortTransformingFunction(subnetTier));

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ protected void openAndRegisterGateway() {
269269
}
270270

271271
// Code is modelled on AbstractApplication.start(locs)
272+
@Override
272273
public void start(Collection<? extends Location> locations) {
273274
PortForwarder portForwarder = getPortForwarder();
274275
portForwarder.inject(getProxy(), ImmutableList.copyOf(Locations.getLocationsCheckingAncestors(locations, this)));
@@ -378,7 +379,6 @@ public synchronized JcloudsPortForwarderExtension getPortForwarderExtension() {
378379
return _portForwarderExtension;
379380
}
380381

381-
382382
@Override
383383
@Effector(description = "Stop the process/service represented by an entity")
384384
public void stop() {
@@ -408,12 +408,14 @@ public void transformSensorStringReplacingWithPublicAddressAndPort(
408408
getAttributeMunger().transformSensorStringReplacingWithPublicAddressAndPort(targetToUpdate, optionalTargetPort, targetsToMatch, replacementSource);
409409
}
410410

411+
@Override
411412
public void transformPort(EntityAndAttribute<Integer> original, EntityAndAttribute<String> destinationToPublish) {
412413
// TODO Should we do this without an enricher? Or change #transformSensorStringReplacingWithPublicAddressAndPort
413414
// to not use an enricher?
414415
destinationToPublish.getEntity().enrichers().add(hostAndPortTransformingEnricher(original, destinationToPublish.getAttribute()));
415416
}
416417

418+
@Override
417419
public void transformUri(EntityAndAttribute<String> targetToUpdate) {
418420
// TODO Should we change #transformSensorStringReplacingWithPublicAddressAndPort
419421
// to not use an enricher?
@@ -422,6 +424,7 @@ public void transformUri(EntityAndAttribute<String> targetToUpdate) {
422424
.configure(Transformer.SUPPRESS_DUPLICATES, true));
423425
}
424426

427+
@Override
425428
public void transformUri(EntityAndAttribute<String> original, EntityAndAttribute<String> destinationToPublish) {
426429
// TODO Should we do this without an enricher? Or change #transformSensorStringReplacingWithPublicAddressAndPort
427430
// to not use an enricher?

vcloud-director/src/test/java/brooklyn/networking/vclouddirector/NatServiceLiveTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public void testAddNatRuleAtTai2b() throws Exception {
145145

146146

147147
@Test(groups="Live")
148+
@Override
148149
public void testAddNatRulesConcurrently() throws Exception {
149150
sharedMutex = new Object();
150151
try {
@@ -154,10 +155,12 @@ public void testAddNatRulesConcurrently() throws Exception {
154155
}
155156
}
156157

158+
@Override
157159
protected HostAndPort openPortForwarding(PortForwardingConfig config) throws Exception {
158160
return openPortForwarding(loc, config);
159161
}
160162

163+
@Override
161164
protected HostAndPort closePortForwarding(PortForwardingConfig config) throws Exception {
162165
return closePortForwarding(loc, config);
163166
}

0 commit comments

Comments
 (0)