summaryrefslogtreecommitdiff
path: root/same/src/main/java/com
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 17:00:53 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 17:00:53 +0100
commit9501f7a2b4b2b174c1b1c413a459b8c56101c53a (patch)
tree4d8c8a2066c02318fa9f0bdd81fd36da8c74bf15 /same/src/main/java/com
parentfe19c8b73039d27676a7f8f80ed3bb0dfa9e2278 (diff)
Improve discovery and error handling.
Diffstat (limited to 'same/src/main/java/com')
-rw-r--r--same/src/main/java/com/orbekk/same/ClientServiceImpl.java8
-rw-r--r--same/src/main/java/com/orbekk/same/SameController.java9
2 files changed, 14 insertions, 3 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
index b46dbfb..92482d5 100644
--- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
@@ -1,5 +1,7 @@
package com.orbekk.same;
+import static com.orbekk.same.StackTraceUtil.throwableToString;
+
import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -108,13 +110,15 @@ public class ClientServiceImpl implements ClientService, UrlReceiver,
@Override
public void discover(String url) {
+ String clientUrl = url + "ClientService.json";
if (!url.equals(myUrl)) {
try {
- connections.getClient(url + "/ClientService.json")
+ connections.getClient(clientUrl)
.notifyNetwork(state.getDataOf(".networkName"),
state.getDataOf(".masterUrl"));
} catch (Exception e) {
- logger.warn("Failed to contact new client {}", url, e);
+ logger.warn("Failed to contact new client {}: {}", clientUrl,
+ throwableToString(e));
}
}
}
diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java
index d7cc747..0601547 100644
--- a/same/src/main/java/com/orbekk/same/SameController.java
+++ b/same/src/main/java/com/orbekk/same/SameController.java
@@ -69,10 +69,10 @@ public class SameController implements UrlReceiver {
public void stop() {
try {
+ master.interrupt();
server.stop();
} catch (Exception e) {
logger.error("Failed to stop webserver", e);
- master.interrupt();
}
}
@@ -122,4 +122,11 @@ public class SameController implements UrlReceiver {
}
}
+ public ClientServiceImpl getClient() {
+ return client;
+ }
+
+ public MasterServiceImpl getMaster() {
+ return master;
+ }
}