summaryrefslogtreecommitdiff
path: root/sources/protocols/implementations
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 /sources/protocols/implementations
parentfae58d2173039e70ad94075d49c0c500e935e454 (diff)
onServerStart vs onClientStart works.
Diffstat (limited to 'sources/protocols/implementations')
-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
8 files changed, 81 insertions, 75 deletions
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() {
}
}