blob: 88c66c5d407cc44188fdd15f51b7d909cfbf50e6 [file] [log] [blame]
Jian Li9e43ec12019-01-21 23:04:23 +09001/*
2 * Copyright 2019-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 stats of Kubernetes node.
20 */
21public enum K8sNodeState {
22
23 /**
24 * Indicates the node is newly added.
25 */
26 INIT {
27 @Override
28 public void process(K8sNodeHandler handler, K8sNode node) {
29 handler.processInitState(node);
30 }
31
32 @Override
33 public K8sNodeState nextState() {
34 return DEVICE_CREATED;
35 }
36 },
37 /**
38 * Indicates bridge devices are added according to the node state.
39 */
40 DEVICE_CREATED {
41 @Override
42 public void process(K8sNodeHandler handler, K8sNode node) {
43 handler.processDeviceCreatedState(node);
44 }
45
46 @Override
47 public K8sNodeState nextState() {
48 return COMPLETE;
49 }
50 },
51 /**
52 * Indicates node initialization is done.
53 */
54 COMPLETE {
55 @Override
56 public void process(K8sNodeHandler handler, K8sNode node) {
57 handler.processCompleteState(node);
58 }
59
60 @Override
61 public K8sNodeState nextState() {
62 return COMPLETE;
63 }
64 },
65 /**
66 * Indicates node is broken.
67 */
68 INCOMPLETE {
69 @Override
70 public void process(K8sNodeHandler handler, K8sNode node) {
71 handler.processIncompleteState(node);
72 }
73
74 @Override
75 public K8sNodeState nextState() {
76 return INIT;
77 }
78 };
79
80 /**
81 * Processes the given node which is under a certain state.
82 *
83 * @param handler kubernetes node handler
84 * @param node kubernetes node
85 */
86 public abstract void process(K8sNodeHandler handler, K8sNode node);
87
88 /**
89 * Transits to the next state.
90 *
91 * @return the next kubernetes node state
92 */
93 public abstract K8sNodeState nextState();
94}