Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / peersim / core / Fallible.java
diff --git a/contrib/psg/src/peersim/core/Fallible.java b/contrib/psg/src/peersim/core/Fallible.java
new file mode 100644 (file)
index 0000000..089cffe
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2003-2005 The BISON Project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+               
+package peersim.core;
+
+
+/**
+* Instances of classes implementing this interface
+* maintain a fail state, i.e. information about the availability
+* of the object.
+*/
+public interface Fallible {
+
+       /**
+       * Fail state which indicates that the object is operating normally.
+       */
+       public int OK = 0;
+
+       /**
+       * Fail state indicating that the object is dead and recovery is
+       * not possible. When this state is set, it is a good idea to make sure
+       * that the state of the object becomes such that any attempt to
+       * operate on it causes a visible error of some kind.
+       */
+       public int DEAD = 1;
+
+       /**
+       * Fail state indicating that the object is not dead, but is temporarily
+       * not accessible.
+       */
+       public int DOWN = 2;
+
+       /**
+       * Returns the state of this object. Must be one of the constants
+       * defined in interface {@link Fallible}.
+       */
+       public int getFailState();
+       
+       /**
+       * Sets the fails state of this object. Parameter must be one of the
+       * constants defined in interface {@link Fallible}.
+       */
+       public void setFailState(int failState);
+
+       /**
+       * Convenience method to check if the node is up and running
+       * @return must return true if and only if
+       * <code>getFailState()==OK</code>
+       */
+       public boolean isUp();
+}
+
+