package org.oransc.policyagent.repository;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Vector;
+
import lombok.Getter;
import lombok.Setter;
+
import org.oransc.policyagent.clients.A1Client.A1ProtocolType;
import org.oransc.policyagent.configuration.RicConfig;
* Represents the dynamic information about a NearRealtime-RIC.
*/
public class Ric {
- private final RicConfig ricConfig;
- private final List<String> managedElementIds;
- private RicState state = RicState.UNDEFINED;
+ @Setter
+ private RicConfig ricConfig;
+ private RicState state = RicState.UNAVAILABLE;
private Map<String, PolicyType> supportedPolicyTypes = new HashMap<>();
@Getter
@Setter
private A1ProtocolType protocolVersion = A1ProtocolType.UNKNOWN;
+ @Getter
+ private final Lock lock = new Lock();
/**
- * Creates the Ric. Initial state is {@link RicState.NOT_INITIATED}.
+ * Creates the Ric. Initial state is {@link RicState.UNDEFINED}.
*
* @param ricConfig The {@link RicConfig} for this Ric.
*/
public Ric(RicConfig ricConfig) {
this.ricConfig = ricConfig;
- this.managedElementIds = new ArrayList<>(ricConfig.managedElementIds());
}
public String name() {
* @return a vector containing the nodes managed by this Ric.
*/
public synchronized Collection<String> getManagedElementIds() {
- return managedElementIds;
+ return ricConfig.managedElementIds();
}
/**
* @return true if the given node is managed by this Ric.
*/
public synchronized boolean isManaging(String managedElementId) {
- return managedElementIds.contains(managedElementId);
- }
-
- /**
- * Adds the given node as managed by this Ric.
- *
- * @param managedElementId the node to add.
- */
- public synchronized void addManagedElement(String managedElementId) {
- if (!managedElementIds.contains(managedElementId)) {
- managedElementIds.add(managedElementId);
- }
- }
-
- /**
- * Removes the given node as managed by this Ric.
- *
- * @param managedElementId the node to remove.
- */
- public synchronized void removeManagedElement(String managedElementId) {
- managedElementIds.remove(managedElementId);
+ return ricConfig.managedElementIds().contains(managedElementId);
}
/**
@Override
public synchronized String toString() {
return Ric.class.getSimpleName() + ": " + "name: " + name() + ", state: " + state + ", baseUrl: "
- + ricConfig.baseUrl() + ", managedNodes: " + managedElementIds;
+ + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
}
/**
*/
public enum RicState {
/**
- * The agent view of the agent may be inconsistent.
+ * The agent view of the Ric may be inconsistent.
*/
- UNDEFINED,
+ UNAVAILABLE,
/**
* The normal state. Policies can be configured.
*/
- IDLE,
+ AVAILABLE,
/**
- * The Ric states are recovered.
+ * The agent is synchronizing the view of the Ric.
*/
- RECOVERING
+ SYNCHRONIZING
}
}