blob: 2c33c992491bcd2738c4fa793105004d8f5ace66 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.cluster;
tom73d6d1e2014-09-17 20:08:01 -070017
Pavlin Radoslavov444b5192014-10-28 10:45:19 -070018import org.onlab.packet.IpAddress;
tom73d6d1e2014-09-17 20:08:01 -070019
20/**
21 * Represents a controller instance as a member in a cluster.
22 */
tome4729872014-09-23 00:37:37 -070023public interface ControllerNode {
tom73d6d1e2014-09-17 20:08:01 -070024
25 /** Represents the operational state of the instance. */
Sho SHIMIZUe2952e42015-09-11 17:11:21 -070026 enum State {
tom73d6d1e2014-09-17 20:08:01 -070027 /**
Thomas Vachuska7a8de842016-03-07 20:56:35 -080028 * Signifies that the instance is active and that all components are
29 * operating normally.
30 */
31 READY,
32
33 /**
tom73d6d1e2014-09-17 20:08:01 -070034 * Signifies that the instance is active and operating normally.
35 */
36 ACTIVE,
37
38 /**
39 * Signifies that the instance is inactive, which means either down or
40 * up, but not operational.
41 */
Thomas Vachuska7a8de842016-03-07 20:56:35 -080042 INACTIVE;
43
44 /**
45 * Indicates whether the state represents node which is active or ready.
46 *
47 * @return true if active or ready
48 */
49 public boolean isActive() {
50 return this == ACTIVE || this == READY;
51 }
52
53 /**
54 * Indicates whether the state represents a node which is ready.
55 *
56 * @return true if active and ready
57 */
58 public boolean isReady() {
59 return this == READY;
60 }
tom73d6d1e2014-09-17 20:08:01 -070061 }
62
63 /**
64 * Returns the instance identifier.
65 *
66 * @return instance identifier
67 */
tome4729872014-09-23 00:37:37 -070068 NodeId id();
tom73d6d1e2014-09-17 20:08:01 -070069
70 /**
71 * Returns the IP address of the controller instance.
72 *
73 * @return IP address
74 */
Pavlin Radoslavov444b5192014-10-28 10:45:19 -070075 IpAddress ip();
tom73d6d1e2014-09-17 20:08:01 -070076
tomee49c372014-09-26 15:14:50 -070077
78 /**
79 * Returns the TCP port on which the node listens for connections.
80 *
81 * @return TCP port
82 */
83 int tcpPort();
84
tom73d6d1e2014-09-17 20:08:01 -070085}