summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/provider/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/data-provider/provider/src/main')
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java76
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsConfig.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java)11
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java)12
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessor.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessor.java)16
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorPm.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorPm.java)19
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java103
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorWithId.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorWithId.java)7
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/FaultEntityManager.java)2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java)60
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseMaintenanceService.java)4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilter.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilter.java)19
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilterStatic.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilterStatic.java)4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryResult.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java)2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java)125
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtUserdataManagerImpl.java)2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeChildObject.java13
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java15
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java140
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java120
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java22
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java7
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java25
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java74
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java13
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java58
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java34
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/MediatorServerDataProvider.java (renamed from sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java)35
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/about/README.json16
-rw-r--r--sdnr/wt/data-provider/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml18
29 files changed, 572 insertions, 480 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java
deleted file mode 100644
index efb52213d..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorStatus.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * 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=========================================================
- *
- */
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor;
-
-import java.io.IOException;
-import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
-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.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.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.FaultsBuilder;
-
-public class DataObjectAcessorStatus extends DataObjectAcessor<Data> {
-
- final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
-
- private final ExtRestClient dbClient;
- private final Entity entity;
-
- public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity) throws ClassNotFoundException {
- super(dbClient, entity, Data.class);
- this.dbClient = dbClient;
- this.entity = entity;
- }
-
- public QueryResult<Data> getDataStatus() throws IOException {
- SearchRequest request = getNewInstanceOfSearchRequest(entity);
- request.setQuery(QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
-
- Data[] data = {new DataBuilder()
- .setFaults(
- new FaultsBuilder().setCriticals(YangHelper2.getLongOrUint32(aggs.getOrDefault("Critical", 0L)))
- .setMajors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Major", 0L)))
- .setMinors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Minor", 0L)))
- .setWarnings(YangHelper2.getLongOrUint32(aggs.getOrDefault("Warning", 0L))).build())
- .build()};
- long toalsize = data.length;
- return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
-
- }
-
-
- private static SearchRequest getNewInstanceOfSearchRequest(Entity entity) {
- return new SearchRequest(entity.getName(), entity.getName());
- }
-
-
-}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsConfig.java
index 44751ffd0..c428b67d3 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsConfig.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch;
import java.net.MalformedURLException;
import java.net.URL;
@@ -49,6 +49,7 @@ public class EsConfig implements Configuration, IEsConfig {
private static final String PROPERTY_KEY_NODE = "esNode";
private static final String PROPERTY_KEY_AUTH_USERNAME = "esAuthUsername";
private static final String PROPERTY_KEY_AUTH_PASSWORD = "esAuthPassword";
+ private static final String PROPERTY_KEY_FULLSIZE = "esFullsize";
private static String defaultHostinfo = "${SDNRDBURL}";
@@ -61,6 +62,7 @@ public class EsConfig implements Configuration, IEsConfig {
private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
private static final String DEFAULT_VALUE_TRUSTALLCERTS = "${SDNRDBTRUSTALLCERTS}";
+ private static final String DEFAULT_VALUE_FULLSIZE = "${SDNRDBFULLSIZEREQUESTS}";
private final ConfigurationFileRepresentation configuration;
@@ -161,6 +163,8 @@ public class EsConfig implements Configuration, IEsConfig {
DEFAULT_VALUE_DBPASSWORD);
configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS,
DEFAULT_VALUE_TRUSTALLCERTS);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_FULLSIZE,
+ DEFAULT_VALUE_FULLSIZE);
}
@@ -212,4 +216,9 @@ public class EsConfig implements Configuration, IEsConfig {
+ getSectionName() + "]";
}
+ @Override
+ public boolean doFullsizeRequests() {
+ return configuration.getPropertyBoolean(SECTION_MARKER_ES, PROPERTY_KEY_FULLSIZE);
+ }
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java
index 153022b4c..a86ecdde1 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/EsDataObjectReaderWriter2.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.database;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch;
import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.IOException;
@@ -78,6 +78,8 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/** Flag true to sync this attribute during write always, what is slow and false do not sync */
private final boolean syncAfterWrite;
+ protected boolean doFullsizeRequest;
+
/**
* Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
*
@@ -103,8 +105,12 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
this.yangtoolsMapper = new YangToolsMapper2<>(clazz, builderClazz);
this.clazz = clazz;
this.syncAfterWrite = syncAfterWrite;
+ this.doFullsizeRequest = false;
}
+ public void setFullsizeRequest(boolean fullsizeRequest) {
+ this.doFullsizeRequest = fullsizeRequest;
+ }
public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz)
throws ClassNotFoundException {
@@ -350,8 +356,10 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
public SearchResult<T> doReadAll(QueryBuilder query, boolean ignoreException) {
+ if(this.doFullsizeRequest) {
+ query.doFullsizeRequest();
+ }
SearchResult<T> res = new SearchResult<T>();
-
SearchResult<SearchHit> result;
List<SearchHit> hits;
if (query != null) {
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessor.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessor.java
index 0cd327bfc..ec467eab1 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessor.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessor.java
@@ -19,14 +19,14 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.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.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsDataObjectReaderWriter2;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryByFilter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -37,8 +37,10 @@ public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderW
private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
- DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
+ DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean doFullsizeRequest)
+ throws ClassNotFoundException {
super(dbClient, entity, clazz);
+ this.setFullsizeRequest(doFullsizeRequest);
LOG.info("Create {}", this.getClass().getName());
}
@@ -50,11 +52,9 @@ public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderW
// This wrong filter by user is allowed an results into empty data.
boolean ignoreException = queryBuilder.contains("range");
- LOG.info("Request: {} filter {} ignoreException{}:", this.getDataTypeName(), queryByFilter, ignoreException);
+ LOG.debug("Request: {} filter {} ignoreException{}:", this.getDataTypeName(), queryByFilter, ignoreException);
SearchResult<T> result = doReadAll(queryBuilder, ignoreException);
return new QueryResult<>(queryByFilter, result);
}
-
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorPm.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorPm.java
index 9280a0602..04849004f 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorPm.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorPm.java
@@ -19,18 +19,17 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor;
import java.io.IOException;
-
import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
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.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.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryByFilter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper.QueryResult;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -70,9 +69,9 @@ public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor
private ExtRestClient dbClient;
private Intervall mode;
- public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz)
- throws ClassNotFoundException {
- super(dbClient, entity, clazz);
+ public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz,
+ boolean doFullsizeRequest) throws ClassNotFoundException {
+ super(dbClient, entity, clazz, doFullsizeRequest);
LOG.info("DataObjectAcessorPm");
this.dbClient = dbClient;
this.mode = mode;
@@ -88,8 +87,8 @@ public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor
public QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
QueryByFilter queryByFilter = new QueryByFilter(input);
- SearchRequest request =
- queryByFilter.getSearchRequestByFilter(NODE_KEY, UUID_KEY, mode.getIndex(), mode.getType());
+ SearchRequest request = queryByFilter.getSearchRequestByFilter(NODE_KEY, UUID_KEY, mode.getIndex(),
+ mode.getType(), this.doFullsizeRequest);
try {
SearchResponse response = this.dbClient.search(request);
AggregationEntries aggs = response.getAggregations(UUID_KEY);
@@ -114,7 +113,7 @@ public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor
QueryByFilter queryByFilter = new QueryByFilter(input);
SearchRequest request =
- queryByFilter.getSearchRequestBySortOrder(NODE_KEY, UUID_KEY, mode.getIndex(), mode.getType());
+ queryByFilter.getSearchRequestBySortOrder(NODE_KEY, UUID_KEY, mode.getIndex(), mode.getType(), this.doFullsizeRequest);
try {
SearchResponse response = this.dbClient.search(request);
AggregationEntries aggs = response.getAggregations(KEY);
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java
new file mode 100644
index 000000000..5811550e6
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorStatus.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * 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=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor;
+
+import java.io.IOException;
+import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
+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.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.database.elasticsearch.data.rpctypehelper.QueryResult;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.DataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.FaultsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.status.entity.NetworkElementConnectionsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+
+public class DataObjectAcessorStatus extends DataObjectAcessor<Data> {
+
+ final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
+ final String ESDATATYPE_NECON_CONNECTIONSTATE_KEY = "status";
+
+ private final ExtRestClient dbClient;
+
+ public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity, boolean doFullsizeRequests)
+ throws ClassNotFoundException {
+ super(dbClient, entity, Data.class, doFullsizeRequests);
+ this.dbClient = dbClient;
+
+ }
+
+ public QueryResult<Data> getDataStatus() throws IOException {
+ SearchRequest request = getNewInstanceOfSearchRequest(Entity.Faultcurrent);
+ QueryBuilder query = QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0);
+ if(this.doFullsizeRequest) {
+ query.doFullsizeRequest();
+ }
+ request.setQuery(query);
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
+
+ DataBuilder builder = new DataBuilder().setFaults(
+ new FaultsBuilder().setCriticals(YangHelper2.getLongOrUint32(aggs.getOrDefault("Critical", 0L)))
+ .setMajors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Major", 0L)))
+ .setMinors(YangHelper2.getLongOrUint32(aggs.getOrDefault("Minor", 0L)))
+ .setWarnings(YangHelper2.getLongOrUint32(aggs.getOrDefault("Warning", 0L))).build());
+
+ request = getNewInstanceOfSearchRequest(Entity.NetworkelementConnection);
+ query = QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_NECON_CONNECTIONSTATE_KEY).size(0);
+ if(this.doFullsizeRequest) {
+ query.doFullsizeRequest();
+ }
+ request.setQuery(query);
+ response = this.dbClient.search(request);
+ aggs = response.getAggregations(ESDATATYPE_NECON_CONNECTIONSTATE_KEY);
+ builder.setNetworkElementConnections(new NetworkElementConnectionsBuilder()
+ .setConnected(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Connected.getName(), 0L)))
+ .setConnecting(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Connecting.getName(), 0L)))
+ .setDisconnected(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Disconnected.getName(), 0L)))
+ .setUnableToConnect(
+ Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.UnableToConnect.getName(), 0L)))
+ .setMounted(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Mounted.getName(), 0L)))
+ .setUnmounted(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Unmounted.getName(), 0L)))
+ .setUndefined(Uint32.valueOf(aggs.getOrDefault(ConnectionLogStatus.Undefined.getName(), 0L)))
+ .setTotal(Uint32.valueOf(response.getTotal())).build());
+
+ long toalsize = 1;
+ return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(new Data[] {builder.build()}, toalsize));
+
+ }
+
+
+ private static SearchRequest getNewInstanceOfSearchRequest(Entity entity) {
+ return new SearchRequest(entity.getName(), entity.getName());
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorWithId.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorWithId.java
index a977890c9..da2b4b151 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/acessor/DataObjectAcessorWithId.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/acessor/DataObjectAcessorWithId.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.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.rev201110.Entity;
@@ -31,11 +31,10 @@ public class DataObjectAcessorWithId<T extends DataObject> extends DataObjectAce
private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorWithId.class);
- public DataObjectAcessorWithId(HtDatabaseClient dbClient, Entity entity, Class<T> clazz)
+ public DataObjectAcessorWithId(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean doFullsizeRequest)
throws ClassNotFoundException {
- super(dbClient, entity, clazz);
+ super(dbClient, entity, clazz, doFullsizeRequest);
setEsIdAttributeName("_id");
LOG.info("Create {}", this.getClass().getName());
}
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
index f1a43359c..36ab39845 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/FaultEntityManager.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.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/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
index b23d882c8..41e94e3f6 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity;
import java.util.ArrayList;
import java.util.Arrays;
@@ -36,8 +36,8 @@ 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.database.DatabaseDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsDataObjectReaderWriter2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.ArchiveCleanProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataInconsistencyException;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
@@ -92,11 +92,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private final EsDataObjectReaderWriter2<PmdataEntity> pmData24hDB;
@SuppressWarnings("unused")
- private final ElasticSearchDataProvider dataProvider;
+ private final DatabaseDataProvider dataProvider;
// --- Construct and initialize
-
- public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider)
+ public HtDatabaseEventsService(HtDatabaseClient client, DatabaseDataProvider elasticSearchDataProvider)
throws Exception {
LOG.info("Create {} start", HtDatabaseEventsService.class);
@@ -166,7 +165,6 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWEventLogDevicemanager.write(event, null);
}
-
// -- Fault log
@Override
@@ -308,7 +306,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
.setTreeLevel(Uint32.valueOf(0));;
for (Inventory item : list) {
repairedItem = new InventoryBuilder(item);
- //check missing tree-level
+ // check missing tree-level
if (!nodeId.equals(item.getNodeId())) {
failures.add(String.format("missing node-id for equipment(uuid=%s)", item.getUuid()));
repairedItem.setNodeId(nodeId);
@@ -322,7 +320,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
} else {
treeLevel = item.getTreeLevel().longValue();
if (treeLevel > 0) {
- //check non root elem and missing parent
+ // check non root elem and missing parent
if (item.getParentUuid() == null) {
failures.add(String.format("Non root level element (uuid=%s) has to have a parent element",
item.getUuid()));
@@ -330,7 +328,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
repairedItem.setParentUuid(UNBOUND_INVENTORY_UUID);
repairList.put(unboundItem.getUuid(), unboundItem.build());
}
- //check that parent exists in list and is tree-level -1
+ // check that parent exists in list and is tree-level -1
else {
Optional<Inventory> parent =
list.stream().filter(e -> item.getParentUuid().equals(e.getUuid())).findFirst();
@@ -342,7 +340,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
}
}
- //check for duplicated uui
+ // check for duplicated uui
Optional<Inventory> duplicate = list
.stream().filter(e -> !item.equals(e) && item.getUuid() != null
&& item.getUuid().equals(e.getUuid()) && repairList.containsKey(e.getUuid()))
@@ -361,7 +359,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
}
- if (!failures.isEmpty()) {
+ if (failures.size() > 0) {
throw new DataInconsistencyException(new ArrayList<>(repairList.values()),
"inventory list is not consistent;\n" + String.join("\n", failures));
}
@@ -369,7 +367,6 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
// -- Networkelement
-
/**
* join base with parameters of toJoin (only non null values)
*
@@ -425,8 +422,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
public boolean updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
String nodeId) {
return this.networkelementConnectionDB.update(networkElementConnectionEntitiy, nodeId) != null;
- // NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
- // this.networkelementConnectionDB.write(this.joinNe(e, networkElementConnectionEntitiy), nodeId);
+ // NetworkElementConnectionEntity e =
+ // this.networkelementConnectionDB.read(nodeId);
+ // this.networkelementConnectionDB.write(this.joinNe(e,
+ // networkElementConnectionEntitiy), nodeId);
}
/**
@@ -441,17 +440,21 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
LOG.info("update networkelement-connection for {} with data {}", nodeId, networkElementConnectionEntitiy);
return this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId,
Arrays.asList("is-required", "username", "password")) != null;
- // NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
- // this.networkelementConnectionDB.write(this.joinNe(e, networkElementConnectionEntitiy), nodeId);
+ // NetworkElementConnectionEntity e =
+ // this.networkelementConnectionDB.read(nodeId);
+ // this.networkelementConnectionDB.write(this.joinNe(e,
+ // networkElementConnectionEntitiy), nodeId);
}
/* please do not remove */
- // public void cleanNetworkElementConnections() {
- // this.networkelementConnectionDB.remove(QueryBuilders.matchQuery("is-required", false));
- // CreateNetworkElementConnectionInput x = new CreateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build();
- // this.networkelementConnectionDB.update(x,QueryBuilders.matchAllQuery());
- // }
+ // public void cleanNetworkElementConnections() {
+ // this.networkelementConnectionDB.remove(QueryBuilders.matchQuery("is-required",
+ // false));
+ // CreateNetworkElementConnectionInput x = new
+ // CreateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build();
+ // this.networkelementConnectionDB.update(x,QueryBuilders.matchAllQuery());
+ // }
@Override
public void removeNetworkConnection(String nodeId) {
@@ -489,7 +492,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
@Override
- public int getNumberOfOldObjects(Date olderAreOutdated) {
+ public long getNumberOfOldObjects(Date olderAreOutdated) {
String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
int numberOfElements = 0;
@@ -535,7 +538,6 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
// ### sub classes
-
private static class EsEventBase {
/**
* Query to get older Elements
@@ -547,6 +549,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
}
}
+
private static class EsFaultLogDevicemanager {
/**
* Get older Elements
@@ -558,6 +561,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
}
}
+
public static class EsFaultCurrent {
/**
* @param nodeName name of the node
@@ -585,7 +589,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
list.forEach(elem -> {
GranularityPeriodType granularityPeriod = nnGetGranularityPeriodType(elem.getGranularityPeriod());
- //_id": "Sim12600/LP-MWPS-TTP-01/2017-07-04T15:15:00.0+00:00"
+ // _id": "Sim12600/LP-MWPS-TTP-01/2017-07-04T15:15:00.0+00:00"
StringBuffer id = new StringBuffer();
DateAndTime date = elem.getTimeStamp();
id.append(elem.getNodeName());
@@ -625,4 +629,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
guiCutThroughDB.write(gcData, nodeId);
}
+ @Override
+ public int clearGuiCutThroughEntriesOfNode(String nodeName) {
+ guiCutThroughDB.remove(nodeName);
+ return 0;
+ }
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java
index 380526d9a..c6161b54c 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/entity/HtDatabaseMaintenanceService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseMaintenanceService.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.entity;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity;
import java.util.ArrayList;
import java.util.List;
@@ -27,7 +27,7 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.EsDataObjectReaderWriter2;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsDataObjectReaderWriter2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
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/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilter.java
index 627d125ae..eef61e09c 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilter.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilter.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,7 +34,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.requests.SearchRequest;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.acessor.DataObjectAcessorPm;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.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.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
@@ -115,12 +115,13 @@ public class QueryByFilter {
return queryBuilder;
}
- public SearchRequest getSearchRequestByFilter(String nodeKey, String uuidKey, String index, String dataType) {
+ public SearchRequest getSearchRequestByFilter(String nodeKey, String uuidKey, String index, String dataType,
+ boolean doFullsizeRequest) {
Filter nodeFilter = getFilter(filterList, nodeKey);
if (nodeFilter != null) {
SearchRequest request = new SearchRequest(index, dataType);
- request.setQuery(
- QueryBuilders.matchQuery(nodeKey, nodeFilter.getFiltervalue()).aggregations(uuidKey).size(0));
+ request.setQuery(QueryBuilders.matchQuery(nodeKey, nodeFilter.getFiltervalue())
+ .setFullsizeRequest(doFullsizeRequest).aggregations(uuidKey).size(0));
return request;
} else {
String msg = "no nodename in filter found ";
@@ -129,14 +130,16 @@ public class QueryByFilter {
}
}
- public SearchRequest getSearchRequestBySortOrder(String nodeKey, String uuidKey, String index, String dataType) {
+ public SearchRequest getSearchRequestBySortOrder(String nodeKey, String uuidKey, String index, String dataType,
+ boolean doFullsizeRequest) {
Sortorder soNode = getSortOrder(sortOrder, nodeKey);
SearchRequest request = new SearchRequest(index, dataType);
QueryBuilder query = null;
if (soNode != null) {
- query = QueryBuilders.matchAllQuery().aggregations(nodeKey, convert(soNode.getSortorder())).size(0);
+ query = QueryBuilders.matchAllQuery().setFullsizeRequest(doFullsizeRequest)
+ .aggregations(nodeKey, convert(soNode.getSortorder())).size(0);
} else {
- query = QueryBuilders.matchAllQuery().aggregations(nodeKey).size(0);
+ query = QueryBuilders.matchAllQuery().setFullsizeRequest(doFullsizeRequest).aggregations(nodeKey).size(0);
}
request.setQuery(query);
return request;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilterStatic.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilterStatic.java
index b76e0a872..4e4c1a9c8 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryByFilterStatic.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryByFilterStatic.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper;
import java.util.Arrays;
import java.util.Calendar;
@@ -32,7 +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.database.elasticsearch.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.rev201110.EntityInput;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryResult.java
index 6e653baf2..d4cf0eb53 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/rpctypehelper/QueryResult.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/rpctypehelper/QueryResult.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data.rpctypehelper;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.rpctypehelper;
import java.math.BigInteger;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
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/database/elasticsearch/impl/ElasticSearchDataProvider.java
index 0a966aef6..53b21e0ed 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/database/elasticsearch/impl/ElasticSearchDataProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : ccsdk features
* ================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,21 +19,26 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
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.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.database.DatabaseDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor.DataObjectAcessorPm;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor.DataObjectAcessorPm.Intervall;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor.DataObjectAcessorStatus;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.acessor.DataObjectAcessorWithId;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.HtDatabaseEventsService;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.HtDatabaseMaintenanceService;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.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.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -52,7 +57,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder;
@@ -77,7 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ElasticSearchDataProvider {
+public class ElasticSearchDataProvider implements DatabaseDataProvider {
private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class);
@@ -102,59 +106,85 @@ public class ElasticSearchDataProvider {
private final HtDatabaseEventsService databaseService;
private final HtDatabaseMaintenanceService databaseMaintenanceService;
+ private final HtDatabaseMediatorserver dbMediatorServerService = new HtDatabaseMediatorserver() {
+
+ @Override
+ public List<MediatorServerEntity> getAll() {
+ return new ArrayList<>(ElasticSearchDataProvider.this.mediatorserverRW.doReadAll().getHits());
+ }
+ };
+
+ @Override
public HtDatabaseClient getRawClient() {
return this.dbClient;
}
public ElasticSearchDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts, null, null, HtDatabaseClient.TRUSTALL_DEFAULT);
+ this(hosts, null, null, HtDatabaseClient.TRUSTALL_DEFAULT, false);
+ }
+
+ public ElasticSearchDataProvider(EsConfig esConfig) throws Exception {
+ this(esConfig.getHosts(), esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword(),
+ esConfig.trustAllCerts(), esConfig.doFullsizeRequests());
}
- public ElasticSearchDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAllCerts)
- throws Exception {
+ public ElasticSearchDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAllCerts,
+ boolean doFullsizeRequests) throws Exception {
super();
LOG.info("Start {}", this.getClass().getName());
this.dbClient = HtDatabaseClient.getClient(hosts, authUsername, authPassword, trustAllCerts);
this.mediatorserverRW = new DataObjectAcessorWithId<>(dbClient, Entity.MediatorServer,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data.class,
+ doFullsizeRequests);
this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
this.maintenanceRW = new DataObjectAcessorWithId<>(dbClient, Entity.Maintenancemode,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data.class,
+ doFullsizeRequests);
this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
- this.guicutthroughRW = new DataObjectAcessorWithId<>(dbClient, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity.Guicutthrough,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data.class);
+ this.guicutthroughRW = new DataObjectAcessorWithId<>(dbClient,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity.Guicutthrough,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data.class,
+ doFullsizeRequests);
this.guicutthroughRW.setWriteInterface(Guicutthrough.class);
this.equipmentRW = new DataObjectAcessorWithId<>(dbClient, Entity.Inventoryequipment,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data.class,
+ doFullsizeRequests);
this.eventRWFaultCurrent = new DataObjectAcessorWithId<>(dbClient, Entity.Faultcurrent,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data.class,
+ doFullsizeRequests);
this.eventRWFaultLog = new DataObjectAcessorWithId<>(dbClient, Entity.Faultlog,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data.class,
+ doFullsizeRequests);
this.connnectionlogRW = new DataObjectAcessorWithId<>(dbClient, Entity.Connectionlog,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data.class,
+ doFullsizeRequests);
this.eventlogRW = new DataObjectAcessorWithId<>(dbClient, Entity.Eventlog,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.Data.class,
+ doFullsizeRequests);
this.networkelementConnectionRW = new DataObjectAcessorWithId<>(dbClient, Entity.NetworkelementConnection,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data.class,
+ doFullsizeRequests);
this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data.class,
+ doFullsizeRequests);
this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data.class);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data.class,
+ doFullsizeRequests);
- this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent);
+ this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent, doFullsizeRequests);
this.databaseService = new HtDatabaseEventsService(dbClient, this);
this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
@@ -164,6 +194,8 @@ public class ElasticSearchDataProvider {
* Provide access to model API
*/
+
+ @Override
public ReadFaultcurrentListOutputBuilder readFaultCurrentList(EntityInput input) {
ReadFaultcurrentListOutputBuilder outputBuilder = new ReadFaultcurrentListOutputBuilder();
@@ -177,6 +209,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) {
ReadFaultlogListOutputBuilder outputBuilder = new ReadFaultlogListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data> result =
@@ -188,6 +221,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> result =
@@ -199,6 +233,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) {
ReadMediatorServerListOutputBuilder outputBuilder = new ReadMediatorServerListOutputBuilder();
@@ -211,6 +246,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(EntityInput input) {
ReadNetworkElementConnectionListOutputBuilder outputBuilder =
new ReadNetworkElementConnectionListOutputBuilder();
@@ -223,6 +259,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) {
ReadInventoryListOutputBuilder outputBuilder = new ReadInventoryListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.inventory.list.output.Data> result =
@@ -234,6 +271,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) {
ReadConnectionlogListOutputBuilder outputBuilder = new ReadConnectionlogListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data> result =
@@ -245,7 +283,8 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
- public ReadEventlogListOutputBuilder readEventlogList(ReadEventlogListInput input) throws IOException {
+ @Override
+ public ReadEventlogListOutputBuilder readEventlogList(EntityInput input) throws IOException {
ReadEventlogListOutputBuilder outputBuilder = new ReadEventlogListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.eventlog.list.output.Data> result =
this.eventlogRW.getData(input);
@@ -256,6 +295,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) {
ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data> result =
@@ -268,6 +308,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) {
ReadPmdata24hListOutputBuilder outputBuilder = new ReadPmdata24hListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data> result =
@@ -279,6 +320,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata15mLtpListOutputBuilder readPmdata15mLtpList(EntityInput input) throws IOException {
ReadPmdata15mLtpListOutputBuilder outputBuilder = new ReadPmdata15mLtpListOutputBuilder();
QueryResult<String> result = pm15mRW.getDataLtpList(input);
@@ -289,6 +331,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata15mDeviceListOutputBuilder readPmdata15mDeviceList(EntityInput input) throws IOException {
ReadPmdata15mDeviceListOutputBuilder outputBuilder = new ReadPmdata15mDeviceListOutputBuilder();
QueryResult<String> result = pm15mRW.getDataDeviceList(input);
@@ -299,6 +342,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata24hLtpListOutputBuilder readPmdata24hLtpList(EntityInput input) throws IOException {
QueryResult<String> result = pm24hRW.getDataLtpList(input);
@@ -312,6 +356,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException {
QueryResult<String> result = pm24hRW.getDataDeviceList(input);
@@ -324,6 +369,7 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public ReadStatusOutputBuilder readStatus() throws IOException {
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.status.output.Data> result =
readStatus.getDataStatus();
@@ -333,10 +379,12 @@ public class ElasticSearchDataProvider {
return outputBuilder;
}
+ @Override
public boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit) {
return this.dbClient.waitForYellowStatus(unit.toMillis(timeout));
}
+ @Override
public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
NetworkElementConnectionEntity input) throws IOException {
String id = this.networkelementConnectionRW.update(input, input.getNodeId());
@@ -350,6 +398,7 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public UpdateNetworkElementConnectionOutputBuilder updateNetworkElementConnection(
UpdateNetworkElementConnectionInput input) throws IOException {
String id = this.networkelementConnectionRW.update(input, input.getId());
@@ -363,6 +412,7 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(
DeleteNetworkElementConnectionInput input) throws IOException {
boolean removed = this.networkelementConnectionRW.remove(input.getId());
@@ -372,6 +422,7 @@ public class ElasticSearchDataProvider {
return new DeleteNetworkElementConnectionOutputBuilder();
}
+ @Override
public DeleteMediatorServerOutputBuilder deleteMediatorServer(DeleteMediatorServerInput input) throws IOException {
boolean removed = this.mediatorserverRW.remove(input.getId());
if (!removed) {
@@ -380,6 +431,7 @@ public class ElasticSearchDataProvider {
return new DeleteMediatorServerOutputBuilder();
}
+ @Override
public DeleteMaintenanceOutputBuilder deleteMaintenance(DeleteMaintenanceInput input) throws IOException {
boolean removed = this.maintenanceRW.remove(input.getId());
if (!removed) {
@@ -388,6 +440,7 @@ public class ElasticSearchDataProvider {
return new DeleteMaintenanceOutputBuilder();
}
+ @Override
public UpdateMaintenanceOutputBuilder updateMaintenance(UpdateMaintenanceInput input) throws IOException {
if (input.getId() == null) {
throw new IOException("please give the id for updating entry");
@@ -400,6 +453,7 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public UpdateMediatorServerOutputBuilder updateMediatorServer(UpdateMediatorServerInput input) throws IOException {
if (input.getId() == null) {
throw new IOException("please give the id for updating entry");
@@ -413,6 +467,7 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public CreateMaintenanceOutputBuilder createMaintenance(CreateMaintenanceInput input) throws IOException {
String id = this.maintenanceRW.write(input, input.getNodeId());
if (id == null) {
@@ -422,6 +477,7 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
String id = this.mediatorserverRW.write(input, null);
@@ -433,23 +489,32 @@ public class ElasticSearchDataProvider {
return builder;
}
+ @Override
public ReadGuiCutThroughEntryOutputBuilder readGuiCutThroughEntry(EntityInput input) {
ReadGuiCutThroughEntryOutputBuilder outputBuilder = new ReadGuiCutThroughEntryOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> result =
this.guicutthroughRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.PaginationBuilder(
- ).build());
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.PaginationBuilder()
+ .build());
return outputBuilder;
}
+ @Override
public DataProvider getDataProvider() {
return this.databaseService;
}
+ @Override
public HtDatabaseMaintenance getHtDatabaseMaintenance() {
return this.databaseMaintenanceService;
}
+ @Override
+ public HtDatabaseMediatorserver getHtDatabaseMediatorServer() {
+ return dbMediatorServerService;
+ }
+
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
index 73cc1a212..9dbdb136a 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtUserdataManagerImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl;
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/DataTreeChildObject.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeChildObject.java
index 91d469700..05e6d2f13 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeChildObject.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeChildObject.java
@@ -91,15 +91,6 @@ public class DataTreeChildObject {
}
}
} else {
- // if(this.children!=null) {
- // for(DataTreeChildObject child:this.children.values()) {
- // itemValue=(String) child.getProperty(childKey, null);
- // if(itemValue!=null && itemValue.equals(itemValueToMatch)) {
- // child.children.put(id, data);
- // return true;
- // }
- // }
- // }
itemValue = this.getProperty(childKey, null);
if (itemValue != null && itemValue.equals(itemValueToMatch)) {
this.children.put(id, data);
@@ -157,8 +148,8 @@ public class DataTreeChildObject {
}
}
o.put("children", c);
- // o.put("ownSeverity", null);
- // o.put("childrenSeveritySummary", null);
+ //o.put("ownSeverity", null);
+ //o.put("childrenSeveritySummary", null);
return o;
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
index 725256b17..103dec70d 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
@@ -25,9 +25,9 @@ import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseServlet;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.MediatorServerDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,8 +102,8 @@ public class MsServlet extends BaseServlet {
trustAll = trust;
}
- public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
- entryProvider = mediatorServerDataProvider;
+ public void setDataProvider(HtDatabaseMediatorserver entryProvider2) {
+ entryProvider = new MediatorServerDataProvider(entryProvider2);
}
@Override
@@ -115,4 +115,11 @@ public class MsServlet extends BaseServlet {
protected boolean isCorsEnabled() {
return false;
}
+
+ public void triggerReloadSync() {
+ if(entryProvider!=null) {
+ entryProvider.triggerReloadSync();
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
deleted file mode 100644
index 284365021..000000000
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * 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=========================================================
- *
- */
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-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.apache.karaf.bundle.core.BundleState;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.MarkdownTable;
-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 ReadyHttpServlet extends HttpServlet {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
- private static boolean status;
-
-
- private BundleService bundleService = null;
-
- public void setBundleService(BundleService bundleService) {
- this.bundleService = bundleService;
- }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- if (isReady() && this.getBundleStatesReady()) {
- resp.setStatus(HttpServletResponse.SC_OK);
- } else {
-
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- } catch (IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}", e);
- }
- }
- }
-
- private static boolean isReady() {
- return status;
- }
-
- public static void setStatus(boolean s) {
- status = s;
- LOG.info("status is set to ready: {}", status);
- }
-
- private boolean getBundleStatesReady() {
- Bundle thisbundle = FrameworkUtil.getBundle(this.getClass());
- BundleContext context = thisbundle ==null?null:thisbundle.getBundleContext();
- if (context == null) {
- LOG.debug("no bundle context available");
- return true;
- }
- Bundle[] bundles = context.getBundles();
- if (bundles == null || bundles.length <= 0) {
- LOG.debug("no bundles found");
- return true;
- }
- LOG.debug("found {} bundles", bundles.length);
- MarkdownTable table = new MarkdownTable();
- table.setHeader(new String[] {"Bundle-Id","Version","Symbolic-Name","Status"});
- int cntNotActive=0;
-
- for (Bundle bundle : bundles) {
- if(this.bundleService!=null) {
- BundleInfo info = this.bundleService.getInfo(bundle);
- if(info.getState()==BundleState.Active ) {
- continue;
- }
- if(info.getState()==BundleState.Resolved ) {
- if(!this.isBundleImportant(bundle.getSymbolicName())) {
- LOG.trace("ignore not important bundle {} with state {}",bundle.getSymbolicName(),info.getState());
- continue;
- }
- }
-
- LOG.trace("bundle {} is in state {}",bundle.getSymbolicName(),info.getState());
- }
- else {
- LOG.warn("bundle service is null");
- }
- cntNotActive++;
- }
-
- return cntNotActive==0;
- }
-
- private boolean isBundleImportant(String symbolicName) {
- symbolicName = symbolicName.toLowerCase();
- if(symbolicName.contains("mdsal")) {
- return true;
- }
- if(symbolicName.contains("netconf")) {
- return true;
- }
- if(symbolicName.contains("ccsdk")) {
- return true;
- }
- if(symbolicName.contains("devicemanager")) {
- return true;
- }
- if(symbolicName.contains("restconf")) {
- return true;
- }
-
- return false;
- }
-
-}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
index 90b5fd9af..64b5fab9f 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
@@ -33,6 +33,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.http.HttpHeaders;
//import org.apache.karaf.bundle.core.BundleInfo;
//import org.apache.karaf.bundle.core.BundleService;
import org.onap.ccsdk.features.sdnr.wt.common.Resources;
@@ -71,22 +72,27 @@ public class AboutHttpServlet extends HttpServlet {
private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
private static final String PLACEHOLDER_DEVICEMANAGER_TABLE = "{devicemanagers}";
private static final String README_FILE = "README.md";
+ private static final String JSON_FILE = "README.json";
private static final String NO_DEVICEMANAGERS_RUNNING_MESSAGE = null;
+ private static final String MIMETYPE_JSON = "application/json";
+ private static final String MIMETYPE_MARKDOWN = "text/markdown";
private final String groupId = this.getGroupIdOrDefault("org.onap.ccsdk.features.sdnr.wt");
private final String artifactId = "sdnr-wt-data-provider-provider";
- private final Map<Integer,String> BUNDLESTATE_LUT;
+ private final Map<Integer, String> BUNDLESTATE_LUT;
private final Map<String, String> data;
private final String readmeContent;
// private BundleService bundleService;
+ private String jsonContent;
public AboutHttpServlet() {
this.data = new HashMap<>();
this.collectStaticData();
- this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
+ this.readmeContent = this.render(ContentType.MARKDOWN, this.getResourceFileContent(README_FILE));
+ this.jsonContent = this.render(ContentType.MARKDOWN, this.getResourceFileContent(JSON_FILE));
this.BUNDLESTATE_LUT = new HashMap<>();
this.BUNDLESTATE_LUT.put(Bundle.UNINSTALLED, "uninstalled");
this.BUNDLESTATE_LUT.put(Bundle.INSTALLED, "installed");
@@ -98,17 +104,17 @@ public class AboutHttpServlet extends HttpServlet {
}
protected String getGroupIdOrDefault(String def) {
- String symbolicName = this.getManifestValue("Bundle-SymbolicName");
- if(symbolicName!=null) {
- int idx = symbolicName.indexOf(this.artifactId);
- if(idx>0) {
- return symbolicName.substring(0, idx-1);
- }
- }
- return def;
- }
-
- // public void setBundleService(BundleService bundleService) {
+ String symbolicName = this.getManifestValue("Bundle-SymbolicName");
+ if (symbolicName != null) {
+ int idx = symbolicName.indexOf(this.artifactId);
+ if (idx > 0) {
+ return symbolicName.substring(0, idx - 1);
+ }
+ }
+ return def;
+ }
+
+ // public void setBundleService(BundleService bundleService) {
// this.bundleService = bundleService;
// }
@@ -136,15 +142,16 @@ public class AboutHttpServlet extends HttpServlet {
String uri = req.getRequestURI().substring(URI_PRE.length());
LOG.debug("request for {}", uri);
if (uri.length() <= 0 || uri.equals("/")) {
+ ContentType ctype = this.detectContentType(req, ContentType.MARKDOWN);
// collect data
- this.collectData();
+ this.collectData(ctype);
// render readme
- String content = this.render();
+ String content = this.render(ctype);
byte[] output = content != null ? content.getBytes() : new byte[0];
// output
resp.setStatus(HttpServletResponse.SC_OK);
resp.setContentLength(output.length);
- resp.setContentType("text/plain");
+ resp.setContentType(ctype.getMimeType());
ServletOutputStream os = null;
try {
os = resp.getOutputStream();
@@ -194,11 +201,11 @@ public class AboutHttpServlet extends HttpServlet {
/**
* collect dynamic data for about.md
*/
- private void collectData() {
+ private void collectData(ContentType ctype) {
LOG.info("collecting dynamic data");
try {
this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
- this.data.put(PLACEHOLDER_DEVICEMANAGER_TABLE, this.getDevicemanagerBundles());
+ this.data.put(PLACEHOLDER_DEVICEMANAGER_TABLE, this.getDevicemanagerBundles(ctype));
} catch (Exception e) {
LOG.warn("problem collecting system data: {}", e);
}
@@ -249,29 +256,6 @@ public class AboutHttpServlet extends HttpServlet {
}
/**
- * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
- *
- * @param key
- * @return
- */
- private String getPomProperty(String key) {
- LOG.info("try to get pom property for {}", key);
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
- if (url == null) {
- return null;
- }
- PomFile pomfile;
- try {
- pomfile = new PomFile(url.openStream());
- return pomfile.getProperty(key);
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
-
- /**
* get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
*
* @return
@@ -293,35 +277,35 @@ public class AboutHttpServlet extends HttpServlet {
return null;
}
- private String getDevicemanagerBundles() {
+ private String getDevicemanagerBundles(ContentType ctype) {
Bundle thisbundle = FrameworkUtil.getBundle(this.getClass());
- BundleContext context = thisbundle ==null?null:thisbundle.getBundleContext();
+ BundleContext context = thisbundle == null ? null : thisbundle.getBundleContext();
if (context == null) {
LOG.debug("no bundle context available");
- return "";
+ return ctype==ContentType.MARKDOWN?"":"[]";
}
Bundle[] bundles = context.getBundles();
if (bundles == null || bundles.length <= 0) {
LOG.debug("no bundles found");
- return NO_DEVICEMANAGERS_RUNNING_MESSAGE;
+ return ctype==ContentType.MARKDOWN?NO_DEVICEMANAGERS_RUNNING_MESSAGE:"[]";
}
LOG.debug("found {} bundles", bundles.length);
MarkdownTable table = new MarkdownTable();
- table.setHeader(new String[] {"Bundle-Id","Version","Symbolic-Name","Status"});
+ table.setHeader(new String[] {"Bundle-Id", "Version", "Symbolic-Name", "Status"});
String name;
for (Bundle bundle : bundles) {
name = bundle.getSymbolicName();
- if(!(name.contains("devicemanager") && name.contains("provider"))) {
+ if (!(name.contains("devicemanager") && name.contains("provider"))) {
continue;
}
- if(name.equals("org.onap.ccsdk.features.sdnr.wt.sdnr-wt-devicemanager-core-provider")) {
+ if (name.equals("org.onap.ccsdk.features.sdnr.wt.sdnr-wt-devicemanager-provider")) {
continue;
}
table.addRow(new String[] {String.valueOf(bundle.getBundleId()), bundle.getVersion().toString(), name,
- BUNDLESTATE_LUT.getOrDefault(bundle.getState(),"unknown")});
+ BUNDLESTATE_LUT.getOrDefault(bundle.getState(), "unknown")});
}
- return table.toMarkDown();
+ return ctype==ContentType.MARKDOWN?table.toMarkDown():table.toJson();
}
/**
@@ -382,10 +366,12 @@ public class AboutHttpServlet extends HttpServlet {
/**
* render this.readmeContent with this.data
*
+ * @param ctype
+ *
* @return
*/
- private String render() {
- return this.render(null);
+ private String render(ContentType ctype) {
+ return this.render(ctype, null);
}
/**
@@ -394,9 +380,9 @@ public class AboutHttpServlet extends HttpServlet {
* @param content
* @return
*/
- private String render(String content) {
+ private String render(ContentType ctype, String content) {
if (content == null) {
- content = this.readmeContent;
+ content = ctype==ContentType.MARKDOWN? this.readmeContent:this.jsonContent;
}
if (content == null) {
return null;
@@ -413,4 +399,30 @@ public class AboutHttpServlet extends HttpServlet {
public void setClusterSize(String value) {
this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
}
+
+ private ContentType detectContentType(HttpServletRequest req, ContentType def) {
+ String accept = req.getHeader(HttpHeaders.ACCEPT);
+ if (accept != null) {
+ if (accept.equals(MIMETYPE_JSON)) {
+ return ContentType.JSON;
+ } else if (accept.equals(MIMETYPE_MARKDOWN)) {
+ return ContentType.MARKDOWN;
+ }
+ }
+ return def;
+ }
+
+ private enum ContentType {
+ MARKDOWN(MIMETYPE_MARKDOWN), JSON(MIMETYPE_JSON);
+
+ private String mimeType;
+
+ ContentType(String mimeType) {
+ this.mimeType = mimeType;
+ }
+
+ String getMimeType() {
+ return this.mimeType;
+ }
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
index ac9cb44fe..1580a0fe3 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/MarkdownTable.java
@@ -23,6 +23,8 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about;
import java.util.ArrayList;
import java.util.List;
+import org.json.JSONArray;
+import org.json.JSONObject;
/**
* @author Michael Dürre
@@ -48,7 +50,7 @@ public class MarkdownTable {
public String toMarkDown() {
StringBuilder sb = new StringBuilder();
final int cols =
- this.columns != null ? this.columns.length : !this.rows.isEmpty() ? this.rows.get(0).length : 0;
+ this.columns != null ? this.columns.length : this.rows.size() > 0 ? this.rows.get(0).length : 0;
if (cols > 0) {
sb.append("|");
for (int i = 0; i < cols; i++) {
@@ -67,9 +69,23 @@ public class MarkdownTable {
}
sb.append("\n");
}
-
-
}
return sb.toString();
}
+
+ public String toJson() {
+ JSONArray a = new JSONArray();
+ final int cols =
+ this.columns != null ? this.columns.length : this.rows.size() > 0 ? this.rows.get(0).length : 0;
+ if (cols > 0) {
+ for (String[] row : this.rows) {
+ JSONObject o = new JSONObject();
+ for (int i = 0; i < cols; i++) {
+ o.put(this.columns[i], row[i]);
+ }
+ a.put(o);
+ }
+ }
+ return a.toString();
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
index 491775eb0..0e43cd251 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
@@ -32,6 +32,9 @@ public class ODLVersionLUT {
if (onapCCSDKVersion == null) {
return def;
}
+ if (onapCCSDKVersion.startsWith("2.2.")) {
+ return "ONAP Istanbul";
+ }
if (onapCCSDKVersion.startsWith("2.1.")) {
return "ONAP Honolulu";
}
@@ -60,6 +63,10 @@ public class ODLVersionLUT {
}
if(odlMdsalVersionLUT==null) {
odlMdsalVersionLUT = new HashMap<>();
+ odlMdsalVersionLUT.put("7.0.7","silicon-SR1 (0.14.1)");
+ odlMdsalVersionLUT.put("7.0.6","silicon-SR0 (0.14.0)");
+ odlMdsalVersionLUT.put("6.0.8","aluminium-SR3 (0.13.3)");
+ //odlMdsalVersionLUT.put("6.0.7","aluminium-SR2 (0.13.2)");
odlMdsalVersionLUT.put("6.0.7","aluminium-SR1 (0.13.1)");
odlMdsalVersionLUT.put("6.0.4","aluminium-SR0 (0.13.0)");
odlMdsalVersionLUT.put("5.0.14","magnesium-SR2 (0.12.2)");
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
index 0d46ad098..c6758e240 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
@@ -33,10 +33,8 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,22 +69,21 @@ public class YangFileProvider {
}
private List<YangFilename> findYangFiles(String module) {
+ LOG.debug("try to find yang files for {}", module);
List<YangFilename> list = new ArrayList<>();
String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
YangFilename yangfile;
- for (String file : files) {
- files = this.mainSourcePath.toFile().list(yangFilenameFilter);
- for (String fn : files) {
- try {
- yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
- if (yangfile.getModule().equals(module)) {
- list.add(yangfile);
- }
- } catch (ParseException e) {
- LOG.warn("unable to handle yangfile {}: {}", file, e);
+ for (String fn : files) {
+ try {
+ yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
}
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", fn, e);
}
}
+
for (Path addPath : this.additionalSources) {
files = addPath.toFile().list(yangFilenameFilter);
for (String file : files) {
@@ -105,7 +102,7 @@ public class YangFileProvider {
/**
* get yang file from source with specified version or least newer one if version is null then the latest one
- *
+ *
* @param module
* @param version
* @return
@@ -140,7 +137,7 @@ public class YangFileProvider {
/**
* write filestream directly to output stream easier for http handling
- *
+ *
* @param module
* @param version
* @param outputStream
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java
new file mode 100644
index 000000000..5e8dc92fc
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java
@@ -0,0 +1,74 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 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=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
+
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.Configuration;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType;
+
+public class DataProviderConfig implements Configuration {
+
+ private static final String PROPERTY_KEY_DBTYPE = "dbType";
+ private static final Object DEFAULT_DBTYPE = "${SDNRDBTYPE}";
+ private static final SdnrDbType DEFAULT_DBTYPE_VALUE = SdnrDbType.ELASTICSEARCH;
+ private final EsConfig esConfig;
+ private final SqlDBConfig maridadbConfig;
+ private ConfigurationFileRepresentation configuration;
+
+ public DataProviderConfig(ConfigurationFileRepresentation configuration) {
+ this.configuration = configuration;
+ defaults();
+ this.esConfig = new EsConfig(configuration);
+ this.maridadbConfig = new SqlDBConfig(configuration);
+ }
+
+ public EsConfig getEsConfig() {
+ return this.esConfig;
+ }
+
+ public SqlDBConfig getMariadbConfig() {
+ return this.maridadbConfig;
+ }
+
+ @Override
+ public void defaults() {
+
+ configuration.setPropertyIfNotAvailable(this.getSectionName(), PROPERTY_KEY_DBTYPE, DEFAULT_DBTYPE);
+ }
+
+ @Override
+ public String getSectionName() {
+ return ConfigurationFileRepresentation.SECTIONNAME_ROOT;
+ }
+
+ public SdnrDbType getDbType() {
+ String value = this.configuration.getProperty(this.getSectionName(), PROPERTY_KEY_DBTYPE);
+ if (value.isEmpty()) {
+ return DEFAULT_DBTYPE_VALUE;
+ }
+ return SdnrDbType.valueOf(value);
+ }
+
+
+}
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 190c78904..e06a1a9a2 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
@@ -25,7 +25,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClientException;
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.UserdataHttpServlet;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
@@ -36,6 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +52,7 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
private DataTreeHttpServlet treeServlet;
private UserdataHttpServlet userdataServlet;
private HtDatabaseClient dbClient;
+ private DataBroker dataBroker;
// Blueprint 1
public DataProviderImpl() {
@@ -77,12 +78,15 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
public void setUserdataServlet(UserdataHttpServlet userdataServlet) {
this.userdataServlet = userdataServlet;
}
+ public void setDataBroker(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ }
public void init() throws Exception {
LOG.info("Session Initiated start {}", APPLICATION_NAME);
try {
// Start RPC Service
- this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet);
+ this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet, this.dataBroker);
this.treeServlet.setDatabaseClient(this.rpcApiService.getRawClient());
this.userdataServlet.setDatabaseClient(this.rpcApiService.getHtDatabaseUserManager());
LOG.info("Session Initiated end. Initialization done");
@@ -137,11 +141,6 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
}
@Override
- public void setReadyStatus(boolean status) {
- ReadyHttpServlet.setStatus(status);
- }
-
- @Override
public void setStatus(StatusKey key, String value) {
if (this.aboutServlet != null) {
if (key == StatusKey.CLUSTER_SIZE) {
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 9e7fc18bc..ad712847f 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
@@ -25,19 +25,31 @@ import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
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;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.ElasticSearchDataProvider;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.HtUserdataManagerImpl;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.ElasticSearchDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.HtUserdataManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet;
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.HtUserdataManager;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.Keystore;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.keystore.entry.KeyCredential;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.keystore.rev171017.keystore.entry.KeyCredentialKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -92,9 +104,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,24 +118,30 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
private static final Logger LOG = LoggerFactory.getLogger(DataProviderServiceImpl.class);
public static final String CONFIGURATIONFILE = "etc/dataprovider.properties";
private static final long DATABASE_TIMEOUT_MS = 120 * 1000L;
+ private static final @NonNull InstanceIdentifier<Keystore> KEYSTORE_IIF = InstanceIdentifier.create(Keystore.class);
+ private static final long DEFAULT_PAGESIZE = 20;
+ private static final long DEFAULT_PAGE = 1;
private final ObjectRegistration<@NonNull DataProviderServiceImpl> rpcReg;
- private final ElasticSearchDataProvider dataProvider;
+ private final DatabaseDataProvider dataProvider;
private final ConfigurationFileRepresentation configuration;
- private final EsConfig esConfig;
- private final MediatorServerDataProvider mediatorServerDataProvider;
+ private final DataProviderConfig dbConfig;
private final HtUserdataManager dbUserManager;
-
- DataProviderServiceImpl(final RpcProviderService rpcProviderService, MsServlet mediatorServerServlet)
- throws Exception {
+ private final DataBroker dataBroker;
+ private final MsServlet mediatorServerServlet;
+ public DataProviderServiceImpl(final RpcProviderService rpcProviderService, MsServlet mediatorServerServlet,
+ DataBroker dataBroker) throws Exception {
this.configuration = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
- this.esConfig = new EsConfig(configuration);
- this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(), esConfig.getBasicAuthUsername(),
- esConfig.getBasicAuthPassword(), esConfig.trustAllCerts());
+ this.dbConfig = new DataProviderConfig(configuration);
+ this.dataBroker = dataBroker;
+ this.mediatorServerServlet = mediatorServerServlet;
+ if (this.dbConfig.getDbType() == SdnrDbType.ELASTICSEARCH) {
+ this.dataProvider = new ElasticSearchDataProvider(this.dbConfig.getEsConfig());
+ } else {
+ this.dataProvider = new SqlDBDataProvider(this.dbConfig.getMariadbConfig());
+ }
this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),
- esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword(),esConfig.trustAllCerts());
- mediatorServerServlet.setDataProvider(this.mediatorServerDataProvider);
+ mediatorServerServlet.setDataProvider(this.dataProvider.getHtDatabaseMediatorServer());
this.dbUserManager = new HtUserdataManagerImpl(this.dataProvider.getRawClient());
// Register ourselves as the REST API RPC implementation
LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName());
@@ -128,7 +149,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
private void sendResyncCallbackToApiGateway() {
- mediatorServerDataProvider.triggerReloadSync();
+ this.mediatorServerServlet.triggerReloadSync();
}
/**
@@ -153,7 +174,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
* @return configuration object
*/
public IEsConfig getEsConfig() {
- return esConfig;
+ return dbConfig.getEsConfig();
}
@@ -385,7 +406,6 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
read(() -> DataProviderServiceImpl.this.dataProvider.readGuiCutThroughEntry(input));
return result.buildFuture();
}
- // -- private classes and functions
private static String assembleExceptionMessage(Exception e) {
StringWriter sw = new StringWriter();
@@ -420,4 +440,6 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
return this.dbUserManager;
}
+
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
index b44906289..cb62e3326 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataTreeProviderImpl.java
@@ -70,12 +70,6 @@ public class DataTreeProviderImpl {
if (nodeId != null) {
bquery.must(QueryBuilders.matchQuery(nodeKey, nodeId));
}
- // if (parentKey != null && parentValue != null) {
- // bquery.must(QueryBuilders.matchQuery(parentKey, parentValue));
- // }
- // if (childKey != null && childValue != null) {
- // bquery.must(QueryBuilders.matchQuery(childKey, childValue));
- // }
query = bquery;
}
@@ -134,7 +128,7 @@ public class DataTreeProviderImpl {
public DataTreeObject readInventoryTree(List<String> tree, String filter) throws IOException {
//root nodes will be node-information -> below inventory
- if (tree == null || tree.isEmpty()) {
+ if (tree == null || tree.size() <= 0) {
return this.readInventoryTreeWithNode(filter);
}
//root node will be inventory on tree-level if sliced treePath
@@ -155,7 +149,7 @@ public class DataTreeProviderImpl {
throws IOException {
DataTreeObject tree = new DataTreeObject(INVENTORY_PROPERTY_PARENTUUID, INVENTORY_PROPERTY_UUID);
final String parentUuid = list.size() > 1 ? list.get(list.size() - 2) : null;
- final String uuid = list.isEmpty() ? null : list.get(list.size() - 1);
+ final String uuid = list.size() > 0 ? list.get(list.size() - 1) : null;
List<SearchHit> matches = this.search(Entity.Inventoryequipment, filter, INVENTORY_PROPERTY_NODEID, nodeId,
INVENTORY_PROPERTY_PARENTUUID, parentUuid, INVENTORY_PROPERTY_UUID, uuid, INVENTORY_PROPERTY_TREELEVEL);
@@ -163,13 +157,13 @@ public class DataTreeProviderImpl {
List<SearchHit> others = this.search(Entity.Inventoryequipment, (String) null, INVENTORY_PROPERTY_NODEID, nodeId,
null, null, null, null, INVENTORY_PROPERTY_TREELEVEL);
if (matches.size() > 0) {
- int treeLevelToStart = (list == null || list.isEmpty()) ? 0 : list.size() - 1;
+ int treeLevelToStart = (list == null || list.size() <= 0) ? 0 : list.size() - 1;
//build tree
JSONObject hitData;
//fill root elems
for (SearchHit hit : matches) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") == treeLevelToStart) {
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) == treeLevelToStart) {
tree.put(hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), true)
.setProperty(INVENTORY_PROPERTY_UUID, hitData.getString(INVENTORY_PROPERTY_UUID))
@@ -179,7 +173,7 @@ public class DataTreeProviderImpl {
}
for (SearchHit hit : others) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") == treeLevelToStart) {
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) == treeLevelToStart) {
tree.putIfNotExists(hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), false)
.setProperty(INVENTORY_PROPERTY_UUID, hitData.getString(INVENTORY_PROPERTY_UUID))
@@ -190,8 +184,8 @@ public class DataTreeProviderImpl {
//fill child elems
for (SearchHit hit : matches) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") > treeLevelToStart) {
- tree.put(hitData.getLong("tree-level") - treeLevelToStart - 1, hit.getId(),
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) > treeLevelToStart) {
+ tree.put(hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) - treeLevelToStart - 1, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), true)
.setProperty(INVENTORY_PROPERTY_UUID, hitData.getString(INVENTORY_PROPERTY_UUID))
.setProperty(INVENTORY_PROPERTY_PARENTUUID,
@@ -200,8 +194,8 @@ public class DataTreeProviderImpl {
}
for (SearchHit hit : others) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") > treeLevelToStart) {
- tree.putIfNotExists(hitData.getLong("tree-level") - treeLevelToStart - 1, hit.getId(),
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) > treeLevelToStart) {
+ tree.putIfNotExists(hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) - treeLevelToStart - 1, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), false)
.setProperty(INVENTORY_PROPERTY_UUID, hitData.getString(INVENTORY_PROPERTY_UUID))
.setProperty(INVENTORY_PROPERTY_PARENTUUID,
@@ -255,7 +249,7 @@ public class DataTreeProviderImpl {
//fill root elems
for (SearchHit hit : matches) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") == 0) {
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) == 0) {
tree.put(0, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), true)
.setProperty(INVENTORY_PROPERTY_UUID, hitData.getString(INVENTORY_PROPERTY_UUID))
@@ -266,7 +260,7 @@ public class DataTreeProviderImpl {
if (others != null) {
for (SearchHit hit : others) {
hitData = hit.getSource();
- if (hitData.getLong("tree-level") == 0) {
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) == 0) {
tree.putIfNotExists(0, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL), false)
.setProperty(INVENTORY_PROPERTY_UUID,
@@ -279,7 +273,7 @@ public class DataTreeProviderImpl {
//fill child elements
for (SearchHit hit : matches) {
hitData = hit.getSource();
- long treeLevel = hitData.getLong("tree-level");
+ long treeLevel = hitData.getLong(INVENTORY_PROPERTY_TREELEVEL);
if (treeLevel > 0) {
tree.put(treeLevel, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL_CHILD), true)
@@ -291,8 +285,8 @@ public class DataTreeProviderImpl {
if (others != null) {
for (SearchHit hit : others) {
hitData = hit.getSource();
- long treeLevel = hitData.getLong("tree-level");
- if (hitData.getLong("tree-level") > 0) {
+ long treeLevel = hitData.getLong(INVENTORY_PROPERTY_TREELEVEL);
+ if (hitData.getLong(INVENTORY_PROPERTY_TREELEVEL) > 0) {
tree.putIfNotExists(treeLevel, hit.getId(),
new DataTreeChildObject(hitData.getString(INVENTORY_PROPERTY_FOR_LABEL_CHILD), false)
.setProperty(INVENTORY_PROPERTY_UUID,
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/impl/MediatorServerDataProvider.java
index c4fe672cd..7ae7a7d40 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/impl/MediatorServerDataProvider.java
@@ -19,7 +19,7 @@
* ============LICENSE_END=========================================================
*
*/
-package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.impl;
import java.util.HashMap;
import java.util.List;
@@ -27,12 +27,8 @@ import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
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.rev201110.Entity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,26 +36,20 @@ public class MediatorServerDataProvider implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
- private final HtDatabaseClient dbClient;
- private final DataObjectAcessorWithId<Data> mediatorserverRW;
+ private final HtDatabaseMediatorserver dbClient;
private final int REFRESH_INTERVAL = 60;
- private final Map<String, Data> entries;
+ private final Map<String, MediatorServerEntity> entries;
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
private boolean isRunning;
- public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts, null, null, false);
- }
-
- public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAll) throws Exception {
- super();
- LOG.info("Start {}", this.getClass().getName());
+ public MediatorServerDataProvider(HtDatabaseMediatorserver entryProvider) {
this.entries = new HashMap<>();
- this.dbClient = HtDatabaseClient.getClient(hosts, authUsername, authPassword, trustAll);
- this.mediatorserverRW = new DataObjectAcessorWithId<>(dbClient, Entity.MediatorServer, Data.class);
+ this.dbClient = entryProvider;
this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
+ LOG.info("Start {}", this.getClass().getName());
}
+
private final Runnable onTick = new Runnable() {
@Override
@@ -72,9 +62,8 @@ public class MediatorServerDataProvider implements AutoCloseable {
};
private void runIt() {
- SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
- List<Data> data = result.getHits();
- for (Data item : data) {
+ List<MediatorServerEntity> result = this.dbClient.getAll();
+ for (MediatorServerEntity item : result) {
MediatorServerDataProvider.this.entries.put(item.getId(), item);
}
}
@@ -85,7 +74,7 @@ public class MediatorServerDataProvider implements AutoCloseable {
* @return url or null if not exists
*/
public String getHostUrl(String dbServerId) {
- Data info = this.entries.getOrDefault(dbServerId, null);
+ MediatorServerEntity info = this.entries.getOrDefault(dbServerId, null);
return info == null ? null : info.getUrl();
}
diff --git a/sdnr/wt/data-provider/provider/src/main/resources/about/README.json b/sdnr/wt/data-provider/provider/src/main/resources/about/README.json
new file mode 100644
index 000000000..f39a4c233
--- /dev/null
+++ b/sdnr/wt/data-provider/provider/src/main/resources/about/README.json
@@ -0,0 +1,16 @@
+{
+ "version-info":{
+ "ONAP-release":"{release-name}",
+ "ONAP-release-version":"{release-version}",
+ "Opendaylight-release":"{odl-version}",
+ "ONAP-CCSDK-version":"{ccsdk-version}",
+ "Build-timestamp":"{build-time}",
+ "Yangtools-version":"{yangtools-version}",
+ "MD-SAL-version":"{mdsal-version}",
+ "SDN-R packages version":"{package-version} ({package-githash})",
+ "Cluster size":"{cluster-size}"
+ },
+ "device-managers":{devicemanagers},
+ "system-info":{}
+
+} \ No newline at end of file
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 686af61d6..d5f8a991a 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
@@ -28,23 +28,10 @@
<reference id="rpcProviderService"
interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
- <reference id="bundleService"
- interface="org.apache.karaf.bundle.core.BundleService" />
-
- <bean id="readyServlet"
- class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.ReadyHttpServlet">
- <property name="bundleService" ref="bundleService"/>
- </bean>
- <service interface="javax.servlet.http.HttpServlet"
- ref="readyServlet">
- <service-properties>
- <entry key="alias" value="/ready"/>
- </service-properties>
- </service>
-
+ <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
+
<bean id="aboutServlet"
class="org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about.AboutHttpServlet">
-<!-- <property name="bundleService" ref="bundleService"/> -->
</bean>
<service interface="javax.servlet.http.HttpServlet"
ref="aboutServlet">
@@ -87,6 +74,7 @@
<property name="treeServlet" ref="treeServlet"/>
<property name="mediatorServerServlet" ref="msServlet"/>
<property name="userdataServlet" ref="userdataServlet"/>
+ <property name="dataBroker" ref="dataBroker" />
</bean>
<bean id="yangServlet"