X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Frepository%2FRic.java;h=0242b90f841d7769320ead45d6e891b410186261;hb=6a5e9e710f27997073db0c78b574681aa18189aa;hp=505fce9e9665ac3d744e0686d825eca19f2351e5;hpb=1722366b9678eb50753db8c020c230afe25cd1f8;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java index 505fce9e..0242b90f 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/Ric.java @@ -20,14 +20,14 @@ 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; @@ -35,24 +35,25 @@ import org.oransc.policyagent.configuration.RicConfig; * Represents the dynamic information about a NearRealtime-RIC. */ public class Ric { - private final RicConfig ricConfig; - private final List managedElementIds; + @Setter + private RicConfig ricConfig; private RicState state = RicState.UNDEFINED; private Map 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() { @@ -77,7 +78,7 @@ public class Ric { * @return a vector containing the nodes managed by this Ric. */ public synchronized Collection getManagedElementIds() { - return managedElementIds; + return ricConfig.managedElementIds(); } /** @@ -87,27 +88,7 @@ public class Ric { * @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); } /** @@ -153,7 +134,7 @@ public class Ric { @Override public synchronized String toString() { return Ric.class.getSimpleName() + ": " + "name: " + name() + ", state: " + state + ", baseUrl: " - + ricConfig.baseUrl() + ", managedNodes: " + managedElementIds; + + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds(); } /** @@ -161,7 +142,7 @@ public class Ric { */ public enum RicState { /** - * The agent view of the agent may be inconsistent. + * The agent view of the Ric may be inconsistent. */ UNDEFINED, /** @@ -169,8 +150,8 @@ public class Ric { */ IDLE, /** - * The Ric states are recovered. + * The agent is synchronizing the view of the Ric. */ - RECOVERING + SYNCHRONIZING } }