Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 109 lines (87 sloc) 3.181 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (*
19 @author Adam Koprowski
20 **)
21
22 (**
23 * This module introduces a notion of a cluster. A cluster is a bunch
24 * of servers, where each server is uniquely identified.
25 * ClusterComm module builds on that and provides primitives for
26 * communication within a cluster.
27 *)
28
29 (**
30 * A unique identification of a server. All operations where a server
31 * needs to be identified use this type.
32 *)
33 (* FIXME, include cluster footprint in [node_id], so that it cannot be
34 * mixed up with sids from other clusters? *)
35 type node_id
36
37 (**
38 * A total order on machine identifiers
39 *)
40 module NodeOrder : (Abstr.SafeOrderedType with type t = node_id)
41
42 module NodeSet : (BaseSetSig.S with type elt = node_id)
43 type nodeset = NodeSet.t
44
45 module NodeMap : (BaseMapSig.S with type key = node_id)
46 type 'a nodemap = 'a NodeMap.t
47
48 (**
49 * A type of a cluster (i.e. a collection of servers)
50 *)
51 type t
52
53 type addr = Unix.sockaddr
54
55 (**
56 * Initializes a cluster. Takes an address of the machine running
57 * this function and of all the other machines in the cluster.
58 *
59 * WARNING: all the machines in a cluster must run this function
60 * consistently (i.e. with the same group of addresses), which then
61 * ensures that the process identifiers will be unique and correct.
62 *)
63 (* FIXME, This of course is no good, big time. In the future we want
64 a less painful way to set-up a cluster & in the long run,
65 we want a cluster with re-configuration capabilities. *)
66 val init : ?me:addr -> addr list -> t
67
68 (**
69 * Returns the [node_id] of the server it is run on.
70 *)
71 exception MeUnknown
72 val me : t -> node_id
73
74 (**
75 * Gives the [node_id]s of all the servers in the cluster
76 *)
77 val all_server_ids : ?including_myself:bool -> t -> node_id list
78
79 (**
80 * Gives a sid of a random server from the cluster.
81 *)
82 val random_server_id : ?including_myself:bool -> t -> node_id
83
84 val get_addr : t -> node_id -> addr
85
86 val get_id : t -> addr -> node_id
87
88 (**
89 * Gives the number of servers in the cluster
90 * [servers_no () = List.length (all_servers ())], but may be
91 * more efficient
92 *)
93 val servers_no : ?including_myself:bool -> t -> int
94
95 (**
96 * Converts [node_id] to integer... Paxos presentation assumes that [node_id]s
97 * from a cluster are mapped to ints: 0..n-1 where [n] is the size of the cluster.
98 *)
99 val node_id_to_int : node_id -> int
100
101 (**
102 * Mainly for debugging.
103 * Converts a [node_id] to a human-readable string, with server name and port.
104 *)
105 val node_id_to_string : t -> node_id -> string
106 val node_id_to_debug_string : node_id -> string
107
108 val label : t -> string
Something went wrong with that request. Please try again.