Added unique name to PdpStatus and HealthCheckReports.
Issue-ID: POLICY-3410
Change-Id: Ife2248ffee9afae76f3eaab7f8b33dba8bdb4019
Signed-off-by: Jim Hahn <jrh3@att.com>
// The logger for this class
private static final Logger LOGGER = LoggerFactory.getLogger(XacmlState.class);
+ /**
+ * Unique name for the xacml-pdp JVM, used in PdpStatus messages.
+ */
+ public static final String PDP_NAME = NetworkUtil.genUniqueName("xacml");
+
/**
* The application manager.
*/
this.appManager = appManager;
this.status = new PdpStatus();
- this.status.setName(NetworkUtil.getHostname());
+ this.status.setName(PDP_NAME);
this.status.setPdpType(pdpType);
this.status.setState(PdpState.PASSIVE);
this.status.setPolicies(Collections.emptyList());
package org.onap.policy.pdpx.main.rest.provider;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
/**
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String URL = "self";
- private static final String NAME = "Policy Xacml PDP";
/**
* Performs the health check of xacml pdp service.
*/
public HealthCheckReport performHealthCheck() {
final var report = new HealthCheckReport();
- report.setName(NAME);
+ report.setName(XacmlState.PDP_NAME);
report.setUrl(URL);
boolean alive = XacmlPdpActivator.getCurrent().isAlive();
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
@Mock
private XacmlPdpActivator act;
- private String hostName;
+ private String pdpName;
private XacmlState state;
*/
@Before
public void setUp() {
- hostName = NetworkUtil.getHostname();
+ pdpName = XacmlState.PDP_NAME;
XacmlPdpActivator.setCurrent(act);
PdpUpdate msg = new PdpUpdate();
assertFalse(state.shouldHandle(msg));
- msg.setName(NetworkUtil.getHostname());
+ msg.setName(XacmlState.PDP_NAME);
assertTrue(state.shouldHandle(msg));
}
// not healthy
PdpStatus status = state.genHeartbeat();
assertEquals(PdpHealthStatus.NOT_HEALTHY, status.getHealthy());
- assertEquals(hostName, status.getName());
+ assertEquals(pdpName, status.getName());
assertEquals(GROUP, status.getPdpGroup());
assertEquals(PDP_TYPE, status.getPdpType());
assertEquals(PdpState.PASSIVE, status.getState());
@Test
public void testUpdateInternalStatePdpStateChange() {
PdpStateChange req = new PdpStateChange();
- req.setName(hostName);
+ req.setName(pdpName);
req.setPdpGroup("wrong-pdp-group");
req.setPdpSubgroup(SUBGROUP);
req.setState(STATE);
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.Test;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
import org.onap.policy.pdpx.main.CommonRest;
+import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.rest.model.StatisticsReport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String SELF = "self";
- private static final String NAME = "Policy Xacml PDP";
+ private static final String NAME = XacmlState.PDP_NAME;
private static final String HEALTHCHECK_ENDPOINT = "healthcheck";
private static final String STATISTICS_ENDPOINT = "statistics";