diff options
author | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2020-08-12 08:25:21 +0200 |
---|---|---|
committer | Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> | 2020-08-12 08:26:10 +0200 |
commit | 1e9b47aa36b47e60dd2a0d028a8080cf25054ad2 (patch) | |
tree | 597e1170899854f7cd7e9c1c0a3a9587a1268692 /sdnr/wt/data-provider/provider/src | |
parent | cd29d2dd98b7c40bd4efb6a8705787ca35e99fe9 (diff) |
organize java sources and optimization
organize java sources and optimization - for better readability and clean segregation
Issue-ID: CCSDK-2639
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I4547b42f3a0fc86283a934bc82a30b591648715e
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/provider/src')
33 files changed, 533 insertions, 62 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java index 30e617ab6..e8d573b79 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java @@ -25,7 +25,13 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.DataObjectAcessorPm.Intervall; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorPm; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorPm.Intervall; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorStatus; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorWithId; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity.HtDatabaseEventsService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity.HtDatabaseMaintenanceService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryResult; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateMaintenanceInput; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java index c229006ff..4998c3031 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorWithId; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data; import org.slf4j.Logger; @@ -47,14 +48,14 @@ public class MediatorServerDataProvider implements AutoCloseable { private boolean isRunning; public MediatorServerDataProvider(HostInfo[] hosts) throws Exception { - this(hosts, null, null); + this(hosts, null, null, false); } - public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception { + public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAll) throws Exception { super(); LOG.info("Start {}", this.getClass().getName()); this.entries = new HashMap<>(); - this.dbClient = HtDatabaseClient.getClient(hosts, authUsername, authPassword); + this.dbClient = HtDatabaseClient.getClient(hosts, authUsername, authPassword, trustAll); this.mediatorserverRW = new DataObjectAcessorWithId<>(dbClient, Entity.MediatorServer, Data.class); this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS); } diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessor.java index c3c63a963..90915fc63 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessor.java @@ -19,11 +19,13 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryByFilter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryResult; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorPm.java index 83017366d..aa9da01ad 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorPm.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor; import java.io.IOException; @@ -29,6 +29,8 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryByFilter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryResult; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; import org.opendaylight.yangtools.yang.binding.DataObject; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java index 1fa6de37d..f6fc60e2f 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor; import java.io.IOException; @@ -30,6 +30,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntries; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryResult; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.DataBuilder; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorWithId.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorWithId.java index 10dd7792c..accd1d894 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorWithId.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorWithId.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : ccsdk features * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. + * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. * All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Entity; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/FaultEntityManager.java index 7efdab110..46252651f 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/FaultEntityManager.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java index 4efbf6e28..46475f02d 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity; import java.util.ArrayList; import java.util.Arrays; @@ -35,6 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.ArchiveCleanProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseMaintenanceService.java index 3e9a93902..1cb7c3a6e 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseMaintenanceService.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity; import java.util.ArrayList; import java.util.List; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilter.java index 4e7bee9d0..a12391acd 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilter.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper; import java.math.BigInteger; import java.util.ArrayList; @@ -36,6 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorPm; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilterStatic.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilterStatic.java index 4abe65856..3e4fcfedd 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilterStatic.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilterStatic.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper; import java.util.Arrays; import java.util.Calendar; @@ -32,6 +32,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.BoolQueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorPm; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java index 7570523cd..544cd059c 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper; import java.math.BigInteger; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java index fdac1c10a..9ac0cc0c3 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java @@ -19,39 +19,32 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about; import java.io.IOException; import java.net.URL; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.jar.Attributes; import java.util.jar.Manifest; - import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - //import org.apache.karaf.bundle.core.BundleInfo; //import org.apache.karaf.bundle.core.BundleService; import org.onap.ccsdk.features.sdnr.wt.common.Resources; import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile; import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AboutHttpServlet extends HttpServlet { /** - * + * */ private static final long serialVersionUID = 1L; private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class); @@ -107,7 +100,6 @@ public class AboutHttpServlet extends HttpServlet { this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN)); this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN)); this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : ""); - this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno")); this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version")); this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion); this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "2.0.0-SNAPSHOT"); @@ -154,7 +146,7 @@ public class AboutHttpServlet extends HttpServlet { /** * load git.commit.id from jar /META-INF/git.properties - * + * * @param def */ private String getGitHash(String def) { @@ -192,7 +184,7 @@ public class AboutHttpServlet extends HttpServlet { /** * get value for key out of /META-INF/MANIFEST.MF - * + * * @param key * @return */ @@ -215,7 +207,7 @@ public class AboutHttpServlet extends HttpServlet { /** * get object representation of /META-INF/maven/groupId/artifactId/pom.properties - * + * * @return */ private PomPropertiesFile getPomProperties() { @@ -236,7 +228,7 @@ public class AboutHttpServlet extends HttpServlet { /** * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section - * + * * @param key * @return */ @@ -259,7 +251,7 @@ public class AboutHttpServlet extends HttpServlet { /** * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml - * + * * @return */ private String getPomParentVersion() { @@ -284,7 +276,7 @@ public class AboutHttpServlet extends HttpServlet { // LOG.debug("no bundle service available"); // return ""; // } - // + // // List<String> ids = new ArrayList<String>(); // List<Bundle> bundles = bundleService.selectBundles("0", ids , true); // if(bundles==null || bundles.size()<=0) { @@ -303,7 +295,7 @@ public class AboutHttpServlet extends HttpServlet { /** * get file by uri from resources and write out to response stream - * + * * @param uri * @param resp */ @@ -330,7 +322,7 @@ public class AboutHttpServlet extends HttpServlet { /** * create http response contentType by filename - * + * * @param filename * @return */ @@ -358,7 +350,7 @@ public class AboutHttpServlet extends HttpServlet { /** * render this.readmeContent with this.data - * + * * @return */ private String render() { @@ -367,7 +359,7 @@ public class AboutHttpServlet extends HttpServlet { /** * render content with this.data - * + * * @param content * @return */ diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MarkdownTable.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java index 52eda0cd8..9fd6975b6 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MarkdownTable.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about; import java.util.ArrayList; import java.util.List; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java index 3ea3e3d02..bd8fae6a0 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ODLVersionLUT.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about; public class ODLVersionLUT { diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java index 12b03ffe6..1497362a6 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/SystemInfo.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/SystemInfo.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about; import java.io.File; import java.io.IOException; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/GetYangSchemaRequest.java index fd2784804..cc1a2c39c 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/GetYangSchemaRequest.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema; import javax.servlet.http.HttpServletRequest; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java index 4f259aa4b..0d46ad098 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema; import java.io.File; import java.io.FileInputStream; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java index e5d0b18cd..eb4961a66 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.data; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema; import java.text.ParseException; import java.text.SimpleDateFormat; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java index 48862a6a5..83518ecb2 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= * */ -package org.onap.ccsdk.features.sdnr.wt.dataprovider.http; +package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema; import java.io.IOException; import java.text.ParseException; @@ -28,7 +28,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java index f9e0fcbc2..ac0ee92f1 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java @@ -22,10 +22,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider; diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java index 4b8564395..6eabc969b 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java @@ -21,11 +21,11 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl; +import com.google.common.util.concurrent.ListenableFuture; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.concurrent.TimeUnit; - import org.eclipse.jdt.annotation.NonNull; import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; @@ -94,8 +94,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.util.concurrent.ListenableFuture; - public class DataProviderServiceImpl implements DataProviderService, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(DataProviderServiceImpl.class); @@ -116,7 +114,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab esConfig.getBasicAuthPassword(), esConfig.trustAllCerts()); this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS); this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(), - esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword()); + esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword(),esConfig.trustAllCerts()); mediatorServerServlet.setDataProvider(this.mediatorServerDataProvider); // Register ourselves as the REST API RPC implementation LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName()); diff --git a/sdnr/wt/data-provider/provider/src/main/resources/about/README.md b/sdnr/wt/data-provider/provider/src/main/resources/about/README.md index 58091d5da..17c3825fd 100644 --- a/sdnr/wt/data-provider/provider/src/main/resources/about/README.md +++ b/sdnr/wt/data-provider/provider/src/main/resources/about/README.md @@ -9,7 +9,6 @@ | Yangtools version | {yangtools-version} | | MD-SAL version | {mdsal-version} | | SDN-R packages version | {package-version} ({package-githash}) | -| ODLUX version | {odlux-revision} | | Cluster size | {cluster-size} | ## Device manager diff --git a/sdnr/wt/data-provider/provider/src/main/resources/es-init.replaced.sh b/sdnr/wt/data-provider/provider/src/main/resources/es-init.replaced.sh new file mode 100755 index 000000000..67d495aa0 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/resources/es-init.replaced.sh @@ -0,0 +1,446 @@ +#!/bin/bash +# ============LICENSE_START======================================================================== +# ONAP : ccsdk feature sdnr wt +# ================================================================================================= +# Copyright (C) 2019 highstreet technologies GmbH 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. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============LICENSE_END========================================================================== +# +# Version 2 +# Usage .. see help below + +SDNRNAME=sdnrdb +REPLICAS=1 +SHARDS=5 +PREFIX="" +VERSION="-v1" +VERBOSE=0 +INITFILENAME="Init.script" + +#declare -a ALIAS +#declare -a MAPPING + +# ------------------------------------------------------------ +# Function with definition of mappings +# $1: alias name for index +# $2: mapping properties and additonal parameter for this section + +set_definition() { + def "connectionlog" '{"node-id": {"type": "keyword"},"timestamp": {"type": "date"},"status": {"type": "keyword"}}' + def "maintenancemode" '{"node-id": {"type": "keyword"},"start": {"type": "date"},"end": {"type": "date"},"description": {"type": "keyword"},"active": {"type": "boolean"}},"date_detection":false}}' + def "faultlog" '{"node-id": {"type": "keyword"},"severity": {"type": "keyword"},"timestamp": {"type": "date"},"problem": {"type": "keyword"},"counter": {"type": "long"},"object-id":{"type": "keyword"},"source-type":{"type": "keyword"}}' + def "faultcurrent" '{"node-id": {"type": "keyword"},"severity": {"type": "keyword"},"timestamp": {"type": "date"},"problem": {"type": "keyword"},"counter": {"type": "long"},"object-id":{"type": "keyword"}}' + def "eventlog" '{"node-id": {"type": "keyword"},"source-type": {"type": "keyword"},"timestamp": {"type": "date"},"new-value": {"type": "keyword"},"attribute-name": {"type": "keyword"},"counter": {"type": "long"},"object-id": {"type": "keyword"}}' + def "inventoryequipment" '{"date": {"type": "keyword"},"model-identifier": {"type": "keyword"},"manufacturer-identifier": {"type": "keyword"},"type-name": {"type": "keyword"},"description": {"type": "keyword"},"uuid": {"type": "keyword"},"version": {"type": "keyword"},"parent-uuid": {"type": "keyword"},"contained-holder": {"type": "keyword"},"node-id": {"type": "keyword"},"tree-level": {"type": "long"},"part-type-id": {"type": "keyword"},"serial": {"type": "keyword"}}' + def "historicalperformance24h" '{"node-name":{"type": "keyword"},"timestamp":{"type": "date"},"suspect-interval-flag":{"type":"boolean"},"scanner-id":{"type": "keyword"},"uuid-interface":{"type": "keyword"},"layer-protocol-name":{"type": "keyword"},"granularity-period":{"type": "keyword"},"radio-signal-id":{"type": "keyword"}}' + def "historicalperformance15min" '{"node-name":{"type": "keyword"},"timestamp":{"type": "date"},"suspect-interval-flag":{"type":"boolean"},"scanner-id":{"type": "keyword"},"uuid-interface":{"type": "keyword"},"layer-protocol-name":{"type": "keyword"},"granularity-period":{"type": "keyword"},"radio-signal-id":{"type": "keyword"}}' + def "mediator-server" '{"url":{"type": "keyword"},"name":{"type": "keyword"}}' + def "networkelement-connection" '{"node-id": {"type": "keyword"},"host": {"type": "keyword"},"port": {"type": "long"},"username": {"type": "keyword"},"password": {"type": "keyword"},"core-model-capability": {"type": "keyword"},"device-type": {"type": "keyword"},"is-required": {"type": "boolean"},"status": {"type": "keyword"}},"date_detection":false' +} + +# ------------------------------------------------------------ +# Functions + +# Get ip of container with database +getsdnrurl() { + if [ ! -z "$DBURL" ]; then + return + fi + cmd=$(which docker) + if [ ! -z "$cmd" ]; then + SDNRIP=$($cmd inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$SDNRNAME") + if [ "$?" = "1" ] ; then + echo "WARN: Container $SDNRNAME not running. Start the sdnrdb container or enter a database url." + echo "continuing with localhost" + SDNRIP="localhost" + fi + else + # if no docker and no db url given + if [ -z "$DBURL" ]; then + echo "WARN: Please enter a database url." + echo "continuing with localhost" + SDNRIP="localhost" + fi + fi + DBURL="http://$SDNRIP:9200" +} + +# Add elements to the array ALIAS and MAPPING +# $1 alias +# $2 mapping properties +def() { + ALIAS=("${ALIAS[@]}" "$1") + MAPPING=("${MAPPING[@]}" "$2") +} + +# $1 Response +print_response() { + response="$1" + body=$(echo $response | sed -E 's/HTTPSTATUS\:[0-9]{3}$//') + code=$(echo $response | tr -d '\n' | sed -E 's/.*HTTPSTATUS:([0-9]{3})$/\1/') + if [ "$VERBOSE" = "0" -a "$code" -ne "200" ] ; then + echo "Error response $code $body" + fi + if [ "$VERBOSE" -ge 1 ] ; then + echo "response $code" + fi + if [ "$VERBOSE" -ge 2 ] ; then + echo "content: $body" + fi +} + +#Write ini file for elasticsearch +# $1 index +# $1 data +file_append() { + echo "PUT:"$1"/:"$2 >> $INITFILENAME +} + +# Send get request to database +# USes DBURL +# $1 url path +# $2 data +http_get_request() { + url="$DBURL/$1" + if [ "$VERBOSE" -ge 2 ] ; then + echo "PUT to $url data $data" + fi + response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X GET -H "Content-Type: application/json" "$url") + print_response "$response" +} + +# Send put request to database +# USes DBURL +# $1 url path +# $2 data +http_put_request() { + url="$DBURL/$1" + if [ "$VERBOSE" -ge 2 ] ; then + echo "PUT to $url data $data" + fi + response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X PUT -H "Content-Type: application/json" -d "$2" "$url") + print_response "$response" +} + +# Send delete request to database +# $1 url +http_delete_request() { + url="$DBURL/$1" + if [ "$VERBOSE" -ge 2 ] ; then + echo "DELETE to $url" + fi + echo "DELETE to $url" + response=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" -X DELETE -H "Content-Type: application/json" $url) + print_response "$response" +} + +# Delete index and alias +# $1 alias +delete_index_alias() { + + echo "deleting alias $alias" + # Delete alias + alias="$PREFIX$1" + index="$PREFIX$1$VERSION" + + url="$index/_alias/$alias" + http_delete_request "$url" + + # Delete index + echo "deleting index $index" + url="$index" + http_delete_request "$url" + + # Delete alias that was falsely autocreated as index + echo "deleting index $index" + url="$alias" + http_delete_request "$url" +} + +# Write mappings +# Uses version, SHARDS and REPLICAS parameters +# $1 alias and datatype "mydatatype" +# $2 mapping properties +# $3 filename or empty for WEB +create_index_alias() { + # Create index + alias="$PREFIX$1" + index="$PREFIX$1$VERSION" + mappings='"mappings":{"'$1'":{"properties":'$2'}}' + settings='"settings":{"index":{"number_of_shards":'$SHARDS',"number_of_replicas":'$REPLICAS'},"analysis":{"analyzer":{"content":{"type":"custom","tokenizer":"whitespace"}}}}' + + if [ -z "$mappings" ]; then + data="{$settings}" + else + data="{$settings,$mappings}" + fi + + url=$index + echo "creating index $index" + if [ -z "$3" ] ; then + http_put_request "$url" "$data" + else + file_append "$url" "$data" + fi + + #Create alias + url="$index/_alias/$alias" + echo "creating alias $alias for $index" + if [ -z "$3" ] ; then + http_put_request "$url" + else + file_append "$url" "{}" + fi +} + +# Wait for status +# $1 time to wait +es_wait_yellow() { + ESSTATUS="yellow" + attempt_counter=0 + max_attempts=5 + echo "Wait up to $max_attempts attempts for $DBURL availability" + until $(curl --output /dev/null --silent --head --fail $DBURL); do + if [ ${attempt_counter} -eq ${max_attempts} ];then + echo "Error: Max attempts reached." + exit 3 + fi + attempt_counter=$(($attempt_counter+1)) + printf '.' + sleep 5 + done + sleep 2 + echo "Wait up to $1 for status $ESSTATUS" + RES=$(curl GET "$DBURL/_cluster/health?wait_for_status=$ESSTATUS&timeout=$1&pretty" 2>/dev/null) + if [ "$?" = "0" ] ; then + if [[ "$RES" =~ .*status.*:.*yellow.* || "$RES" =~ .*status.*:.*green.* ]] ; then + echo "Status $ESSTATUS reached: $RES" + else + echo "Error: DB Reachable, but status $ESSTATUS not reached" + exit 2 + fi + else + echo "Error: $DBURL not reachable" + exit 2 + fi +} + +# Commands + +cmd_create() { + if [ -n "$WAITYELLOW" ] ; then + es_wait_yellow "$WAITYELLOW" + fi + for i in "${!ALIAS[@]}"; do + create_index_alias "${ALIAS[$i]}" "${MAPPING[$i]}" + done +} + +cmd_delete() { + if [ -n "$WAITYELLOW" ] ; then + es_wait_yellow "$WAITYELLOW" + fi + for i in "${!ALIAS[@]}"; do + delete_index_alias "${ALIAS[$i]}" + done + for i in "${!ALIAS[@]}"; do + delete_index_alias "${ALIAS[$i]}" + done +} +cmd_purge() { +# http_get_request '_cat/aliases' +# body=$(echo $response | sed -E 's/HTTPSTATUS\:[0-9]{3}$//') +# echo "$response" | awk '/^([^ ]*)[ ]*([^ ]*).*$/{ print $2"/_alias/"$1 }' +# http_get_request '_cat/indices' +# echo "indices" +# echo "$response" +# echo "$response" | awk '/^[^ ]*[ ]*[^ ]*[ ]*([^ ]*).*$/{ print $3 }' + echo "not yet implemented" +} +cmd_initfile() { + echo "Create script initfile: $INITFILENAME" + if [ -f "$INITFILENAME" ] ; then + rm $INITFILENAME + else + mkdir -p $(dirname $INITFILENAME ) + fi + for i in "${!ALIAS[@]}"; do + create_index_alias "${ALIAS[$i]}" "${MAPPING[$i]}" file + done +} + +# Prepare database startup +cmd_startup() { + ESWAIT=30s + echo "Startup ElasticSearch DBURL=$DBURL CMD=$STARTUP_CMD CLUSTER=$CLUSTER_ENABLED INDEX=$NODE_INDEX" + if $CLUSTER_ENABLED ; then + if [ "$NODE_INDEX" = "0" ] ; then + echo "Cluster node 0 detected .. create" + es_wait_yellow $ESWAIT + cmd_create + else + echo "Cluster node > 0 detected .. do nothing" + fi + else + echo "No cluster" + es_wait_yellow $ESWAIT + cmd_create + fi +} + +# Parse arguments +parse_args() { + while [[ $# -gt 0 ]] + do + par=($(echo $1 | tr '=' '\n')) + echo "" + if [ ${#par[@]} == "2" ] ; then + # Equal sign found + key=${par[0]} + value=${par[1]} + else + # No equal sign + key="$1" + value="$2" + fi + shift + #Further shift if parameter is used + case $key in + -db|--dburl|--database) + DBURL="$value" + shift + ;; + -r|--replicas) + REPLICAS="$value" + shift + ;; + -s|--shards) + SHARDS="$value" + shift + ;; + -p|--prefix) + PREFIX="$value" + shift + ;; + -f|--file) + INITFILENAME="$value" + shift + ;; + -x|--verbose) + VERBOSE="${value:-0}" + shift + ;; + -v|--version) + VERSION="${value:--v1}" + shift + ;; + -vx|--versionx) + VERSION="" + ;; + -w|--wait) + WAITYELLOW="${value:-30s}" + shift + ;; + --cmd) + STARTUP_CMD="$value" + shift + ;; + --odlcluster) + CLUSTER_ENABLED="$value" + shift + ;; + --index) + NODE_INDEX="$value" + shift + ;; + *) + ;; + esac; + done +} + +# ----------------------------------------- +# Main starts here + +TASK=$1 +shift +parse_args "$@" + +set_definition + + +echo "------------------------------" +echo "Elasticsearch for SDN-R helper" +echo "------------------------------" +echo "Uses database container $SDNRNAME" +echo "Database url $DBURL" +echo " shards=$SHARDS replicas=$REPLICAS prefix=$PREFIX verbose=$VERBOSE version='$VERSION'" + + +case "$TASK" in + "create") + getsdnrurl + if [ -z "$DBURL" ] ; then + echo "Error: unable to detect database url." + exit 1 + fi + cmd_create + ;; + "delete") + getsdnrurl + if [ -z "$DBURL" ] ; then + echo "Error: unable to detect database url." + exit 1 + fi + cmd_delete + ;; + "purge") + getsdnrurl + if [ -z "$DBURL" ] ; then + echo "Error: unable to detect database url." + exit 1 + fi + cmd_purge + ;; + "initfile") + cmd_initfile + ;; + "startup") + cmd_startup + ;; + *) + echo "usage:" + echo " es-init.sh COMMAND [OPTIONS]" + echo " Commands:" + echo " create create SDN-R used indices and aliases" + echo " delete delete SDN-R used indices and aliases" + echo " initfile Create initfile for java unit tests" + echo " purge Clear complete database (indices and aliases)" + echo " startup Initial database write if node number 01" + echo " Options:" + echo -e " -db\--database DATABASEURL" + echo -e " -r\--replicas REPLICAS" + echo -e " -s\--shards SHARDS" + echo -e " -p\--prefix DATABASE-PREFIX" + echo -e " -f\--file init filename" + echo -e " -x\--verbose Verbose level less 0 .. 2 full" + echo -e " -v\--version Version prefix" + echo -e " -vx\--versionx Version prefix empty" + echo -e " -i\--ignore Ignore error responses" + echo -e " --odlcluster true/false if odl configured as cluster" + echo -e " --index Cluster node 0.." + echo -e " --cmd startup sub command" + echo " examples:" + echo " single node db:" + echo " es-init.sh create -db http://sdnrdb:9200 -r 0" + ;; +esac diff --git a/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh b/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh new file mode 100755 index 000000000..1cbfd7d7a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/resources/es-init.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# ============LICENSE_START======================================================================== +# ONAP : ccsdk feature sdnr wt +# ================================================================================================= +# Copyright (C) 2019 highstreet technologies GmbH 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. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. +# ============LICENSE_END========================================================================== +# +# Version 2 +# Usage .. see help below + +echo "Depricated. Please use init container and jar directly" +java -jar $ODL_HOME/system/org/onap/ccsdk/features/sdnr/wt/sdnr-wt-data-provider-setup/$FEATURES_SDNR/sdnr-dmt.jar -c init -db $SDNRDBURL -dbu $SDNRDBUSERNAME -dbp $SDNRDBPASSWORD diff --git a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 7235b9042..ad9661f66 100644 --- a/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -43,7 +43,7 @@ </service> <bean id="aboutServlet" - class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet"> + class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet"> <!-- <property name="bundleService" ref="bundleService"/> --> </bean> <service interface="javax.servlet.http.HttpServlet" @@ -80,7 +80,7 @@ </bean> <bean id="yangServlet" - class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet"> + class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangSchemaHttpServlet"> </bean> <service interface="javax.servlet.http.HttpServlet" ref="yangServlet"> diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java index 5d9011ab0..1e6752764 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java @@ -24,7 +24,8 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet; + import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java index 9c95a7d98..ccb1ea53f 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java @@ -38,7 +38,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest; import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtDatabaseEventsService; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity.HtDatabaseEventsService; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java index 5c2a66e75..717b7add6 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java @@ -34,7 +34,7 @@ import org.mockito.Mockito; import org.mockito.stubbing.Answer; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryByFilter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SortOrder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter; diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java index 2aedabee4..aa010939d 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java @@ -28,9 +28,9 @@ import java.util.Set; import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section; import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.AboutHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.DataTreeHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderImpl; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey; import org.opendaylight.mdsal.binding.api.RpcProviderService; diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java index e757e24d3..b8fa5d668 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java @@ -32,7 +32,7 @@ import org.json.JSONObject; import org.junit.Test; import org.mockito.Mockito; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.QueryByFilter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper.QueryByFilter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EntityInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.Filter; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder; diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java index 4221891b3..d8d424174 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java @@ -209,7 +209,6 @@ public class TestYangGenSalMapping { out(generatedNode.toString()); // Print it with specified indentation } - @Test public void test5() throws IOException { // @formatter:off @@ -270,10 +269,8 @@ public class TestYangGenSalMapping { // Map to JSON String to Object Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class); out(generatedNode.toString()); // Print it with specified indentation - } - @Test public void test6() throws Exception { out(method()); diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java index 244d6b053..a2b90074e 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java @@ -45,9 +45,10 @@ import javax.servlet.http.HttpServletResponse; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFileProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.YangFilename; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.YangSchemaHttpServlet; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangFileProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangFilename; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangSchemaHttpServlet; + import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; |