2 * Copyright (c) 2003-2005 The BISON Project
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.
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.
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.
22 * A protocol that does nothing but knows everything.
23 * It provides an interface which models a protocol that knows all nodes
24 * in the network, i.e. the neighborhood set of this protocol is always the
25 * whole node set. this protocol is also extremely cheap, in fact it
28 public final class OracleIdleProtocol implements Protocol, Linkable {
30 // =================== initialization, creation ======================
31 // ===================================================================
35 public OracleIdleProtocol(String prefix) {}
37 // --------------------------------------------------------------------
39 /** Returns <tt>this</tt> to maximize memory saving. It contains no fields.*/
40 public Object clone() { return this; }
43 // ===================== public methods ===============================
44 // ====================================================================
47 /** This is an expensive operation, should not be used at all.
48 * It returns false only if the given node is not in the current network.
50 public boolean contains(Node n) {
52 final int len = Network.size();
53 for (int i=0; i < len; i++)
55 if (Network.node[i] == n)
61 // --------------------------------------------------------------------
63 /** Unsupported operation */
64 public boolean addNeighbor(Node n) {
66 throw new UnsupportedOperationException();
69 // --------------------------------------------------------------------
72 * The neighborhood contains the node itself, ie it contains the loop
75 public Node getNeighbor(int i) {
77 return Network.node[i];
80 // --------------------------------------------------------------------
84 return Network.size();
87 // --------------------------------------------------------------------
91 // --------------------------------------------------------------------
93 public void onKill() {}
95 // --------------------------------------------------------------------
97 public String toString() {
99 return degree()+" [all the nodes of the overlay network]";