summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-26 19:44:51 +0000
committerPaul Buetow <paul@buetow.org>2008-05-26 19:44:51 +0000
commit8fd9c3e2980eb5720033584ac3cd2d156b5c9d63 (patch)
tree1c7d183495319ac020134e71129d91d535bee417 /sources
parent99ae411186cb049bfd55887b2c521bbf0e8bc2be (diff)
new onClientSchedule and onServerSchedule abstract methods
Diffstat (limited to 'sources')
-rw-r--r--sources/events/internal/ProtocolScheduleEvent.java4
-rw-r--r--sources/protocols/VSAbstractProtocol.java52
-rw-r--r--sources/protocols/implementations/BerkelyTimeProtocol.java12
-rw-r--r--sources/protocols/implementations/BroadcastSturmProtocol.java12
-rw-r--r--sources/protocols/implementations/DummyProtocol.java12
-rw-r--r--sources/protocols/implementations/ExternalTimeSyncProtocol.java12
-rw-r--r--sources/protocols/implementations/InternalTimeSyncProtocol.java12
-rw-r--r--sources/protocols/implementations/OnePhaseCommitProtocol.java12
-rw-r--r--sources/protocols/implementations/PingPongProtocol.java12
-rw-r--r--sources/protocols/implementations/TwoPhaseCommitProtocol.java12
10 files changed, 150 insertions, 2 deletions
diff --git a/sources/events/internal/ProtocolScheduleEvent.java b/sources/events/internal/ProtocolScheduleEvent.java
index c5b7562..24eb6fd 100644
--- a/sources/events/internal/ProtocolScheduleEvent.java
+++ b/sources/events/internal/ProtocolScheduleEvent.java
@@ -66,5 +66,9 @@ public class ProtocolScheduleEvent extends VSAbstractEvent {
* @see events.VSAbstractEvent#onStart()
*/
public void onStart() {
+ if (isClientSchedule)
+ protocol.onClientScheduleStart();
+ else
+ protocol.onServerScheduleStart();
}
}
diff --git a/sources/protocols/VSAbstractProtocol.java b/sources/protocols/VSAbstractProtocol.java
index b726a2e..2c84d96 100644
--- a/sources/protocols/VSAbstractProtocol.java
+++ b/sources/protocols/VSAbstractProtocol.java
@@ -53,8 +53,28 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
*/
public final void onStart() {
if (isClient) {
+ currentContextIsServer = false;
onClientStart();
+ }
+ }
+
+ /**
+ * Runs a client schedule
+ */
+ public final void onClientScheduleStart() {
+ if (isClient) {
currentContextIsServer = false;
+ onClientSchedule();
+ }
+ }
+
+ /**
+ * Runs a server schedule
+ */
+ public final void onServerScheduleStart() {
+ if (isServer) {
+ currentContextIsServer = true;
+ onServerSchedule();
}
}
@@ -79,7 +99,7 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
}
/**
- * Checks if is server.
+ * Sets if is server.
*
* @param isServer the is server
*/
@@ -88,7 +108,16 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
}
/**
- * Checks if is client.
+ * Checks if is server.
+ *
+ * @param isServer the is server
+ */
+ public final boolean isServer() {
+ return isServer;
+ }
+
+ /**
+ * Sets if is client.
*
* @param isClient the is client
*/
@@ -97,6 +126,15 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
}
/**
+ * Checks if is client.
+ *
+ * @param isClient the is client
+ */
+ public final boolean isClient() {
+ return isClient;
+ }
+
+ /**
* Reset.
*/
public void reset() {
@@ -124,6 +162,11 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
abstract protected void onClientReset();
/**
+ * On client schedule.
+ */
+ abstract protected void onClientSchedule();
+
+ /**
* On client recv.
*
* @param message the message
@@ -143,6 +186,11 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent {
abstract protected void onServerRecv(VSMessage message);
/**
+ * On server schedule.
+ */
+ abstract protected void onServerSchedule();
+
+ /**
* Gets the num processes.
*
* @return the num processes
diff --git a/sources/protocols/implementations/BerkelyTimeProtocol.java b/sources/protocols/implementations/BerkelyTimeProtocol.java
index 9a52c4c..635b1cd 100644
--- a/sources/protocols/implementations/BerkelyTimeProtocol.java
+++ b/sources/protocols/implementations/BerkelyTimeProtocol.java
@@ -107,6 +107,12 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
}
+ /* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
/**
* Calculate the new average time.
*
@@ -176,6 +182,12 @@ public class BerkelyTimeProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/BroadcastSturmProtocol.java b/sources/protocols/implementations/BroadcastSturmProtocol.java
index 49e183d..cfd258c 100644
--- a/sources/protocols/implementations/BroadcastSturmProtocol.java
+++ b/sources/protocols/implementations/BroadcastSturmProtocol.java
@@ -59,6 +59,12 @@ public class BroadcastSturmProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -66,6 +72,12 @@ public class BroadcastSturmProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage)
*/
protected void onServerRecv(VSMessage recvMessage) {
diff --git a/sources/protocols/implementations/DummyProtocol.java b/sources/protocols/implementations/DummyProtocol.java
index 929ace4..684de87 100644
--- a/sources/protocols/implementations/DummyProtocol.java
+++ b/sources/protocols/implementations/DummyProtocol.java
@@ -61,6 +61,12 @@ public class DummyProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -75,6 +81,12 @@ public class DummyProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/ExternalTimeSyncProtocol.java b/sources/protocols/implementations/ExternalTimeSyncProtocol.java
index 3430f98..243418a 100644
--- a/sources/protocols/implementations/ExternalTimeSyncProtocol.java
+++ b/sources/protocols/implementations/ExternalTimeSyncProtocol.java
@@ -74,6 +74,12 @@ public class ExternalTimeSyncProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -94,6 +100,12 @@ public class ExternalTimeSyncProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/InternalTimeSyncProtocol.java b/sources/protocols/implementations/InternalTimeSyncProtocol.java
index 5676d58..5b18740 100644
--- a/sources/protocols/implementations/InternalTimeSyncProtocol.java
+++ b/sources/protocols/implementations/InternalTimeSyncProtocol.java
@@ -78,6 +78,12 @@ public class InternalTimeSyncProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -99,6 +105,12 @@ public class InternalTimeSyncProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/OnePhaseCommitProtocol.java b/sources/protocols/implementations/OnePhaseCommitProtocol.java
index 9c40493..c8dd7f2 100644
--- a/sources/protocols/implementations/OnePhaseCommitProtocol.java
+++ b/sources/protocols/implementations/OnePhaseCommitProtocol.java
@@ -65,6 +65,12 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -78,6 +84,12 @@ public class OnePhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/PingPongProtocol.java b/sources/protocols/implementations/PingPongProtocol.java
index 167feb6..4082dd3 100644
--- a/sources/protocols/implementations/PingPongProtocol.java
+++ b/sources/protocols/implementations/PingPongProtocol.java
@@ -66,6 +66,12 @@ public class PingPongProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -88,6 +94,12 @@ public class PingPongProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {
diff --git a/sources/protocols/implementations/TwoPhaseCommitProtocol.java b/sources/protocols/implementations/TwoPhaseCommitProtocol.java
index db0277c..770c9cd 100644
--- a/sources/protocols/implementations/TwoPhaseCommitProtocol.java
+++ b/sources/protocols/implementations/TwoPhaseCommitProtocol.java
@@ -45,6 +45,12 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onClientSchedule()
+ */
+ protected void onClientSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#onServerReset()
*/
protected void onServerReset() {
@@ -57,6 +63,12 @@ public class TwoPhaseCommitProtocol extends VSAbstractProtocol {
}
/* (non-Javadoc)
+ * @see protocols.VSAbstractProtocol#onServerSchedule()
+ */
+ protected void onServerSchedule() {
+ }
+
+ /* (non-Javadoc)
* @see protocols.VSAbstractProtocol#toString()
*/
public String toString() {