diff options
| author | Paul Buetow <paul@buetow.org> | 2008-08-04 20:44:54 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-08-04 20:44:54 +0000 |
| commit | 8ae434c63e6382a8cb850551d947285f5fcb3c25 (patch) | |
| tree | 751b0b24cd86768d57e9338cf0718485f68a095e /sources/protocols/implementations | |
| parent | bb4eb6634485d05e9e8cff6497c60ef696a28eeb (diff) | |
restructured stuff
Diffstat (limited to 'sources/protocols/implementations')
4 files changed, 142 insertions, 13 deletions
diff --git a/sources/protocols/implementations/VSBerkelyTimeProtocol.java b/sources/protocols/implementations/VSBerkelyTimeProtocol.java index f432a1f..382a470 100644 --- a/sources/protocols/implementations/VSBerkelyTimeProtocol.java +++ b/sources/protocols/implementations/VSBerkelyTimeProtocol.java @@ -80,7 +80,7 @@ public class VSBerkelyTimeProtocol extends VSAbstractProtocol { * @see protocols.VSAbstractProtocol#onServerReset() */ public void onServerReset() { - //System.out.println("FOOBAR"); + //System.out.println("FOOBAR"); processTimes.clear(); recvTimes.clear(); realTimesRTT.clear(); @@ -91,7 +91,7 @@ public class VSBerkelyTimeProtocol extends VSAbstractProtocol { * @see protocols.VSAbstractProtocol#onServerStart() */ public void onServerStart() { - //System.out.println("FOO"); + //System.out.println("FOO"); peers.addAll(getVector("pids")); requestTime = process.getTime(); VSMessage message = new VSMessage(); diff --git a/sources/protocols/implementations/VSBroadcastProtocol.java b/sources/protocols/implementations/VSBroadcastProtocol.java new file mode 100644 index 0000000..0ae8fae --- /dev/null +++ b/sources/protocols/implementations/VSBroadcastProtocol.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * All icons of the icons/ folder are under a Creative Commons + * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. + * + * The icon's homepage is http://code.google.com/p/ultimate-gnome/ + */ + +package protocols.implementations; + +import java.util.ArrayList; + +import core.VSMessage; +import protocols.VSAbstractProtocol; + +/** + * The class VSBroadcastProtocol, an implementation of the broadcast + * sturm protocol. + * + * @author Paul C. Buetow + */ +public class VSBroadcastProtocol extends VSAbstractProtocol { + /** The serial version uid */ + private static final long serialVersionUID = 1L; + + /** The sent messages. */ + private ArrayList<Integer> sentMessages; + + /** The broadcast count. */ + private static int broadcastCount; + + /** + * Instantiates a new broadcast sturm protocol. + */ + public VSBroadcastProtocol() { + super(VSAbstractProtocol.HAS_ON_CLIENT_START); + setClassname(getClass().toString()); + sentMessages = new ArrayList<Integer>(); + } + + /* (non-Javadoc) + * @see events.VSAbstractProtocol#onClientInit() + */ + public void onClientInit() { + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onClientReset() + */ + public void onClientReset() { + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onClientStart() + */ + public void onClientStart() { + VSMessage message = new VSMessage(); + message.setInteger("Broadcast", broadcastCount++); + sentMessages.add(message.getIntegerObj("Broadcast")); + sendMessage(message); + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onClientRecv(core.VSMessage) + */ + public void onClientRecv(VSMessage recvMessage) { + onServerRecv(recvMessage); + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onClientSchedule() + */ + public void onClientSchedule() { + } + + /* (non-Javadoc) + * @see events.VSAbstractProtocol#onServerInit() + */ + public void onServerInit() { + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onServerReset() + */ + public void onServerReset() { + sentMessages.clear(); + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onServerSchedule() + */ + public void onServerSchedule() { + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#onServerRecv(core.VSMessage) + */ + public void onServerRecv(VSMessage recvMessage) { + if (!sentMessages.contains(recvMessage.getIntegerObj("Broadcast"))) { + VSMessage message = new VSMessage(); + message.setInteger("Broadcast", + recvMessage.getInteger("Broadcast")); + sentMessages.add(message.getIntegerObj("Broadcast")); + sendMessage(message); + } + } + + /* (non-Javadoc) + * @see protocols.VSAbstractProtocol#toString() + */ + public String toString() { + return super.toString(); + } +} diff --git a/sources/protocols/implementations/VSOnePhaseCommitProtocol.java b/sources/protocols/implementations/VSOnePhaseCommitProtocol.java index 3c4e20e..0581b74 100644 --- a/sources/protocols/implementations/VSOnePhaseCommitProtocol.java +++ b/sources/protocols/implementations/VSOnePhaseCommitProtocol.java @@ -116,7 +116,7 @@ public class VSOnePhaseCommitProtocol extends VSAbstractProtocol { /* Remove the active schedule which has been created in the onServerStart method */ removeSchedules(); - } + } } } diff --git a/sources/protocols/implementations/VSReliableMulticastProtocol.java b/sources/protocols/implementations/VSReliableMulticastProtocol.java index 8a605fd..b876295 100644 --- a/sources/protocols/implementations/VSReliableMulticastProtocol.java +++ b/sources/protocols/implementations/VSReliableMulticastProtocol.java @@ -89,7 +89,7 @@ public class VSReliableMulticastProtocol extends VSAbstractProtocol { VSMessage message = new VSMessage(); message.setBoolean("isMulticast", true); sendMessage(message); - } + } } /* (non-Javadoc) @@ -124,8 +124,8 @@ public class VSReliableMulticastProtocol extends VSAbstractProtocol { onClientStart(); } - /** True if ACK has been sent already */ - private boolean ackSent; + /** True if ACK has been sent already */ + private boolean ackSent; /* (non-Javadoc) * @see events.VSAbstractProtocol#onServerInit() @@ -137,7 +137,7 @@ public class VSReliableMulticastProtocol extends VSAbstractProtocol { * @see protocols.VSAbstractProtocol#onServerReset() */ public void onServerReset() { - ackSent = false; + ackSent = false; } /* (non-Javadoc) @@ -150,13 +150,13 @@ public class VSReliableMulticastProtocol extends VSAbstractProtocol { message.setInteger("pid", process.getProcessID()); sendMessage(message); - if (ackSent) { - logg("ACK erneut versendet"); + if (ackSent) { + logg("ACK erneut versendet"); - } else { - logg("ACK versendet"); - ackSent = true; - } + } else { + logg("ACK versendet"); + ackSent = true; + } } } |
