import java.util.Timer;
import java.util.TimerTask;
import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
-import org.onap.policy.models.pdp.concepts.PdpStateChange;
-import org.onap.policy.models.pdp.enums.PdpState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private Timer timer;
private XacmlPdpMessage heartbeatMessage;
- private Object message;
private static TopicSinkClient topicSinkClient;
private static volatile boolean alive = false;
- public static PdpState pdpState;
-
/**
* Constructor for instantiating XacmlPdpPublisher.
* @param message of the PDP
* @param topicSinkClient used to send heartbeat message
*/
- public XacmlPdpHearbeatPublisher(TopicSinkClient topicSinkClient, PdpStateChange message) {
- this.message = message;
- this.pdpState = message.getState();
+ public XacmlPdpHearbeatPublisher(TopicSinkClient topicSinkClient, XacmlPdpMessage message ) {
this.topicSinkClient = topicSinkClient;
- this.heartbeatMessage = new XacmlPdpMessage();
+ this.heartbeatMessage = message;
timer = new Timer(false);
timer.scheduleAtFixedRate(this, 0, 60000); // time interval temp hard coded now but will be parameterized
setAlive(true);
@Override
public void run() {
- topicSinkClient.send(heartbeatMessage.formatHeartbeatMessage((PdpStateChange) message));
+ topicSinkClient.send(heartbeatMessage.formatPdpStatusMessage());
LOGGER.info("Sending Xacml PDP heartbeat to the PAP");
}
setAlive(false);
}
- public void updateInternalState(PdpState state) {
- ((PdpStateChange) this.message).setState(state);
- this.pdpState = state;
- }
-
public static boolean isAlive() {
return alive;
}