diff options
Diffstat (limited to 'same/src/main/java')
4 files changed, 22 insertions, 9 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientService.java b/same/src/main/java/com/orbekk/same/ClientService.java index 480b813..9382bfa 100644 --- a/same/src/main/java/com/orbekk/same/ClientService.java +++ b/same/src/main/java/com/orbekk/same/ClientService.java @@ -1,7 +1,7 @@ package com.orbekk.same; public interface ClientService { - void notifyNetwork(String networkName, String masterUrl); + void notifyNetwork(String networkName, String masterUrl) throws Exception; - void setState(String component, String data, long revision); + void setState(String component, String data, long revision) throws Exception; } diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java index 36918cf..3f84c2e 100644 --- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java +++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java @@ -42,7 +42,11 @@ public class ClientServiceImpl implements ClientService, UrlReceiver { if (myUrl != null) { MasterService master = connections.getMaster(masterUrl); state.clear(); - master.joinNetworkRequest(myUrl); + try { + master.joinNetworkRequest(myUrl); + } catch (Exception e) { + logger.error("Unable to connect to master.", e); + } } else { logger.error("Tried to join network at {}, but my url is unknown. " + "Run discovery service.", masterUrl); diff --git a/same/src/main/java/com/orbekk/same/MasterService.java b/same/src/main/java/com/orbekk/same/MasterService.java index 46e8ec1..6076ed4 100644 --- a/same/src/main/java/com/orbekk/same/MasterService.java +++ b/same/src/main/java/com/orbekk/same/MasterService.java @@ -1,6 +1,7 @@ package com.orbekk.same; public interface MasterService { - void joinNetworkRequest(String clientUrl); - boolean updateStateRequest(String component, String newData, long revision); + void joinNetworkRequest(String clientUrl) throws Exception; + boolean updateStateRequest(String component, String newData, long revision) + throws Exception; } diff --git a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java index a8acc52..5511dbf 100644 --- a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java +++ b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java @@ -45,9 +45,13 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable { for (final String component : state.getAndClearUpdatedComponents()) { logger.info("Broadcasting new component {}", state.show(component)); broadcaster.broadcast(participants(), new ServiceOperation() { - @Override public void run(ClientService client) { - client.setState(component, state.getDataOf(component), - state.getRevision(component)); + @Override public void run(ClientService client) { + try { + client.setState(component, state.getDataOf(component), + state.getRevision(component)); + } catch (Exception e) { + logger.warn("Exception when connecting to client.", e); + } } }); worked = true; @@ -62,7 +66,11 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable { broadcaster.broadcast(_fullStateReceivers, new ServiceOperation() { @Override public void run(ClientService client) { for (Component c : components) { - client.setState(c.getName(), c.getData(), c.getRevision()); + try { + client.setState(c.getName(), c.getData(), c.getRevision()); + } catch (Exception e) { + logger.warn("Exception when connecting to client.", e); + } } } }); |