1 package at.ac.tuwien.sbc.valesriegler.xvsm.waiter;
3 import java.io.Serializable;
6 import org.mozartspaces.core.MzsCoreException;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
10 import at.ac.tuwien.sbc.valesriegler.DEP_Table;
11 import at.ac.tuwien.sbc.valesriegler.xvsm.XVSMConnector;
14 * This is a waiter using XVSM
16 * @author Gregor Riegler <gregor DOT riegler AT gmail DOT com>
19 public class Waiter implements Serializable {
20 private static final String USAGE = "Waiter needs exactly one parameter: ID of type Integer";
21 private static final Logger log = LoggerFactory.getLogger(Waiter.class);
24 private XVSMConnector xvsm;
26 public static void main(String[] args) {
27 if(args.length != 1) {
28 throw new IllegalArgumentException(USAGE);
33 parsedId = Integer.parseInt(args[0]);
34 } catch (NumberFormatException e) {
39 Waiter waiter = new Waiter(parsedId);
43 private void start() {
44 initSpaceCommunication();
46 List<DEP_Table> tables = xvsm.readTables();
48 log.info("Number of free tables received: {}", tables.size());
52 private void initSpaceCommunication() {
54 xvsm = new XVSMConnector();
55 xvsm.initSpaceCommunication();
56 } catch (MzsCoreException e) {
57 log.error(e.getMessage());
58 log.error("The Waiter has no Space connection! Have you started the Space Server?");
62 log.info("Space Connection established!");
67 public Waiter(int id) {
69 log.info("I AM A WAITER WITH ID {}", id);