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;
@Setter(lombok.AccessLevel.PRIVATE)
private volatile boolean alive = false;
+ @Getter
+ private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
+
/**
* Instantiate the activator for onappf PDP-A.
*
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);
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",
() -> 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",
pdpStatus.setHealthy(PdpHealthStatus.HEALTHY);
pdpStatus.setDescription(pdpStatusParameters.getDescription());
pdpStatus.setName(instanceId);
- pdpStatus.setSupportedPolicyTypes(getSupportedPolicyTypesFromParameters(pdpStatusParameters));
return pdpStatus;
}
* @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());
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());