From fc2664fbaea8480c5fdd638d6785a25df496eae5 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Mon, 10 Jun 2013 20:38:47 +0200 Subject: [PATCH] [JMS] Benchmark works somehow. (its run twice :/ ) --- .../tuwien/sbc/valesriegler/group/GroupAgent.java | 4 +++- .../group/jms/GroupJMSNACMsgListener.java | 14 +++++++++++++- .../valesriegler/group/jms/JMSGroupConnector.java | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java index 106f995..096ed93 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/GroupAgent.java @@ -101,10 +101,12 @@ public class GroupAgent { GroupAgent.getInstance().onDeliveryGroupsCreated(groups3); GroupAgent.getInstance().onDeliveryGroupsCreated(groups1); + log.warn("Starting benchmark in 20 sec"); Thread.sleep(20000); jmsnac.sendNACMsg(new BenchmarkStart()); Thread.sleep(60000); jmsnac.sendNACMsg(new BenchmarkStop()); + log.warn("Benchmark Stop Signal sent."); } catch (InterruptedException | JMSException e) { log.warn("EXCEPTION!", e); } @@ -134,7 +136,7 @@ public class GroupAgent { public List createGroups(List pizzaTypes1, String pizzeria, int number) { List newDeliveryGroups = new ArrayList<>(); final String fakeAddress = "address"; - final GroupCreationDetailsRequest gc = new GroupCreationDetailsRequest(number, 100, pizzaTypes1, fakeAddress, + final GroupCreationDetailsRequest gc = new GroupCreationDetailsRequest(number, 1000, pizzaTypes1, fakeAddress, pizzeria); for (int i = 0; i < gc.numberOfGroups; i++) { diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/GroupJMSNACMsgListener.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/GroupJMSNACMsgListener.java index 70f439f..0d45921 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/GroupJMSNACMsgListener.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/GroupJMSNACMsgListener.java @@ -12,6 +12,7 @@ import at.ac.tuwien.sbc.valesriegler.group.GroupAgent; import at.ac.tuwien.sbc.valesriegler.jms.nac.AbstractJMSNACMsgListener; import at.ac.tuwien.sbc.valesriegler.jms.nac.actions.AddressInfoRequest; import at.ac.tuwien.sbc.valesriegler.jms.nac.actions.AddressInfoResponse; +import at.ac.tuwien.sbc.valesriegler.jms.nac.actions.BenchmarkStart; import at.ac.tuwien.sbc.valesriegler.jms.nac.actions.BenchmarkStop; /** * Handles the NAC communication for the Group Agent. @@ -35,23 +36,34 @@ public class GroupJMSNACMsgListener extends AbstractJMSNACMsgListener implements ObjectMessage objMsg = (ObjectMessage) msg; Object obj = objMsg.getObject(); if (obj instanceof AddressInfoRequest) { + log.debug("Received: " + obj); + return; // DO NOTHING. } else if (obj instanceof AddressInfoResponse) { + log.debug("Received: " + obj); AddressInfoResponse response = (AddressInfoResponse) obj; GroupAgent.getInstance().getPizzeriaIdentifiers().add(response.getAddress()); if (!Util.runSimulation) { GroupAgent.getGroupGui().getFrame().repaint(); JMSGroupConnector.getConnectors().put(response.getAddress(), new JMSGroupConnector(response.getAddress())); } + return; + } else if (obj instanceof BenchmarkStop) { + log.debug("Received: " + obj); for (String keys : JMSGroupConnector.getConnectors().keySet()) { JMSGroupConnector c = JMSGroupConnector.getConnector(keys); c.getConnection().close(); GroupAgent.getInstance().getDeliveryModel().createStatistics(); } - } else if (obj instanceof BenchmarkStop) { + return; + + } else if (obj instanceof BenchmarkStart) { + log.debug("Received: " + obj); + return; // DO NOTHING. + } else { log.warn("Received unknown Object: " + obj); } diff --git a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java index ddafe41..672c872 100644 --- a/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java +++ b/src/main/java/at/ac/tuwien/sbc/valesriegler/group/jms/JMSGroupConnector.java @@ -103,7 +103,7 @@ public class JMSGroupConnector extends AbstractGroupConnector implements Message } else if (obj instanceof DeliveryOrderResponse) { DeliveryOrderResponse deliveryOrderResponse = (DeliveryOrderResponse) obj; - log.warn("Received: " + deliveryOrderResponse); + log.debug("Received: " + deliveryOrderResponse); deliveryOrderResponse.getDeliveryGroupData().setWaiterIdOfOrder(deliveryOrderResponse.getWaiterId()); ArrayList gd = new ArrayList(); gd.add(deliveryOrderResponse.getDeliveryGroupData()); @@ -112,7 +112,7 @@ public class JMSGroupConnector extends AbstractGroupConnector implements Message } else if (obj instanceof DeliveryOrderInfo) { DeliveryOrderInfo deliveryOrderInfo = (DeliveryOrderInfo) obj; - log.warn("Received: " + deliveryOrderInfo); + log.debug("Received: " + deliveryOrderInfo); ArrayList gd = new ArrayList(); gd.add(deliveryOrderInfo.getDeliveryGroupData()); GroupAgent.getInstance().getDeliveryModel().addDeliveries(gd); @@ -120,7 +120,7 @@ public class JMSGroupConnector extends AbstractGroupConnector implements Message } else if (obj instanceof OrderDeliveredInfo) { OrderDeliveredInfo orderDeliveredInfo = (OrderDeliveredInfo) obj; - log.warn("Received: " + orderDeliveredInfo); + log.debug("Received: " + orderDeliveredInfo); orderDeliveredInfo.getDeliveryGroupData().setDriverId(orderDeliveredInfo.getDriverId()); ArrayList gd = new ArrayList(); gd.add(orderDeliveredInfo.getDeliveryGroupData()); -- 2.43.0