diff options
Diffstat (limited to 'services/services-onappf/src')
5 files changed, 36 insertions, 15 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java index affbf39e9..ec2f5b34a 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/ApexStarterActivator.java @@ -36,10 +36,12 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSink; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; +import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.common.utils.services.ServiceManager; import org.onap.policy.common.utils.services.ServiceManagerException; import org.onap.policy.models.pdp.enums.PdpMessageType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +77,9 @@ public class ApexStarterActivator { @Setter(lombok.AccessLevel.PRIVATE) private volatile boolean alive = false; + @Getter + private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes; + /** * Instantiate the activator for onappf PDP-A. * @@ -88,10 +93,8 @@ public class ApexStarterActivator { topicSources = TopicEndpointManager.getManager() .addTopicSources(apexStarterParameterGroup.getTopicParameterGroup().getTopicSources()); - // TODO: instanceId currently set as a random string, could be fetched from actual deployment - final int random = (int) (Math.random() * 100); - final String instanceId = "apex_" + random; - LOGGER.debug("ApexStarterActivator initializing with instance id:" + instanceId); + final String instanceId = NetworkUtil.getHostname(); + LOGGER.debug("ApexStarterActivator initializing with instance id: {}", instanceId); try { this.apexStarterParameterGroup = apexStarterParameterGroup; this.msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES); @@ -101,6 +104,10 @@ public class ApexStarterActivator { final PdpUpdateListener pdpUpdateListener = new PdpUpdateListener(); final PdpStateChangeListener pdpStateChangeListener = new PdpStateChangeListener(); + final PdpMessageHandler pdpMessageHandler = new PdpMessageHandler(); + supportedPolicyTypes = + pdpMessageHandler.getSupportedPolicyTypesFromParameters(apexStarterParameterGroup.getPdpStatusParameters()); + // @formatter:off this.manager = new ServiceManager() .addAction("topics", @@ -111,7 +118,7 @@ public class ApexStarterActivator { () -> setAlive(false)) .addAction("register pdp status context object", () -> Registry.register(ApexStarterConstants.REG_PDP_STATUS_OBJECT, - new PdpMessageHandler().createPdpStatusFromParameters(instanceId, + pdpMessageHandler.createPdpStatusFromParameters(instanceId, apexStarterParameterGroup.getPdpStatusParameters())), () -> Registry.unregister(ApexStarterConstants.REG_PDP_STATUS_OBJECT)) .addAction("topic sinks", diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java index b1f38d688..697f3d47f 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java @@ -59,7 +59,6 @@ public class PdpMessageHandler { pdpStatus.setHealthy(PdpHealthStatus.HEALTHY); pdpStatus.setDescription(pdpStatusParameters.getDescription()); pdpStatus.setName(instanceId); - pdpStatus.setSupportedPolicyTypes(getSupportedPolicyTypesFromParameters(pdpStatusParameters)); return pdpStatus; } @@ -69,7 +68,7 @@ public class PdpMessageHandler { * @param pdpStatusParameters pdp status parameters * @return supportedPolicyTypes list of PolicyTypeIdent */ - private List<ToscaPolicyTypeIdentifier> getSupportedPolicyTypesFromParameters( + public List<ToscaPolicyTypeIdentifier> getSupportedPolicyTypesFromParameters( final PdpStatusParameters pdpStatusParameters) { final List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>(pdpStatusParameters.getSupportedPolicyTypes().size()); @@ -94,7 +93,6 @@ public class PdpMessageHandler { pdpStatus.setState(pdpStatusContext.getState()); pdpStatus.setHealthy(pdpStatusContext.getHealthy()); pdpStatus.setDescription(pdpStatusContext.getDescription()); - pdpStatus.setSupportedPolicyTypes(pdpStatusContext.getSupportedPolicyTypes()); pdpStatus.setPolicies(pdpStatusContext.getPolicies()); pdpStatus.setPdpGroup(pdpStatusContext.getPdpGroup()); pdpStatus.setPdpSubgroup(pdpStatusContext.getPdpSubgroup()); diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyStateFinalizerExecutor.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyStateFinalizerExecutor.java index cdbd27b8f..6f2474aa1 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyStateFinalizerExecutor.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyStateFinalizerExecutor.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.services.onappf.parameters.dummyclasses; import java.util.Map; import java.util.Properties; + import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor; import org.onap.policy.apex.core.engine.executor.exception.StateMachineException; @@ -31,7 +32,9 @@ import org.onap.policy.apex.core.engine.executor.exception.StateMachineException * Dummy state finalizer executor for testing. */ public class DummyStateFinalizerExecutor extends StateFinalizerExecutor { - public DummyStateFinalizerExecutor() {} + public DummyStateFinalizerExecutor() { + // Default constructor + } @Override public String execute(final long executionId, final Properties executorProperties, diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java index d3fa9b570..387479b12 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskExecutor.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.services.onappf.parameters.dummyclasses; import java.util.Map; import java.util.Properties; + import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.TaskExecutor; @@ -34,10 +35,14 @@ import org.onap.policy.apex.model.policymodel.concepts.AxTask; * Dummy task executor for testing. */ public class DummyTaskExecutor extends TaskExecutor { - public DummyTaskExecutor() {} + public DummyTaskExecutor() { + // Default constructor + } @Override - public void prepare() throws StateMachineException {} + public void prepare() throws StateMachineException { + // Not used + } @Override public Map<String, Object> execute(final long executionId, final Properties executorProperties, @@ -54,5 +59,7 @@ public class DummyTaskExecutor extends TaskExecutor { } @Override - public void cleanUp() throws StateMachineException {} + public void cleanUp() throws StateMachineException { + // Not used + } } diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskSelectExecutor.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskSelectExecutor.java index b27ff6ebc..b6e0dd432 100644 --- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskSelectExecutor.java +++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/parameters/dummyclasses/DummyTaskSelectExecutor.java @@ -22,6 +22,7 @@ package org.onap.policy.apex.services.onappf.parameters.dummyclasses; import java.util.Properties; + import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.core.engine.event.EnEvent; import org.onap.policy.apex.core.engine.executor.TaskSelectExecutor; @@ -32,10 +33,13 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; * Dummy task selection executor for testing. */ public class DummyTaskSelectExecutor extends TaskSelectExecutor { - public DummyTaskSelectExecutor() {} + public DummyTaskSelectExecutor() { + } @Override - public void prepare() throws StateMachineException {} + public void prepare() throws StateMachineException { + // Not used + } @Override public AxArtifactKey execute(final long executionId, final Properties executorProperties, @@ -45,5 +49,7 @@ public class DummyTaskSelectExecutor extends TaskSelectExecutor { } @Override - public void cleanUp() throws StateMachineException {} + public void cleanUp() throws StateMachineException { + // Not used + } } |