From 925be2bd0288a0d188952351f27eb7a3848fd50b Mon Sep 17 00:00:00 2001 From: Gregor Riegler Date: Sat, 15 Jun 2013 18:18:43 +0200 Subject: [PATCH] [XVSM] Add presentation --- README.md | 24 +++- erkenntnisse | 1 + presentation.odp | Bin 0 -> 16792 bytes runXVSM.sh | 14 +-- .../tuwien/sbc/valesriegler/common/Bill.java | 4 +- .../tuwien/sbc/valesriegler/common/Util.java | 2 - .../sbc/valesriegler/xvsm/CookXVSM.java | 116 ++++++++++-------- .../sbc/valesriegler/xvsm/DriverXVSM.java | 27 +++- .../valesriegler/xvsm/LoadBalancerXVSM.java | 14 +++ .../sbc/valesriegler/xvsm/cook/Cook.java | 1 + .../xvsm/spacehelpers/SpaceListener.java | 11 +- .../xvsm/spacehelpers/SpaceListenerImpl.java | 13 +- .../SpaceListenerImplBuilder.java | 12 +- 13 files changed, 160 insertions(+), 79 deletions(-) create mode 100644 presentation.odp diff --git a/README.md b/README.md index f79e5bf..637f12c 100644 --- a/README.md +++ b/README.md @@ -16,17 +16,35 @@ Space Based Computing SS 2013 XVSM ---- +The Group Agent always expects a running space on 9876 and 9877! +The Load Balancer also expects a running space (given as argument) as well as waiters, cooks, pizzerias and drivers. + +Start the Spaces first and then the actors! + ### 1. Start the Group Space Server mvn exec:java -Dexec.mainClass="org.mozartspaces.core.Server" -Dexec.args=9876 -### 2. Start the Group Space GUI +### 2. Start the Customers' Space + mvn exec:java -Dexec.mainClass="org.mozartspaces.core.Server" -Dexec.args=9877 + +### 3. Start the Group Space GUI mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.group.GroupAgent" -Dexec.args="XVSM" ### Start a Pizzeria GUI mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent" -Dexec.args="XVSM " ### Start a Space Waiter - mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="1 " + mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args=" " ### Start a Space Cook - mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 " + mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args=" " + +### Start a Space Driver + mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args=" " + +### Start a Load Balancer + mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.loadbalancer.LoadBalancer" -Dexec.args=" " + + +As an example three files are included in the Root-directory: runXVSM-spaces.sh, runXVSM.sh, runXVSM-group.sh, runXVSM-loadbalancer.sh +Run them in that order. \ No newline at end of file diff --git a/erkenntnisse b/erkenntnisse index 692c1b4..f2b1915 100644 --- a/erkenntnisse +++ b/erkenntnisse @@ -22,3 +22,4 @@ nullpointer-exception: java.lang.NullPointerException at org.mozartspaces.core.Capi.sendRequestAndWaitForResult(Capi.java:1307) at org.mozartspaces.core.Capi.commitTransaction(Capi.java:997) at org.mozartspaces.core.Capi.commitTransaction(Capi.java:980) +durch persistence - berkeleydb funktioniert nichts mehr diff --git a/presentation.odp b/presentation.odp new file mode 100644 index 0000000000000000000000000000000000000000..feb1ed1cb18e93544746d4c2b0d9abc4874fd130 GIT binary patch literal 16792 zcmd6PWk6invTox9cXto&?hxGF-5nbD-~@-@PH=a(pn>4-gb>_=YaYx@&g7mmbMD-K zZ*}+X-FsDitCn=_ULRE`NP~f+0RYedK=RvhVHS$=Vg>*J@bY@T1hBQVHFfrIFg0{= zu(32Ybhfm&V{o-Ip|>{#S_0|q9Zc;^?2TP)P3@fN9h^*o&+os7{zgO{*xH#Ey|7H`nouREMklWdq`&Z+*f0gF`t)btqxZ7CT zS@V%tI6FIVGcdThxzW3^(AztiGca*+aWVW>OY%okCdU7gb8vC8`Ay2in8DP>^ribi z1}1tYhM%%87XDMCUSxk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@0|C zbF&;xo6+*pi>q>DUD&%0;Bk=KjQmbvx|GJ3hz}=C6U1*k%4&rz@4*>S)0x8InYl3< zr_gcESoDg`3)=0j#~RwJv?uF(QqrKX(oCH+<%wxjo!RroEBglqvFDAz%XX3OiC^m) z9suC4{BPSu^ylrO>>Cv!I!QS(2HWQZO*2#AZ`l|X${+1|iQqb}X-JOWRusJ=KQf%^ z%((}MWuU!+165}86F@1kEi6&~a2XVJbe(mXvzVP(A%~Q3wot47)I%+J#1km;nIDnx z5_kE8JxbZaQ-X{^NOhZ0cRFb+Y^uy8UUZ8{a%u{yd+gv4Ao+Bd%recU4ZTpiTG)Da zIUuaNz3F~%T-V^D;B1rH4CU13I)SY^jg@0c4Q^eZH$@@0aHh$qzyFO`n0jZWw-1L7 zLE@}-8{aN~CA_2^h80BdjD!zg!zCv)`==-nbpJU%e-dW@6ouz6Q2r#)en6f{#mYh{>HB=NJBur Sh#@^c*q{GJf(+lwr~d~x^hT`! literal 0 HcmV?d00001 diff --git a/runXVSM.sh b/runXVSM.sh index 9826b7a..9124747 100755 --- a/runXVSM.sh +++ b/runXVSM.sh @@ -1,15 +1,15 @@ #!/bin/bash mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 9875" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="2 9875" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 9874" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="2 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="1 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.cook.Cook" -Dexec.args="2 9874" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="2 9875" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="2 9875" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="1 9874" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="2 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="1 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.waiter.Waiter" -Dexec.args="2 9874" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="1 9875" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="2 9875" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="1 9874" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="2 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="1 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.xvsm.driver.Driver" -Dexec.args="2 9874" & mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent" -Dexec.args="XVSM 9875" & -mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent" -Dexec.args="XVSM 9874" & +#mvn exec:java -Dexec.mainClass="at.ac.tuwien.sbc.valesriegler.pizzeria.PizzeriaAgent" -Dexec.args="XVSM 9874" & diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Bill.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Bill.java index a174603..399c7a7 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Bill.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Bill.java @@ -4,10 +4,10 @@ package at.ac.tuwien.sbc.valesriegler.common; import java.io.Serializable; public class Bill implements Serializable { - public final int amount; + public final double amount; public final int groupId; - public Bill(int amount, int groupId) { + public Bill(double amount, int groupId) { this.amount = amount; this.groupId = groupId; } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java index 2cafdec..0fb836e 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/common/Util.java @@ -61,8 +61,6 @@ public abstract class Util { public static final String PIZZERIA_GROUP = "pizzeriaGroupContainer"; public static final String PIZZERIA_TABLE = "pizzeriaTableContainer"; public static final String PIZZERIA_DELIVERY = "pizzeriaDeliveryContainer"; - public static final String DELIVERY_PROGRESS = "deliveryInProgress"; - public static final String DELIVERY_DONE = "deliveryDone"; public static final boolean runSimulation = false; diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java index a217f37..22e1aca 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/CookXVSM.java @@ -3,11 +3,11 @@ package at.ac.tuwien.sbc.valesriegler.xvsm; import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.types.*; import at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers.SpaceAction; +import at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers.SpaceListenerImpl; import org.mozartspaces.capi3.EntryLockedException; import org.mozartspaces.core.MzsConstants; import org.mozartspaces.core.MzsConstants.RequestTimeout; import org.mozartspaces.core.MzsCoreException; -import org.mozartspaces.core.RequestContext; import org.mozartspaces.core.TransactionReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,6 +22,9 @@ public class CookXVSM extends AbstractXVSMConnector { private static final Logger log = LoggerFactory.getLogger(CookXVSM.class); private int cookId; + private SpaceListenerImpl listenForDeliveryPizzas; + private SpaceListenerImpl listenForNormalPizzas; + public CookXVSM(int id, int port) { super(port); @@ -38,79 +41,73 @@ public class CookXVSM extends AbstractXVSMConnector { } public void listenForPizzas() { - getDefaultBuilder("listenForNormalPizzas").setLookaround(true).setCref(preparePizzasContainer).setTimeout(15000).setSpaceAction(new SpaceAction() { - - @Override - public void onEntriesWritten(List entries) - throws Exception { + listenForNormalPizzas = getDefaultBuilder("listenForNormalPizzas").noNotification().setCref(preparePizzasContainer).setTimeout(15000).setSpaceAction(new SpaceAction() { - List pizzas = castEntries(entries); + @Override + public void onEntriesWritten(List entries) + throws Exception { - sortOrShufflePizzas(pizzas, inNotification.get()); + log.info("Normal pizzas onEntrieswritten of cook {} with size {}", cookId, entries.size()); + List pizzas = castEntries(entries); - for (PizzaOrder pizzaOrder : pizzas) { + Collections.sort(pizzas); - TransactionReference tx = capi.createTransaction(9000, URI.create(String.format(Util.SERVER_ADDR, port))); - String pizzaAlreadyCooked = String.format("Normal pizza with id %d has already been cooked by another cook", pizzaOrder.getId()); + for (PizzaOrder pizzaOrder : pizzas) { - try { - if (!mayPrepareCustomerPizza(pizzaOrder, tx)) { - capi.rollbackTransaction(tx); - continue; - } + TransactionReference tx = capi.createTransaction(9000, URI.create(String.format(Util.SERVER_ADDR, port))); + String pizzaAlreadyCooked = String.format("Normal pizza with id %d has already been cooked by another cook", pizzaOrder.getId()); - // Require the lock for preparing the pizza - PizzaOrder order = takeMatchingEntity(new PizzaOrder(pizzaOrder.getId()), preparePizzasContainer, tx, RequestTimeout.ZERO, pizzaAlreadyCooked); + try { + if (!mayPrepareCustomerPizza(pizzaOrder, tx)) { + capi.rollbackTransaction(tx); + continue; + } - // tell the space that you prepare the pizza -> without a transaction!! - Pizza pizzaInProgress = Pizza.createPizzaFromPizzaOrder(order, cookId, true); - pizzaInProgress.setStatus(PizzaOrderStatus.IN_PREPARATION); + // Require the lock for preparing the pizza + PizzaOrder order = takeMatchingEntity(new PizzaOrder(pizzaOrder.getId()), preparePizzasContainer, tx, RequestTimeout.ZERO, pizzaAlreadyCooked); - notifyCustomerPizzaInProgress(order, pizzaInProgress); + // tell the space that you prepare the pizza -> without a transaction!! + Pizza pizzaInProgress = Pizza.createPizzaFromPizzaOrder(order, cookId, true); + pizzaInProgress.setStatus(PizzaOrderStatus.IN_PREPARATION); - PizzaOrder pizza = createPizza(order); + notifyCustomerPizzaInProgress(order, pizzaInProgress); - notifyCustomerPizzaDone(pizza, tx); - capi.commitTransaction(tx); - log.info("I have completed preparing a pizza for order {}!", pizza.getOrderId()); - } catch (NullPointerException e) { - // the strange nullpointer exception from the space - } catch (EntityNotFoundByTemplate e) { - log.info("entitynotfound: {}", e.getMessage()); - } catch (EntryLockedException e) { - capi.rollbackTransaction(tx); - } catch (Exception e) { - log.error("outer cook"); - log.error(e.getMessage()); - } + PizzaOrder pizza = createPizza(order); - } - } - }).createSpaceListenerImpl(); + notifyCustomerPizzaDone(pizza, tx); + capi.commitTransaction(tx); + log.info("I have completed preparing a pizza for order {}!", pizza.getOrderId()); + } catch (NullPointerException e) { + // the strange nullpointer exception from the space + } catch (EntityNotFoundByTemplate e) { + log.info("entitynotfound: {}", e.getMessage()); + } catch (EntryLockedException e) { + capi.rollbackTransaction(tx); + } catch (Exception e) { + log.error("outer cook"); + log.error(e.getMessage()); + } - } + } + } + }).createSpaceListenerImpl(); - private void sortOrShufflePizzas(List pizzas, boolean notification) { - if (notification) Collections.shuffle(pizzas); - else { - Collections.sort(pizzas); - } } public void listenForDeliveryPizzas() { - getDefaultBuilder("listenForDeliveryPizzas").setLookaround(true).setCref(prepareDeliveryPizzasContainer).setTimeout(15000).setSpaceAction(new SpaceAction() { + listenForDeliveryPizzas = getDefaultBuilder("listenForDeliveryPizzas").noNotification().setCref(prepareDeliveryPizzasContainer).setTimeout(15000).setSpaceAction(new SpaceAction() { @Override public void onEntriesWritten(List entries) throws Exception { + log.info("Delivery pizzas onEntrieswritten of cook {} with size {}", cookId, entries.size()); List pizzas = castEntries(entries); - sortOrShufflePizzas(pizzas, inNotification.get()); + Collections.sort(pizzas); for (PizzaOrder pizzaOrder : pizzas) { - final RequestContext requestContext = new RequestContext(); TransactionReference tx = capi.createTransaction(12000, URI.create(String.format(Util.SERVER_ADDR, port))); String pizzaAlreadyCooked = String.format("Delivery Pizza with id %d has already been cooked by another cook", pizzaOrder.getId()); @@ -161,6 +158,21 @@ public class CookXVSM extends AbstractXVSMConnector { } + public void start() { + try { + final SpaceAction spaceActionDelivery = listenForDeliveryPizzas.getSpaceAction(); + final SpaceAction spaceActionNormalGroup = listenForNormalPizzas.getSpaceAction(); + while(true) { + spaceActionDelivery.onEntriesWritten(listenForDeliveryPizzas.getEntries()); + Thread.sleep(1000); + spaceActionNormalGroup.onEntriesWritten(listenForNormalPizzas.getEntries()); + Thread.sleep(1000); + } + } catch (Exception e) { + log.info(e.getMessage()); + } + } + /** * A cook may prepare a pizza if there is no current delivery order or if at least a pizza of the same order is * in preparation or has been done! @@ -226,6 +238,13 @@ public class CookXVSM extends AbstractXVSMConnector { sendItemsToContainer(Arrays.asList(groupData), pizzeriaGroupContainer, RequestTimeout.DEFAULT, tx); } + private void sortOrShufflePizzas(List pizzas, boolean notification) { + if (notification) Collections.shuffle(pizzas); + else { + Collections.sort(pizzas); + } + } + private void notifyDeliveryPizzaDone(PizzaOrder pizza, TransactionReference tx) throws MzsCoreException { sendItemsToContainer(Arrays.asList(pizza), preparedDeliveryPizzasContainer, RequestTimeout.DEFAULT, tx); final DeliveryGroupData group = new DeliveryGroupData(); @@ -309,5 +328,4 @@ public class CookXVSM extends AbstractXVSMConnector { pizza.setStatus(PizzaOrderStatus.DONE); return pizza; } - } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java index 5f6a23d..736596f 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/DriverXVSM.java @@ -3,10 +3,7 @@ package at.ac.tuwien.sbc.valesriegler.xvsm; import at.ac.tuwien.sbc.valesriegler.common.Bill; import at.ac.tuwien.sbc.valesriegler.common.Util; -import at.ac.tuwien.sbc.valesriegler.types.DeliveryGroupData; -import at.ac.tuwien.sbc.valesriegler.types.DeliveryStatus; -import at.ac.tuwien.sbc.valesriegler.types.Order; -import at.ac.tuwien.sbc.valesriegler.types.Pizza; +import at.ac.tuwien.sbc.valesriegler.types.*; import at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers.SpaceAction; import org.mozartspaces.capi3.EntryLockedException; import org.mozartspaces.core.ContainerReference; @@ -91,7 +88,8 @@ public class DriverXVSM extends AbstractXVSMConnector { if (success) { group.setDeliveryStatus(DeliveryStatus.DELIVERED); if (!Util.runSimulation) { - sendItemsToContainer(Arrays.asList(new Bill(1000, group.getId())), cref, MzsConstants.RequestTimeout.ZERO, null); + double sum = computeSum(group.getOrder()); + sendItemsToContainer(Arrays.asList(new Bill(sum, group.getId())), cref, MzsConstants.RequestTimeout.ZERO, null); } } else { group.setDeliveryStatus(DeliveryStatus.DELIVERY_FAILED); @@ -110,6 +108,25 @@ public class DriverXVSM extends AbstractXVSMConnector { } } + private double computeSum(Order order) { + final List orderedPizzas = order.getOrderedPizzas(); + double sum = 0; + for (PizzaOrder pizza : orderedPizzas) { + final PizzaType pizzaType = pizza.getPizzaType(); + switch (pizzaType) { + case CARDINALE: sum = sum + 6; + break; + case MARGHERITA: sum = sum + 5; + break; + case SALAMI: sum = sum + 5.5; + break; + default: + throw new RuntimeException("Unhandled Pizzatype: " + pizzaType); + } + } + return sum; + } + public void listenForPreparedDeliveryPizzas() { getDefaultBuilder("listenForPreparedDeliveryPizzas").setCref(preparedDeliveryPizzasContainer).setLookaround(true).setSpaceAction(new SpaceAction() { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/LoadBalancerXVSM.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/LoadBalancerXVSM.java index b09cb07..87393d9 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/LoadBalancerXVSM.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/LoadBalancerXVSM.java @@ -4,12 +4,14 @@ package at.ac.tuwien.sbc.valesriegler.xvsm; import at.ac.tuwien.sbc.valesriegler.common.Util; import at.ac.tuwien.sbc.valesriegler.types.DeliveryGroupData; import at.ac.tuwien.sbc.valesriegler.types.DeliveryStatus; +import at.ac.tuwien.sbc.valesriegler.types.PizzaOrder; import at.ac.tuwien.sbc.valesriegler.xvsm.loadbalancer.PizzeriaState; import at.ac.tuwien.sbc.valesriegler.xvsm.loadbalancer.PizzeriaStatus; import at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers.SpaceAction; import org.mozartspaces.capi3.AnyCoordinator; import org.mozartspaces.core.ContainerReference; import org.mozartspaces.core.MzsConstants; +import org.mozartspaces.core.MzsCoreException; import org.mozartspaces.core.TransactionReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -138,6 +140,7 @@ public class LoadBalancerXVSM extends AbstractXVSMConnector { int movedDelivieries = 0; final ContainerReference sourceOrderTakenContainer = useContainerOfSpaceWithPort(Util.DELIVERY_ORDER_TAKEN, pizzeriaId); final ContainerReference sourceDeliveryGroupContainer = useContainerOfSpaceWithPort(Util.PIZZERIA_DELIVERY, pizzeriaId); + final ContainerReference sourcePizzaContainer = useContainerOfSpaceWithPort(Util.PREPARE_DELIVERY_PIZZAS, pizzeriaId); final ContainerReference targetPhoneCallsContainer = useContainerOfSpaceWithPort(Util.PHONE_CALLS, otherPizzeriaId); final ContainerReference targetDeliveryGroupContainer = useContainerOfSpaceWithPort(Util.PIZZERIA_DELIVERY, otherPizzeriaId); @@ -175,6 +178,17 @@ public class LoadBalancerXVSM extends AbstractXVSMConnector { log.warn(e.getMessage()); continue; } + + try { + // Take the pizzas from the container + final PizzaOrder pizza = new PizzaOrder(); + pizza.setOrderId(group.getOrder().getId()); + takeMatchingEntities(pizza, sourcePizzaContainer, tx, MzsConstants.RequestTimeout.DEFAULT, "Cannot take from sourcePizzaContainer"); + } catch (MzsCoreException e) { + log.warn(e.getMessage()); + continue; + } + group.setOriginalPizzeriaId(String.valueOf(pizzeriaId)); group.setPizzeriaId(String.valueOf(otherPizzeriaId)); group.setWaiterIdOfOrder(null); diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/cook/Cook.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/cook/Cook.java index 3c46775..f6492e2 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/cook/Cook.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/cook/Cook.java @@ -26,6 +26,7 @@ public class Cook { xvsm = new CookXVSM(id, pizzeriaPort); xvsm.listenForPizzas(); xvsm.listenForDeliveryPizzas(); + xvsm.start(); } public Cook(int id, int pizzeriaPort) { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListener.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListener.java index 02eb6c6..7a9b6c2 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListener.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListener.java @@ -33,9 +33,11 @@ public abstract class SpaceListener implements NotificationListener { protected boolean lookAround = true; protected long timeout = 3000; + protected SpaceAction spaceAction; - public String name; + public String name; + public boolean noNotification; @Override public void entryOperationFinished(Notification arg0, Operation arg1, List entries) { @@ -48,12 +50,16 @@ public abstract class SpaceListener implements NotificationListener { } catch (Exception e) { // e.printStackTrace(); } - + } } abstract List getEntries() throws Exception; + public SpaceAction getSpaceAction() { + return spaceAction; + } + public void startHandlingAbsenceOfNotifications() { if(!lookAround || Util.runSimulation) return; AbstractXVSMConnector.timeOflastOperation.set(new Date().getTime() + 3500); @@ -83,7 +89,6 @@ public abstract class SpaceListener implements NotificationListener { } } catch (Exception e) { log.info(e.getMessage()); -// e.printStackTrace(); } } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImpl.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImpl.java index f45ce4a..5cc32e8 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImpl.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImpl.java @@ -1,6 +1,6 @@ package at.ac.tuwien.sbc.valesriegler.xvsm.spacehelpers; -import org.mozartspaces.capi3.FifoCoordinator; +import org.mozartspaces.capi3.AnyCoordinator; import org.mozartspaces.core.Capi; import org.mozartspaces.core.ContainerReference; import org.mozartspaces.core.MzsConstants; @@ -24,7 +24,7 @@ public class SpaceListenerImpl extends SpaceListener { private final boolean countAll; - public SpaceListenerImpl(Capi capi, ContainerReference cref, int timeout, SpaceAction spaceAction, NotificationManager notificationManager, boolean lookaround, boolean countAll, String name) { + public SpaceListenerImpl(Capi capi, ContainerReference cref, int timeout, SpaceAction spaceAction, NotificationManager notificationManager, boolean lookaround, boolean countAll, String name, boolean noNotification) { this.capi = capi; this.cref = cref; this.timeout = timeout; @@ -33,13 +33,14 @@ public class SpaceListenerImpl extends SpaceListener { this.lookAround = lookaround; this.countAll = countAll; this.name = name; + this.noNotification = noNotification; } @Override - List getEntries() throws Exception { + public List getEntries() throws Exception { final int count = countAll ? MzsConstants.Selecting.COUNT_ALL : MzsConstants.Selecting.COUNT_MAX; - return capi.read(cref, FifoCoordinator - .newSelector(count), - RequestTimeout.DEFAULT, null); + return capi.read(cref, AnyCoordinator + .newSelector(count), + RequestTimeout.DEFAULT, null); } } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImplBuilder.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImplBuilder.java index 2a54663..20b7053 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImplBuilder.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/xvsm/spacehelpers/SpaceListenerImplBuilder.java @@ -15,6 +15,7 @@ public class SpaceListenerImplBuilder { private NotificationManager notificationManager; private boolean countAll = false; private String name; + private boolean noNotification = false; public SpaceListenerImplBuilder setCapi(Capi capi) { this.capi = capi; @@ -52,10 +53,12 @@ public class SpaceListenerImplBuilder { } public SpaceListenerImpl createSpaceListenerImpl() { - final SpaceListenerImpl spaceListener = new SpaceListenerImpl(capi, cref, timeout, spaceAction, notificationManager, lookaround, countAll, name); + final SpaceListenerImpl spaceListener = new SpaceListenerImpl(capi, cref, timeout, spaceAction, notificationManager, lookaround, countAll, name, noNotification); spaceListener.startHandlingAbsenceOfNotifications(); try { - notificationManager.createNotification(cref, spaceListener, Operation.WRITE); + if(! noNotification) { + notificationManager.createNotification(cref, spaceListener, Operation.WRITE); + } } catch (Exception e) { Util.handleSpaceErrorAndTerminate(e); } @@ -66,4 +69,9 @@ public class SpaceListenerImplBuilder { this.name = name; return this; } + + public SpaceListenerImplBuilder noNotification() { + this.noNotification = true; + return this; + } } \ No newline at end of file -- 2.43.0