2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 Nordix Foundation
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 package org.oransc.policyagent.repository;
23 import org.oransc.policyagent.configuration.RicConfig;
24 import org.oransc.policyagent.repository.Ric.RicState;
27 * Represents the dynamic information about a NearRealtime-RIC.
30 private final RicConfig ricConfig;
31 private RicState state = RicState.NOT_INITIATED;
34 * Creates the Ric. Initial state is {@link RicState.NOT_INITIATED}.
36 * @param ricConfig The {@link RicConfig} for this Ric.
38 public Ric(RicConfig ricConfig) {
39 this.ricConfig = ricConfig;
42 public String name() {
43 return ricConfig.name();
46 public RicState state() {
50 public void setState(RicState newState) {
55 * Determines if the given node is managed by this Ric.
57 * @param nodeName the node name to check.
58 * @return true if the given node is managed by this Ric.
60 public boolean isManaging(String nodeName) {
61 return ricConfig.managedElementIds().contains(nodeName);
65 * Adds the given node as managed by this Ric.
67 * @param nodeName the node to add.
69 public void addManagedNode(String nodeName) {
70 if (!ricConfig.managedElementIds().contains(nodeName)) {
71 ricConfig.managedElementIds().add(nodeName);
76 * Removes the given node as managed by this Ric.
78 * @param nodeName the node to remove.
80 public void removeManagedNode(String nodeName) {
81 ricConfig.managedElementIds().remove(nodeName);
85 * Represents the states possible for a Ric.
87 public static enum RicState {
89 * The Ric has not been initiated yet.
93 * The Ric is working fine.
97 * Something is wrong with the Ric.
101 * The node is unreachable at the moment.