This commit is contained in:
Edward Capriolo
2015-01-17 18:17:38 -05:00
parent 6d70b28e82
commit 4506fe4a79
2 changed files with 76 additions and 68 deletions

View File

@ -13,7 +13,7 @@ public class GossipRunner {
File configFile; File configFile;
if (args.length == 1) { if (args.length == 1) {
configFile = new File("./"+args[0]); configFile = new File("./" + args[0]);
} else { } else {
configFile = new File("gossip.conf"); configFile = new File("gossip.conf");
} }
@ -40,7 +40,8 @@ public class GossipRunner {
System.err.println("Error while starting the gossip service: " + e.getMessage()); System.err.println("Error while starting the gossip service: " + e.getMessage());
} }
} else { } else {
System.out.println("The gossip.conf file is not found.\n\nEither specify the path to the startup settings file or place the gossip.json file in the same folder as the JAR file."); System.out
.println("The gossip.conf file is not found.\n\nEither specify the path to the startup settings file or place the gossip.json file in the same folder as the JAR file.");
} }
} }
} }

View File

@ -17,24 +17,32 @@ import com.google.code.gossip.manager.random.RandomGossipManager;
public class GossipService { public class GossipService {
public static final Logger LOGGER = Logger.getLogger(GossipService.class); public static final Logger LOGGER = Logger.getLogger(GossipService.class);
private GossipManager _gossipManager; private GossipManager _gossipManager;
/** /**
* Constructor with the default settings. * Constructor with the default settings.
*
* @throws InterruptedException * @throws InterruptedException
* @throws UnknownHostException * @throws UnknownHostException
*/ */
public GossipService(StartupSettings startupSettings) throws InterruptedException, UnknownHostException { public GossipService(StartupSettings startupSettings) throws InterruptedException,
this(InetAddress.getLocalHost().getHostAddress(), startupSettings.getPort(), "", startupSettings.getLogLevel(), startupSettings.getGossipMembers(), startupSettings.getGossipSettings()); UnknownHostException {
this(InetAddress.getLocalHost().getHostAddress(), startupSettings.getPort(), "",
startupSettings.getLogLevel(), startupSettings.getGossipMembers(), startupSettings
.getGossipSettings());
} }
/** /**
* Setup the client's lists, gossiping parameters, and parse the startup config file. * Setup the client's lists, gossiping parameters, and parse the startup config file.
*
* @throws SocketException * @throws SocketException
* @throws InterruptedException * @throws InterruptedException
* @throws UnknownHostException * @throws UnknownHostException
*/ */
public GossipService(String ipAddress, int port, String id, int logLevel, ArrayList<GossipMember> gossipMembers, GossipSettings settings) throws InterruptedException, UnknownHostException { public GossipService(String ipAddress, int port, String id, int logLevel,
ArrayList<GossipMember> gossipMembers, GossipSettings settings)
throws InterruptedException, UnknownHostException {
_gossipManager = new RandomGossipManager(ipAddress, port, id, settings, gossipMembers); _gossipManager = new RandomGossipManager(ipAddress, port, id, settings, gossipMembers);
} }
@ -54,5 +62,4 @@ public class GossipService {
this._gossipManager = _gossipManager; this._gossipManager = _gossipManager;
} }
} }