Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.cluster; |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 17 | |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 18 | import org.onlab.packet.IpAddress; |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 19 | |
| 20 | /** |
| 21 | * Represents a controller instance as a member in a cluster. |
| 22 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 23 | public interface ControllerNode { |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 24 | |
| 25 | /** Represents the operational state of the instance. */ |
Sho SHIMIZU | e2952e4 | 2015-09-11 17:11:21 -0700 | [diff] [blame] | 26 | enum State { |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 27 | /** |
Thomas Vachuska | 7a8de84 | 2016-03-07 20:56:35 -0800 | [diff] [blame] | 28 | * Signifies that the instance is active and that all components are |
| 29 | * operating normally. |
| 30 | */ |
| 31 | READY, |
| 32 | |
| 33 | /** |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 34 | * 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 Vachuska | 7a8de84 | 2016-03-07 20:56:35 -0800 | [diff] [blame] | 42 | 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 | } |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Returns the instance identifier. |
| 65 | * |
| 66 | * @return instance identifier |
| 67 | */ |
tom | e472987 | 2014-09-23 00:37:37 -0700 | [diff] [blame] | 68 | NodeId id(); |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Returns the IP address of the controller instance. |
| 72 | * |
| 73 | * @return IP address |
| 74 | */ |
Pavlin Radoslavov | 444b519 | 2014-10-28 10:45:19 -0700 | [diff] [blame] | 75 | IpAddress ip(); |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 76 | |
tom | ee49c37 | 2014-09-26 15:14:50 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Returns the TCP port on which the node listens for connections. |
| 79 | * |
| 80 | * @return TCP port |
| 81 | */ |
| 82 | int tcpPort(); |
| 83 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 84 | } |