Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | */ |
| 16 | package org.onosproject.upgrade; |
| 17 | |
| 18 | import com.google.common.annotations.Beta; |
| 19 | import org.onosproject.core.Version; |
| 20 | import org.onosproject.event.ListenerService; |
| 21 | |
| 22 | /** |
| 23 | * Upgrade service. |
| 24 | */ |
| 25 | @Beta |
| 26 | public interface UpgradeService |
| 27 | extends ListenerService<UpgradeEvent, UpgradeEventListener> { |
| 28 | |
| 29 | /** |
slowr | 0a44fde | 2017-10-09 14:48:53 -0700 | [diff] [blame] | 30 | * Returns the current upgrade state. |
| 31 | * |
| 32 | * @return the current upgrade state |
| 33 | */ |
| 34 | Upgrade getState(); |
| 35 | |
| 36 | /** |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 37 | * Returns whether an upgrade is in progress. |
| 38 | * <p> |
| 39 | * An upgrade is in progress if the upgrade {@link Upgrade.Status} is active, e.g. |
| 40 | * {@link Upgrade.Status#INITIALIZED}, {@link Upgrade.Status#UPGRADED}, etc. |
| 41 | * |
| 42 | * @return indicates whether an upgrade is in progress |
| 43 | */ |
| 44 | boolean isUpgrading(); |
| 45 | |
| 46 | /** |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 47 | * Returns the currently active software version. |
| 48 | * <p> |
| 49 | * The returned version is representative of the version currently in control of the network. When the upgrade |
| 50 | * transitions to the {@link Upgrade.Status#UPGRADING} state, control over the network is transferred from |
| 51 | * {@link Upgrade#source()} nodes to {@link Upgrade#target()} nodes, and the version returned by this method |
| 52 | * represents that change. |
| 53 | * |
| 54 | * @return the software version |
| 55 | */ |
| 56 | Version getVersion(); |
| 57 | |
| 58 | /** |
| 59 | * Returns whether the local node is active. |
| 60 | * <p> |
| 61 | * The local node will be active if its {@link Version} matches the version returned by {@link #getVersion()}. |
| 62 | * |
| 63 | * @return indicates whether the local node is active according to its version |
| 64 | */ |
| 65 | boolean isLocalActive(); |
| 66 | |
| 67 | /** |
| 68 | * Returns whether the local node is an upgraded node. |
| 69 | * |
| 70 | * @return {@code true} if the local node's version matches {@link Upgrade#target()} |
| 71 | */ |
| 72 | boolean isLocalUpgraded(); |
| 73 | |
| 74 | } |