aboutsummaryrefslogtreecommitdiffstats
path: root/feature-state-management/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-state-management/src/main/java')
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java225
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java4
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java19
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java38
4 files changed, 176 insertions, 110 deletions
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
index 3b7410fa..915a3225 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java
@@ -20,7 +20,8 @@
package org.onap.policy.drools.statemanagement;
-import java.net.InetSocketAddress;
+import org.onap.policy.drools.statemanagement.StateManagementProperties;
+
import java.util.ArrayList;
import java.util.Properties;
@@ -52,6 +53,19 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
static private Properties subsystemTestProperties = null;
static private final String PROPERTIES_NAME = "feature-state-management.properties";
+
+ static private void missingProperty(String prop) throws StateManagementPropertiesException{
+ String msg = "init: missing IntegrityMonitor property: ".concat(prop);
+ logger.error(msg);
+ throw new StateManagementPropertiesException(msg);
+ }
+
+ static private void logPropertyValue(String prop, String val){
+ if(logger.isInfoEnabled()){
+ String msg = "\n\n init: property: " + prop + " = " + val + "\n";
+ logger.info(msg);
+ }
+ }
/**
* Static initialization -- create Drools Integrity Monitor, and
* an HTTP server to handle REST 'test' requests
@@ -64,139 +78,132 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
// read in properties
Properties stateManagementProperties =
PropertyUtil.getProperties(configDir + "/" + PROPERTIES_NAME);
-
- subsystemTestProperties = stateManagementProperties;
-
- // fetch and verify definitions of some properties
+ // fetch and verify definitions of some properties
// (the 'IntegrityMonitor' constructor does some additional verification)
-
- String resourceName = stateManagementProperties.getProperty("resource.name");
- String hostPort = stateManagementProperties.getProperty("hostPort");
- String fpMonitorInterval = stateManagementProperties.getProperty("fp_monitor_interval");
- String failedCounterThreshold = stateManagementProperties.getProperty("failed_counter_threshold");
- String testTransInterval = stateManagementProperties.getProperty("test_trans_interval");
- String writeFpcInterval = stateManagementProperties.getProperty("write_fpc_interval");
- String siteName = stateManagementProperties.getProperty("site_name");
- String nodeType = stateManagementProperties.getProperty("node_type");
- String dependencyGroups = stateManagementProperties.getProperty("dependency_groups");
- String javaxPersistenceJdbcDriver = stateManagementProperties.getProperty("javax.persistence.jdbc.driver");
- String javaxPersistenceJdbcUrl = stateManagementProperties.getProperty("javax.persistence.jdbc.url");
- String javaxPersistenceJdbcUser = stateManagementProperties.getProperty("javax.persistence.jdbc.user");
- String javaxPersistenceJdbcPassword = stateManagementProperties.getProperty("javax.persistence.jdbc.password");
-
- if (resourceName == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'resource.name'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'resource.name'");
- }
- if (hostPort == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'hostPort'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'hostPort'");
+ String testHost = stateManagementProperties.getProperty(StateManagementProperties.TEST_HOST);
+ String testPort = stateManagementProperties.getProperty(StateManagementProperties.TEST_PORT);
+ String testServices = stateManagementProperties.getProperty(StateManagementProperties.TEST_SERVICES,
+ StateManagementProperties.TEST_SERVICES_DEFAULT);
+ String testRestClasses = stateManagementProperties.getProperty(StateManagementProperties.TEST_REST_CLASSES,
+ StateManagementProperties.TEST_REST_CLASSES_DEFAULT);
+ String testManaged = stateManagementProperties.getProperty(StateManagementProperties.TEST_MANAGED,
+ StateManagementProperties.TEST_MANAGED_DEFAULT);
+ String testSwagger = stateManagementProperties.getProperty(StateManagementProperties.TEST_SWAGGER,
+ StateManagementProperties.TEST_SWAGGER_DEFAULT);
+ String resourceName = stateManagementProperties.getProperty(StateManagementProperties.RESOURCE_NAME);
+ String fpMonitorInterval = stateManagementProperties.getProperty(StateManagementProperties.FP_MONITOR_INTERVAL);
+ String failedCounterThreshold = stateManagementProperties.getProperty(StateManagementProperties.FAILED_COUNTER_THRESHOLD);
+ String testTransInterval = stateManagementProperties.getProperty(StateManagementProperties.TEST_TRANS_INTERVAL);
+ String writeFpcInterval = stateManagementProperties.getProperty(StateManagementProperties.WRITE_FPC_INTERVAL);
+ String siteName = stateManagementProperties.getProperty(StateManagementProperties.SITE_NAME);
+ String nodeType = stateManagementProperties.getProperty(StateManagementProperties.NODE_TYPE);
+ String dependencyGroups = stateManagementProperties.getProperty(StateManagementProperties.DEPENDENCY_GROUPS);
+ String javaxPersistenceJdbcDriver = stateManagementProperties.getProperty(StateManagementProperties.DB_DRIVER);
+ String javaxPersistenceJdbcUrl = stateManagementProperties.getProperty(StateManagementProperties.DB_URL);
+ String javaxPersistenceJdbcUser = stateManagementProperties.getProperty(StateManagementProperties.DB_USER);
+ String javaxPersistenceJdbcPassword = stateManagementProperties.getProperty(StateManagementProperties.DB_PWD);
+
+ if (testHost == null){
+ missingProperty(StateManagementProperties.TEST_HOST);
+ }
+ if (testPort == null){
+ missingProperty(StateManagementProperties.TEST_PORT);
+ }
+ if (!testServices.equals(StateManagementProperties.TEST_SERVICES_DEFAULT)){
+ logger.error("init: property {} does not have the expected value of {}",
+ StateManagementProperties.TEST_SERVICES,
+ StateManagementProperties.TEST_SERVICES_DEFAULT);
+ }
+ if (!testRestClasses.equals(StateManagementProperties.TEST_REST_CLASSES_DEFAULT)){
+ logger.error("init: property {} does not have the expected value of {}",
+ StateManagementProperties.TEST_REST_CLASSES,
+ StateManagementProperties.TEST_REST_CLASSES_DEFAULT);
+ }
+ if (!testManaged.equals(StateManagementProperties.TEST_MANAGED_DEFAULT)){
+ logger.warn("init: property {} does not have the expected value of {}",
+ StateManagementProperties.TEST_MANAGED,
+ StateManagementProperties.TEST_MANAGED_DEFAULT);
+ }
+ if (!testSwagger.equals(StateManagementProperties.TEST_SWAGGER_DEFAULT)){
+ logger.warn("init: property {} does not have the expected value of {}",
+ StateManagementProperties.TEST_SWAGGER,
+ StateManagementProperties.TEST_SWAGGER_DEFAULT);
+ }
+ if (resourceName == null){
+ missingProperty(StateManagementProperties.RESOURCE_NAME);
}
- if (fpMonitorInterval == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'fp_monitor_interval'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'fp_monitor_interval'");
+ if (fpMonitorInterval == null){
+ missingProperty(StateManagementProperties.FP_MONITOR_INTERVAL);
}
- if (failedCounterThreshold == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'failed_counter_threshold'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'failed_counter_threshold'");
+ if (failedCounterThreshold == null){
+ missingProperty(StateManagementProperties.FAILED_COUNTER_THRESHOLD);
}
- if (testTransInterval == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'test_trans_interval'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'test_trans_interval'");
+ if (testTransInterval == null){
+ missingProperty(StateManagementProperties.TEST_TRANS_INTERVAL);
}
- if (writeFpcInterval == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'write_fpc_interval'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'write_fpc_interval'");
+ if (writeFpcInterval == null){
+ missingProperty(StateManagementProperties.WRITE_FPC_INTERVAL);
}
- if (siteName == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'site_name'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'site_name'");
+ if (siteName == null){
+ missingProperty(StateManagementProperties.SITE_NAME);
}
- if (nodeType == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'node_type'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'node_type'");
+ if (nodeType == null){
+ missingProperty(StateManagementProperties.NODE_TYPE);
}
- if (dependencyGroups == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'dependency_groups'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'dependency_groups'");
+ if (dependencyGroups == null){
+ missingProperty(StateManagementProperties.DEPENDENCY_GROUPS);
}
- if (javaxPersistenceJdbcDriver == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'javax.persistence.jbdc.driver for xacml DB'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'javax.persistence.jbdc.driver for xacml DB'");
+ if (javaxPersistenceJdbcDriver == null){
+ missingProperty(StateManagementProperties.DB_DRIVER);
}
- if (javaxPersistenceJdbcUrl == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'javax.persistence.jbdc.url for xacml DB'");
- throw(new Exception
- ("Missing IntegrityMonitor property: 'javax.persistence.jbdc.url for xacml DB'"));
+ if (javaxPersistenceJdbcUrl == null){
+ missingProperty(StateManagementProperties.DB_URL);
}
- if (javaxPersistenceJdbcUser == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'javax.persistence.jbdc.user for xacml DB'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'javax.persistence.jbdc.user for xacml DB'");
+ if (javaxPersistenceJdbcUser == null){
+ missingProperty(StateManagementProperties.DB_USER);
}
- if (javaxPersistenceJdbcPassword == null)
- {
- logger.error("init: Missing IntegrityMonitor property: 'javax.persistence.jbdc.password for xacml DB'");
- throw new Exception
- ("Missing IntegrityMonitor property: 'javax.persistence.jbdc.password' for xacml DB'");
- }
+ if (javaxPersistenceJdbcPassword == null){
+ missingProperty(StateManagementProperties.DB_PWD);
+ }
+
+ //Log the values so we can diagnose any issues
+ logPropertyValue(StateManagementProperties.TEST_HOST,testHost);
+ logPropertyValue(StateManagementProperties.TEST_PORT,testPort);
+ logPropertyValue(StateManagementProperties.TEST_SERVICES,testServices);
+ logPropertyValue(StateManagementProperties.TEST_REST_CLASSES,testRestClasses);
+ logPropertyValue(StateManagementProperties.TEST_MANAGED,testManaged);
+ logPropertyValue(StateManagementProperties.TEST_SWAGGER,testSwagger);
+ logPropertyValue(StateManagementProperties.RESOURCE_NAME,resourceName);
+ logPropertyValue(StateManagementProperties.FP_MONITOR_INTERVAL,fpMonitorInterval);
+ logPropertyValue(StateManagementProperties.FAILED_COUNTER_THRESHOLD,failedCounterThreshold);
+ logPropertyValue(StateManagementProperties.TEST_TRANS_INTERVAL,testTransInterval);
+ logPropertyValue(StateManagementProperties.WRITE_FPC_INTERVAL,writeFpcInterval);
+ logPropertyValue(StateManagementProperties.SITE_NAME,siteName);
+ logPropertyValue(StateManagementProperties.NODE_TYPE,nodeType);
+ logPropertyValue(StateManagementProperties.DEPENDENCY_GROUPS,dependencyGroups);
+ logPropertyValue(StateManagementProperties.DB_DRIVER,javaxPersistenceJdbcDriver);
+ logPropertyValue(StateManagementProperties.DB_URL,javaxPersistenceJdbcUrl);
+ logPropertyValue(StateManagementProperties.DB_USER,javaxPersistenceJdbcUser);
+ logPropertyValue(StateManagementProperties.DB_PWD,javaxPersistenceJdbcPassword);
+
+ subsystemTestProperties = stateManagementProperties;
// Now that we've validated the properties, create Drools Integrity Monitor
// with these properties.
im = new DroolsPDPIntegrityMonitor(resourceName,
stateManagementProperties);
- logger.info("init: New DroolsPDPIntegrityMonitor instantiated, hostPort= {}", hostPort);
-
- // determine host and port for HTTP server
- int index = hostPort.lastIndexOf(':');
- InetSocketAddress addr;
-
- if (index < 0)
- {
- addr = new InetSocketAddress(Integer.valueOf(hostPort));
- }
- else
- {
- addr = new InetSocketAddress
- (hostPort.substring(0, index),
- Integer.valueOf(hostPort.substring(index + 1)));
- }
+ logger.info("init: New DroolsPDPIntegrityMonitor instantiated, resourceName = ", resourceName);
// create http server
try {
- logger.info("init: Starting HTTP server, addr= {}", addr);
+ logger.info("init: Starting HTTP server, addr= {}", testHost+":"+testPort);
IntegrityMonitorRestServer server = new IntegrityMonitorRestServer();
server.init(stateManagementProperties);
-
- System.out.println("init: Started server on hostPort=" + hostPort);
} catch (Exception e) {
- logger.error("init: Caught Exception attempting to start server on hostPort= {}, message = {}",
- hostPort, e.getMessage());
+ logger.error("init: Caught Exception attempting to start server on testPort= {} message:",
+ testPort, e);
throw e;
-
}
logger.info("init: Exiting and returning DroolsPDPIntegrityMonitor");
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
index ed522fce..b6491e7a 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/IntegrityMonitorRestManager.java
@@ -61,7 +61,9 @@ public class IntegrityMonitorRestManager {
@GET
@Path("test")
public Response test() {
- logger.error("integrity monitor /test accessed");
+ if(logger.isDebugEnabled()){
+ logger.debug("integrity monitor /test accessed");
+ }
// The responses are stored within the audit objects, so we need to
// invoke the audits and get responses before we handle another
// request.
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
index f90f7482..192acc16 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementProperties.java
@@ -22,6 +22,7 @@ package org.onap.policy.drools.statemanagement;
import java.util.Properties;
+import org.onap.policy.drools.properties.PolicyProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,6 +31,7 @@ public class StateManagementProperties {
private static final Logger logger = LoggerFactory.getLogger(StateManagementProperties.class);
public static final String NODE_NAME = "resource.name";
+ public static final String NODE_TYPE = "node_type";
public static final String SITE_NAME = "site_name";
public static final String DB_DRIVER = "javax.persistence.jdbc.driver";
@@ -37,6 +39,23 @@ public class StateManagementProperties {
public static final String DB_USER = "javax.persistence.jdbc.user";
public static final String DB_PWD = "javax.persistence.jdbc.password";
+ public static final String TEST_SERVICES = PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES;
+ public static final String TEST_SERVICES_DEFAULT = "TEST";
+ public static final String TEST_HOST = TEST_SERVICES + "." + TEST_SERVICES_DEFAULT + PolicyProperties.PROPERTY_HTTP_HOST_SUFFIX;
+ public static final String TEST_PORT = TEST_SERVICES + "." + TEST_SERVICES_DEFAULT + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX;
+ public static final String TEST_REST_CLASSES = TEST_SERVICES + "." + TEST_SERVICES_DEFAULT + PolicyProperties.PROPERTY_HTTP_REST_CLASSES_SUFFIX;
+ public static final String TEST_REST_CLASSES_DEFAULT = IntegrityMonitorRestManager.class.getName();
+ public static final String TEST_MANAGED = TEST_SERVICES + "." + TEST_SERVICES_DEFAULT + PolicyProperties.PROPERTY_MANAGED_SUFFIX;
+ public static final String TEST_MANAGED_DEFAULT = "false";
+ public static final String TEST_SWAGGER = TEST_SERVICES + "." + TEST_SERVICES_DEFAULT + PolicyProperties.PROPERTY_HTTP_SWAGGER_SUFFIX;
+ public static final String TEST_SWAGGER_DEFAULT = "true";
+ public static final String RESOURCE_NAME = "resource.name";
+ public static final String FP_MONITOR_INTERVAL = "fp_monitor_interval";
+ public static final String FAILED_COUNTER_THRESHOLD = "failed_counter_threshold";
+ public static final String TEST_TRANS_INTERVAL = "test_trans_interval";
+ public static final String WRITE_FPC_INTERVAL = "write_fpc_interval";
+ public static final String DEPENDENCY_GROUPS = "dependency_groups";
+
private static Properties properties = null;
private StateManagementProperties(){
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java
new file mode 100644
index 00000000..51145cd6
--- /dev/null
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Feature-State-Management
+ * ================================================================================
+ * 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.onap.policy.drools.statemanagement;
+
+public class StateManagementPropertiesException extends Exception{
+ private static final long serialVersionUID = 1L;
+ public StateManagementPropertiesException() {
+ }
+ public StateManagementPropertiesException(String message) {
+ super(message);
+ }
+
+ public StateManagementPropertiesException(Throwable cause) {
+ super(cause);
+ }
+ public StateManagementPropertiesException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}