summaryrefslogtreecommitdiffstats
path: root/policy-management
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java10
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java2
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java46
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java41
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java41
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java66
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java11
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java82
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java2
11 files changed, 189 insertions, 118 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
index 9689776c..8a0073c0 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java
@@ -100,12 +100,12 @@ public class MavenDroolsController implements DroolsController {
/**
* recent source events processed
*/
- protected final CircularFifoQueue<Object> recentSourceEvents = new CircularFifoQueue<Object>(10);
+ protected final CircularFifoQueue<Object> recentSourceEvents = new CircularFifoQueue<>(10);
/**
* recent sink events processed
*/
- protected final CircularFifoQueue<String> recentSinkEvents = new CircularFifoQueue<String>(10);
+ protected final CircularFifoQueue<String> recentSinkEvents = new CircularFifoQueue<>(10);
/**
* original Drools Model/Rules classloader hash
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
index 2c4e40be..6dd542c3 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java
@@ -158,7 +158,7 @@ public class NullDroolsController implements DroolsController {
@Override
public Map<String, Integer> factClassNames(String sessionName)
throws IllegalArgumentException {
- return new HashMap<String,Integer>();
+ return new HashMap<>();
}
@Override
diff --git a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
index 905e50c2..b436ef97 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/persistence/FileSystemPersistence.java
@@ -80,13 +80,15 @@ public class FileSystemPersistence implements SystemPersistence {
@Override
public void setConfigurationDir(String configDir) {
- if (configDir == null) {
- configDir = DEFAULT_CONFIGURATION_DIR;
+ String tempConfigDir = configDir;
+
+ if (tempConfigDir == null) {
+ tempConfigDir = DEFAULT_CONFIGURATION_DIR;
this.configurationDirectory = Paths.get(DEFAULT_CONFIGURATION_DIR);
}
- if (!configDir.equals(DEFAULT_CONFIGURATION_DIR))
- this.configurationDirectory = Paths.get(configDir);
+ if (!tempConfigDir.equals(DEFAULT_CONFIGURATION_DIR))
+ this.configurationDirectory = Paths.get(tempConfigDir);
if (Files.notExists(this.configurationDirectory)) {
try {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
index 0a52d254..12d0ffe5 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/coders/JsonProtocolFilter.java
@@ -197,7 +197,7 @@ public class JsonProtocolFilter {
for (FilterRule filter: rules) {
if (filter.regex == null ||
filter.regex.isEmpty() ||
- filter.regex.equals(".*")) {
+ ".*".equals(filter.regex)) {
// Only check for presence
if (!event.has(filter.name)) {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
index b0b8b504..845c4944 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/ControllerConfiguration.java
@@ -198,25 +198,13 @@ public class ControllerConfiguration {
protected boolean declaredProperty(String name, Object value) {
switch (name) {
case "name":
- if (value instanceof String) {
- setName(((String) value));
- } else {
- throw new IllegalArgumentException(("property \"name\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetName(value);
return true;
case "operation":
- if (value instanceof String) {
- setOperation(((String) value));
- } else {
- throw new IllegalArgumentException(("property \"operation\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetOperation(value);
return true;
case "drools":
- if (value instanceof DroolsConfiguration) {
- setDrools(((DroolsConfiguration) value));
- } else {
- throw new IllegalArgumentException(("property \"drools\" is of type \"org.onap.policy.drools.protocol.configuration.Drools\", but got "+ value.getClass().toString()));
- }
+ callSetDrools(value);
return true;
default:
return false;
@@ -250,13 +238,13 @@ public class ControllerConfiguration {
public void set(String name, Object value) {
if (!declaredProperty(name, value)) {
- getAdditionalProperties().put(name, ((Object) value));
+ getAdditionalProperties().put(name, (Object) value);
}
}
public ControllerConfiguration with(String name, Object value) {
if (!declaredProperty(name, value)) {
- getAdditionalProperties().put(name, ((Object) value));
+ getAdditionalProperties().put(name, (Object) value);
}
return this;
}
@@ -277,5 +265,29 @@ public class ControllerConfiguration {
ControllerConfiguration rhs = ((ControllerConfiguration) other);
return new EqualsBuilder().append(name, rhs.name).append(operation, rhs.operation).append(drools, rhs.drools).append(additionalProperties, rhs.additionalProperties).isEquals();
}
+
+ public void callSetName(Object value) {
+ if (value instanceof String) {
+ setName((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"name\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+
+ public void callSetOperation(Object value) {
+ if (value instanceof String) {
+ setOperation((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"operation\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+
+ public void callSetDrools(Object value) {
+ if (value instanceof DroolsConfiguration) {
+ setDrools((DroolsConfiguration) value);
+ } else {
+ throw new IllegalArgumentException("property \"drools\" is of type \"org.onap.policy.drools.protocol.configuration.Drools\", but got "+ value.getClass().toString());
+ }
+ }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
index 4c672e7b..e822d88e 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/DroolsConfiguration.java
@@ -196,25 +196,13 @@ public class DroolsConfiguration {
protected boolean declaredProperty(String name, Object value) {
switch (name) {
case "artifactId":
- if (value instanceof String) {
- setArtifactId((String) value);
- } else {
- throw new IllegalArgumentException(("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetArtifactId(value);
return true;
case "groupId":
- if (value instanceof String) {
- setGroupId((String) value);
- } else {
- throw new IllegalArgumentException(("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetGroupId(value);
return true;
case "version":
- if (value instanceof String) {
- setVersion((String) value);
- } else {
- throw new IllegalArgumentException(("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetVersion(value);
return true;
default:
return false;
@@ -275,5 +263,28 @@ public class DroolsConfiguration {
DroolsConfiguration rhs = ((DroolsConfiguration) other);
return new EqualsBuilder().append(artifactId, rhs.artifactId).append(groupId, rhs.groupId).append(version, rhs.version).append(additionalProperties, rhs.additionalProperties).isEquals();
}
+
+ public void callSetArtifactId(Object value) {
+ if (value instanceof String) {
+ setArtifactId((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"artifactId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+
+ public void callSetGroupId(Object value) {
+ if (value instanceof String) {
+ setGroupId((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"groupId\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+ public void callSetVersion(Object value) {
+ if (value instanceof String) {
+ setVersion((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"version\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
index 8d6f9bfd..c7a227b1 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/protocol/configuration/PdpdConfiguration.java
@@ -201,25 +201,13 @@ public class PdpdConfiguration {
protected boolean declaredProperty(String name, Object value) {
switch (name) {
case "requestID":
- if (value instanceof String) {
- setRequestID((String) value);
- } else {
- throw new IllegalArgumentException(("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetRequestId(value);
return true;
case "entity":
- if (value instanceof String) {
- setEntity((String) value);
- } else {
- throw new IllegalArgumentException(("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
- }
+ callSetEntity(value);
return true;
case "controllers":
- if (value instanceof List) {
- setControllers((List<ControllerConfiguration> ) value);
- } else {
- throw new IllegalArgumentException(("property \"controllers\" is of type \"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", but got "+ value.getClass().toString()));
- }
+ callSetControllers(value);
return true;
default:
return false;
@@ -280,5 +268,28 @@ public class PdpdConfiguration {
PdpdConfiguration rhs = (PdpdConfiguration) other;
return new EqualsBuilder().append(requestID, rhs.requestID).append(entity, rhs.entity).append(controllers, rhs.controllers).append(additionalProperties, rhs.additionalProperties).isEquals();
}
+
+ public void callSetRequestId(Object value) {
+ if (value instanceof String) {
+ setRequestID((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"requestID\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+
+ public void callSetEntity(Object value) {
+ if (value instanceof String) {
+ setEntity((String) value);
+ } else {
+ throw new IllegalArgumentException("property \"entity\" is of type \"java.lang.String\", but got "+ value.getClass().toString());
+ }
+ }
+ public void callSetControllers(Object value) {
+ if (value instanceof List) {
+ setControllers((List<ControllerConfiguration> ) value);
+ } else {
+ throw new IllegalArgumentException("property \"controllers\" is of type \"java.util.List<org.onap.policy.drools.protocol.configuration.Controller>\", but got "+ value.getClass().toString());
+ }
+ }
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
index 93bdc0b2..25f378a7 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java
@@ -1507,15 +1507,15 @@ public class RestManager {
}
final CodingResult result = new CodingResult();
- result.decoding = false;
- result.encoding = false;
- result.jsonEncoding = null;
+ result.setDecoding(false);
+ result.setEncoding(false);
+ result.setJsonEncoding(null);
Object event;
try {
event = EventProtocolCoder.manager.decode(policyController.getDrools().getGroupId(),
policyController.getDrools().getArtifactId(), topic, json);
- result.decoding = true;
+ result.setDecoding(true);
} catch (final Exception e) {
logger.debug("{}: cannot get policy-controller {} topic {} because of {}", this,
controllerName, topic, e.getMessage(), e);
@@ -1523,8 +1523,8 @@ public class RestManager {
}
try {
- result.jsonEncoding = EventProtocolCoder.manager.encode(topic, event);
- result.encoding = true;
+ result.setJsonEncoding(EventProtocolCoder.manager.encode(topic, event));
+ result.setEncoding(true);
} catch (final Exception e) {
// continue so to propagate decoding results ..
logger.debug("{}: cannot encode for policy-controller {} topic {} because of {}", this,
@@ -1978,15 +1978,15 @@ public class RestManager {
@ApiOperation(value = "all active loggers", responseContainer = "List")
@ApiResponses(value = {@ApiResponse(code = 500, message = "logging misconfiguration")})
public Response loggers() {
- final List<String> names = new ArrayList<String>();
+ final List<String> names = new ArrayList<>();
if (!(LoggerFactory.getILoggerFactory() instanceof LoggerContext)) {
logger.warn("The SLF4J logger factory is not configured for logback");
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(names).build();
}
final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- for (final Logger logger : context.getLoggerList()) {
- names.add(logger.getName());
+ for (final Logger lgr : context.getLoggerList()) {
+ names.add(lgr.getName());
}
return Response.status(Status.OK).entity(names).build();
@@ -2006,12 +2006,12 @@ public class RestManager {
}
final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- final ch.qos.logback.classic.Logger logger = context.getLogger(loggerName);
- if (logger == null) {
+ final ch.qos.logback.classic.Logger lgr = context.getLogger(loggerName);
+ if (lgr == null) {
return Response.status(Status.NOT_FOUND).build();
}
- final String loggerLevel = (logger.getLevel() != null) ? logger.getLevel().toString() : "";
+ final String loggerLevel = (lgr.getLevel() != null) ? lgr.getLevel().toString() : "";
return Response.status(Status.OK).entity(loggerLevel).build();
}
@@ -2081,27 +2081,59 @@ public class RestManager {
* serialized output
*/
- public String jsonEncoding;
+ private String jsonEncoding;
/**
* encoding result
*/
- public Boolean encoding;
+ private Boolean encoding;
/**
* decoding result
*/
- public Boolean decoding;
+ private Boolean decoding;
+
+ public String getJsonEncoding() {
+ return jsonEncoding;
+ }
+
+ public void setJsonEncoding(String jsonEncoding) {
+ this.jsonEncoding = jsonEncoding;
+ }
+
+ public Boolean getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(Boolean encoding) {
+ this.encoding = encoding;
+ }
+
+ public Boolean getDecoding() {
+ return decoding;
+ }
+
+ public void setDecoding(Boolean decoding) {
+ this.decoding = decoding;
+ }
}
/**
* Generic Error Reporting class
*/
public static class Error {
- public String error;
+ private String error;
public Error(String error) {
- this.error = error;
+ this.setError(error);
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
}
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
index d0b625d7..8c188c0b 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyControllerFactory.java
@@ -349,18 +349,19 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory {
* @throws IllegalArgumentException
*/
protected void unmanage(PolicyController controller) throws IllegalArgumentException {
- if (controller == null) {
+ PolicyController tempController = controller;
+ if (tempController == null) {
throw new IllegalArgumentException("Invalid Controller");
}
synchronized(this) {
- if (!this.policyControllers.containsKey(controller.getName())) {
+ if (!this.policyControllers.containsKey(tempController.getName())) {
return;
}
- controller = this.policyControllers.remove(controller.getName());
+ tempController = this.policyControllers.remove(tempController.getName());
- String coordinates = toKey(controller.getDrools().getGroupId(),
- controller.getDrools().getArtifactId());
+ String coordinates = toKey(tempController.getDrools().getGroupId(),
+ tempController.getDrools().getArtifactId());
this.coordinates2Controller.remove(coordinates);
}
}
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 583deacc..c90d8bea 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
@@ -387,7 +387,7 @@ class PolicyEngineManager implements PolicyEngine {
/**
* Policy Engine HTTP Servers
*/
- protected List<HttpServletServer> httpServers = new ArrayList<HttpServletServer>();
+ protected List<HttpServletServer> httpServers = new ArrayList<>();
/**
* gson parser to decode configuration requests
@@ -459,7 +459,7 @@ class PolicyEngineManager implements PolicyEngine {
TELEMETRY_SERVER_DEFAULT_HOST);
defaultConfig.put(PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "."
+ TELEMETRY_SERVER_DEFAULT_NAME + PolicyProperties.PROPERTY_HTTP_PORT_SUFFIX,
- "" + TELEMETRY_SERVER_DEFAULT_PORT);
+ "" + Integer.toString(TELEMETRY_SERVER_DEFAULT_PORT));
defaultConfig.put(
PolicyProperties.PROPERTY_HTTP_SERVER_SERVICES + "." + TELEMETRY_SERVER_DEFAULT_NAME
+ PolicyProperties.PROPERTY_HTTP_REST_PACKAGES_SUFFIX,
@@ -534,24 +534,25 @@ class PolicyEngineManager implements PolicyEngine {
public synchronized PolicyController createPolicyController(String name, Properties properties)
throws IllegalArgumentException, IllegalStateException {
+ String tempName = name;
// check if a PROPERTY_CONTROLLER_NAME property is present
// if so, override the given name
final String propertyControllerName =
properties.getProperty(PolicyProperties.PROPERTY_CONTROLLER_NAME);
if (propertyControllerName != null && !propertyControllerName.isEmpty()) {
- if (!propertyControllerName.equals(name)) {
- throw new IllegalStateException("Proposed name (" + name + ") and properties name ("
+ if (!propertyControllerName.equals(tempName)) {
+ throw new IllegalStateException("Proposed name (" + tempName + ") and properties name ("
+ propertyControllerName + ") don't match");
}
- name = propertyControllerName;
+ tempName = propertyControllerName;
}
PolicyController controller;
for (final PolicyControllerFeatureAPI controllerFeature : PolicyControllerFeatureAPI.providers
.getList()) {
try {
- controller = controllerFeature.beforeCreate(name, properties);
+ controller = controllerFeature.beforeCreate(tempName, properties);
if (controller != null)
return controller;
} catch (final Exception e) {
@@ -560,7 +561,7 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- controller = PolicyController.factory.build(name, properties);
+ controller = PolicyController.factory.build(tempName, properties);
if (this.isLocked())
controller.lock();
@@ -589,22 +590,8 @@ class PolicyEngineManager implements PolicyEngine {
final String entity = config.getEntity();
switch (entity) {
- case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
- /* only this one supported for now */
- final List<ControllerConfiguration> configControllers = config.getControllers();
- if (configControllers == null || configControllers.isEmpty()) {
- if (logger.isInfoEnabled())
- logger.info("No controller configuration provided: " + config);
- return false;
- }
- final List<PolicyController> policyControllers =
- this.updatePolicyControllers(config.getControllers());
- if (policyControllers == null || policyControllers.isEmpty())
- return false;
- else if (policyControllers.size() == configControllers.size())
- return true;
-
- return false;
+ case PdpdConfiguration.CONFIG_ENTITY_CONTROLLER:
+ return controllerConfig(config);
default:
final String msg = "Configuration Entity is not supported: " + entity;
logger.warn(msg);
@@ -617,7 +604,7 @@ class PolicyEngineManager implements PolicyEngine {
List<ControllerConfiguration> configControllers)
throws IllegalArgumentException, IllegalStateException {
- final List<PolicyController> policyControllers = new ArrayList<PolicyController>();
+ final List<PolicyController> policyControllers = new ArrayList<>();
if (configControllers == null || configControllers.isEmpty()) {
if (logger.isInfoEnabled())
logger.info("No controller configuration provided: " + configControllers);
@@ -677,14 +664,14 @@ class PolicyEngineManager implements PolicyEngine {
logger.warn("controller " + controllerName + " does not exist. "
+ "Attempting recovery from disk");
- final Properties properties =
+ final Properties controllerProperties =
SystemPersistence.manager.getControllerProperties(controllerName);
/*
* returned properties cannot be null (per implementation) assert (properties != null)
*/
- if (properties == null) {
+ if (controllerProperties == null) {
throw new IllegalArgumentException(controllerName + " is invalid");
}
@@ -695,11 +682,11 @@ class PolicyEngineManager implements PolicyEngine {
* try to bring up bad controller in brainless mode, after having it working, apply the new
* create/update operation.
*/
- properties.setProperty(PolicyProperties.RULES_GROUPID, DroolsController.NO_GROUP_ID);
- properties.setProperty(PolicyProperties.RULES_ARTIFACTID, DroolsController.NO_ARTIFACT_ID);
- properties.setProperty(PolicyProperties.RULES_VERSION, DroolsController.NO_VERSION);
+ controllerProperties.setProperty(PolicyProperties.RULES_GROUPID, DroolsController.NO_GROUP_ID);
+ controllerProperties.setProperty(PolicyProperties.RULES_ARTIFACTID, DroolsController.NO_ARTIFACT_ID);
+ controllerProperties.setProperty(PolicyProperties.RULES_VERSION, DroolsController.NO_VERSION);
- policyController = PolicyEngine.manager.createPolicyController(controllerName, properties);
+ policyController = PolicyEngine.manager.createPolicyController(controllerName, controllerProperties);
/* fall through to do brain update operation */
}
@@ -1140,7 +1127,7 @@ class PolicyEngineManager implements PolicyEngine {
@JsonProperty("controllers")
@Override
public List<String> getPolicyControllerIds() {
- final List<String> controllerNames = new ArrayList<String>();
+ final List<String> controllerNames = new ArrayList<>();
for (final PolicyController controller : PolicyController.factory.inventory()) {
controllerNames.add(controller.getName());
}
@@ -1173,7 +1160,7 @@ class PolicyEngineManager implements PolicyEngine {
@Override
public List<String> getFeatures() {
- final List<String> features = new ArrayList<String>();
+ final List<String> features = new ArrayList<>();
for (final PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
features.add(feature.getName());
}
@@ -1231,12 +1218,12 @@ class PolicyEngineManager implements PolicyEngine {
if (this.isLocked())
throw new IllegalStateException("Policy Engine is locked");
- final List<? extends TopicSink> sinks = TopicEndpoint.manager.getTopicSinks(topic);
- if (sinks == null || sinks.isEmpty() || sinks.size() > 1)
+ final List<? extends TopicSink> topicSinks = TopicEndpoint.manager.getTopicSinks(topic);
+ if (topicSinks == null || topicSinks.isEmpty() || topicSinks.size() > 1)
throw new IllegalStateException(
- "Cannot ensure correct delivery on topic " + topic + ": " + sinks);
+ "Cannot ensure correct delivery on topic " + topic + ": " + topicSinks);
- return this.deliver(sinks.get(0).getTopicCommInfrastructure(), topic, event);
+ return this.deliver(topicSinks.get(0).getTopicCommInfrastructure(), topic, event);
}
@Override
@@ -1417,10 +1404,7 @@ class PolicyEngineManager implements PolicyEngine {
for (final PolicyController policyController : this.getPolicyControllers()) {
try {
policyController.stop();
- } catch (final Exception e) {
- logger.error("{}: cannot deactivate (stop) policy-controller {} because of {}", this,
- policyController, e.getMessage(), e);
- } catch (final LinkageError e) {
+ } catch (final Exception | LinkageError e) {
logger.error("{}: cannot deactivate (stop) policy-controller {} because of {}", this,
policyController, e.getMessage(), e);
}
@@ -1437,6 +1421,24 @@ class PolicyEngineManager implements PolicyEngine {
}
}
}
+
+ public boolean controllerConfig(PdpdConfiguration config) {
+ /* only this one supported for now */
+ final List<ControllerConfiguration> configControllers = config.getControllers();
+ if (configControllers == null || configControllers.isEmpty()) {
+ if (logger.isInfoEnabled())
+ logger.info("No controller configuration provided: " + config);
+ return false;
+ }
+ final List<PolicyController> policyControllers =
+ this.updatePolicyControllers(config.getControllers());
+ if (policyControllers == null || policyControllers.isEmpty())
+ return false;
+ else if (policyControllers.size() == configControllers.size())
+ return true;
+
+ return false;
+ }
@Override
public String toString() {
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
index e67e542f..0645bdc5 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java
@@ -74,7 +74,7 @@ public class AggregatedPolicyController implements PolicyController,
*/
@JsonIgnore
protected final HashMap<String, TopicSink> topic2Sinks =
- new HashMap<String, TopicSink>();
+ new HashMap<>();
/**
* Is this Policy Controller running (alive) ?