Upgrade to 2.0.0 and improve stuff #29

Merged
merged 3 commits into from Mar 27, 2013
@@ -62,7 +62,7 @@
<dependency>
<groupId>com.rackspacecloud</groupId>
<artifactId>service-registry-client</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -12,13 +12,14 @@
public ServiceRegistryClientProvider(String user, String key, String region) {
client = new Client(user, key, region);
}
+
@Override
public List<Service> getServices(String tag) throws Exception {
- return client.services.list(null, tag);
+ return client.getServicesClient().list(null, tag);
}
@Override
public List<ConfigurationValue> getConfiguration() throws Exception {
- return client.configuration.list(null);
+ return client.getConfigurationClient().list(null);
}
}
@@ -48,9 +48,15 @@ public PollResult poll(boolean initial, Object checkPoint)
for (String tag: serviceTags) {
Set<InetSocketAddress> pairs = new HashSet<InetSocketAddress>();
String key = PREFIX + DELIMITER + tag + DELIMITER + SUFFIX;
+
for (Service service : client.getServices(tag)) {
- pairs.add(getHostPortPair(service));
+ InetSocketAddress pair = getHostPortPair(service);
+
+ if (pair != null) {
+ pairs.add(pair);
+ }
}
+
if (!pairs.isEmpty()) {
map.put(key, StringUtils.join(pairs, SEPARATOR));
}
@@ -86,7 +86,7 @@ public void testPolling() throws Exception {
testInstance.addService(tag, ServiceRegistryConfigurationProvider.setHostPortPair(
host,
port,
- new Service("faux" + i, "fauxSession", Collections.singletonList(tag), new HashMap<String, String>())));
+ new Service("faux" + i, 15, Collections.singletonList(tag), new HashMap<String, String>())));
}
String key = ServiceRegistryConfigurationProvider.PREFIX + "." + tag + ".addresses";
pollOnce();
@@ -110,7 +110,7 @@ public void testPollingChanging() throws Exception {
testInstance.addService(tags[i], ServiceRegistryConfigurationProvider.setHostPortPair(
host + i + j,
port,
- new Service("faux" + i + j, "fauxSession", Collections.singletonList(tags[i]), new HashMap<String, String>())));
+ new Service("faux" + i + j, 15, Collections.singletonList(tags[i]), new HashMap<String, String>())));
Integer score = scoreboard.get(tags[i]);