summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main')
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java30
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java29
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java30
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java45
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java73
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java27
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java36
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java69
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java33
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java134
-rw-r--r--openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/resources/factoryConfiguration.json4
14 files changed, 592 insertions, 0 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java
new file mode 100644
index 0000000000..947387b4a6
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDao.java
@@ -0,0 +1,26 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health;
+
+public interface HealthCheckDao {
+ boolean checkHealth() throws Exception;
+ String getVersion();
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java
new file mode 100644
index 0000000000..387d24d07c
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckDaoFactory.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class HealthCheckDaoFactory extends AbstractComponentFactory<HealthCheckDao> {
+ public static HealthCheckDaoFactory getInstance() {
+ return AbstractFactory.getInstance(HealthCheckDaoFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java
new file mode 100644
index 0000000000..0575d06058
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManager.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health;
+
+import org.openecomp.sdc.health.data.HealthInfo;
+
+import java.util.Collection;
+
+public interface HealthCheckManager {
+ Collection<HealthInfo> checkHealth();
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java
new file mode 100644
index 0000000000..c3766068b2
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/HealthCheckManagerFactory.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+
+public abstract class HealthCheckManagerFactory extends AbstractComponentFactory<HealthCheckManager> {
+ public static HealthCheckManagerFactory getInstance() {
+ return AbstractFactory.getInstance(HealthCheckManagerFactory.class);
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java
new file mode 100644
index 0000000000..3bb78aa180
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckResult.java
@@ -0,0 +1,45 @@
+package org.openecomp.sdc.health.data;
+
+import java.util.Collection;
+
+/**
+ * {
+ "sdcVersion": "1702.0.83.37.1",
+
+ "componentsInfo": [
+ {
+ "healthCheckComponent": “<component name>",
+ "healthCheckStatus": “<UP / DOWN>",
+ "version": “<component version>",
+ "description": “<OK or error description>"
+ },
+ …..
+ ]
+ }
+
+ */
+public class HealthCheckResult {
+ String sdcVersion;
+ Collection<HealthInfo> componentsInfo;
+
+ public HealthCheckResult() {
+ }
+
+ public String getSdcVersion() {
+ return sdcVersion;
+ }
+
+ public void setSdcVersion(String sdcVersion) {
+ this.sdcVersion = sdcVersion;
+ }
+
+ public Collection<HealthInfo> getComponentsInfo() {
+ return componentsInfo;
+ }
+
+ public void setComponentsInfo(Collection<HealthInfo> componentsInfo) {
+ this.componentsInfo = componentsInfo;
+ }
+
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java
new file mode 100644
index 0000000000..a876128bce
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthCheckStatus.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.health.data;
+
+
+public enum HealthCheckStatus {
+ UP("UP"),
+ DOWN("DOWN");
+
+ private String name;
+
+ HealthCheckStatus(String name) {
+ this.name = name;
+ }
+
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public static final HealthCheckStatus toValue(String inVal){
+ for (HealthCheckStatus val : values()){
+ if (val.toString().equals(inVal)){
+ return val;
+ }
+ }
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java
new file mode 100644
index 0000000000..6b005b0c53
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/HealthInfo.java
@@ -0,0 +1,73 @@
+package org.openecomp.sdc.health.data;
+
+/**
+ * {
+   "sdcVersion": "<SERVER_FULL_VERSION>"
+   "componentsInfo": [
+     {
+       "healthCheckComponent": "<COMPONENT_NAME>",
+       "healthCheckStatus": "<UP_OR_DOWN>",
+       "version": "<COMPONENT_VERSION>",
+       "description": "<OK_OR_ERROR_VERSION>"
+     }
+   ]
+ }
+ */
+public class HealthInfo {
+ private MonitoredModules healthCheckComponent;
+ private HealthCheckStatus healthCheckStatus;
+ private String version;
+ private String description;
+
+ public HealthInfo() {
+ }
+
+ public HealthInfo(MonitoredModules healthCheckComponent, HealthCheckStatus healthCheckStatus, String version, String description) {
+ this.healthCheckComponent = healthCheckComponent;
+ this.healthCheckStatus = healthCheckStatus;
+ this.version = version;
+ this.description = description;
+ }
+
+ public MonitoredModules getHealthCheckComponent() {
+ return healthCheckComponent;
+ }
+
+ public void setHealthCheckComponent(MonitoredModules healthCheckComponent) {
+ this.healthCheckComponent = healthCheckComponent;
+ }
+
+ public HealthCheckStatus getHealthCheckStatus() {
+ return healthCheckStatus;
+ }
+
+ public void setHealthCheckStatus(HealthCheckStatus healthCheckStatus) {
+ this.healthCheckStatus = healthCheckStatus;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ @Override
+ public String toString() {
+ return "HealthInfo{" +
+ "healthCheckComponent='" + healthCheckComponent + '\'' +
+ ", healthCheckStatus=" + healthCheckStatus +
+ ", version='" + version + '\'' +
+ ", description='" + description + '\'' +
+ '}';
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java
new file mode 100644
index 0000000000..576f4c4076
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/MonitoredModules.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.health.data;
+
+
+public enum MonitoredModules {
+ BE("BE"), CAS("Cassandra"),
+ ZU("Zusammen");
+
+ private String name;
+
+ MonitoredModules(String name) {
+ this.name = name;
+ }
+
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public static final MonitoredModules toValue(String inVal) {
+ for (MonitoredModules val : values()) {
+ if (val.toString().equals(inVal)) {
+ return val;
+ }
+ }
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java
new file mode 100644
index 0000000000..94d48d79fd
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/data/SiteMode.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.health.data;
+
+
+public enum SiteMode {
+ Active("active"), NOT_ACTIVE("NotActive");
+
+ private String name;
+
+ SiteMode(String name) {
+ this.name = name;
+ }
+
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ public static final SiteMode toValue(String inVal) {
+ for (SiteMode val : values()) {
+ if (val.toString().equals(inVal)) {
+ return val;
+ }
+ }
+ return null;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java
new file mode 100644
index 0000000000..ec0931c90b
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoFactoryImpl.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health.impl;
+
+
+import org.openecomp.sdc.health.HealthCheckDao;
+import org.openecomp.sdc.health.HealthCheckDaoFactory;
+
+public class HealthCheckDaoFactoryImpl
+ extends HealthCheckDaoFactory {
+ private static final HealthCheckDao INSTANCE =
+ new HealthCheckDaoImpl();
+
+ @Override
+ public HealthCheckDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java
new file mode 100644
index 0000000000..f9b4215322
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckDaoImpl.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health.impl;
+
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.exceptions.DriverException;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.health.HealthCheckDao;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+
+public class HealthCheckDaoImpl implements HealthCheckDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+
+ private static final CheckHealthAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(CheckHealthAccessor.class);
+ private static final Logger logger = LoggerFactory.getLogger(HealthCheckDaoImpl.class);
+
+ @Override
+ public boolean checkHealth() throws Exception {
+ try {
+ ResultSet resultSet = accessor.checkHealth();
+ return resultSet.getColumnDefinitions().contains("key");
+ } catch (DriverException ex) {
+ logger.error("Health check failure" + ex.getMessage(), ex);
+ throw ex;
+ } catch (Exception ex) {
+ logger.error("Health check failure" + ex.getMessage(), ex);
+ throw new Exception("Internal Error.");
+ }
+ }
+
+ @Override
+ public String getVersion() {
+ return noSqlDb.getVersion();
+ }
+
+ @Accessor
+ interface CheckHealthAccessor {
+
+ @Query("SELECT * FROM application_config LIMIT 1")
+ ResultSet checkHealth();
+
+ }
+
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
new file mode 100644
index 0000000000..1da515fac0
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health.impl;
+
+import org.openecomp.sdc.health.*;
+
+public class HealthCheckManagerFactoryImpl extends HealthCheckManagerFactory {
+ private static final HealthCheckManager INSTANCE ;
+
+ static {
+ INSTANCE = new HealthCheckManagerImpl();
+ }
+
+ @Override
+ public HealthCheckManager createInterface() {return INSTANCE;}
+}
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
new file mode 100644
index 0000000000..2ee15811af
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/java/org/openecomp/sdc/health/impl/HealthCheckManagerImpl.java
@@ -0,0 +1,134 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * 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.sdc.health.impl;
+
+import com.amdocs.zusammen.commons.health.data.HealthInfo;
+import com.amdocs.zusammen.commons.health.data.HealthStatus;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.health.HealthCheckManager;
+import org.openecomp.sdc.health.data.HealthCheckStatus;
+import org.openecomp.sdc.health.data.MonitoredModules;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.health.HealthCheckDao;
+import org.openecomp.sdc.health.HealthCheckDaoFactory;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class HealthCheckManagerImpl implements HealthCheckManager {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage;
+ private HealthCheckDao healthCheckDao;
+
+ private static final Logger logger;
+
+ static {
+ mdcDataDebugMessage = new MdcDataDebugMessage();
+ logger = LoggerFactory.getLogger(HealthCheckManagerImpl.class);
+ }
+
+ public HealthCheckManagerImpl() {
+ healthCheckDao = HealthCheckDaoFactory.getInstance().createInterface();
+ }
+
+ public String getBEVersion() {
+ return this.getClass().getPackage().getImplementationVersion();
+ }
+
+ @Override
+ public Collection<org.openecomp.sdc.health.data.HealthInfo> checkHealth() {
+ org.openecomp.sdc.health.data.HealthInfo zeHealthInfo = null;
+ org.openecomp.sdc.health.data.HealthInfo beHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.BE, HealthCheckStatus.UP, getBEVersion(), "OK");
+ org.openecomp.sdc.health.data.HealthInfo cassandraHealthInfo = null;
+ String zVersion = "Unknown";
+ try {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ZusammenAdaptor zusammenAdaptor = ZusammenAdaptorFactory
+ .getInstance().createInterface();
+ Collection<HealthInfo> zeHealthInfos = new ArrayList<>();
+ try {
+ zeHealthInfos = zusammenAdaptor.checkHealth(context);
+ } catch (Exception ex) {
+ logger.error(ex.getMessage(), ex);
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.ZU, HealthCheckStatus.DOWN,
+ zVersion, ex.getMessage());
+ }
+ boolean cassandraHealth = false;
+ String description = "OK";
+ try {
+ cassandraHealth = healthCheckDao.checkHealth();
+ } catch (Exception ex) {
+ logger.error(ex.getMessage(), ex);
+ description = ex.getMessage();
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion, ex.getMessage());
+ }
+ zVersion = zusammenAdaptor.getVersion(context);
+ if (cassandraHealthInfo == null) {
+ HealthCheckStatus status = cassandraHealth ? HealthCheckStatus.UP : HealthCheckStatus.DOWN;
+ if (!cassandraHealth){
+ description = "Cassandra is not available";
+ }
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(MonitoredModules.CAS, status,
+ healthCheckDao.getVersion(), description);
+ }
+ if (zeHealthInfo == null) {
+ List<HealthInfo> downHealth = zeHealthInfos.stream().
+ filter(h -> h.getHealthStatus().equals(HealthStatus.DOWN)).
+ collect(Collectors.toList());
+
+ if (downHealth.isEmpty()) {
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.ZU, HealthCheckStatus.UP,
+ zVersion, "OK");
+ } else {
+ String desc = downHealth.stream().map(healthInfo -> healthInfo.getDescription())
+ .collect(Collectors.joining(" , ", "[", "]"));
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.ZU, HealthCheckStatus.DOWN,
+ zVersion, desc);
+ }
+
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ zeHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.ZU, HealthCheckStatus.DOWN, zVersion, e.getMessage()
+ );
+ cassandraHealthInfo = new org.openecomp.sdc.health.data.HealthInfo(
+ MonitoredModules.CAS, HealthCheckStatus.DOWN, zVersion, e.getMessage());
+ }
+ return Arrays.asList(zeHealthInfo, beHealthInfo, cassandraHealthInfo);
+ }
+
+
+}
+
diff --git a/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/resources/factoryConfiguration.json b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..e0da4d732f
--- /dev/null
+++ b/openecomp-be/backend/openecomp-sdc-healthcheck-manager/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,4 @@
+{
+ "org.openecomp.sdc.health.HealthCheckManagerFactory": "org.openecomp.sdc.health.impl.HealthCheckManagerFactoryImpl",
+ "org.openecomp.sdc.health.HealthCheckDaoFactory": "org.openecomp.sdc.health.impl.HealthCheckDaoFactoryImpl"
+} \ No newline at end of file