summaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2022-05-13 09:34:20 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2022-05-24 12:57:32 +0200
commit7671f9dac833881b446355700db7c414eb9a34e5 (patch)
tree98c3653aee25ec1e432e35d4fd2d4c3cc58a495b /a1-policy-management/src/main/java
parentca9a543e882c0fa891230d72311d5f7631d099bc (diff)
NONRTRIC PMS removalof usage of immutable
Issue-ID: CCSDK-3629 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: Ib256d15a035133e25cd455fae44cfe33d8b82797
Diffstat (limited to 'a1-policy-management/src/main/java')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java14
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java6
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java14
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java59
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java22
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java48
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ControllerConfig.java25
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java29
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java43
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyStatusInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java4
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatus.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java3
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java16
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java2
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java62
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java36
31 files changed, 195 insertions, 237 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
index 774b2363..4e4ec2d5 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/SwaggerConfig.java
@@ -60,7 +60,8 @@ public class SwaggerConfig {
"<li>A1 Policy creation, modification and deletion.</li>" + //
"<li>Monitoring and maintaining consistency of the SMO view of A1 policies and the Near-RT RICs</li>" + //
"<li>Maintaining a view of supported Near-RT RIC policy types</li>" + //
- "<li>Supervision of using services (R-APPs). When a service is unavailable, its policies are removed.</li>" + //
+ "<li>Supervision of using services (R-APPs). When a service is unavailable, its policies are removed.</li>"
+ + //
"</ul>" + //
"<h2>APIs provided by the service</h2>" + //
H3 + PolicyController.API_NAME + H3_END + //
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
index 04dd08ee..75ba2515 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
@@ -95,7 +95,7 @@ public class A1ClientFactory {
}
private ControllerConfig getControllerConfig(Ric ric) throws ServiceException {
- String controllerName = ric.getConfig().controllerName();
+ String controllerName = ric.getConfig().getControllerName();
if (controllerName.isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id());
@@ -110,7 +110,7 @@ public class A1ClientFactory {
private A1Client createCustomAdapter(Ric ric) throws ServiceException {
try {
- Class<?> clazz = Class.forName(ric.getConfig().customAdapterClass());
+ Class<?> clazz = Class.forName(ric.getConfig().getCustomAdapterClass());
if (A1Client.class.isAssignableFrom(clazz)) {
Constructor<?> constructor = clazz.getConstructor(RicConfig.class, AsyncRestClientFactory.class);
return (A1Client) constructor.newInstance(ric.getConfig(), this.restClientFactory);
@@ -121,14 +121,14 @@ public class A1ClientFactory {
throw new ServiceException("The custom class must either implement A1Client.Factory or A1Client");
}
} catch (ClassNotFoundException e) {
- throw new ServiceException("Could not find class: " + ric.getConfig().customAdapterClass(), e);
+ throw new ServiceException("Could not find class: " + ric.getConfig().getCustomAdapterClass(), e);
} catch (Exception e) {
- throw new ServiceException("Cannot create custom adapter: " + ric.getConfig().customAdapterClass(), e);
+ throw new ServiceException("Cannot create custom adapter: " + ric.getConfig().getCustomAdapterClass(), e);
}
}
private void assertNoControllerConfig(Ric ric, A1ProtocolType version) throws ServiceException {
- if (!ric.getConfig().controllerName().isEmpty()) {
+ if (!ric.getConfig().getControllerName().isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException(
"Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
@@ -152,9 +152,7 @@ public class A1ClientFactory {
.doOnNext(ric::setProtocolVersion)
.doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version,
ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
- .onErrorResume(
- notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id()));
} else {
return Mono.just(ric.getProtocolVersion());
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
index 959d85e2..c4afdb2f 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClient.java
@@ -154,8 +154,8 @@ public class AsyncRestClient {
}
private boolean isHttpProxyConfigured() {
- return httpProxyConfig != null && httpProxyConfig.httpProxyPort() > 0
- && !httpProxyConfig.httpProxyHost().isEmpty();
+ return httpProxyConfig != null && httpProxyConfig.getHttpProxyPort() > 0
+ && !httpProxyConfig.getHttpProxyHost().isEmpty();
}
private HttpClient buildHttpClient() {
@@ -172,7 +172,7 @@ public class AsyncRestClient {
if (isHttpProxyConfigured()) {
httpClient = httpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP)
- .host(httpProxyConfig.httpProxyHost()).port(httpProxyConfig.httpProxyPort()));
+ .host(httpProxyConfig.getHttpProxyHost()).port(httpProxyConfig.getHttpProxyPort()));
}
return httpClient;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java
index 844db540..204af9c0 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/AsyncRestClientFactory.java
@@ -60,7 +60,7 @@ public class AsyncRestClientFactory {
public AsyncRestClientFactory(WebClientConfig clientConfig, SecurityContext securityContext) {
if (clientConfig != null) {
this.sslContextFactory = new CachingSslContextFactory(clientConfig);
- this.httpProxyConfig = clientConfig.httpProxyConfig();
+ this.httpProxyConfig = clientConfig.getHttpProxyConfig();
} else {
logger.warn("No configuration for web client defined, HTTPS will not work");
this.sslContextFactory = null;
@@ -105,8 +105,8 @@ public class AsyncRestClientFactory {
private SslContext createSslContext(KeyManagerFactory keyManager)
throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
if (this.clientConfig.isTrustStoreUsed()) {
- return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
- this.clientConfig.trustStorePassword(), keyManager);
+ return createSslContextRejectingUntrustedPeers(this.clientConfig.getTrustStore(),
+ this.clientConfig.getTrustStorePassword(), keyManager);
} else {
// Trust anyone
return SslContextBuilder.forClient() //
@@ -154,10 +154,10 @@ public class AsyncRestClientFactory {
private KeyManagerFactory createKeyManager() throws NoSuchAlgorithmException, CertificateException, IOException,
UnrecoverableKeyException, KeyStoreException {
final KeyManagerFactory keyManager = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
- final String keyStoreFile = this.clientConfig.keyStore();
- final String keyStorePassword = this.clientConfig.keyStorePassword();
- final String keyPassword = this.clientConfig.keyPassword();
+ final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.getKeyStoreType());
+ final String keyStoreFile = this.clientConfig.getKeyStore();
+ final String keyStorePassword = this.clientConfig.getKeyStorePassword();
+ final String keyPassword = this.clientConfig.getKeyPassword();
try (final InputStream inputStream = new FileInputStream(keyStoreFile)) {
keyStore.load(inputStream, keyStorePassword.toCharArray());
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
index c3f00407..cb4e2ebb 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/CcsdkA1AdapterClient.java
@@ -29,7 +29,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import org.immutables.value.Value;
+import lombok.Getter;
+
import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
@@ -50,20 +51,30 @@ public class CcsdkA1AdapterClient implements A1Client {
static final int CONCURRENCY_RIC = 1; // How many paralell requests that is sent to one NearRT RIC
- @Value.Immutable
- @org.immutables.gson.Gson.TypeAdapters
- public interface AdapterRequest {
- public String nearRtRicUrl();
+ @Getter
+ public static class AdapterRequest {
+ private String nearRtRicUrl = null;
+ private String body = null;
+
+ public AdapterRequest(String url, String body) {
+ this.nearRtRicUrl = url;
+ this.body = body;
+ }
- public Optional<String> body();
+ public AdapterRequest() {}
}
- @Value.Immutable
- @org.immutables.gson.Gson.TypeAdapters
- public interface AdapterOutput {
- public Optional<String> body();
+ @Getter
+ public static class AdapterOutput {
+ private String body = null;
+ private int httpStatus = 0;
- public int httpStatus();
+ public AdapterOutput(int status, String body) {
+ this.httpStatus = status;
+ this.body = body;
+ }
+
+ public AdapterOutput() {}
}
static com.google.gson.Gson gson = new GsonBuilder() //
@@ -93,7 +104,7 @@ public class CcsdkA1AdapterClient implements A1Client {
public CcsdkA1AdapterClient(A1ProtocolType protocolType, RicConfig ricConfig, ControllerConfig controllerConfig,
AsyncRestClientFactory restClientFactory) {
this(protocolType, ricConfig, controllerConfig,
- restClientFactory.createRestClientNoHttpProxy(controllerConfig.baseUrl() + "/restconf/operations"));
+ restClientFactory.createRestClientNoHttpProxy(controllerConfig.getBaseUrl() + "/restconf/operations"));
}
/**
@@ -119,7 +130,7 @@ public class CcsdkA1AdapterClient implements A1Client {
this.ricConfig = ricConfig;
this.protocolType = protocolType;
this.controllerConfig = controllerConfig;
- logger.debug("CcsdkA1AdapterClient for ric: {}, a1Controller: {}", ricConfig.ricId(), controllerConfig);
+ logger.debug("CcsdkA1AdapterClient for ric: {}, a1Controller: {}", ricConfig.getRicId(), controllerConfig);
} else {
throw new IllegalArgumentException("Not handeled protocolversion: " + protocolType);
}
@@ -265,29 +276,27 @@ public class CcsdkA1AdapterClient implements A1Client {
}
private Mono<String> post(String rpcName, String ricUrl, Optional<String> body) {
- AdapterRequest inputParams = ImmutableAdapterRequest.builder() //
- .nearRtRicUrl(ricUrl) //
- .body(body) //
- .build();
+ AdapterRequest inputParams = new AdapterRequest(ricUrl, body.isPresent() ? body.get() : null);
+
final String inputJsonString = A1AdapterJsonHelper.createInputJsonString(inputParams);
logger.debug("POST inputJsonString = {}", inputJsonString);
return restClient
- .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.userName(),
- this.controllerConfig.password()) //
+ .postWithAuthHeader(controllerUrl(rpcName), inputJsonString, this.controllerConfig.getUserName(),
+ this.controllerConfig.getPassword()) //
.flatMap(this::extractResponseBody);
}
private Mono<String> extractResponse(JSONObject responseOutput) {
- AdapterOutput output = gson.fromJson(responseOutput.toString(), ImmutableAdapterOutput.class);
- Optional<String> optionalBody = output.body();
- String body = optionalBody.isPresent() ? optionalBody.get() : "";
- if (HttpStatus.valueOf(output.httpStatus()).is2xxSuccessful()) {
+ AdapterOutput output = gson.fromJson(responseOutput.toString(), AdapterOutput.class);
+
+ String body = output.body == null ? "" : output.body;
+ if (HttpStatus.valueOf(output.httpStatus).is2xxSuccessful()) {
return Mono.just(body);
} else {
- logger.debug("Error response: {} {}", output.httpStatus(), body);
+ logger.debug("Error response: {} {}", output.httpStatus, body);
byte[] responseBodyBytes = body.getBytes(StandardCharsets.UTF_8);
- HttpStatus httpStatus = HttpStatus.valueOf(output.httpStatus());
+ HttpStatus httpStatus = HttpStatus.valueOf(output.httpStatus);
WebClientResponseException responseException = new WebClientResponseException(httpStatus.value(),
httpStatus.getReasonPhrase(), null, responseBodyBytes, StandardCharsets.UTF_8, null);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
index 78a418ab..dfe33e7d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/OscA1Client.java
@@ -110,7 +110,7 @@ public class OscA1Client implements A1Client {
}
private String baseUri() {
- return ricConfig.baseUrl() + "/a1-p";
+ return ricConfig.getBaseUrl() + "/a1-p";
}
}
@@ -125,7 +125,7 @@ public class OscA1Client implements A1Client {
public OscA1Client(RicConfig ricConfig, AsyncRestClient restClient) {
this.restClient = restClient;
- logger.debug("OscA1Client for ric: {}", ricConfig.ricId());
+ logger.debug("OscA1Client for ric: {}", ricConfig.getRicId());
uri = new UriBuilder(ricConfig);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
index b158ad25..5eae7759 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion1.java
@@ -75,7 +75,7 @@ public class StdA1ClientVersion1 implements A1Client {
}
private String baseUri() {
- return ricConfig.baseUrl() + "/A1-P/v1";
+ return ricConfig.getBaseUrl() + "/A1-P/v1";
}
private String policiesBaseUri() {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
index b91edee3..0022057b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/StdA1ClientVersion2.java
@@ -121,7 +121,7 @@ public class StdA1ClientVersion2 implements A1Client {
}
private String baseUri() {
- return ricConfig.baseUrl() + "/A1-P/v2";
+ return ricConfig.getBaseUrl() + "/A1-P/v2";
}
}
@@ -136,7 +136,7 @@ public class StdA1ClientVersion2 implements A1Client {
public StdA1ClientVersion2(RicConfig ricConfig, AsyncRestClient restClient) {
this.restClient = restClient;
- logger.debug("OscA1Client for ric: {}", ricConfig.ricId());
+ logger.debug("OscA1Client for ric: {}", ricConfig.getRicId());
uriBuiler = new OranV2UriBuilder(ricConfig);
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
index 236d4381..0e2294fc 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfig.java
@@ -100,13 +100,13 @@ public class ApplicationConfig {
public WebClientConfig getWebClientConfig() {
if (this.webClientConfig == null) {
- HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
+ HttpProxyConfig httpProxyConfig = HttpProxyConfig.builder() //
.httpProxyHost(this.httpProxyHost) //
.httpProxyPort(this.httpProxyPort) //
.httpProxyType(ProxyProvider.Proxy.valueOf(this.httpProxyType)) //
.build();
- this.webClientConfig = ImmutableWebClientConfig.builder() //
+ this.webClientConfig = WebClientConfig.builder() //
.keyStoreType(this.sslKeyStoreType) //
.keyStorePassword(this.sslKeyStorePassword) //
.keyStore(this.sslKeyStore) //
@@ -156,23 +156,23 @@ public class ApplicationConfig {
ApplicationConfigParser.ConfigParserResult parserResult) {
Collection<RicConfigUpdate> modifications = new ArrayList<>();
- this.controllerConfigs = parserResult.controllerConfigs();
+ this.controllerConfigs = parserResult.getControllerConfigs();
- this.dmaapConsumerTopicUrl = parserResult.dmaapConsumerTopicUrl();
- this.dmaapProducerTopicUrl = parserResult.dmaapProducerTopicUrl();
+ this.dmaapConsumerTopicUrl = parserResult.getDmaapConsumerTopicUrl();
+ this.dmaapProducerTopicUrl = parserResult.getDmaapProducerTopicUrl();
Map<String, RicConfig> newRicConfigs = new HashMap<>();
- for (RicConfig newConfig : parserResult.ricConfigs()) {
- RicConfig oldConfig = this.ricConfigs.get(newConfig.ricId());
- this.ricConfigs.remove(newConfig.ricId());
+ for (RicConfig newConfig : parserResult.getRicConfigs()) {
+ RicConfig oldConfig = this.ricConfigs.get(newConfig.getRicId());
+ this.ricConfigs.remove(newConfig.getRicId());
if (oldConfig == null) {
- newRicConfigs.put(newConfig.ricId(), newConfig);
+ newRicConfigs.put(newConfig.getRicId(), newConfig);
modifications.add(new RicConfigUpdate(newConfig, RicConfigUpdate.Type.ADDED));
} else if (!newConfig.equals(oldConfig)) {
modifications.add(new RicConfigUpdate(newConfig, RicConfigUpdate.Type.CHANGED));
- newRicConfigs.put(newConfig.ricId(), newConfig);
+ newRicConfigs.put(newConfig.getRicId(), newConfig);
} else {
- newRicConfigs.put(oldConfig.ricId(), oldConfig);
+ newRicConfigs.put(oldConfig.getRicId(), oldConfig);
}
}
for (RicConfig deletedConfig : this.ricConfigs.values()) {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
index fc1985ac..3990bc7b 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ApplicationConfigParser.java
@@ -41,8 +41,9 @@ import java.util.Set;
import javax.validation.constraints.NotNull;
-import org.immutables.gson.Gson;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.Getter;
+
import org.json.JSONObject;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.slf4j.Logger;
@@ -63,16 +64,19 @@ public class ApplicationConfigParser {
this.applicationConfig = applicationConfig;
}
- @Value.Immutable
- @Gson.TypeAdapters
- public interface ConfigParserResult {
- List<RicConfig> ricConfigs();
+ @Builder
+ @Getter
+ public static class ConfigParserResult {
+ private List<RicConfig> ricConfigs;
- Map<String, ControllerConfig> controllerConfigs();
+ @Builder.Default
+ private Map<String, ControllerConfig> controllerConfigs = new HashMap<>();
- String dmaapConsumerTopicUrl();
+ @Builder.Default
+ private String dmaapConsumerTopicUrl = "";
- String dmaapProducerTopicUrl();
+ @Builder.Default
+ private String dmaapProducerTopicUrl = "";
}
@@ -103,7 +107,7 @@ public class ApplicationConfigParser {
Map<String, ControllerConfig> controllerConfigs = parseControllerConfigs(pmsConfigJson);
checkConfigurationConsistency(ricConfigs, controllerConfigs);
- return ImmutableConfigParserResult.builder() //
+ return ConfigParserResult.builder() //
.dmaapConsumerTopicUrl(dmaapConsumerTopicUrl) //
.dmaapProducerTopicUrl(dmaapProducerTopicUrl) //
.ricConfigs(ricConfigs) //
@@ -147,15 +151,15 @@ public class ApplicationConfigParser {
Set<String> ricUrls = new HashSet<>();
Set<String> ricNames = new HashSet<>();
for (RicConfig ric : ricConfigs) {
- if (!ricUrls.add(ric.baseUrl())) {
- throw new ServiceException("Configuration error, more than one RIC URL: " + ric.baseUrl());
+ if (!ricUrls.add(ric.getBaseUrl())) {
+ throw new ServiceException("Configuration error, more than one RIC URL: " + ric.getBaseUrl());
}
- if (!ricNames.add(ric.ricId())) {
- throw new ServiceException("Configuration error, more than one RIC with name: " + ric.ricId());
+ if (!ricNames.add(ric.getRicId())) {
+ throw new ServiceException("Configuration error, more than one RIC with name: " + ric.getRicId());
}
- if (!ric.controllerName().isEmpty() && controllerConfigs.get(ric.controllerName()) == null) {
+ if (!ric.getControllerName().isEmpty() && controllerConfigs.get(ric.getControllerName()) == null) {
throw new ServiceException(
- "Configuration error, controller configuration not found: " + ric.controllerName());
+ "Configuration error, controller configuration not found: " + ric.getControllerName());
}
}
}
@@ -164,17 +168,17 @@ public class ApplicationConfigParser {
List<RicConfig> result = new ArrayList<>();
for (JsonElement ricElem : getAsJsonArray(config, "ric")) {
JsonObject ricJsonObj = ricElem.getAsJsonObject();
- RicConfig ricConfig = ImmutableRicConfig.builder() //
+ RicConfig ricConfig = RicConfig.builder() //
.ricId(get(ricJsonObj, "name", "id", "ricId").getAsString()) //
.baseUrl(get(ricJsonObj, "baseUrl").getAsString()) //
.managedElementIds(parseManagedElementIds(get(ricJsonObj, "managedElementIds").getAsJsonArray())) //
.controllerName(getString(ricJsonObj, CONTROLLER, ""))
.customAdapterClass(getString(ricJsonObj, "customAdapterClass", "")) //
.build();
- if (!ricConfig.baseUrl().isEmpty()) {
+ if (!ricConfig.getBaseUrl().isEmpty()) {
result.add(ricConfig);
} else {
- logger.error("RIC configuration error {}, baseUrl is empty", ricConfig.ricId());
+ logger.error("RIC configuration error {}, baseUrl is empty", ricConfig.getRicId());
}
}
return result;
@@ -195,16 +199,16 @@ public class ApplicationConfigParser {
Map<String, ControllerConfig> result = new HashMap<>();
for (JsonElement element : getAsJsonArray(config, CONTROLLER)) {
JsonObject controllerAsJson = element.getAsJsonObject();
- ImmutableControllerConfig controllerConfig = ImmutableControllerConfig.builder() //
+ ControllerConfig controllerConfig = ControllerConfig.builder() //
.name(get(controllerAsJson, "name").getAsString()) //
.baseUrl(get(controllerAsJson, "baseUrl").getAsString()) //
.password(get(controllerAsJson, "password").getAsString()) //
.userName(get(controllerAsJson, "userName").getAsString()) // )
.build();
- if (result.put(controllerConfig.name(), controllerConfig) != null) {
+ if (result.put(controllerConfig.getName(), controllerConfig) != null) {
throw new ServiceException(
- "Configuration error, more than one controller with name: " + controllerConfig.name());
+ "Configuration error, more than one controller with name: " + controllerConfig.getName());
}
}
return result;
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ControllerConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ControllerConfig.java
index 5f00cf69..1c52edc2 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ControllerConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/ControllerConfig.java
@@ -20,19 +20,22 @@
package org.onap.ccsdk.oran.a1policymanagementservice.configuration;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
-@Value.Immutable
-@Value.Style(redactedMask = "####")
+@Builder
+@Getter
+@EqualsAndHashCode
+@ToString
+public class ControllerConfig {
+ private String name;
-public interface ControllerConfig {
- public String name();
+ private String baseUrl;
- public String baseUrl();
-
- public String userName();
-
- @Value.Redacted
- public String password();
+ private String userName;
+ @ToString.Exclude
+ private String password;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java
index 251be5e7..ffe853f5 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/RicConfig.java
@@ -20,20 +20,29 @@
package org.onap.ccsdk.oran.a1policymanagementservice.configuration;
-import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.Collection;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
-@Value.Immutable
-public interface RicConfig {
- public String ricId();
+@Builder
+@Getter
+@EqualsAndHashCode
+@ToString
+public class RicConfig {
+ private String ricId;
- public String controllerName();
+ @Builder.Default
+ private String controllerName = "";
- public String baseUrl();
+ private String baseUrl;
- public ImmutableList<String> managedElementIds();
-
- public String customAdapterClass();
+ @Builder.Default
+ private Collection<String> managedElementIds = new ArrayList<>();
+ @Builder.Default
+ private String customAdapterClass = "";
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java
index 1e5d7ffa..e71f8557 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/configuration/WebClientConfig.java
@@ -20,38 +20,41 @@
package org.onap.ccsdk.oran.a1policymanagementservice.configuration;
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.ToString;
import reactor.netty.transport.ProxyProvider;
-@Value.Immutable
-@Value.Style(redactedMask = "####")
-public interface WebClientConfig {
- public String keyStoreType();
+@Builder
+@Getter
+@ToString
+public class WebClientConfig {
+ private String keyStoreType;
- @Value.Redacted
- public String keyStorePassword();
+ private String keyStorePassword;
- public String keyStore();
+ private String keyStore;
- @Value.Redacted
- public String keyPassword();
+ @ToString.Exclude
+ private String keyPassword;
- public boolean isTrustStoreUsed();
+ private boolean isTrustStoreUsed;
- @Value.Redacted
- public String trustStorePassword();
+ private String trustStorePassword;
- public String trustStore();
+ private String trustStore;
- @Value.Immutable
- public interface HttpProxyConfig {
- public String httpProxyHost();
+ @Builder
+ @Getter
+ @ToString
+ public static class HttpProxyConfig {
+ private String httpProxyHost;
- public int httpProxyPort();
+ private int httpProxyPort;
- public ProxyProvider.Proxy httpProxyType();
+ private ProxyProvider.Proxy httpProxyType;
}
- public HttpProxyConfig httpProxyConfig();
+ private HttpProxyConfig httpProxyConfig;
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
index 7d89206c..c5436cd3 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/ServiceCallbackInfo.java
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "service_callback_info_v2",
description = "Information transferred as in Service callbacks (callback_url)")
public class ServiceCallbackInfo {
@@ -35,7 +32,6 @@ public class ServiceCallbackInfo {
private static final String EVENT_TYPE_DESCRIPTION = "values:\n" //
+ "AVAILABLE: the Near-RT RIC has become available for A1 Policy management";
- @Gson.TypeAdapters
@Schema(name = "event_type_v2", description = EVENT_TYPE_DESCRIPTION)
public enum EventType {
AVAILABLE
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
index 754d1694..6470abfe 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/VoidResponse.java
@@ -22,9 +22,6 @@ package org.onap.ccsdk.oran.a1policymanagementservice.controllers;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "void", description = "Void/empty")
public class VoidResponse {
private VoidResponse() {}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java
index cc9b83aa..4e55c506 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyIdList.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policy_id_list_v2", description = "A list of policy identities")
public class PolicyIdList {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
index 2e19a3de..55a9343d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfo.java
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policy_info_v2", description = "Information for one A1-P Policy")
public class PolicyInfo {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java
index 08923fd9..04f7e1ec 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyInfoList.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policy_info_list_v2", description = "List of policy information")
public class PolicyInfoList {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyStatusInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyStatusInfo.java
index bc95e54f..c19c4a0d 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyStatusInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyStatusInfo.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.time.Instant;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policy_status_info_v2", description = "Status for one A1-P Policy")
public class PolicyStatusInfo {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java
index deedf2f7..c2610b07 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeIdList.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policytype_id_list_v2", description = "Information about policy types")
public class PolicyTypeIdList {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java
index b619e44b..591c1caf 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/PolicyTypeInfo.java
@@ -27,9 +27,6 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "policytype_v2", description = "Policy type")
public class PolicyTypeInfo {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
index 38797cae..44927707 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfo.java
@@ -27,13 +27,9 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "ric_info_v2", description = "Information for a Near-RT RIC")
public class RicInfo {
- @Gson.TypeAdapters
@Schema(name = "ric_state_v2", description = "Represents the states for a Near-RT RIC")
public enum RicState {
UNAVAILABLE, AVAILABLE, SYNCHRONIZING, CONSISTENCY_CHECK
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
index 05b9569e..f5612f9c 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/RicInfoList.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "ric_info_list_v2", description = "List of Near-RT RIC information")
public class RicInfoList {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
index 17277c9a..0f975c24 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceRegistrationInfo.java
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "service_registration_info_v2", description = "Information for one service")
public class ServiceRegistrationInfo {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatus.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatus.java
index 02869485..f25aff0e 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatus.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatus.java
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
import io.swagger.v3.oas.annotations.media.Schema;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "service_status_v2")
public class ServiceStatus {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java
index 981c95b6..e6aa8d41 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/ServiceStatusList.java
@@ -27,9 +27,6 @@ import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collection;
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
@Schema(name = "service_list_v2", description = "List of service information")
public class ServiceStatusList {
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
index df9dfd19..28d434b7 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/controllers/v2/StatusController.java
@@ -27,7 +27,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
-import org.immutables.gson.Gson;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@@ -45,7 +44,6 @@ public class StatusController {
public static final String API_NAME = "Health Check";
public static final String API_DESCRIPTION = "";
- @Gson.TypeAdapters
@Schema(name = "status_info_v2")
class StatusInfo {
@Schema(description = "status text")
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
index 012f1f62..2971feb2 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/repository/Ric.java
@@ -30,11 +30,14 @@ import lombok.Setter;
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1ProtocolType;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Holds information about a Near-RT RIC.
*/
public class Ric {
+ private static final Logger logger = LoggerFactory.getLogger(Ric.class);
@Setter
private RicConfig ricConfig;
@@ -54,11 +57,11 @@ public class Ric {
*/
public Ric(RicConfig ricConfig) {
this.ricConfig = ricConfig;
- this.lock = new Lock(ricConfig.ricId());
+ this.lock = new Lock(ricConfig.getRicId());
}
public String id() {
- return ricConfig.ricId();
+ return ricConfig.getRicId();
}
public RicConfig getConfig() {
@@ -70,11 +73,12 @@ public class Ric {
}
public synchronized void setState(RicState state) {
+ logger.debug("Ric {} state set to {}", getConfig().getRicId(), state);
this.state = state;
}
public synchronized A1ProtocolType getProtocolVersion() {
- if (this.ricConfig.customAdapterClass().isEmpty()) {
+ if (this.ricConfig.getCustomAdapterClass().isEmpty()) {
return this.protocolVersion;
} else {
return A1ProtocolType.CUSTOM_PROTOCOL;
@@ -87,7 +91,7 @@ public class Ric {
* @return a vector containing the nodes managed by this Ric.
*/
public synchronized Collection<String> getManagedElementIds() {
- return new Vector<>(ricConfig.managedElementIds());
+ return new Vector<>(ricConfig.getManagedElementIds());
}
/**
@@ -97,7 +101,7 @@ public class Ric {
* @return true if the given node is managed by this Ric.
*/
public synchronized boolean isManaging(String managedElementId) {
- return ricConfig.managedElementIds().contains(managedElementId);
+ return ricConfig.getManagedElementIds().contains(managedElementId);
}
/**
@@ -143,7 +147,7 @@ public class Ric {
@Override
public synchronized String toString() {
return Ric.class.getSimpleName() + ": " + "name: " + id() + ", state: " + state + ", baseUrl: "
- + ricConfig.baseUrl() + ", managedNodes: " + ricConfig.managedElementIds();
+ + ricConfig.getBaseUrl() + ", managedNodes: " + ricConfig.getManagedElementIds();
}
/**
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
index e3d489b5..fea242ae 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshConfigTask.java
@@ -195,7 +195,7 @@ public class RefreshConfigTask {
public Mono<RicConfigUpdate.Type> handleUpdatedRicConfig(RicConfigUpdate updatedInfo) {
synchronized (this.rics) {
- String ricId = updatedInfo.getRicConfig().ricId();
+ String ricId = updatedInfo.getRicConfig().getRicId();
RicConfigUpdate.Type event = updatedInfo.getType();
if (event == RicConfigUpdate.Type.ADDED) {
logger.debug("RIC added {}", ricId);
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
index 8926ec16..e4711c98 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSupervision.java
@@ -64,11 +64,11 @@ public class RicSupervision {
private final Services services;
private final AsyncRestClientFactory restClientFactory;
- private static class SynchStartedException extends ServiceException {
+ private static class SynchNeededException extends ServiceException {
private static final long serialVersionUID = 1L;
- public SynchStartedException(String message) {
- super(message);
+ public SynchNeededException(RicData ric) {
+ super("SynchNeededException for " + ric.ric.id());
}
}
@@ -113,41 +113,34 @@ public class RicSupervision {
}
private Mono<RicData> checkOneRic(RicData ricData) {
- return checkRicState(ricData) //
- .flatMap(x -> ricData.ric.getLock().lock(LockType.EXCLUSIVE, "checkOneRic")) //
- .flatMap(notUsed -> setRicState(ricData)) //
+ if (ricData.ric.getState() == RicState.CONSISTENCY_CHECK || ricData.ric.getState() == RicState.SYNCHRONIZING) {
+ return Mono.empty(); // Skip, already in progress
+ }
+ return ricData.ric.getLock().lock(LockType.EXCLUSIVE, "checkOneRic") //
+ .flatMap(lock -> synchIfUnavailable(ricData)) //
+ .doOnNext(ric -> ric.ric.setState(RicState.CONSISTENCY_CHECK)) //
.flatMap(x -> checkRicPolicies(ricData)) //
.flatMap(x -> checkRicPolicyTypes(ricData)) //
.doOnNext(x -> onRicCheckedOk(ricData)) //
- .doOnError(t -> onRicCheckedError(t, ricData)) //
+ .onErrorResume(t -> onRicCheckedError(t, ricData)) //
+ .doFinally(sig -> ricData.ric.getLock().unlockBlocking()) //
.onErrorResume(throwable -> Mono.empty());
}
- private void onRicCheckedError(Throwable t, RicData ricData) {
+ private Mono<RicData> onRicCheckedError(Throwable t, RicData ricData) {
logger.debug("Ric: {} check stopped, exception: {}", ricData.ric.id(), t.getMessage());
- if (!(t instanceof SynchStartedException)) {
- // If synch is started, the synch will set the final state
- ricData.ric.setState(RicState.UNAVAILABLE);
+ ricData.ric.setState(RicState.UNAVAILABLE);
+ if ((t instanceof SynchNeededException)) {
+ return startSynchronization(ricData);
+ } else {
+ logger.warn("RicSupervision, ric: {}, exception: {}", ricData.ric.id(), t.getMessage());
+ return Mono.empty();
}
- ricData.ric.getLock().unlockBlocking();
}
private void onRicCheckedOk(RicData ricData) {
logger.debug("Ric: {} checked OK", ricData.ric.id());
ricData.ric.setState(RicState.AVAILABLE);
- ricData.ric.getLock().unlockBlocking();
- }
-
- @SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields
- private Mono<RicData> setRicState(RicData ric) {
- synchronized (ric) {
- if (ric.ric.getState() == RicState.CONSISTENCY_CHECK) {
- logger.debug("Ric: {} is already being checked", ric.ric.getConfig().ricId());
- return Mono.empty();
- }
- ric.ric.setState(RicState.CONSISTENCY_CHECK);
- return Mono.just(ric);
- }
}
private Mono<RicData> createRicData(Ric ric) {
@@ -156,13 +149,9 @@ public class RicSupervision {
.map(a1Client -> new RicData(ric, a1Client));
}
- private Mono<RicData> checkRicState(RicData ric) {
+ private Mono<RicData> synchIfUnavailable(RicData ric) {
if (ric.ric.getState() == RicState.UNAVAILABLE) {
- logger.debug("RicSupervision, starting ric: {} synchronization (state == UNAVAILABLE)", ric.ric.id());
- return startSynchronization(ric) //
- .onErrorResume(t -> Mono.empty());
- } else if (ric.ric.getState() == RicState.SYNCHRONIZING || ric.ric.getState() == RicState.CONSISTENCY_CHECK) {
- return Mono.empty();
+ return Mono.error(new SynchNeededException(ric));
} else {
return Mono.just(ric);
}
@@ -178,14 +167,14 @@ public class RicSupervision {
if (ricPolicies.size() != policies.getForRic(ric.ric.id()).size()) {
logger.debug("RicSupervision, starting ric: {} synchronization (noOfPolicices == {}, expected == {})",
ric.ric.id(), ricPolicies.size(), policies.getForRic(ric.ric.id()).size());
- return startSynchronization(ric);
+ return Mono.error(new SynchNeededException(ric));
}
for (String policyId : ricPolicies) {
if (!policies.containsPolicy(policyId)) {
logger.debug("RicSupervision, starting ric: {} synchronization (unexpected policy in RIC: {})",
ric.ric.id(), policyId);
- return startSynchronization(ric);
+ return Mono.error(new SynchNeededException(ric));
}
}
return Mono.just(ric);
@@ -202,22 +191,23 @@ public class RicSupervision {
logger.debug(
"RicSupervision, starting ric: {} synchronization (unexpected numer of policy types in RIC: {}, expected: {})",
ric.ric.id(), ricTypes.size(), ric.ric.getSupportedPolicyTypes().size());
- return startSynchronization(ric);
+ return Mono.error(new SynchNeededException(ric));
}
for (String typeName : ricTypes) {
if (!ric.ric.isSupportingType(typeName)) {
logger.debug("RicSupervision, starting ric: {} synchronization (unexpected policy type: {})",
ric.ric.id(), typeName);
- return startSynchronization(ric);
+ return Mono.error(new SynchNeededException(ric));
}
}
return Mono.just(ric);
}
private Mono<RicData> startSynchronization(RicData ric) {
+ logger.debug("RicSupervision, starting ric: {} synchronization, state: {}", ric.ric.id(), ric.ric.getState());
RicSynchronizationTask synchronizationTask = createSynchronizationTask();
return synchronizationTask.synchronizeRic(ric.ric) //
- .flatMap(notUsed -> Mono.error(new SynchStartedException("Syncronization started")));
+ .flatMap(notUsed -> Mono.just(ric));
}
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
index 6305abf0..94e873ed 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RicSynchronizationTask.java
@@ -37,10 +37,8 @@ import org.onap.ccsdk.oran.a1policymanagementservice.repository.Services;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import reactor.core.publisher.BaseSubscriber;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
-import reactor.core.publisher.SignalType;
/**
* Synchronizes the content of a Near-RT RIC with the content in the repository.
@@ -78,27 +76,22 @@ public class RicSynchronizationTask {
}
public void run(Ric ric) {
- logger.debug("Ric synchronization task created: {}", ric.getConfig().ricId());
+ logger.debug("Ric synchronization task created: {}", ric.getConfig().getRicId());
if (ric.getState() == RicState.SYNCHRONIZING) {
- logger.debug("Ric: {} is already being synchronized", ric.getConfig().ricId());
+ logger.debug("Ric: {} is already being synchronized", ric.getConfig().getRicId());
return;
}
ric.getLock().lock(LockType.EXCLUSIVE, "RicSynchronizationTask") //
.flatMap(notUsed -> synchronizeRic(ric)) //
- .subscribe(new BaseSubscriber<Object>() {
-
- @Override
- protected void hookFinally(SignalType type) {
- ric.getLock().unlockBlocking();
- }
- });
+ .doFinally(sig -> ric.getLock().unlockBlocking()) //
+ .subscribe();
}
public Mono<Ric> synchronizeRic(Ric ric) {
- return setRicState(ric) //
- .flatMap(lock -> this.a1ClientFactory.createA1Client(ric)) //
+ return this.a1ClientFactory.createA1Client(ric) //
+ .doOnNext(client -> ric.setState(RicState.SYNCHRONIZING)) //
.flatMapMany(client -> runSynchronization(ric, client)) //
.onErrorResume(throwable -> deleteAllPolicyInstances(ric, throwable)) //
.collectList() //
@@ -115,24 +108,11 @@ public class RicSynchronizationTask {
return a1Client.getPolicyTypeIdentities() //
.doOnNext(x -> ric.clearSupportedPolicyTypes()) //
.flatMapMany(Flux::fromIterable) //
- .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().ricId(), typeId)) //
+ .doOnNext(typeId -> logger.debug("For ric: {}, handling type: {}", ric.getConfig().getRicId(), typeId)) //
.flatMap(policyTypeId -> getPolicyType(policyTypeId, a1Client), CONCURRENCY_RIC) //
.doOnNext(ric::addSupportedPolicyType); //
}
- @SuppressWarnings("squid:S2445") // Blocks should be synchronized on "private final" fields
- private Mono<Ric> setRicState(Ric ric) {
- synchronized (ric) {
- if (ric.getState() == RicState.SYNCHRONIZING) {
- logger.debug("Ric: {} is already being synchronized", ric.getConfig().ricId());
- return Mono.empty();
- }
- logger.debug("Ric state set to SYNCHRONIZING: {}", ric.getConfig().ricId());
- ric.setState(RicState.SYNCHRONIZING);
- return Mono.just(ric);
- }
- }
-
private Flux<Object> runSynchronization(Ric ric, A1Client a1Client) {
Flux<PolicyType> synchronizedTypes = synchronizePolicyTypes(ric, a1Client);
Flux<?> policiesDeletedInRic = a1Client.deleteAllPolicies();
@@ -188,7 +168,7 @@ public class RicSynchronizationTask {
}
private Flux<Policy> putPolicy(Policy policy, Ric ric, A1Client a1Client) {
- logger.trace("Recreating policy: {}, for ric: {}", policy.getId(), ric.getConfig().ricId());
+ logger.trace("Recreating policy: {}, for ric: {}", policy.getId(), ric.getConfig().getRicId());
return a1Client.putPolicy(policy) //
.flatMapMany(notUsed -> Flux.just(policy));
}