diff options
author | rameshiyer27 <ramesh.murugan.iyer@est.tech> | 2021-06-15 18:22:04 +0100 |
---|---|---|
committer | rameshiyer27 <ramesh.murugan.iyer@est.tech> | 2021-06-16 11:03:26 +0100 |
commit | 43fb6c9a683efb014c40d5736419cb0085556642 (patch) | |
tree | 0777ca250d3c2d0af417d29e46e7c5840b3bd429 | |
parent | 399e86d983057304673f701a22b172a69d5aa7dc (diff) |
Fix CLAMP build failure and kub-participant module startup issue.
Initialising ParticipantK8sParameters in the constructor to fix Null pointer Exception in kub-participant module.
Constructor cannot use autowired properties.
Updated pfDao getFiltered method signature to align with latest code in policy models.
Issue-ID: POLICY-3240
Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech>
Change-Id: I9405c1e050b31b153ee53829ffece9f4be27818e
5 files changed, 42 insertions, 16 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java index dacde8e79..00eab8f69 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java @@ -30,6 +30,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementSt import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfReferenceTimestampKey; +import org.onap.policy.models.dao.PfFilterParameters; import org.onap.policy.models.provider.PolicyModelsProviderParameters; import org.onap.policy.models.provider.impl.AbstractModelsProvider; @@ -130,7 +131,19 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider { public List<ClElementStatistics> getFilteredClElementStatistics(final String name, final String version, final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, final String sortOrder, final int getRecordNum) { - return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, name, version, - startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); + + // @formatter:off + PfFilterParameters filterParams = PfFilterParameters + .builder() + .name(name) + .version(version) + .startTime(startTimeStamp) + .endTime(endTimeStamp) + .filterMap(filterMap) + .sortOrder(sortOrder) + .recordNum(getRecordNum) + .build(); + // @formatter:on + return asClElementStatisticsList(getPfDao().getFiltered(JpaClElementStatistics.class, filterParams)); } } diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java index 4ea76ff4b..137af3a5e 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java @@ -30,6 +30,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.base.PfTimestampKey; +import org.onap.policy.models.dao.PfFilterParameters; import org.onap.policy.models.provider.PolicyModelsProviderParameters; import org.onap.policy.models.provider.impl.AbstractModelsProvider; @@ -87,8 +88,20 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider { final Instant startTimeStamp, final Instant endTimeStamp, Map<String, Object> filterMap, final String sortOrder, final int getRecordNum) { - return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, name, version, - startTimeStamp, endTimeStamp, filterMap, sortOrder, getRecordNum)); + // @formatter:off + PfFilterParameters filterParams = PfFilterParameters + .builder() + .name(name) + .version(version) + .startTime(startTimeStamp) + .endTime(endTimeStamp) + .filterMap(filterMap) + .sortOrder(sortOrder) + .recordNum(getRecordNum) + .build(); + // @formatter:on + + return asParticipantStatisticsList(getPfDao().getFiltered(JpaParticipantStatistics.class, filterParams)); } diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java index 456122f3d..1b7599ce9 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java @@ -113,8 +113,6 @@ public class HelmClient { static String executeCommand(ProcessBuilder processBuilder) throws ServiceException { var commandStr = toString(processBuilder); - processBuilder.redirectInput(ProcessBuilder.Redirect.DISCARD); - try { var process = processBuilder.start(); process.waitFor(); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java index 2d0ce7a83..041c0c810 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java @@ -51,8 +51,7 @@ public class ChartStore { private static final StandardCoder STANDARD_CODER = new StandardCoder(); - @Autowired - private ParticipantK8sParameters participantK8sParameters; + private final ParticipantK8sParameters participantK8sParameters; /** * The chartStore map contains chart name as key & ChartInfo as value. @@ -62,7 +61,8 @@ public class ChartStore { /** * Constructor method. */ - public ChartStore() { + public ChartStore(@Autowired ParticipantK8sParameters participantK8sParameters) { + this.participantK8sParameters = participantK8sParameters; this.restoreFromLocalFileSystem(); } @@ -177,12 +177,11 @@ public class ChartStore { } private synchronized void restoreFromLocalFileSystem() { - Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); - try { + Path localChartDirectoryPath = Paths.get(participantK8sParameters.getLocalChartDirectory()); Files.createDirectories(localChartDirectoryPath); restoreFromLocalFileSystem(localChartDirectoryPath); - } catch (IOException ioe) { + } catch (Exception ioe) { LOGGER.warn("Could not restore charts from local file system: {}", ioe); } } @@ -194,8 +193,11 @@ public class ChartStore { @Override public FileVisitResult visitFile(Path localChartFile, BasicFileAttributes attrs) throws IOException { try { - ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); - localChartMap.put(key(chart), chart); + // Decode only the json file excluding the helm charts + if (localChartFile.endsWith(participantK8sParameters.getInfoFileName())) { + ChartInfo chart = STANDARD_CODER.decode(localChartFile.toFile(), ChartInfo.class); + localChartMap.put(key(chart), chart); + } return FileVisitResult.CONTINUE; } catch (CoderException ce) { throw new IOException("Error decoding chart file", ce); diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json index 620e05552..e854a9375 100644 --- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json +++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/KubernetesParticipantConfig.json @@ -49,8 +49,8 @@ "implementation":"org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl", "databaseDriver":"org.mariadb.jdbc.Driver", "databaseUrl":"jdbc:mariadb://localhost:3306/controlloop", - "databaseUser":"admin", - "databasePassword":"passme", + "databaseUser":"policy", + "databasePassword":"P01icY", "persistenceUnit":"ToscaConceptTest" } } |