blob: f9a07c35488f45101ac7b2231f6297969b41c659 [file] [log] [blame]
Jian Li58b33982020-07-01 19:07:02 +09001/*
2 * Copyright 2020-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 */
16package org.onosproject.k8snode.api;
17
18/**
19 * Defines the initialization state of Kubernetes host.
20 */
21public enum K8sHostState {
22
23 /**
24 * Indicates the host is newly added.
25 */
26 INIT {
27 @Override
28 public void process(K8sHostHandler handler, K8sHost host) {
29 handler.processInitState(host);
30 }
31
32 @Override
33 public K8sHostState nextState() {
34 return COMPLETE;
35 }
36 },
37 /**
38 * Indicates the host initialization is done.
39 */
40 COMPLETE {
41 @Override
42 public void process(K8sHostHandler handler, K8sHost host) {
43 handler.processCompleteState(host);
44 }
45
46 @Override
47 public K8sHostState nextState() {
48 return COMPLETE;
49 }
50 },
51 /**
52 * Indicates host is broken.
53 */
54 INCOMPLETE {
55 @Override
56 public void process(K8sHostHandler handler, K8sHost host) {
57 handler.processIncompleteState(host);
58 }
59
60 @Override
61 public K8sHostState nextState() {
62 return INIT;
63 }
64 };
65
66 /**
67 * Processes the given host which is under a certain state.
68 *
69 * @param handler kubernetes host handler
70 * @param host kubernetes host
71 */
72 public abstract void process(K8sHostHandler handler, K8sHost host);
73
74 /**
75 * Transits to the next state.
76 *
77 * @return the next kubernetes host state
78 */
79 public abstract K8sHostState nextState();
80}