aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation
diff options
context:
space:
mode:
Diffstat (limited to 'asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation')
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AaiClientPropertiesImpl.java62
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AsdcPropertiesUtils.java59
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/DistributionStatus.java29
-rw-r--r--asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/WatchdogDistribution.java239
4 files changed, 0 insertions, 389 deletions
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AaiClientPropertiesImpl.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AaiClientPropertiesImpl.java
deleted file mode 100644
index be5af5d51f..0000000000
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AaiClientPropertiesImpl.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.asdc.tenantIsolation;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.openecomp.mso.asdc.tenantIsolation.AsdcPropertiesUtils;
-import org.openecomp.mso.client.aai.AAIProperties;
-import org.openecomp.mso.client.aai.AAIVersion;
-import org.openecomp.mso.properties.MsoJavaProperties;
-
-public class AaiClientPropertiesImpl implements AAIProperties {
-
- final MsoJavaProperties props;
- public AaiClientPropertiesImpl() {
- this.props = AsdcPropertiesUtils.loadMsoProperties ();
- }
-
- @Override
- public URL getEndpoint() throws MalformedURLException {
- return new URL(props.getProperty("aai.endpoint", null));
- }
-
- @Override
- public String getSystemName() {
- return "MSO";
- }
-
- @Override
- public AAIVersion getDefaultVersion() {
- return AAIVersion.LATEST;
- }
-
- @Override
- public String getAuth() {
- return props.getProperty("aai.auth", null);
- }
-
- @Override
- public String getKey() {
- return props.getProperty("mso.msoKey", null);
- }
-}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AsdcPropertiesUtils.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AsdcPropertiesUtils.java
deleted file mode 100644
index 462ef0d51d..0000000000
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/AsdcPropertiesUtils.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.mso.asdc.tenantIsolation;
-
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class AsdcPropertiesUtils {
-
- public final static String MSO_ASDC_CLIENTS = "MSO_ASDC_CLIENTS";
-
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory ();
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
-
- private static boolean noProperties = true;
-
- public synchronized static MsoJavaProperties loadMsoProperties () {
- MsoJavaProperties msoProperties;
- try {
- msoProperties = msoPropertiesFactory.getMsoJavaProperties (MSO_ASDC_CLIENTS);
- } catch (Exception e) {
- msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND, MSO_ASDC_CLIENTS, "", "", MsoLogger.ErrorCode.DataError, "Exception when loading MSO ASDC Clients Properties", e);
- return null;
- }
-
- if (msoProperties != null && msoProperties.size () > 0) {
- noProperties = false;
- msoLogger.info (MessageEnum.ASDC_PROPERTIES_LOAD_SUCCESS, "", "");
- return msoProperties;
- } else {
- msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND, MSO_ASDC_CLIENTS, "", "", MsoLogger.ErrorCode.DataError, "No MSO ASDC Clients Properties found");
- return null;
- }
- }
-
- public synchronized static final boolean getNoPropertiesState() {
- return noProperties;
- }
-}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/DistributionStatus.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/DistributionStatus.java
deleted file mode 100644
index 4d04bfa59a..0000000000
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/DistributionStatus.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.asdc.tenantIsolation;
-
-public enum DistributionStatus {
-
- SUCCESS,
- FAILURE,
- TIMEOUT,
- INCOMPLETE
-}
diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/WatchdogDistribution.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/WatchdogDistribution.java
deleted file mode 100644
index 6efcd64204..0000000000
--- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/tenantIsolation/WatchdogDistribution.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.asdc.tenantIsolation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.mso.asdc.client.ASDCConfiguration;
-import org.openecomp.mso.client.aai.AAIObjectType;
-import org.openecomp.mso.client.aai.AAIResourcesClient;
-import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
-import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
-import org.openecomp.mso.client.aai.entities.uri.Depth;
-import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.Service;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.properties.MsoJsonProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.requestsdb.WatchdogComponentDistributionStatus;
-import org.openecomp.mso.requestsdb.WatchdogComponentDistributionStatusDb;
-import org.openecomp.mso.requestsdb.WatchdogDistributionStatusDb;
-import org.openecomp.mso.requestsdb.WatchdogServiceModVerIdLookupDb;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class WatchdogDistribution {
-
- private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC);
- private static final String MSO_PROP_ASDC = "MSO_PROP_ASDC";
- private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- private WatchdogDistributionStatusDb watchdogDistDb;
- private WatchdogComponentDistributionStatusDb watchdogCompDistDb;
- private WatchdogServiceModVerIdLookupDb watchdogSerlookupDb;
- private CatalogDatabase catalogDb;
- private AAIResourcesClient aaiClient;
- //protected ASDCConfiguration asdcConfig;
-
- public String getOverallDistributionStatus(String distributionId) throws MsoPropertiesException, Exception {
- LOGGER.debug("Entered getOverallDistributionStatus method for distrubutionId: " + distributionId);
-
- String status = null;
- try {
- String distributionStatus = getWatchdogDistDb().getWatchdogDistributionIdStatus(distributionId);
-
- if(DistributionStatus.TIMEOUT.name().equalsIgnoreCase(distributionStatus)) {
- LOGGER.debug("Ignoring to update WatchdogDistributionStatus as distributionId: " + distributionId + " status is set to: " + distributionStatus);
- return DistributionStatus.TIMEOUT.name();
- } else {
- List<WatchdogComponentDistributionStatus> results = getWatchdogCompDistDb().getWatchdogComponentDistributionStatus(distributionId);
- LOGGER.debug("Executed RequestDB getWatchdogComponentDistributionStatus for distrubutionId: " + distributionId);
-
- MsoJsonProperties properties = msoPropertiesFactory.getMsoJsonProperties(MSO_PROP_ASDC);
-
- //*************************************************************************************************************************************************
- //**** Compare config values verse DB watchdog component names to see if every component has reported status before returning final result back to ASDC
- //**************************************************************************************************************************************************
-
- //List<String> configNames = asdcConfig.getComponentNames();
-
- List<String> dbNames = watchdogCompDistDb.getWatchdogComponentNames(distributionId);
-
- boolean allComponentsComplete = true;
-
- JsonNode masterConfigNode = properties.getJsonRootNode().get("componentNames");
-
- if (masterConfigNode != null) {
-
- Iterator<JsonNode> config = masterConfigNode.elements();
-
- while( config.hasNext() ) {
- String name = (String)config.next().asText();
-
- boolean match = false;
-
- for(String dbName: dbNames){
-
- if(name.equals(dbName)){
- LOGGER.debug("Found componentName " + name + " in the WatchDog Component DB");
- match = true;
- break;
- }
- }
-
- if(match==false){
- LOGGER.debug(name + " has not be updated in the the WatchDog Component DB yet, so ending the loop");
- allComponentsComplete = false;
- break;
- }
-
- }
-
- }
-
- if(allComponentsComplete) {
- //if(node.asInt() == results.size()) {
- LOGGER.debug("Components Size matched with the WatchdogComponentDistributionStatus results.");
-
- for(WatchdogComponentDistributionStatus componentDist : results) {
- String componentDistributionStatus = componentDist.getComponentDistributionStatus();
- LOGGER.debug("Component status: " + componentDistributionStatus + " on componentName: " + componentDist.getComponentName());
- if(componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_ERROR")) {
- status = DistributionStatus.FAILURE.name();
- break;
- } else if(componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_OK")) {
- status = DistributionStatus.SUCCESS.name();
- } else {
- throw new Exception("Invalid Component distribution status: " + componentDistributionStatus);
- }
- }
-
- LOGGER.debug("Updating overall DistributionStatus to: " + status + " for distributionId: " + distributionId);
- getWatchdogDistDb().updateWatchdogDistributionIdStatus(distributionId, status);
- } else {
- LOGGER.debug("Components Size Didn't match with the WatchdogComponentDistributionStatus results.");
- status = DistributionStatus.INCOMPLETE.name();
- return status;
- }
- }
- } catch (MsoPropertiesException e) {
- String error = "Error occurred when trying to load MSOJson Properties.";
- LOGGER.debug(error);
- throw new MsoPropertiesException(e.getMessage());
- } catch (Exception e) {
- LOGGER.debug("Exception occurred on getOverallDistributionStatus : " + e.getMessage());
- throw new Exception(e);
- }
-
- LOGGER.debug("Exciting getOverallDistributionStatus method in WatchdogDistribution");
- return status;
- }
-
- public void executePatchAAI(String distributionId, String serviceModelInvariantUUID, String distributionStatus) throws Exception {
- LOGGER.debug("Entered executePatchAAI method with distrubutionId: " + distributionId + " and distributionStatus: " + distributionStatus);
-
- try {
- String serviceModelVersionId = getWatchdogSerlookupDb().getWatchdogServiceModVerId(distributionId);
- LOGGER.debug("Executed RequestDB getWatchdogServiceModVerIdLookup with distributionId: " + distributionId + " and serviceModelVersionId: " + serviceModelVersionId);
-
- LOGGER.debug("ASDC Notification ServiceModelInvariantUUID : " + serviceModelInvariantUUID);
-
- if(serviceModelInvariantUUID == null) {
- String error = "No Service found with serviceModelInvariantUUID: " + serviceModelInvariantUUID;
- LOGGER.debug(error);
- throw new Exception(error);
- }
-
- AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID, serviceModelVersionId);
- aaiUri.depth(Depth.ZERO); //Do not return relationships if any
- LOGGER.debug("Target A&AI Resource URI: " + aaiUri.build().toString());
-
- Map<String, String> payload = new HashMap<>();
- payload.put("distribution-status", distributionStatus);
- getAaiClient().update(aaiUri, payload);
-
- LOGGER.debug("A&AI UPDATE MODEL Version is success!");
- } catch (Exception e) {
- LOGGER.debug("Exception occurred on executePatchAAI : " + e.getMessage());
- throw new Exception(e);
- }
- }
-
- public WatchdogDistributionStatusDb getWatchdogDistDb() {
- if(watchdogDistDb == null) {
- watchdogDistDb = WatchdogDistributionStatusDb.getInstance();
- }
- return watchdogDistDb;
- }
-
- public void setWatchdogDistDb(WatchdogDistributionStatusDb watchdogDistDb) {
- this.watchdogDistDb = watchdogDistDb;
- }
-
- public WatchdogComponentDistributionStatusDb getWatchdogCompDistDb() {
- if(watchdogCompDistDb == null) {
- watchdogCompDistDb = WatchdogComponentDistributionStatusDb.getInstance();
- }
- return watchdogCompDistDb;
- }
-
- public void setWatchdogCompDistDb(WatchdogComponentDistributionStatusDb watchdogCompDistDb) {
- this.watchdogCompDistDb = watchdogCompDistDb;
- }
-
- public WatchdogServiceModVerIdLookupDb getWatchdogSerlookupDb() {
- if(watchdogSerlookupDb == null) {
- watchdogSerlookupDb = WatchdogServiceModVerIdLookupDb.getInstance();
- }
- return watchdogSerlookupDb;
- }
-
- public void setWatchdogSerlookupDb(WatchdogServiceModVerIdLookupDb watchdogSerlookupDb) {
- this.watchdogSerlookupDb = watchdogSerlookupDb;
- }
-
- public CatalogDatabase getCatalogDb() {
- if(catalogDb == null) {
- catalogDb = CatalogDatabase.getInstance();
- }
- return catalogDb;
- }
-
- public void setCatalogDb(CatalogDatabase catalogDb) {
- this.catalogDb = catalogDb;
- }
-
- public AAIResourcesClient getAaiClient() {
- if(aaiClient == null) {
- aaiClient = new AAIResourcesClient();
- }
- return aaiClient;
- }
-
- public void setAaiClient(AAIResourcesClient aaiClient) {
- this.aaiClient = aaiClient;
- }
-
-}