summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-27 20:13:54 +0000
committerPaul Buetow <paul@buetow.org>2008-05-27 20:13:54 +0000
commit23055ca47090021dbf84d05d5e14c8990479bfe1 (patch)
tree36edcf38df1569abb3f81f92cf6b6acc1689b714
parentfae58d2173039e70ad94075d49c0c500e935e454 (diff)
onServerStart vs onClientStart works.
-rw-r--r--ROADMAP2
-rw-r--r--sources/events/VSRegisteredEvents.java20
-rw-r--r--sources/prefs/VSDefaultPrefs.java1
-rw-r--r--sources/protocols/VSAbstractProtocol.java37
-rw-r--r--sources/protocols/implementations/BerkelyTimeProtocol.java40
-rw-r--r--sources/protocols/implementations/BroadcastSturmProtocol.java1
-rw-r--r--sources/protocols/implementations/DummyProtocol.java1
-rw-r--r--sources/protocols/implementations/ExternalTimeSyncProtocol.java1
-rw-r--r--sources/protocols/implementations/InternalTimeSyncProtocol.java2
-rw-r--r--sources/protocols/implementations/OnePhaseCommitProtocol.java45
-rw-r--r--sources/protocols/implementations/PingPongProtocol.java1
-rw-r--r--sources/protocols/implementations/TwoPhaseCommitProtocol.java65
-rw-r--r--sources/simulator/VSSimulator.java24
13 files changed, 150 insertions, 90 deletions
diff --git a/ROADMAP b/ROADMAP
index 57e582e..dee37b8 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -1,7 +1,7 @@
TODO:
-Nicht nur Clientanfragen, auch Serveranfragen erlauben.
VSSimulatorEditor: DEFAULT Prozesseinsgellungen, DEFAULT Nachrichteneinstellungen
+Kapseln: Protokolle sollen nur fuer sie bestimtme methoden aufrufen koennen
Periodische Tasks anlegen koennen
Ganze simulationseinstellungen abspeichern/laden koennen
TaskManager + Tasks serialisierbar machen
diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java
index 52cb042..05857be 100644
--- a/sources/events/VSRegisteredEvents.java
+++ b/sources/events/VSRegisteredEvents.java
@@ -42,6 +42,9 @@ public final class VSRegisteredEvents {
private static HashMap<String,ArrayList<String>> serverVariables =
new HashMap<String,ArrayList<String>>();
+ private static HashMap<String,Boolean> isOnServerStartProtocol =
+ new HashMap<String,Boolean>();
+
/** The prefs. */
private static VSPrefs prefs;
@@ -95,6 +98,9 @@ public final class VSRegisteredEvents {
variables.addAll(clientProtocol.getAllFullKeys());
clientVariables.put(protocolClassname, variables);
}
+
+ if (serverProtocol.hasOnServerStart())
+ isOnServerStartProtocol.put(protocolClassname, new Boolean(true));
}
}
}
@@ -245,6 +251,20 @@ public final class VSRegisteredEvents {
}
/**
+ * Checks if the protocol uses onServerStart or onClientStart
+ *
+ * @param protocolClassname the protocol's classname
+ *
+ * @return true if onServerStart, false if onClientStart
+ */
+ public static boolean isOnServerStartProtocol(String protocolClassname) {
+ if (isOnServerStartProtocol.containsKey(protocolClassname))
+ return isOnServerStartProtocol.get(protocolClassname).booleanValue();
+
+ return false;
+ }
+
+ /**
* Creates the event instance by classname.
*
* @param eventClassname the event classname
diff --git a/sources/prefs/VSDefaultPrefs.java b/sources/prefs/VSDefaultPrefs.java
index c5951ff..d3547f4 100644
--- a/sources/prefs/VSDefaultPrefs.java
+++ b/sources/prefs/VSDefaultPrefs.java
@@ -51,6 +51,7 @@ public class VSDefaultPrefs extends VSPrefs {
initString("lang.cancel", "Abbrechen");
initString("lang.client", "Client");
initString("lang.clientrequest.start", "Clientanfrage starten");
+ initString("lang.serverrequest.start", "Serveranfrage starten");
initString("lang.close", "Schliessen");
initString("lang.colorchooser", "Farbauswahl");
initString("lang.colorchooser2", "Bitte Farbe auswählen");
diff --git a/sources/protocols/VSAbstractProtocol.java b/sources/protocols/VSAbstractProtocol.java
index 299d23d..461fe01 100644
--- a/sources/protocols/VSAbstractProtocol.java
+++ b/sources/protocols/VSAbstractProtocol.java
@@ -15,6 +15,11 @@ import core.*;
*/
abstract public class VSAbstractProtocol extends VSAbstractEvent {
private static final long serialVersionUID = 1L;
+ protected static final boolean HAS_ON_SERVER_START = true;
+ protected static final boolean HAS_ON_CLIENT_START = false;
+
+ /** True, if onServerStart is used, false if onClientStart is used */
+ private boolean hasOnServerStart;
/** The protocol object is a server. */
private boolean isServer;
@@ -31,7 +36,8 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
/** The protocol's client schedules */
private ArrayList<VSTask> clientSchedules = new ArrayList<VSTask>();
- public VSAbstractProtocol() {
+ public VSAbstractProtocol(boolean hasOnServerStart) {
+ this.hasOnServerStart = hasOnServerStart;
}
/**
@@ -64,9 +70,16 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
* @see events.VSAbstractEvent#onStart()
*/
public final void onStart() {
- if (isClient) {
- currentContextIsServer(false);
- onClientStart();
+ if (hasOnServerStart) {
+ if (isServer) {
+ currentContextIsServer(true);
+ onServerStart();
+ }
+ } else {
+ if (isClient) {
+ currentContextIsServer(false);
+ onClientStart();
+ }
}
}
@@ -136,6 +149,15 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
}
/**
+ * Checks how the protocol will start
+ *
+ * @return true, if this protocol uses onServerStart instead of onClientStart
+ */
+ public final boolean hasOnServerStart() {
+ return hasOnServerStart;
+ }
+
+ /**
* Sets if is server.
*
* @param isServer the is server
@@ -226,7 +248,7 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
/**
* On client start.
*/
- abstract public void onClientStart();
+ public void onClientStart() { };
/**
* On client reset.
@@ -251,6 +273,11 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
abstract public void onServerInit();
/**
+ * On server start.
+ */
+ public void onServerStart() { };
+
+ /**
* On server reset.
*/
abstract public void onServerReset();
diff --git a/sources/protocols/implementations/BerkelyTimeProtocol.java b/sources/protocols/implementations/BerkelyTimeProtocol.java
index d680f41..ab4c96e 100644
--- a/sources/protocols/implementations/BerkelyTimeProtocol.java
+++ b/sources/protocols/implementations/BerkelyTimeProtocol.java
@@ -21,6 +21,7 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
* Instantiates a new berkely time protocol.
*/
public BerkelyTimeProtocol() {
+ super(VSAbstractProtocol.HAS_ON_SERVER_START);
setClassname(getClass().toString());
}
@@ -39,11 +40,10 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
/** Time the request/response has started */
private long requestTime;
-
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onClientInit()
+ * @see events.VSAbstractProtocol#onServerInit()
*/
- public void onClientInit() {
+ public void onServerInit() {
/* Those prefs are editable through the VSAbstractProtocol VSAbstractEditor GUI. */
Vector<Integer> vec = new Vector<Integer>();
vec.add(2);
@@ -52,9 +52,9 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientReset()
+ * @see protocols.VSAbstractProtocol#onServerReset()
*/
- public void onClientReset() {
+ public void onServerReset() {
processTimes.clear();
recvTimes.clear();
realTimesRTT.clear();
@@ -63,9 +63,9 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientStart()
+ * @see protocols.VSAbstractProtocol#onServerStart()
*/
- public void onClientStart() {
+ public void onServerStart() {
peers.addAll(getVector("pids"));
requestTime = process.getTime();
VSMessage message = new VSMessage();
@@ -74,9 +74,9 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
*/
- public void onClientRecv(VSMessage recvMessage) {
+ public void onServerRecv(VSMessage recvMessage) {
/* Ignore all protocol messages which are not a response message, e.g. itself */
if (!recvMessage.getBoolean("isResponse"))
return;
@@ -101,14 +101,14 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
/* Tell all other processes what to do in order to justify their times */
sendJustifyRequests(avgTime);
/* Start "clean" next time */
- onClientReset();
+ onServerReset();
}
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientSchedule()
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
*/
- public void onClientSchedule() {
+ public void onServerSchedule() {
}
/**
@@ -149,21 +149,21 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onServerInit()
+ * @see events.VSAbstractProtocol#onClientInit()
*/
- public void onServerInit() {
+ public void onClientInit() {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerReset()
+ * @see protocols.VSAbstractProtocol#onClientReset()
*/
- public void onServerReset() {
+ public void onClientReset() {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
*/
- public void onServerRecv(VSMessage recvMessage) {
+ public void onClientRecv(VSMessage recvMessage) {
if (recvMessage.getBoolean("isRequest")) {
VSMessage message = new VSMessage();
message.setInteger("processID", process.getProcessID());
@@ -186,9 +186,9 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerSchedule()
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
*/
- public void onServerSchedule() {
+ public void onClientSchedule() {
}
/* (non-Javadoc)
diff --git a/sources/protocols/implementations/BroadcastSturmProtocol.java b/sources/protocols/implementations/BroadcastSturmProtocol.java
index 1121e98..6d49fad 100644
--- a/sources/protocols/implementations/BroadcastSturmProtocol.java
+++ b/sources/protocols/implementations/BroadcastSturmProtocol.java
@@ -26,6 +26,7 @@ public class BroadcastSturmProtocol extends VSAbstractProtocol {
* Instantiates a new broadcast sturm protocol.
*/
public BroadcastSturmProtocol() {
+ super(VSAbstractProtocol.HAS_ON_CLIENT_START);
setClassname(getClass().toString());
sentMessages = new ArrayList<VSMessage>();
}
diff --git a/sources/protocols/implementations/DummyProtocol.java b/sources/protocols/implementations/DummyProtocol.java
index 91e46c8..dee873e 100644
--- a/sources/protocols/implementations/DummyProtocol.java
+++ b/sources/protocols/implementations/DummyProtocol.java
@@ -17,6 +17,7 @@ public class DummyProtocol extends VSAbstractProtocol {
* Instantiates a new dummy protocol.
*/
public DummyProtocol() {
+ super(VSAbstractProtocol.HAS_ON_CLIENT_START);
setClassname(getClass().toString());
}
diff --git a/sources/protocols/implementations/ExternalTimeSyncProtocol.java b/sources/protocols/implementations/ExternalTimeSyncProtocol.java
index 97a20ef..382ae1e 100644
--- a/sources/protocols/implementations/ExternalTimeSyncProtocol.java
+++ b/sources/protocols/implementations/ExternalTimeSyncProtocol.java
@@ -24,6 +24,7 @@ public class ExternalTimeSyncProtocol extends VSAbstractProtocol {
* Instantiates a new external time sync protocol.
*/
public ExternalTimeSyncProtocol() {
+ super(VSAbstractProtocol.HAS_ON_CLIENT_START);
setClassname(getClass().toString());
}
diff --git a/sources/protocols/implementations/InternalTimeSyncProtocol.java b/sources/protocols/implementations/InternalTimeSyncProtocol.java
index c35e201..3c1d5d5 100644
--- a/sources/protocols/implementations/InternalTimeSyncProtocol.java
+++ b/sources/protocols/implementations/InternalTimeSyncProtocol.java
@@ -21,8 +21,8 @@ public class InternalTimeSyncProtocol extends VSAbstractProtocol {
* Instantiates a new internal time sync protocol.
*/
public InternalTimeSyncProtocol() {
+ super(VSAbstractProtocol.HAS_ON_CLIENT_START);
setClassname(getClass().toString());
-
}
/* (non-Javadoc)
diff --git a/sources/protocols/implementations/OnePhaseCommitProtocol.java b/sources/protocols/implementations/OnePhaseCommitProtocol.java
index 53c8ce6..fcb5499 100644
--- a/sources/protocols/implementations/OnePhaseCommitProtocol.java
+++ b/sources/protocols/implementations/OnePhaseCommitProtocol.java
@@ -16,23 +16,24 @@ import core.VSMessage;
public class OnePhaseCommitProtocol extends VSAbstractProtocol {
private static final long serialVersionUID = 1L;
- /* Server variables, coordinator */
+ /* Client variables, coordinator */
private ArrayList<Integer> pids;
- /* Client variables */
+ /* Server variables */
private boolean ackSent;
/**
* Instantiates a one phase commit protocol.
*/
public OnePhaseCommitProtocol() {
+ super(VSAbstractProtocol.HAS_ON_SERVER_START);
setClassname(getClass().toString());
}
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onClientInit()
+ * @see events.VSAbstractProtocol#onServerInit()
*/
- public void onClientInit() {
+ public void onServerInit() {
/* Can be changed via GUI variables editor of each process */
Vector<Integer> vec = new Vector<Integer>();
vec.add(2);
@@ -43,9 +44,9 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientReset()
+ * @see protocols.VSAbstractProtocol#onServerReset()
*/
- public void onClientReset() {
+ public void onServerReset() {
if (pids != null) {
pids.clear();
pids.addAll(getVector("pids"));
@@ -53,9 +54,9 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientStart()
+ * @see protocols.VSAbstractProtocol#onServerStart()
*/
- public void onClientStart() {
+ public void onServerStart() {
if (pids == null) {
pids = new ArrayList<Integer>();
pids.addAll(getVector("pids"));
@@ -63,7 +64,7 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
if (pids.size() != 0) {
long timeout = getLong("timeout") + process.getTime();
- scheduleAt(timeout); /* Will run onClientSchedule() at the specified local time */
+ scheduleAt(timeout); /* Will run onServerSchedule() at the specified local time */
VSMessage message = new VSMessage();
message.setBoolean("wantAck", true);
@@ -72,9 +73,9 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
*/
- public void onClientRecv(VSMessage recvMessage) {
+ public void onServerRecv(VSMessage recvMessage) {
if (pids.size() == 0)
return;
@@ -93,29 +94,29 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientSchedule()
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
*/
- public void onClientSchedule() {
- onClientStart();
+ public void onServerSchedule() {
+ onServerStart();
}
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onServerInit()
+ * @see events.VSAbstractProtocol#onClientInit()
*/
- public void onServerInit() {
+ public void onClientInit() {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerReset()
+ * @see protocols.VSAbstractProtocol#onClientReset()
*/
- public void onServerReset() {
+ public void onClientReset() {
ackSent = false;
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
*/
- public void onServerRecv(VSMessage recvMessage) {
+ public void onClientRecv(VSMessage recvMessage) {
if (ackSent)
return;
@@ -128,9 +129,9 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerSchedule()
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
*/
- public void onServerSchedule() {
+ public void onClientSchedule() {
}
/* (non-Javadoc)
diff --git a/sources/protocols/implementations/PingPongProtocol.java b/sources/protocols/implementations/PingPongProtocol.java
index 13a7b32..d8d2013 100644
--- a/sources/protocols/implementations/PingPongProtocol.java
+++ b/sources/protocols/implementations/PingPongProtocol.java
@@ -24,6 +24,7 @@ public class PingPongProtocol extends VSAbstractProtocol {
* Instantiates a new ping pong protocol.
*/
public PingPongProtocol() {
+ super(VSAbstractProtocol.HAS_ON_CLIENT_START);
setClassname(getClass().toString());
}
diff --git a/sources/protocols/implementations/TwoPhaseCommitProtocol.java b/sources/protocols/implementations/TwoPhaseCommitProtocol.java
index cd1a5ce..8f6872d 100644
--- a/sources/protocols/implementations/TwoPhaseCommitProtocol.java
+++ b/sources/protocols/implementations/TwoPhaseCommitProtocol.java
@@ -16,6 +16,14 @@ import core.VSMessage;
public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
private static final long serialVersionUID = 1L;
+ /**
+ * Instantiates a one phase commit protocol.
+ */
+ public TwoPhaseCommitProtocol() {
+ super(VSAbstractProtocol.HAS_ON_SERVER_START);
+ setClassname(getClass().toString());
+ }
+
/** PIDs of all processes which still have to vote */
private ArrayList<Integer> votePids;
@@ -25,17 +33,10 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
/** The gloal vote result */
private boolean voteResult;
- /**
- * Instantiates a one phase commit protocol.
- */
- public TwoPhaseCommitProtocol() {
- setClassname(getClass().toString());
- }
-
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onClientInit()
+ * @see events.VSAbstractProtocol#onServerInit()
*/
- public void onClientInit() {
+ public void onServerInit() {
Vector<Integer> vec = new Vector<Integer>();
vec.add(2);
vec.add(3);
@@ -45,9 +46,9 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientReset()
+ * @see protocols.VSAbstractProtocol#onServerReset()
*/
- public void onClientReset() {
+ public void onServerReset() {
if (votePids != null) {
voteResult = true;
votePids.clear();
@@ -58,9 +59,9 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientStart()
+ * @see protocols.VSAbstractProtocol#onServerStart()
*/
- public void onClientStart() {
+ public void onServerStart() {
if (votePids == null) {
voteResult = true;
votePids = new ArrayList<Integer>();
@@ -71,7 +72,7 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
if (votePids.size() != 0) {
long timeout = getLong("timeout") + process.getTime();
- scheduleAt(timeout); /* Will run onClientSchedule() at the specified local time */
+ scheduleAt(timeout); /* Will run onServerSchedule() at the specified local time */
VSMessage message = new VSMessage();
message.setBoolean("wantVote", true);
@@ -79,7 +80,7 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
} else if (ackPids.size() != 0) {
long timeout = getLong("timeout") + process.getTime();
- scheduleAt(timeout); /* Will run onClientSchedule() at the specified local time */
+ scheduleAt(timeout); /* Will run onServerSchedule() at the specified local time */
VSMessage message = new VSMessage();
message.setBoolean("isVoteResult", true);
@@ -89,9 +90,9 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
*/
- public void onClientRecv(VSMessage recvMessage) {
+ public void onServerRecv(VSMessage recvMessage) {
if (votePids.size() != 0 && recvMessage.getBoolean("isVote")) {
Integer pid = recvMessage.getIntegerObj("pid");
if (votePids.contains(pid))
@@ -107,10 +108,10 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
if (votePids.size() == 0) {
logg("Abstimmungen von allen beteiligten Prozessen erhalten! Globales Ergebnis: " + voteResult);
- /* Remove the active schedule which has been created in the onClientStart method */
+ /* Remove the active schedule which has been created in the onServerStart method */
removeSchedules();
/* Create a new schedule and send the vote result */
- onClientStart();
+ onServerStart();
}
} else if (ackPids.size() != 0 && recvMessage.getBoolean("isAck")) {
Integer pid = recvMessage.getIntegerObj("pid");
@@ -120,7 +121,7 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
return;
if (ackPids.size() == 0) {
- /* Remove the active schedule which has been created in the onClientStart method */
+ /* Remove the active schedule which has been created in the onServerStart method */
removeSchedules();
logg("Alle Teilnehmer haben die Abstimmung erhalten");
}
@@ -128,34 +129,34 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onClientSchedule()
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
*/
- public void onClientSchedule() {
- onClientStart();
+ public void onServerSchedule() {
+ onServerStart();
}
- /* Client variables */
+ /* Server variables */
private boolean voteSent;
private boolean myVote;
/* (non-Javadoc)
- * @see events.VSAbstractProtocol#onServerInit()
+ * @see events.VSAbstractProtocol#onClientInit()
*/
- public void onServerInit() {
+ public void onClientInit() {
initInteger("ackProb", 50, "Festschreibw'keit", 0, 100, "%");
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerReset()
+ * @see protocols.VSAbstractProtocol#onClientReset()
*/
- public void onServerReset() {
+ public void onClientReset() {
voteSent = false;
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
+ * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage)
*/
- public void onServerRecv(VSMessage recvMessage) {
+ public void onClientRecv(VSMessage recvMessage) {
if (recvMessage.getBoolean("wantVote")) {
if (!voteSent) {
voteSent = true;
@@ -182,8 +183,8 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
- * @see protocols.VSAbstractProtocol#onServerSchedule()
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
*/
- public void onServerSchedule() {
+ public void onClientSchedule() {
}
}
diff --git a/sources/simulator/VSSimulator.java b/sources/simulator/VSSimulator.java
index 056c70a..61d68ee 100644
--- a/sources/simulator/VSSimulator.java
+++ b/sources/simulator/VSSimulator.java
@@ -487,7 +487,7 @@ public class VSSimulator extends JPanel {
/* Those values are for ProtocolClient onStart events */
/** The is client request. */
- private boolean isClientRequest;
+ private boolean isRequest;
/**
* Instantiates a new lang.process.removecreate task.
@@ -534,10 +534,10 @@ public class VSSimulator extends JPanel {
/**
* Checks if is client request.
*
- * @param isClientRequest the is client request
+ * @param isRequest the is client request
*/
- public void isClientRequest(boolean isClientRequest) {
- this.isClientRequest = isClientRequest;
+ public void isRequest(boolean isRequest) {
+ this.isRequest = isRequest;
}
/**
@@ -570,7 +570,7 @@ public class VSSimulator extends JPanel {
public VSTask createTask(VSProcess process, long time, boolean localTimedTask) {
VSAbstractEvent event = null;
- if (isClientRequest) {
+ if (isRequest) {
event = process.getProtocolObject(eventClassname);
} else {
@@ -958,22 +958,28 @@ public class VSSimulator extends JPanel {
String activate = prefs.getString("lang.activate");
String client = prefs.getString("lang.client");
- String clientrequest = prefs.getString("lang.clientrequest.start");
+ String clientRequest = prefs.getString("lang.clientrequest.start");
String deactivate = prefs.getString("lang.deactivate");
- String protocolEventClassname = "events.internal.ProtocolEvent";
String server = prefs.getString("lang.server");
+ String serverRequest = prefs.getString("lang.serverrequest.start");
+ String protocolEventClassname = "events.internal.ProtocolEvent";
eventClassnames = VSRegisteredEvents.getProtocolClassnames();
for (String eventClassname : eventClassnames) {
String eventShortname_ = VSRegisteredEvents.getShortnameByClassname(eventClassname);
+ String eventShortname = null;
+
+ if (VSRegisteredEvents.isOnServerStartProtocol(eventClassname))
+ eventShortname = eventShortname_ + " " + serverRequest;
+ else
+ eventShortname = eventShortname_ + " " + clientRequest;
- String eventShortname = eventShortname_ + " " + clientrequest;
comboBox.addItem(eventShortname);
if (createTaskFlag) {
VSCreateTask createTask = new VSCreateTask(eventClassname);
createTask.setShortname(eventShortname);
- createTask.isClientRequest(true);
+ createTask.isRequest(true);
createTasks.add(createTask);
}