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 | |
| 20 | /** |
| 21 | * Abstraction for executing the stages of the upgrade process. |
| 22 | * <p> |
| 23 | * Upgrades are performed in three phases: |
| 24 | * <ul> |
| 25 | * <li>{@code initialize} - Initializes an upgrade</li> |
| 26 | * <li>{@code upgrade} - Performs an upgrade, transferring device mastership from the current version to the |
| 27 | * upgraded version</li> |
| 28 | * <li>{@code commit} or {@code rollback} - Completes or rolls back an upgrade, transferring mastership back |
| 29 | * to nodes running the previous version</li> |
| 30 | * </ul> |
| 31 | */ |
| 32 | @Beta |
| 33 | public interface UpgradeAdminService { |
| 34 | |
| 35 | /** |
| 36 | * Initializes an upgrade. |
| 37 | * <p> |
| 38 | * This method must be called to initialize an upgrade and prior to physically upgrading any nodes. |
| 39 | * |
| 40 | * @throws IllegalStateException if an upgrade is already in progress |
| 41 | */ |
| 42 | void initialize(); |
| 43 | |
| 44 | /** |
| 45 | * Performs an upgrade, transferring device mastership to upgraded nodes. |
| 46 | * <p> |
| 47 | * This method transfers mastership from the current version of the software to the upgraded version. Thus, |
| 48 | * a subset of the nodes in the cluster must have been physically upgraded and restarted prior to executing this |
| 49 | * phase of the upgrade protocol. |
| 50 | * |
| 51 | * @throws IllegalStateException if no upgrade has been initialized |
| 52 | */ |
| 53 | void upgrade(); |
| 54 | |
| 55 | /** |
| 56 | * Commits an upgrade. |
| 57 | * <p> |
| 58 | * Completes the upgrade process, committing the new cluster version. |
| 59 | * |
| 60 | * @throws IllegalStateException if no upgrade is in progress or not all nodes have been upgraded |
| 61 | */ |
| 62 | void commit(); |
| 63 | |
| 64 | /** |
| 65 | * Rolls back an upgrade. |
| 66 | * <p> |
| 67 | * When an upgrade is rolled back, mastership is transferred from upgraded nodes back to nodes running the |
| 68 | * version of the software prior to the upgrade. |
| 69 | * |
| 70 | * @throws IllegalStateException if no upgrade is in progress |
| 71 | */ |
| 72 | void rollback(); |
| 73 | |
| 74 | /** |
| 75 | * Resets an upgrade. |
| 76 | * <p> |
| 77 | * When an upgrade is rolled back, once nodes have been restored to the previos version the upgrade must be reset |
| 78 | * to restore the upgrade state to {@link Upgrade.Status#INACTIVE}. |
| 79 | * |
| 80 | * @throws IllegalStateException if nodes have not been restored to the previous state |
| 81 | */ |
| 82 | void reset(); |
| 83 | |
| 84 | } |