diff options
Diffstat (limited to 'VS-Sim-Sources')
76 files changed, 15972 insertions, 0 deletions
diff --git a/VS-Sim-Sources/LICENSE b/VS-Sim-Sources/LICENSE new file mode 100644 index 0000000..207233e --- /dev/null +++ b/VS-Sim-Sources/LICENSE @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2008 Paul 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/ + */ diff --git a/VS-Sim-Sources/build.xml b/VS-Sim-Sources/build.xml new file mode 100644 index 0000000..6487c16 --- /dev/null +++ b/VS-Sim-Sources/build.xml @@ -0,0 +1,65 @@ +<project name="Verteilte Systeme" default="dist" basedir="."> + <description>This is the distributed systems simulation/learning environment!</description> + + <!-- set global properties for this build --> + <property name="sources" location="sources" /> + <property name="dist" location="dist" /> + <property name="classes" location="classes" /> + + <target name="init"> + <tstamp /> + <mkdir dir="${classes}" /> + </target> + + <target name="compile" depends="init" description="compile the source" > + <javac srcdir="${sources}" destdir="${classes}"> + <compilerarg value="-Xlint:deprecation,unchecked" /> + </javac> + <copy todir="${classes}/icons"> + <fileset dir="icons" /> + </copy> + </target> + + <target name="dist" depends="compile" description="generate the distribution" > + <delete file="MANIFEST.MF" /> + + <manifest file="MANIFEST.MF"> + <attribute name="Built-By" value="Paul C. Buetow" /> + <attribute name="Main-Class" value="simulator/VSMain" /> + </manifest> + + <mkdir dir="${dist}/lib" /> + <jar jarfile="${dist}/lib/VS-Sim-${DSTAMP}.jar" basedir="${classes}" manifest="MANIFEST.MF" /> + <copy file="${dist}/lib/VS-Sim-${DSTAMP}.jar" tofile="${dist}/lib/VS-Sim-Latest.jar" /> + </target> + + <target name="clean" description="clean up" > + <delete dir="${basedir}/javadoc/" /> + <delete dir="${classes}" /> + <delete dir="${dist}" /> + <delete file="MANIFEST.MF" /> + </target> + + <target name="rundist" depends="dist"> + <java jar="${dist}/lib/VS-Sim-Latest.jar" fork="true" /> + </target> + + <target name="run" depends="compile"> + <java dir="${classes}" classname="simulator.VSMain" fork="true" /> + </target> + + <target name="testdist" depends="dist,rundist" /> + + <target name="test" depends="compile"> + <java dir="${classes}" classname="simulator.VSMain" fork="true"> + <!-- <arg value="-debug" /> --> + </java> + </target> + + <target name="javadoc" description="Generate Javadocs"> + <mkdir dir="${basedir}/javadoc/"/> + <javadoc destdir="${basedir}/javadoc/"> + <fileset dir="${basedir}/" includes="**/*.java" /> + </javadoc> + </target> +</project> diff --git a/VS-Sim-Sources/docs/SERIALIZATION_NOTES.txt b/VS-Sim-Sources/docs/SERIALIZATION_NOTES.txt new file mode 100644 index 0000000..44ad0a4 --- /dev/null +++ b/VS-Sim-Sources/docs/SERIALIZATION_NOTES.txt @@ -0,0 +1,40 @@ +VSSerialize + prefs(=VSPrefs).serialize + writeObject(...) + simulator(=VSSimulator).serialize + simulatorCanvas(=VSSimulatorCanvas).serialize + writeObject(numProcesses) + for (porcess : processes) process(=VSProcess).serialize { + super(=VSPrefs).serialize + writeObject(processID) + writeObject(numProtocolsToReset) + for (protocol : protocolsToReset) { + writeObject(protocolClassname) + protocol(=VSAbstractProtocol).serialize + super(=VSAbstractEvent).serialize + super(=VSPrefs).serialize + s.o. + writeObject(id) + writeObject(eventShortname) + writeObject(eventClassname) + writeObject(hasOnServerStart) + } + } + taskManager(=VSTaskManager).serialize + writeObject(numTasks) + for (task : tasks) task(=VSTask).serialize + writeObject(eventClassname) + event(=VSAbstractEvent).serialize + s.o. + writeObject(eventID) + writeObject(processNum) + writeObject(taskNum) + writeObject(taskTime) + writeObject(isGlobalTimed) + writeObject(isProgrammed) + +VSProtocolEvent.serialize + super(=VSAbstractEvent).serialize + writeObject(protocolClassname) + writeObject(isClientProtocol) + writeObject(isProtocolActivation) diff --git a/VS-Sim-Sources/icons/pause.png b/VS-Sim-Sources/icons/pause.png Binary files differnew file mode 100644 index 0000000..7976413 --- /dev/null +++ b/VS-Sim-Sources/icons/pause.png diff --git a/VS-Sim-Sources/icons/replay.png b/VS-Sim-Sources/icons/replay.png Binary files differnew file mode 100644 index 0000000..416a3b3 --- /dev/null +++ b/VS-Sim-Sources/icons/replay.png diff --git a/VS-Sim-Sources/icons/reset.png b/VS-Sim-Sources/icons/reset.png Binary files differnew file mode 100644 index 0000000..bca89e3 --- /dev/null +++ b/VS-Sim-Sources/icons/reset.png diff --git a/VS-Sim-Sources/icons/start.png b/VS-Sim-Sources/icons/start.png Binary files differnew file mode 100644 index 0000000..63f6798 --- /dev/null +++ b/VS-Sim-Sources/icons/start.png diff --git a/VS-Sim-Sources/scripts/beforecommit.sh b/VS-Sim-Sources/scripts/beforecommit.sh new file mode 100755 index 0000000..a06ee8f --- /dev/null +++ b/VS-Sim-Sources/scripts/beforecommit.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 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. + +./scripts/formatthecode.sh +./scripts/checklinelengths.sh + diff --git a/VS-Sim-Sources/scripts/checklinelengths.sh b/VS-Sim-Sources/scripts/checklinelengths.sh new file mode 100755 index 0000000..cf98cd8 --- /dev/null +++ b/VS-Sim-Sources/scripts/checklinelengths.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# +# 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. + +MAXLEN=80 + +for i in `find ./sources -name \*.java | grep -v VSDefaultPrefs.java` +do + awk -v MAXLEN=$MAXLEN -v file=$i '{ + if (length > MAXLEN) + print file " line " NR " is " length " chars long " + }' $i +done diff --git a/VS-Sim-Sources/scripts/formatthecode.sh b/VS-Sim-Sources/scripts/formatthecode.sh new file mode 100755 index 0000000..5733c31 --- /dev/null +++ b/VS-Sim-Sources/scripts/formatthecode.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# +# 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. + +find ./sources -name \*.java | xargs astyle --style=java --mode=java -n diff --git a/VS-Sim-Sources/scripts/pdf2txtrmcr.pl b/VS-Sim-Sources/scripts/pdf2txtrmcr.pl new file mode 100644 index 0000000..5ffb05d --- /dev/null +++ b/VS-Sim-Sources/scripts/pdf2txtrmcr.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +for (<DATA>) { + chomp if /[a-z]/; + print; +} + +__DATA__ + diff --git a/VS-Sim-Sources/scripts/printstatistics.sh b/VS-Sim-Sources/scripts/printstatistics.sh new file mode 100755 index 0000000..614d36e --- /dev/null +++ b/VS-Sim-Sources/scripts/printstatistics.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 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. + +find ./sources -name \*.java | xargs wc -l +echo "Num .java files:" +find ./sources -name \*.java | wc -l diff --git a/VS-Sim-Sources/scripts/replaceastring.sh b/VS-Sim-Sources/scripts/replaceastring.sh new file mode 100755 index 0000000..6b50b83 --- /dev/null +++ b/VS-Sim-Sources/scripts/replaceastring.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# 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. + +FROM=$1 +INTO=$2 + +echo "Replaceing $FROM with $INTO" + +find ./sources -name \*.java -exec sh -c "sed -n 's/$FROM/$INTO/g; \ + w .tmp' {} && mv -f .tmp {}" \; diff --git a/VS-Sim-Sources/sources/core/VSAbstractProcess.java b/VS-Sim-Sources/sources/core/VSAbstractProcess.java new file mode 100644 index 0000000..c46194f --- /dev/null +++ b/VS-Sim-Sources/sources/core/VSAbstractProcess.java @@ -0,0 +1,753 @@ +/* + * 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 core; + +import java.awt.*; +import java.io.*; +import java.util.*; + +import core.time.*; +//import events.*; +//import events.implementations.*; +import prefs.*; +import protocols.*; +import serialize.*; +import simulator.*; +import utils.*; + +/** + * The class VSAbstractProcess, an object of this class represents a process + * of a simulator. + * + * @author Paul C. Buetow + */ +public abstract class VSAbstractProcess extends VSSerializablePrefs + implements VSSerializable { + /** The data serialization id. */ + protected static final long serialVersionUID = 1L; + + /** The protocols to reset if the simulator is over or the reset + * button has been pressed. + */ + protected ArrayList<VSAbstractProtocol> protocolsToReset; + + /** The crash history. represents all crashes of the process using the + * global simulator time. + */ + protected ArrayList<Long> crashHistory; + + /** The lamport time history. */ + protected ArrayList<VSLamportTime> lamportTimeHistory; + + /** The vector time history. */ + protected ArrayList<VSVectorTime> vectorTimeHistory; + + /** The color used if the process has crashed. */ + protected Color crashedColor;; + + /** The process' current color. */ + protected Color currentColor; + + /** A temp. color. For internal usage. */ + protected Color tmpColor; + + /** The loging object. */ + protected VSLogging loging; + + /** The simulator's default prefs. */ + protected VSPrefs prefs; + + /** The random generator of the process. */ + protected VSRandom random; + + /** The simulator canvas. */ + protected VSSimulatorVisualization simulatorVisualization; + + /** The random crash task. May be null if there is no such random task. */ + protected VSTask randomCrashTask; + + /** The vector time. */ + protected VSVectorTime vectorTime; + + /** The tasks of the process. DO ONLY MANIPULATE THIS OBJECT WITHIN THE + * VSTaskManager CLASS! OTHERWISE THE SYNCHRONIZATION IS WRONG! Use the + * VSAbstractProcess.getTasks() method to get a reference to this object + * within the VSTaskManager! */ + protected VSPriorityQueue<VSTask> tasks; + + /** The process has crashed. But may be working again. */ + protected boolean hasCrashed; + + /** The process has started. But may be paused or crashed.. */ + protected boolean hasStarted; + + /** The process is crashed. */ + protected boolean isCrashed; + + /** The process is highlighted. */ + protected boolean isHighlighted; + + /** The process is paused. */ + protected boolean isPaused; + + /** The time has been modified in a task |
