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 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 18 | /** |
| 19 | * Represents a controller instance as a member in a cluster. |
| 20 | */ |
Jordan Halterman | 00e92da | 2018-05-22 23:05:52 -0700 | [diff] [blame] | 21 | public interface ControllerNode extends Node { |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 22 | |
| 23 | /** Represents the operational state of the instance. */ |
Sho SHIMIZU | e2952e4 | 2015-09-11 17:11:21 -0700 | [diff] [blame] | 24 | enum State { |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 25 | /** |
Thomas Vachuska | 7a8de84 | 2016-03-07 20:56:35 -0800 | [diff] [blame] | 26 | * Signifies that the instance is active and that all components are |
| 27 | * operating normally. |
| 28 | */ |
| 29 | READY, |
| 30 | |
| 31 | /** |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 32 | * Signifies that the instance is active and operating normally. |
| 33 | */ |
| 34 | ACTIVE, |
| 35 | |
| 36 | /** |
| 37 | * Signifies that the instance is inactive, which means either down or |
| 38 | * up, but not operational. |
| 39 | */ |
Thomas Vachuska | 7a8de84 | 2016-03-07 20:56:35 -0800 | [diff] [blame] | 40 | INACTIVE; |
| 41 | |
| 42 | /** |
| 43 | * Indicates whether the state represents node which is active or ready. |
| 44 | * |
| 45 | * @return true if active or ready |
| 46 | */ |
| 47 | public boolean isActive() { |
| 48 | return this == ACTIVE || this == READY; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Indicates whether the state represents a node which is ready. |
| 53 | * |
| 54 | * @return true if active and ready |
| 55 | */ |
| 56 | public boolean isReady() { |
| 57 | return this == READY; |
| 58 | } |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 59 | } |
| 60 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 61 | } |