summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/main/java/com/orbekk')
-rw-r--r--same/src/main/java/com/orbekk/same/App.java1
-rw-r--r--same/src/main/java/com/orbekk/same/ClientApp.java28
-rw-r--r--same/src/main/java/com/orbekk/same/ClientServiceImpl.java1
-rw-r--r--same/src/main/java/com/orbekk/same/SameController.java20
4 files changed, 3 insertions, 47 deletions
diff --git a/same/src/main/java/com/orbekk/same/App.java b/same/src/main/java/com/orbekk/same/App.java
index 2416899..2955311 100644
--- a/same/src/main/java/com/orbekk/same/App.java
+++ b/same/src/main/java/com/orbekk/same/App.java
@@ -13,6 +13,7 @@ public class App {
SameController controller = SameController.create(configuration);
try {
controller.start();
+ controller.joinNetwork(configuration.get("masterUrl"));
controller.join();
} catch (Exception e) {
logger.error("Error in App.", e);
diff --git a/same/src/main/java/com/orbekk/same/ClientApp.java b/same/src/main/java/com/orbekk/same/ClientApp.java
deleted file mode 100644
index 5a57fcd..0000000
--- a/same/src/main/java/com/orbekk/same/ClientApp.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.orbekk.same;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.orbekk.same.config.Configuration;
-
-public class ClientApp {
- private Logger logger = LoggerFactory.getLogger(getClass());
-
- public void run(Configuration configuration) {
- String networkName = configuration.get("networkName");
- String masterUrl = configuration.get("masterUrl");
- SameController controller = SameController.create(configuration);
- try {
- controller.start();
- } catch (Exception e) {
- logger.error("Failed to start Same", e);
- }
- controller.joinNetwork(masterUrl);
- controller.join();
- }
-
- public static void main(String[] args) {
- Configuration configuration = Configuration.loadOrDie();
- (new ClientApp()).run(configuration);
- }
-}
diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
index 0854458..c503919 100644
--- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
@@ -77,6 +77,7 @@ public class ClientServiceImpl implements DiscoveryListener {
}
public void joinNetwork(String masterUrl) {
+ logger.info("joinNetwork({})", masterUrl);
MasterService master = connections.getMaster(masterUrl);
state.clear();
try {
diff --git a/same/src/main/java/com/orbekk/same/SameController.java b/same/src/main/java/com/orbekk/same/SameController.java
index d898c1d..44e1721 100644
--- a/same/src/main/java/com/orbekk/same/SameController.java
+++ b/same/src/main/java/com/orbekk/same/SameController.java
@@ -99,26 +99,8 @@ public class SameController {
}
}
- public boolean tryGetUrl(String serverUrl) {
- int retries = 100;
- while (client.getUrl() == null && retries > 0) {
- HttpUtil.sendHttpRequest(serverUrl + "ping?port=" +
- port);
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- return false;
- }
- retries -= 1;
- }
- return client.getUrl() != null;
- }
-
public void joinNetwork(String url) {
- boolean hasUrl = tryGetUrl(url);
- if (hasUrl) {
- client.joinNetwork(url + "MasterService.json");
- }
+ client.joinNetwork(url);
}
public ClientServiceImpl getClient() {