Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
peersimgrid release 1.0
[simgrid.git] / contrib / psg / src / peersim / core / Fallible.java
1 /*
2  * Copyright (c) 2003-2005 The BISON Project
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  */
18                 
19 package peersim.core;
20
21
22 /**
23 * Instances of classes implementing this interface
24 * maintain a fail state, i.e. information about the availability
25 * of the object.
26 */
27 public interface Fallible {
28  
29
30         /**
31         * Fail state which indicates that the object is operating normally.
32         */
33         public int OK = 0;
34
35         /**
36         * Fail state indicating that the object is dead and recovery is
37         * not possible. When this state is set, it is a good idea to make sure
38         * that the state of the object becomes such that any attempt to
39         * operate on it causes a visible error of some kind.
40         */
41         public int DEAD = 1;
42
43         /**
44         * Fail state indicating that the object is not dead, but is temporarily
45         * not accessible.
46         */
47         public int DOWN = 2;
48
49         /**
50         * Returns the state of this object. Must be one of the constants
51         * defined in interface {@link Fallible}.
52         */
53         public int getFailState();
54         
55         /**
56         * Sets the fails state of this object. Parameter must be one of the
57         * constants defined in interface {@link Fallible}.
58         */
59         public void setFailState(int failState);
60
61         /**
62         * Convenience method to check if the node is up and running
63         * @return must return true if and only if
64         * <code>getFailState()==OK</code>
65         */
66         public boolean isUp();
67 }
68
69