summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java158
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java10
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java172
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DroolsPDPIntegrityMonitor.java76
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java80
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java12
-rw-r--r--feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementPropertiesException.java3
-rw-r--r--feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/BusPublisher.java6
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java8
-rw-r--r--pom.xml4
11 files changed, 322 insertions, 221 deletions
diff --git a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
index cc6f02e0..bdb15a70 100644
--- a/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
+++ b/feature-healthcheck/src/main/java/org/onap/policy/drools/healthcheck/HealthCheck.java
@@ -21,6 +21,7 @@
package org.onap.policy.drools.healthcheck;
import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
import javax.ws.rs.core.Response;
@@ -45,63 +46,119 @@ public interface HealthCheck extends Startable {
/**
* Named Entity in the report
*/
- public String name;
+ private String name;
/**
* URL queried
*/
- public String url;
+ private String url;
/**
* healthy?
*/
- public boolean healthy;
+ private boolean healthy;
/**
* return code
*/
- public int code;
+ private int code;
/**
* Message from remote entity
*/
- public String message;
+ private String message;
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Report [name=");
- builder.append(name);
+ builder.append(getName());
builder.append(", url=");
- builder.append(url);
+ builder.append(getUrl());
builder.append(", healthy=");
- builder.append(healthy);
+ builder.append(isHealthy());
builder.append(", code=");
- builder.append(code);
+ builder.append(getCode());
builder.append(", message=");
- builder.append(message);
+ builder.append(getMessage());
builder.append("]");
return builder.toString();
}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public boolean isHealthy() {
+ return healthy;
+ }
+
+ public void setHealthy(boolean healthy) {
+ this.healthy = healthy;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
}
/**
* Report aggregation
*/
public static class Reports {
- public boolean healthy;
- public ArrayList<Report> details = new ArrayList<>();
+ private boolean healthy;
+ private List<Report> details = new ArrayList<>();
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Reports [healthy=");
- builder.append(healthy);
+ builder.append(isHealthy());
builder.append(", details=");
- builder.append(details);
+ builder.append(getDetails());
builder.append("]");
return builder.toString();
}
+
+ public boolean isHealthy() {
+ return healthy;
+ }
+
+ public void setHealthy(boolean healthy) {
+ this.healthy = healthy;
+ }
+
+ public List<Report> getDetails() {
+ return details;
+ }
+
+ public void setDetails(ArrayList<Report> details) {
+ this.details = details;
+ }
}
/**
@@ -147,41 +204,37 @@ class HealthCheckMonitor implements HealthCheck {
@Override
public Reports healthCheck() {
Reports reports = new Reports();
- reports.healthy = PolicyEngine.manager.isAlive();
+ reports.setHealthy(PolicyEngine.manager.isAlive());
HealthCheck.Report engineReport = new Report();
- engineReport.healthy = PolicyEngine.manager.isAlive();
- engineReport.name = "PDP-D";
- engineReport.url = "self";
- engineReport.code = PolicyEngine.manager.isAlive() ? 200 : 500;
- engineReport.message = PolicyEngine.manager.isAlive() ? "alive" : "not alive";
- reports.details.add(engineReport);
+ engineReport.setHealthy(PolicyEngine.manager.isAlive());
+ engineReport.setName("PDP-D");
+ engineReport.setUrl("self");
+ engineReport.setCode(PolicyEngine.manager.isAlive() ? 200 : 500);
+ engineReport.setMessage(PolicyEngine.manager.isAlive() ? "alive" : "not alive");
+ reports.getDetails().add(engineReport);
for (HttpClient client : clients) {
HealthCheck.Report report = new Report();
- report.name = client.getName();
- report.url = client.getBaseUrl();
- report.healthy = true;
+ report.setName(client.getName());
+ report.setUrl(client.getBaseUrl());
+ report.setHealthy(true);
try {
Response response = client.get();
- report.code = response.getStatus();
- if (report.code != 200) {
- report.healthy = false;
- reports.healthy = false;
- }
-
- try {
- report.message = HttpClient.getBody(response, String.class);
- } catch (Exception e) {
- logger.info("{}: cannot get body from http-client {}", this, client, e);
+ report.setCode(response.getStatus());
+ if (report.getCode() != 200) {
+ report.setHealthy(false);
+ reports.setHealthy(false);
}
+
+ report.setMessage(getHttpBody(response, client));
} catch (Exception e) {
logger.warn("{}: cannot contact http-client {}", this, client, e);
- report.healthy = false;
- reports.healthy = false;
+ report.setHealthy(false);
+ reports.setHealthy(false);
}
- reports.details.add(report);
+ reports.getDetails().add(report);
}
return reports;
}
@@ -198,11 +251,7 @@ class HealthCheckMonitor implements HealthCheck {
this.clients = HttpClient.factory.build(healthCheckProperties);
for (HttpServletServer server : servers) {
- try {
- server.start();
- } catch (Exception e) {
- logger.warn("{}: cannot start http-server {}", this, server, e);
- }
+ startServer(server);
}
} catch (Exception e) {
logger.warn("{}: cannot start {}", this, e);
@@ -256,16 +305,37 @@ class HealthCheckMonitor implements HealthCheck {
/**
* @return list of attached Http Servers
*/
- public ArrayList<HttpServletServer> getServers() {
+ public List<HttpServletServer> getServers() {
return this.servers;
}
/**
* @return list of attached Http Clients
*/
- public ArrayList<HttpClient> getClients() {
+ public List<HttpClient> getClients() {
return this.clients;
}
+
+ public String getHttpBody(Response response, HttpClient client) {
+
+ String body = null;
+ try {
+ body = HttpClient.getBody(response, String.class);
+ } catch (Exception e) {
+ logger.info("{}: cannot get body from http-client {}", this,
+ client, e);
+ }
+
+ return body;
+ }
+
+ public void startServer(HttpServletServer server) {
+ try {
+ server.start();
+ } catch (Exception e) {
+ logger.warn("{}: cannot start http-server {}", this, server, e);
+ }
+ }
@Override
public String toString() {
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index 1c0b45fb..a56483c4 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -131,11 +131,11 @@ public class HealthCheckFeatureTest {
Reports reports = HealthCheck.monitor.healthCheck();
- for (Report rpt : reports.details) {
- if (rpt.name == "HEALTHCHECK") {
- assertTrue(rpt.healthy);
- assertEquals(200,rpt.code);
- assertEquals("All Alive", rpt.message);
+ for (Report rpt : reports.getDetails()) {
+ if (rpt.getName() == "HEALTHCHECK") {
+ assertTrue(rpt.isHealthy());
+ assertEquals(200,rpt.getCode());
+ assertEquals("All Alive", rpt.getMessage());
break;
}
}
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
index b2830e8c..67991c7b 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/DbAudit.java
@@ -24,6 +24,7 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
@@ -38,19 +39,27 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
// get an instance of logger
private static Logger logger = LoggerFactory.getLogger(DbAudit.class);
// single global instance of this audit object
- final static private DbAudit instance = new DbAudit();
+ private static final DbAudit instance = new DbAudit();
// This indicates if 'CREATE TABLE IF NOT EXISTS Audit ...' should be
// invoked -- doing this avoids the need to create the table in advance.
- static private boolean createTableNeeded = true;
+ private static boolean createTableNeeded = true;
- synchronized private static void setCreateTableNeeded(boolean b) {
- DbAudit.createTableNeeded = b;
+ private static boolean isJunit = false;
+
+ /**
+ * Constructor - set the name to 'Database'
+ */
+ private DbAudit()
+ {
+ super("Database");
}
- static private boolean isJunit = false;
+ private static synchronized void setCreateTableNeeded(boolean b) {
+ DbAudit.createTableNeeded = b;
+ }
- synchronized public static void setIsJunit(boolean b) {
+ public static synchronized void setIsJunit(boolean b) {
DbAudit.isJunit = b;
}
@@ -64,15 +73,7 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
*/
public static DroolsPDPIntegrityMonitor.AuditBase getInstance()
{
- return(instance);
- }
-
- /**
- * Constructor - set the name to 'Database'
- */
- private DbAudit()
- {
- super("Database");
+ return instance;
}
/**
@@ -132,64 +133,19 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
if (createTableNeeded)
{
phase = "create table";
- if(logger.isDebugEnabled()){
- logger.info("DbAudit: Creating 'Audit' table, if needed");
- }
- try (PreparedStatement statement = connection.prepareStatement
- ("CREATE TABLE IF NOT EXISTS Audit (\n"
- + " name varchar(64) DEFAULT NULL,\n"
- + " UNIQUE KEY name (name)\n"
- + ") DEFAULT CHARSET=latin1;")) {
- statement.execute();
- DbAudit.setCreateTableNeeded(false);
- } catch (Exception e) {
- throw e;
- }
+ createTable(connection);
}
// insert an entry into the table
phase = "insert entry";
String key = UUID.randomUUID().toString();
- try (PreparedStatement statement = connection.prepareStatement
- ("INSERT INTO Audit (name) VALUES (?)")) {
- statement.setString(1, key);
- statement.executeUpdate();
- } catch (Exception e) {
- throw e;
- }
+ insertEntry(connection, key);
- // fetch the entry from the table
phase = "fetch entry";
- try (PreparedStatement statement = connection.prepareStatement
- ("SELECT name FROM Audit WHERE name = ?")) {
- statement.setString(1, key);
- try (ResultSet rs = statement.executeQuery()) {
- if (rs.first())
- {
- // found entry
- if(logger.isDebugEnabled()){
- logger.debug("DbAudit: Found key {}", rs.getString(1));
- }
- }
- else
- {
- logger.error
- ("DbAudit: can't find newly-created entry with key {}", key);
- setResponse("Can't find newly-created entry");
- }
- } catch (Exception e) {
- throw e;
- }
- }
- // delete entries from table
+ findEntry(connection, key);
+
phase = "delete entry";
- try (PreparedStatement statement = connection.prepareStatement
- ("DELETE FROM Audit WHERE name = ?")) {
- statement.setString(1, key);
- statement.executeUpdate();
- } catch (Exception e) {
- throw e;
- }
+ deleteEntry(connection, key);
}
catch (Exception e)
{
@@ -199,4 +155,90 @@ public class DbAudit extends DroolsPDPIntegrityMonitor.AuditBase
}
}
+ /**
+ * Creates the table.
+ * @param connection
+ * @throws SQLException
+ */
+ private void createTable(Connection connection) throws SQLException {
+ if(logger.isDebugEnabled()){
+ logger.info("DbAudit: Creating 'Audit' table, if needed");
+ }
+ try (PreparedStatement statement = connection.prepareStatement
+ ("CREATE TABLE IF NOT EXISTS Audit (\n"
+ + " name varchar(64) DEFAULT NULL,\n"
+ + " UNIQUE KEY name (name)\n"
+ + ") DEFAULT CHARSET=latin1;")) {
+ statement.execute();
+ DbAudit.setCreateTableNeeded(false);
+ }
+ }
+
+ /**
+ * Inserts an entry.
+ * @param connection
+ * @param key
+ * @throws SQLException
+ */
+ private void insertEntry(Connection connection, String key) throws SQLException {
+ try (PreparedStatement statement = connection.prepareStatement
+ ("INSERT INTO Audit (name) VALUES (?)")) {
+ statement.setString(1, key);
+ statement.executeUpdate();
+ }
+ }
+
+ /**
+ * Finds an entry.
+ * @param connection
+ * @param key
+ * @throws SQLException
+ */
+ private void findEntry(Connection connection, String key) throws SQLException {
+ try (PreparedStatement statement = connection.prepareStatement
+ ("SELECT name FROM Audit WHERE name = ?")) {
+ statement.setString(1, key);
+ getEntry(statement, key);
+ }
+ }
+
+ /**
+ * Executes the query to determine if the entry exists. Sets the response
+ * if it fails.
+ * @param statement
+ * @param key
+ * @throws SQLException
+ */
+ private void getEntry(PreparedStatement statement, String key) throws SQLException {
+ try (ResultSet rs = statement.executeQuery()) {
+ if (rs.first())
+ {
+ // found entry
+ if(logger.isDebugEnabled()){
+ logger.debug("DbAudit: Found key {}", rs.getString(1));
+ }
+ }
+ else
+ {
+ logger.error
+ ("DbAudit: can't find newly-created entry with key {}", key);
+ setResponse("Can't find newly-created entry");
+ }
+ }
+ }
+
+ /**
+ * Deletes an entry.
+ * @param connection
+ * @param key
+ * @throws SQLException
+ */
+ private void deleteEntry(Connection connection, String key) throws SQLException {
+ try (PreparedStatement statement = connection.prepareStatement
+ ("DELETE FROM Audit WHERE name = ?")) {
+ statement.setString(1, key);
+ statement.executeUpdate();
+ }
+ }
+
}
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 915a3225..f599e3dc 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
@@ -40,27 +40,43 @@ import org.slf4j.LoggerFactory;
public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
{
- // get an instance of logger
+ private static final String INVALID_PROPERTY_VALUE = "init: property {} does not have the expected value of {}";
+
+// get an instance of logger
private static final Logger logger = LoggerFactory.getLogger(DroolsPDPIntegrityMonitor.class);
// static global instance
- static private DroolsPDPIntegrityMonitor im = null;
+ private static DroolsPDPIntegrityMonitor im = null;
// list of audits to run
- static private AuditBase[] audits =
+ private static AuditBase[] audits =
new AuditBase[]{DbAudit.getInstance(), RepositoryAudit.getInstance()};
- static private Properties subsystemTestProperties = null;
+ private static Properties subsystemTestProperties = null;
+
+ private static final String PROPERTIES_NAME = "feature-state-management.properties";
- static private final String PROPERTIES_NAME = "feature-state-management.properties";
+ /**
+ * Constructor - pass arguments to superclass, but remember properties
+ * @param resourceName unique name of this Integrity Monitor
+ * @param url the JMX URL of the MBean server
+ * @param properties properties used locally, as well as by
+ * 'IntegrityMonitor'
+ * @throws Exception (passed from superclass)
+ */
+ private DroolsPDPIntegrityMonitor(String resourceName,
+ Properties consolidatedProperties
+ ) throws Exception {
+ super(resourceName, consolidatedProperties);
+ }
- static private void missingProperty(String prop) throws StateManagementPropertiesException{
+ private static 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){
+ private static void logPropertyValue(String prop, String val){
if(logger.isInfoEnabled()){
String msg = "\n\n init: property: " + prop + " = " + val + "\n";
logger.info(msg);
@@ -70,7 +86,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
* Static initialization -- create Drools Integrity Monitor, and
* an HTTP server to handle REST 'test' requests
*/
- static public DroolsPDPIntegrityMonitor init(String configDir) throws Exception
+ public static DroolsPDPIntegrityMonitor init(String configDir) throws Exception
{
logger.info("init: Entering and invoking PropertyUtil.getProperties() on '{}'", configDir);
@@ -110,22 +126,22 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
missingProperty(StateManagementProperties.TEST_PORT);
}
if (!testServices.equals(StateManagementProperties.TEST_SERVICES_DEFAULT)){
- logger.error("init: property {} does not have the expected value of {}",
+ logger.error(INVALID_PROPERTY_VALUE,
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 {}",
+ logger.error(INVALID_PROPERTY_VALUE,
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 {}",
+ logger.warn(INVALID_PROPERTY_VALUE,
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 {}",
+ logger.warn(INVALID_PROPERTY_VALUE,
StateManagementProperties.TEST_SWAGGER,
StateManagementProperties.TEST_SWAGGER_DEFAULT);
}
@@ -211,20 +227,6 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
}
/**
- * Constructor - pass arguments to superclass, but remember properties
- * @param resourceName unique name of this Integrity Monitor
- * @param url the JMX URL of the MBean server
- * @param properties properties used locally, as well as by
- * 'IntegrityMonitor'
- * @throws Exception (passed from superclass)
- */
- private DroolsPDPIntegrityMonitor(String resourceName,
- Properties consolidatedProperties
- ) throws Exception {
- super(resourceName, consolidatedProperties);
- }
-
- /**
* Run tests (audits) unique to Drools PDP VM (Database + Repository)
*/
@Override
@@ -284,7 +286,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
/**
* This is the base class for audits invoked in 'subsystemTest'
*/
- static public abstract class AuditBase
+ public abstract static class AuditBase
{
// name of the audit
protected String name;
@@ -345,18 +347,14 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
}
@Override
- public boolean start() throws IllegalStateException {
+ public boolean start() {
try {
ArrayList<HttpServletServer> servers = HttpServletServer.factory.build(integrityMonitorRestServerProperties);
if (!servers.isEmpty()) {
server = servers.get(0);
- try {
- server.waitedStart(5);
- } catch (Exception e) {
- logger.error("Exception waiting for servers to start: ", e);
- }
+ waitServerStart();
}
} catch (Exception e) {
logger.error("Exception building servers", e);
@@ -366,8 +364,16 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
return true;
}
+ private void waitServerStart() {
+ try {
+ server.waitedStart(5);
+ } catch (Exception e) {
+ logger.error("Exception waiting for servers to start: ", e);
+ }
+ }
+
@Override
- public boolean stop() throws IllegalStateException {
+ public boolean stop() {
try {
server.stop();
} catch (Exception e) {
@@ -378,7 +384,7 @@ public class DroolsPDPIntegrityMonitor extends IntegrityMonitor
}
@Override
- public void shutdown() throws IllegalStateException {
+ public void shutdown() {
this.stop();
}
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
index b36c1657..1e2a3a05 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/RepositoryAudit.java
@@ -46,22 +46,22 @@ public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase
// get an instance of logger
private static Logger logger = LoggerFactory.getLogger(RepositoryAudit.class);
// single global instance of this audit object
- static private RepositoryAudit instance = new RepositoryAudit();
+ private static RepositoryAudit instance = new RepositoryAudit();
/**
- * @return the single 'RepositoryAudit' instance
+ * Constructor - set the name to 'Repository'
*/
- public static DroolsPDPIntegrityMonitor.AuditBase getInstance()
+ private RepositoryAudit()
{
- return instance;
+ super("Repository");
}
/**
- * Constructor - set the name to 'Repository'
+ * @return the single 'RepositoryAudit' instance
*/
- private RepositoryAudit()
+ public static DroolsPDPIntegrityMonitor.AuditBase getInstance()
{
- super("Repository");
+ return instance;
}
/**
@@ -433,34 +433,7 @@ public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase
/*
* 7) Remove the temporary directory
*/
- Files.walkFileTree
- (dir,
- new SimpleFileVisitor<Path>()
- {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
- {
- // logger.info("RepositoryAudit: Delete " + file);
- file.toFile().delete();
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path file, IOException e)
- throws IOException
- {
- if (e == null)
- {
- // logger.info("RepositoryAudit: Delete " + file);
- file.toFile().delete();
- return FileVisitResult.CONTINUE;
- }
- else
- {
- throw e;
- }
- }
- });
+ Files.walkFileTree(dir, new RecursivelyDeleteDirectory());
}
/**
@@ -502,7 +475,37 @@ public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase
return -1;
}
- /* ============================================================ */
+ /**
+ * This class is used to recursively delete a directory and all of its
+ * contents.
+ */
+ private final class RecursivelyDeleteDirectory extends SimpleFileVisitor<Path> {
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
+ {
+ // logger.info("RepositoryAudit: Delete " + file);
+ file.toFile().delete();
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path file, IOException e)
+ throws IOException
+ {
+ if (e == null)
+ {
+ // logger.info("RepositoryAudit: Delete " + file);
+ file.toFile().delete();
+ return FileVisitResult.CONTINUE;
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+/* ============================================================ */
/**
* An instance of this class exists for each artifact that we are trying
@@ -510,7 +513,10 @@ public class RepositoryAudit extends DroolsPDPIntegrityMonitor.AuditBase
*/
static class Artifact
{
- String groupId, artifactId, version, type;
+ String groupId;
+ String artifactId;
+ String version;
+ String type;
/**
* Constructor - populate the 'Artifact' instance
diff --git a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
index 0143c58b..66d806be 100644
--- a/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
+++ b/feature-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeature.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.util.Observer;
import java.util.Properties;
-import org.onap.policy.common.im.StandbyStatusException;
import org.onap.policy.common.im.StateManagement;
import org.onap.policy.drools.core.PolicySessionFeatureAPI;
import org.onap.policy.drools.features.PolicyEngineFeatureAPI;
@@ -64,7 +63,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
}
@Override
- public void globalInit(String args[], String configDir)
+ public void globalInit(String[] args, String configDir)
{
// Initialization code associated with 'PolicyContainer'
if(logger.isDebugEnabled()){
@@ -185,7 +184,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
* {@inheritDoc}
*/
@Override
- public void promote() throws StandbyStatusException, Exception {
+ public void promote() throws Exception {
stateManagement.promote();
}
@@ -241,12 +240,7 @@ public class StateManagementFeature implements StateManagementFeatureAPI,
*/
@Override
public boolean isLocked(){
- String admin = stateManagement.getAdminState();
- if(admin.equals(StateManagement.LOCKED)){
- return true;
- }else{
- return false;
- }
+ return StateManagement.LOCKED.equals(stateManagement.getAdminState());
}
@Override
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
index 51145cd6..59802ebd 100644
--- 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
@@ -22,8 +22,11 @@ package org.onap.policy.drools.statemanagement;
public class StateManagementPropertiesException extends Exception{
private static final long serialVersionUID = 1L;
+
public StateManagementPropertiesException() {
+ super();
}
+
public StateManagementPropertiesException(String message) {
super(message);
}
diff --git a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
index 6f2a0e25..85e0ed85 100644
--- a/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
+++ b/feature-state-management/src/test/java/org/onap/policy/drools/statemanagement/test/StateManagementTest.java
@@ -53,12 +53,6 @@ public class StateManagementTest {
// get an instance of logger
private static Logger logger = LoggerFactory.getLogger(StateManagementTest.class);
- /*
- * Sleep after each test to allow interrupt (shutdown) recovery.
- */
-
- private long interruptRecoveryTime = 1500L;
-
StateManagementFeatureAPI stateManagementFeature;
/*
@@ -134,8 +128,6 @@ public class StateManagementTest {
logger.debug(msg);
}
- Thread.sleep(interruptRecoveryTime);
-
String admin = stateManagementFeature.getAdminState();
String oper = stateManagementFeature.getOpState();
String avail = stateManagementFeature.getAvailStatus();
@@ -155,9 +147,7 @@ public class StateManagementTest {
logger.error(e.getMessage());
assertTrue(e.getMessage(), false);
}
-
- Thread.sleep(interruptRecoveryTime);
-
+
admin = stateManagementFeature.getAdminState();
oper = stateManagementFeature.getOpState();
avail = stateManagementFeature.getAvailStatus();
@@ -179,8 +169,6 @@ public class StateManagementTest {
logger.debug(e.getMessage());
}
- Thread.sleep(interruptRecoveryTime);
-
admin = stateManagementFeature.getAdminState();
oper = stateManagementFeature.getOpState();
avail = stateManagementFeature.getAvailStatus();
diff --git a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/BusPublisher.java b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/BusPublisher.java
index df2088c1..f664cfa7 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/BusPublisher.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/drools/event/comm/bus/internal/BusPublisher.java
@@ -139,10 +139,7 @@ public interface BusPublisher {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("CambriaPublisherWrapper [").
- append("publisher.getPendingMessageCount()=").
- append(publisher.getPendingMessageCount()).
- append("]");
+ builder.append("CambriaPublisherWrapper []");
return builder.toString();
}
@@ -289,7 +286,6 @@ public interface BusPublisher {
append(", publisher.getHost()=").append(publisher.getHost()).
append(", publisher.getProtocolFlag()=").append(publisher.getProtocolFlag()).
append(", publisher.getUsername()=").append(publisher.getUsername()).
- append(", publisher.getPendingMessageCount()=").append(publisher.getPendingMessageCount()).
append("]");
return builder.toString();
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
index d60e817a..583deacc 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java
@@ -357,12 +357,12 @@ class PolicyEngineManager implements PolicyEngine {
/**
* Is the Policy Engine running?
*/
- protected boolean alive = false;
+ protected volatile boolean alive = false;
/**
* Is the engine locked?
*/
- protected boolean locked = false;
+ protected volatile boolean locked = false;
/**
* Properties used to initialize the engine
@@ -1018,7 +1018,7 @@ class PolicyEngineManager implements PolicyEngine {
}
@Override
- public synchronized boolean isAlive() {
+ public boolean isAlive() {
return this.alive;
}
@@ -1117,7 +1117,7 @@ class PolicyEngineManager implements PolicyEngine {
}
@Override
- public synchronized boolean isLocked() {
+ public boolean isLocked() {
return this.locked;
}
diff --git a/pom.xml b/pom.xml
index b5f35624..8e25b619 100644
--- a/pom.xml
+++ b/pom.xml
@@ -292,10 +292,6 @@
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>sonar-maven-plugin</artifactId>
- </plugin>
</plugins>
<pluginManagement>