summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common/src/main
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2020-02-24 11:17:47 +0100
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2020-02-24 11:18:16 +0100
commit64d0d3d599e0ea26ec1613b2befd411ad08f884d (patch)
tree5e9ea5e1a68bd2e836ab1f50fa51753b89a03735 /sdnr/wt/common/src/main
parenta2041a822f0406742edbd7a1074a73f9c838c0bf (diff)
update common lib
add some more es functionality Issue-ID: SDNC-1082 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: Ic7a9b0922ddd9d389e1ab6e1df3201874409a883
Diffstat (limited to 'sdnr/wt/common/src/main')
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java38
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java433
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java64
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java24
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java49
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java46
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java135
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java104
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java46
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java29
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java73
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java27
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java29
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java27
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java27
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java81
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java87
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java (renamed from sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CountResponse.java)8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java28
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java72
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java63
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java63
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java37
24 files changed, 1211 insertions, 383 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
index 094da6389..1160c281c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
@@ -22,6 +22,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConversionException;
import org.slf4j.Logger;
@@ -53,12 +55,36 @@ public class Section {
return this.getProperty(key, "");
}
- public String getProperty(String key, String defValue) {
- if (values.containsKey(key)) {
- return values.get(key).getValue();
- }
- return defValue;
- }
+ public String getProperty(final String key, final String defValue) {
+ String value=defValue;
+ LOG.debug("try to get property for {} with def {}",key,defValue);
+ if (values.containsKey(key)) {
+ value = values.get(key).getValue();
+ }
+ //try to read env var
+ if (value != null && value.contains("${")) {
+
+ LOG.debug("try to find env var(s) for {}",value);
+ final String regex = "(\\$\\{[A-Z]+\\})";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(value);
+ String tmp=new String(value);
+ while(matcher.find() && matcher.groupCount()>0) {
+ final String mkey = matcher.group(1);
+ if(mkey!=null) {
+ try {
+ LOG.debug("match found for v={} and env key={}",tmp,mkey);
+ String env=System.getenv(mkey.substring(2,mkey.length()-1));
+ tmp = tmp.replace(mkey, env==null?"":env );
+ } catch (SecurityException e) {
+ LOG.warn("unable to read env {}: {}", value, e);
+ }
+ }
+ }
+ value=tmp;
+ }
+ return value;
+ }
public String getName() {
return name;
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
index 6fb26f541..5ef326f41 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
@@ -18,6 +18,8 @@
package org.onap.ccsdk.features.sdnr.wt.common.database;
import java.io.IOException;
+import java.text.ParseException;
+
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -32,14 +34,19 @@ import org.json.JSONException;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterHealthRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateAliasRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteAliasRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteIndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetInfoRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.IndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.IndicesAliasesRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ListAliasesRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ListIndicesRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.NodeStatsRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.RefreshIndexRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
@@ -47,12 +54,17 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateByQueryReq
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AcknowledgedResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterHealthResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateAliasResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateIndexResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteAliasResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteByQueryResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteIndexResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.GetInfoResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.GetResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.IndexResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ListAliasesResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ListIndicesResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.NodeStatsResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.RefreshIndexResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.SearchResponse;
@@ -63,234 +75,247 @@ import org.slf4j.LoggerFactory;
public class ExtRestClient {
- private static final Logger LOG = LoggerFactory.getLogger(ExtRestClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ExtRestClient.class);
- private class BasicAuthHttpClientConfigCallback implements HttpClientConfigCallback {
+ private class BasicAuthHttpClientConfigCallback implements HttpClientConfigCallback {
- private final String basicAuthUsername;
- private final String basicAuthPassword;
+ private final String basicAuthUsername;
+ private final String basicAuthPassword;
- BasicAuthHttpClientConfigCallback(String username, String password) {
- this.basicAuthUsername = username;
- this.basicAuthPassword = password;
- }
+ BasicAuthHttpClientConfigCallback(String username, String password) {
+ this.basicAuthUsername = username;
+ this.basicAuthPassword = password;
+ }
- @Override
- public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
- if (basicAuthPassword == null || basicAuthUsername == null) {
- return httpClientBuilder;
- }
- final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
- credentialsProvider.setCredentials(AuthScope.ANY,
- new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword));
+ @Override
+ public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
+ if (basicAuthPassword == null || basicAuthUsername == null) {
+ return httpClientBuilder;
+ }
+ final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+ credentialsProvider.setCredentials(AuthScope.ANY,
+ new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword));
- return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
- }
+ return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
+ }
- }
-// private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
+ }
+// private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
//
-// private final String certFilename;
+// private final String certFilename;
//
-// SSLCercAuthHttpClientConfigCallback(String certfile) {
-// this.certFilename = certfile;
-// }
+// SSLCercAuthHttpClientConfigCallback(String certfile) {
+// this.certFilename = certfile;
+// }
//
-// @Override
-// public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
-// if (this.certFilename == null) {
-// return httpClientBuilder;
-// }
+// @Override
+// public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
+// if (this.certFilename == null) {
+// return httpClientBuilder;
+// }
//
-// char[] keystorePass = "MY PASSWORD".toCharArray();
+// char[] keystorePass = "MY PASSWORD".toCharArray();
//
-// FileInputStream fis = null;
+// FileInputStream fis = null;
//
-// // Loading KEYSTORE in JKS format
-// KeyStore keyStorePci = null;
-// try {
-// keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
-// } catch (KeyStoreException e1) {
-// LOG.warn("unable to load keystore: {}",e1);
-// }
-// if (keyStorePci != null) {
-// try {
-// fis = new FileInputStream(this.certFilename);
-// keyStorePci.load(fis, keystorePass);
-// } catch (Exception e) {
-// LOG.error("Error loading keystore: " + this.certFilename);
-// } finally {
-// if (fis != null) {
-// try {
-// fis.close();
-// } catch (IOException e) {
+// // Loading KEYSTORE in JKS format
+// KeyStore keyStorePci = null;
+// try {
+// keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
+// } catch (KeyStoreException e1) {
+// LOG.warn("unable to load keystore: {}",e1);
+// }
+// if (keyStorePci != null) {
+// try {
+// fis = new FileInputStream(this.certFilename);
+// keyStorePci.load(fis, keystorePass);
+// } catch (Exception e) {
+// LOG.error("Error loading keystore: " + this.certFilename);
+// } finally {
+// if (fis != null) {
+// try {
+// fis.close();
+// } catch (IOException e) {
//
-// }
-// }
-// }
-// }
-// SSLContext sslcontext=null;
-// try {
-// sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
-// } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
-// | KeyStoreException e) {
-// LOG.warn("unable to load sslcontext: {}",e);
-// }
-// return httpClientBuilder.setSSLContext(sslcontext);
-// }
-// }
-
- private RestClient client;
-
- protected ExtRestClient(HostInfo[] hosts) {
- this(hosts, null, null);
- }
- protected ExtRestClient(HostInfo[] hosts,String username,String password) {
- this.client = RestClient.builder(get(hosts)).setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password) ).build();
- }
+// }
+// }
+// }
+// }
+// SSLContext sslcontext=null;
+// try {
+// sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
+// } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
+// | KeyStoreException e) {
+// LOG.warn("unable to load sslcontext: {}",e);
+// }
+// return httpClientBuilder.setSSLContext(sslcontext);
+// }
+// }
- public ClusterHealthResponse health(ClusterHealthRequest request)
- throws UnsupportedOperationException, IOException, JSONException {
- return new ClusterHealthResponse(this.client.performRequest(request.getInner()));
- }
+ private final RestClient client;
- public void close() throws IOException {
- this.client.close();
-
- }
- //
- public boolean indicesExists(GetIndexRequest request) throws IOException {
- Response response = this.client.performRequest(request.getInner());
- return response.getStatusLine().getStatusCode()==200;
- }
+ protected ExtRestClient(HostInfo[] hosts) {
+ this(hosts, null, null);
+ }
+ protected ExtRestClient(HostInfo[] hosts,String username,String password) {
+ this.client = RestClient.builder(get(hosts)).setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password) ).build();
+ }
- public AcknowledgedResponse updateAliases(IndicesAliasesRequest request) throws IOException{
- return new AcknowledgedResponse(this.client.performRequest(request.getInner()));
- }
+ public ClusterHealthResponse health(ClusterHealthRequest request)
+ throws UnsupportedOperationException, IOException, JSONException {
+ return new ClusterHealthResponse(this.client.performRequest(request.getInner()));
+ }
- public CreateIndexResponse createIndex(CreateIndexRequest request) throws IOException {
- CreateIndexResponse response = new CreateIndexResponse(this.client.performRequest(request.getInner()));
- return response;
- }
- public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) throws IOException {
- return new DeleteIndexResponse(this.client.performRequest(request.getInner()));
- }
- public IndexResponse index(IndexRequest request) throws IOException{
- return new IndexResponse(this.client.performRequest(request.getInner()));
- }
+ public void close() throws IOException {
+ this.client.close();
- public DeleteResponse delete(DeleteRequest request) throws IOException{
- Response response=null;
- try {
- response = this.client.performRequest(request.getInner());
- }
- catch(ResponseException e) {
- new DeleteResponse(e.getResponse());
- }
- return new DeleteResponse(response);
- }
- public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException {
- Response response=null;
- try {
- response = this.client.performRequest(request.getInner());
- }
- catch(ResponseException e) {
- new DeleteResponse(e.getResponse());
- }
- return new DeleteByQueryResponse(response);
+ }
+ //
+ public boolean indicesExists(GetIndexRequest request) throws IOException {
+ Response response = this.client.performRequest(request.getInner());
+ return response.getStatusLine().getStatusCode()==200;
+ }
+
+ public AcknowledgedResponse updateAliases(IndicesAliasesRequest request) throws IOException{
+ return new AcknowledgedResponse(this.client.performRequest(request.getInner()));
+ }
+
+ public CreateIndexResponse createIndex(CreateIndexRequest request) throws IOException {
+ return new CreateIndexResponse(this.client.performRequest(request.getInner()));
+ }
+ public CreateAliasResponse createAlias(CreateAliasRequest request) throws IOException {
+ return new CreateAliasResponse(this.client.performRequest(request.getInner()));
}
- public SearchResponse search(SearchRequest request) throws IOException{
- return this.search(request,false);
+ public DeleteAliasResponse deleteAlias(DeleteAliasRequest request) throws IOException {
+ return new DeleteAliasResponse(this.client.performRequest(request.getInner()));
}
+ public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) throws IOException {
+ return new DeleteIndexResponse(this.client.performRequest(request.getInner()));
+ }
+ public IndexResponse index(IndexRequest request) throws IOException{
+ return new IndexResponse(this.client.performRequest(request.getInner()));
+ }
- /**
- *
- * @param request
- * @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
- * @return
- * @throws IOException
- */
- public SearchResponse search(SearchRequest request, boolean ignoreParseException) throws IOException {
- if (ignoreParseException) {
- try {
- return new SearchResponse(this.client.performRequest(request.getInner()));
- } catch (ResponseException e) {
- LOG.debug("ignoring Exception for request {}: {}",request,e.getMessage());
- return new SearchResponse(e.getResponse());
- }
- } else {
- return new SearchResponse(this.client.performRequest(request.getInner()));
- }
- }
+ public DeleteResponse delete(DeleteRequest request) throws IOException{
+ Response response=null;
+ try {
+ response = this.client.performRequest(request.getInner());
+ }
+ catch(ResponseException e) {
+ new DeleteResponse(e.getResponse());
+ }
+ return new DeleteResponse(response);
+ }
+ public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException {
+ Response response=null;
+ try {
+ response = this.client.performRequest(request.getInner());
+ }
+ catch(ResponseException e) {
+ new DeleteResponse(e.getResponse());
+ }
+ return new DeleteByQueryResponse(response);
+ }
+ public SearchResponse search(SearchRequest request) throws IOException{
+ return this.search(request,false);
+ }
- public GetResponse get(GetRequest request) throws IOException{
- try {
- return new GetResponse(this.client.performRequest(request.getInner()));
- }
- catch (ResponseException e) {
- return new GetResponse(e.getResponse());
- }
- }
-
+ /**
+ * Search for database entries
+ * @param request inputRequest
+ * @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
+ * @return Response with related entries
+ * @throws IOException of client
+ */
+ public SearchResponse search(SearchRequest request, boolean ignoreParseException) throws IOException {
+ if (ignoreParseException) {
+ try {
+ return new SearchResponse(this.client.performRequest(request.getInner()));
+ } catch (ResponseException e) {
+ LOG.debug("ignoring Exception for request {}: {}",request,e.getMessage());
+ return new SearchResponse(e.getResponse());
+ }
+ } else {
+ return new SearchResponse(this.client.performRequest(request.getInner()));
+ }
+ }
- public UpdateByQueryResponse update(UpdateByQueryRequest request) throws IOException {
- return new UpdateByQueryResponse(this.client.performRequest(request.getInner()));
-
- }
- public UpdateResponse update(UpdateRequest request) throws IOException {
- return new UpdateResponse(this.client.performRequest(request.getInner()));
-
- }
- public RefreshIndexResponse refreshIndex(RefreshIndexRequest request) throws IOException{
- return new RefreshIndexResponse(this.client.performRequest(request.getInner()));
- }
-
- public NodeStatsResponse stats(NodeStatsRequest request) throws IOException{
- return new NodeStatsResponse(this.client.performRequest(request.getInner()));
- }
-
- public boolean waitForYellowStatus(long timeoutms) {
-
- ClusterHealthRequest request = new ClusterHealthRequest();
- request.timeout(timeoutms/1000);
- ClusterHealthResponse response = null;
- String status="";
- try {
- response = this.health(request);
-
- } catch (UnsupportedOperationException | IOException | JSONException e) {
- LOG.error(e.getMessage());
- }
- if(response!=null) {
- status=response.getStatus();
- LOG.debug("Elasticsearch service started with status {}", response.getStatus());
-
- }
- else {
- LOG.warn("Elasticsearch service not started yet with status {}. current status is {}",status,"none");
- return false;
- }
- return response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW);
+ public GetResponse get(GetRequest request) throws IOException{
+ try {
+ return new GetResponse(this.client.performRequest(request.getInner()));
+ }
+ catch (ResponseException e) {
+ return new GetResponse(e.getResponse());
+ }
+ }
- }
-
- private static HttpHost[] get(HostInfo[] hosts) {
- HttpHost[] httphosts = new HttpHost[hosts.length];
- for(int i=0;i<hosts.length;i++) {
- httphosts[i]=new HttpHost(hosts[i].hostname, hosts[i].port, hosts[i].protocol.toString());
- }
- return httphosts;
- }
- public static ExtRestClient createInstance(HostInfo[] hosts) {
- return new ExtRestClient(hosts);
- }
- public static ExtRestClient createInstance(HostInfo[] hosts,String username,String password) {
- return new ExtRestClient(hosts,username,password);
- }
- public static ExtRestClient createInstance(String hostname, int port, Protocol protocol){
- return createInstance(new HostInfo[] {new HostInfo(hostname,port,protocol)});
- }
-
+ public UpdateByQueryResponse update(UpdateByQueryRequest request) throws IOException {
+ return new UpdateByQueryResponse(this.client.performRequest(request.getInner()));
+
+ }
+ public UpdateResponse update(UpdateRequest request) throws IOException {
+ return new UpdateResponse(this.client.performRequest(request.getInner()));
+
+ }
+ public RefreshIndexResponse refreshIndex(RefreshIndexRequest request) throws IOException{
+ return new RefreshIndexResponse(this.client.performRequest(request.getInner()));
+ }
+
+ public NodeStatsResponse stats(NodeStatsRequest request) throws IOException{
+ return new NodeStatsResponse(this.client.performRequest(request.getInner()));
+ }
+ public ListIndicesResponse getIndices() throws ParseException, IOException {
+ return new ListIndicesResponse(this.client.performRequest(new ListIndicesRequest().getInner()));
+ }
+ public ListAliasesResponse getAliases() throws ParseException, IOException {
+ return new ListAliasesResponse(this.client.performRequest(new ListAliasesRequest().getInner()));
+ }
+ public GetInfoResponse getInfo() throws IOException, Exception {
+ return new GetInfoResponse(this.client.performRequest(new GetInfoRequest().getInner()));
+ }
+ public boolean waitForYellowStatus(long timeoutms) {
+
+ ClusterHealthRequest request = new ClusterHealthRequest();
+ request.timeout(timeoutms/1000);
+ ClusterHealthResponse response = null;
+ String status="";
+ try {
+ response = this.health(request);
+
+ } catch (UnsupportedOperationException | IOException | JSONException e) {
+ LOG.error(e.getMessage());
+ }
+ if(response!=null) {
+ status=response.getStatus();
+ LOG.debug("Elasticsearch service started with status {}", response.getStatus());
+
+ }
+ else {
+ LOG.warn("Elasticsearch service not started yet with status {}. current status is {}",status,"none");
+ return false;
+ }
+ return response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW);
+
+ }
+
+ private static HttpHost[] get(HostInfo[] hosts) {
+ HttpHost[] httphosts = new HttpHost[hosts.length];
+ for(int i=0;i<hosts.length;i++) {
+ httphosts[i]=new HttpHost(hosts[i].hostname, hosts[i].port, hosts[i].protocol.toString());
+ }
+ return httphosts;
+ }
+ public static ExtRestClient createInstance(HostInfo[] hosts) {
+ return new ExtRestClient(hosts);
+ }
+ public static ExtRestClient createInstance(HostInfo[] hosts,String username,String password) {
+ return new ExtRestClient(hosts,username,password);
+ }
+ public static ExtRestClient createInstance(String hostname, int port, Protocol protocol){
+ return createInstance(new HostInfo[] {new HostInfo(hostname,port,protocol)});
+
+ }
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
index 9a04f0dfd..d64f7cc01 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
@@ -26,6 +26,7 @@ import org.json.JSONObject;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
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.CreateAliasRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
@@ -35,6 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.RefreshIndexRequ
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateIndexResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteByQueryResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteResponse;
import org.onap.ccsdk.features.sdnr.wt.common.database.responses.GetResponse;
@@ -293,5 +295,5 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
}
return del;
}
-
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
index b6df2620b..020dd2b46 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
@@ -21,42 +21,38 @@ import org.json.JSONObject;
public class SearchHit {
- private final String index;
- private final String type;
- private final String id;
- private final JSONObject source;
- private final JSONObject raw;
+ private final String index;
+ private final String type;
+ private final String id;
+ private final JSONObject source;
+ private final JSONObject raw;
- public SearchHit(JSONObject o) {
- this.raw = o;
- this.index=o.getString("_index");
- this.type = o.getString("_type");
- this.id = o.getString("_id");
- this.source = o.getJSONObject("_source");
- }
-
- public String getIndex() {
- return this.index;
- }
- public String getType() {
- return this.type;
- }
- public String getId() {
- return this.id;
- }
+ public SearchHit(JSONObject o) {
+ this.raw = o;
+ this.index=o.getString("_index");
+ this.type = o.getString("_type");
+ this.id = o.getString("_id");
+ this.source = o.getJSONObject("_source");
+ }
- public JSONObject getSource() {
- return this.source;
- }
- public String getSourceAsString() {
- return this.source.toString();
- }
+ public String getIndex() {
+ return this.index;
+ }
+ public String getType() {
+ return this.type;
+ }
+ public String getId() {
+ return this.id;
+ }
- /**
- * @return
- */
- public JSONObject getRaw() {
- return this.raw;
- }
+ public JSONObject getSource() {
+ return this.source;
+ }
+ public String getSourceAsString() {
+ return this.source.toString();
+ }
+ public JSONObject getRaw() {
+ return this.raw;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
index 11554b5b6..2b4172df8 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
@@ -17,6 +17,10 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.common.database.config;
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
public class HostInfo {
public enum Protocol{
@@ -75,4 +79,24 @@ public class HostInfo {
public static HostInfo getDefault() {
return new HostInfo("localhost",9200,Protocol.HTTP);
}
+
+ /**
+ * @param dbUrl
+ * @return
+ */
+ public static HostInfo parse(String dbUrl) throws ParseException{
+ final String regex = "^(https?):\\/\\/([^:]*):?([0-9]{0,5})$";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(dbUrl);
+ if(!matcher.find() || matcher.groupCount()<2) {
+ throw new ParseException("url "+dbUrl+" not parseable", 0);
+ }
+ Protocol p = Protocol.getValueOf(matcher.group(1));
+ String host = matcher.group(2);
+ int port = p==Protocol.HTTP?80:443;
+ if(matcher.groupCount()>2) {
+ port=Integer.parseInt(matcher.group(3));
+ }
+ return new HostInfo(host,port,p);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java
new file mode 100644
index 000000000..73d50db83
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * 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.common.database.data;
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class AliasesEntry {
+ private static final String regex = "^([^\\ ]+)[\\ ]+([^\\ ]+)[\\ ]+.*$";
+ private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+
+
+ public String getAlias() {
+ return alias;
+ }
+ public String getIndex() {
+ return index;
+ }
+ private final String alias;
+ private final String index;
+ public AliasesEntry(String line) throws ParseException {
+ final Matcher matcher = pattern.matcher(line);
+ if (!matcher.find() || matcher.groupCount() < 2) {
+ throw new ParseException("unable to parse string:" + line, 0);
+ }
+ this.alias = matcher.group(1);
+ this.index = matcher.group(2);
+ }
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java
new file mode 100644
index 000000000..a3a8e728d
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * 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.common.database.data;
+
+import java.util.ArrayList;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class AliasesEntryList extends ArrayList<AliasesEntry>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param alias
+ * @return
+ */
+ public AliasesEntry findByAlias(String alias) {
+ for(AliasesEntry e:this) {
+ if(e.getAlias().equals(alias)) {
+ return e;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java
new file mode 100644
index 000000000..8d5269115
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * 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.common.database.data;
+
+import java.text.ParseException;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class EsVersion {
+
+ private final String raw;
+ private final int major;
+ private final int minor;
+ private final int revision;
+
+ public EsVersion(@NonNull String version) throws ParseException {
+ String[] hlp=version.split("\\.");
+ if(hlp.length<3) {
+ throw new ParseException("unable to parse version string: "+version, 0);
+ }
+ this.raw = version;
+ this.major = Integer.parseInt(hlp[0]);
+ this.minor = Integer.parseInt(hlp[1]);
+ this.revision = Integer.parseInt(hlp[2]);
+ }
+
+ /**
+ * @param major
+ * @param minor
+ * @param revision
+ */
+ public EsVersion(int major, int minor, int revision) {
+ this.raw = String.format("%d.%d.%d", major,minor,revision);
+ this.major = major;
+ this.minor = minor;
+ this.revision = revision;
+ }
+
+ /**
+ * @return the revision
+ */
+ public int getRevision() {
+ return revision;
+ }
+
+ /**
+ * @return the minor
+ */
+ public int getMinor() {
+ return minor;
+ }
+
+ /**
+ * @return the major
+ */
+ public int getMajor() {
+ return major;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if(!(obj instanceof EsVersion)) {
+ return false;
+ }
+ EsVersion esobj = (EsVersion)obj;
+ return this.major==esobj.major && this.minor==esobj.minor && this.revision==esobj.revision;
+ }
+ @Override
+ public int hashCode() {
+ return this.raw.hashCode();
+ }
+ public boolean isNewerOrEqualThan(EsVersion v) {
+ if(this.equals(v)) {
+ return true;
+ }
+ if(this.major>v.major) {
+ return true;
+ }
+ else if(this.major<v.major) {
+ return false;
+ }
+ if(this.minor>v.minor) {
+ return true;
+ }
+ else if(this.minor<v.minor) {
+ return false;
+ }
+ if(this.revision>v.revision) {
+ return true;
+ }
+ return false;
+ }
+ public boolean isOlderOrEqualThan(EsVersion v) {
+ if(this.equals(v)) {
+ return true;
+ }
+ if(this.major<v.major) {
+ return true;
+ }
+ else if(this.major>v.major) {
+ return false;
+ }
+ if(this.minor<v.minor) {
+ return true;
+ }
+ else if(this.minor>v.minor) {
+ return false;
+ }
+ if(this.revision<v.revision) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
new file mode 100644
index 000000000..760f9ff70
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * 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.common.database.data;
+
+import java.text.ParseException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Michael Dürre
+ *
+ * Entry of list indices http request (/_cat/indices)
+ *
+ * yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb
+ */
+public class IndicesEntry {
+
+ private static final String regex = "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
+ private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+
+ private final String status;
+ private final String status2;
+ private final String name;
+ private final String hash;
+ private final int shards;
+ private final int replicas;
+ private final int c1;
+ private final int c2;
+ private final String size1;
+ private final String size2;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getStatus2() {
+ return status2;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getHash() {
+ return hash;
+ }
+
+ public int getShards() {
+ return shards;
+ }
+
+ public int getReplicas() {
+ return replicas;
+ }
+
+ public int getC1() {
+ return c1;
+ }
+
+ public int getC2() {
+ return c2;
+ }
+
+ public String getSize1() {
+ return size1;
+ }
+
+ public String getSize2() {
+ return size2;
+ }
+
+ public IndicesEntry(String line) throws ParseException {
+ final Matcher matcher = pattern.matcher(line);
+ if(!matcher.find() || matcher.groupCount()<10) {
+ throw new ParseException("unable to parse string:" +line,0);
+ }
+ this.status = matcher.group(1);
+ this.status2 = matcher.group(2);
+ this.name = matcher.group(3);
+ this.hash = matcher.group(4);
+ this.shards = Integer.parseInt(matcher.group(5));
+ this.replicas = Integer.parseInt(matcher.group(6));
+ this.c1 = Integer.parseInt(matcher.group(7));
+ this.c2 = Integer.parseInt(matcher.group(8));
+ this.size1 = matcher.group(9);
+ this.size2 = matcher.group(10);
+
+ }
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java
new file mode 100644
index 000000000..0931b44a5
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * 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.common.database.data;
+
+import java.util.ArrayList;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class IndicesEntryList extends ArrayList<IndicesEntry>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * @param index
+ * @return
+ */
+ public IndicesEntry findByIndex(String index) {
+ for(IndicesEntry e:this) {
+ if(e.getName().equals(index)) {
+ return e;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java
new file mode 100644
index 000000000..15132fda5
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
+
+//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_alias.json
+public class CreateAliasRequest extends BaseRequest{
+
+
+ public CreateAliasRequest(String index,String alias) {
+ super("PUT","/"+index+"/_alias/"+alias);
+ }
+
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
index c7e27ee4a..c08ee880b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
@@ -23,41 +23,42 @@ import org.json.JSONObject;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json
public class CreateIndexRequest extends BaseRequest{
- private JSONObject settings;
- private JSONObject mappings;
-
- public CreateIndexRequest(String index) {
- super("PUT","/"+index);
- this.mappings=new JSONObject();
- }
-
- private void setRequest() {
-
- JSONObject o=new JSONObject();
- if(this.mappings!=null) {
- o.put("mappings", this.mappings);
- }
- if(this.settings!=null) {
- o.put("settings", this.settings);
- }
- super.setQuery(o);
- }
- public void mappings(JSONObject mappings) {
- this.mappings=mappings;
- this.setRequest();
- }
-
- public void settings(JSONObject settings) {
- this.settings = settings;
- this.setRequest();
- }
-
- public boolean hasMappings() {
- return this.mappings!=null;
- }
-
- public boolean hasSettings() {
- return this.settings!=null;
- }
+ private JSONObject settings;
+ private JSONObject mappings;
+
+ public CreateIndexRequest(String index) {
+ super("PUT","/"+index);
+ this.mappings=new JSONObject();
+ }
+
+ private void setRequest() {
+
+ JSONObject o=new JSONObject();
+ if(this.mappings!=null) {
+ o.put("mappings", this.mappings);
+ }
+ if(this.settings!=null) {
+ o.put("settings", this.settings);
+ }
+ super.setQuery(o);
+ }
+ @SuppressWarnings("hiding")
+ public void mappings(JSONObject mappings) {
+ this.mappings=mappings;
+ this.setRequest();
+ }
+
+ public void settings(JSONObject settings) {
+ this.settings = settings;
+ this.setRequest();
+ }
+
+ public boolean hasMappings() {
+ return this.mappings!=null;
+ }
+
+ public boolean hasSettings() {
+ return this.settings!=null;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java
new file mode 100644
index 000000000..b3d8877df
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
+
+//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_alias.json
+public class DeleteAliasRequest extends BaseRequest{
+
+ public DeleteAliasRequest(String index,String alias) {
+ super("DELETE","/"+index+"/_alias/"+alias);
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java
new file mode 100644
index 000000000..949444b35
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
+
+//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists.json
+public class GetInfoRequest extends BaseRequest {
+
+ public GetInfoRequest() {
+ super("GET","/");
+ }
+
+
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java
new file mode 100644
index 000000000..b538291b0
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
+
+public class ListAliasesRequest extends BaseRequest{
+
+
+ public ListAliasesRequest() {
+ super("GET","/_cat/aliases");
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java
new file mode 100644
index 000000000..d8b7d5fee
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
+
+public class ListIndicesRequest extends BaseRequest{
+
+
+ public ListIndicesRequest() {
+ super("GET","/_cat/indices");
+ }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
index 49447f660..01219f0f0 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
@@ -18,9 +18,11 @@
package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
import java.io.IOException;
-import java.io.InputStream;
-import java.util.Scanner;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Response;
import org.json.JSONObject;
import org.slf4j.Logger;
@@ -28,48 +30,61 @@ import org.slf4j.LoggerFactory;
public class BaseResponse {
private static final Logger LOG = LoggerFactory.getLogger(BaseResponse.class);
- private int responseCode;
- public int getResponseCode() {
+ private final int responseCode;
+
+ BaseResponse(Response response) {
+ this.responseCode = response != null ? response.getStatusLine().getStatusCode() : 0;
+ }
+
+ int getResponseCode() {
return this.responseCode;
}
+
public boolean isResponseSucceeded() {
- return this.responseCode<300;
+ return this.responseCode < 300;
}
- public BaseResponse() {
- }
- public BaseResponse(Response response) {
- this.responseCode = response!=null?response.getStatusLine().getStatusCode():0;
- }
- protected JSONObject getJson(Response response) {
- Scanner s;
- JSONObject o=null;
- try {
- //input stream used because Scanner ignored whitespaces
- InputStream is = response.getEntity().getContent();
- long len;
- int BUFSIZE=1024;
- byte[] buffer = new byte[BUFSIZE];
- StringBuffer sresponse = new StringBuffer();
- while (true) {
- len = is.read(buffer, 0, BUFSIZE);
- if (len <= 0) {
- break;
- }
-
- sresponse.append(new String(buffer));
- }
- LOG.debug("parsing response={}",sresponse);
- o = new JSONObject(sresponse.toString());
+ JSONObject getJson(Response response) {
+ try {
+ String sresponse = EntityUtils.toString(response.getEntity());
+ LOG.debug("parsing response={}", sresponse);
+ return new JSONObject(sresponse);
} catch (UnsupportedOperationException | IOException e) {
- LOG.warn("error parsing es response: {}",e.getMessage());
+ LOG.warn("error parsing es response: {}", e.getMessage());
+ return null;
}
- return o;
}
- protected JSONObject getJson(String json) {
+
+ JSONObject getJson(String json) {
return new JSONObject(json);
}
+ /**
+ * @param response
+ * @return
+ */
+ List<String> getLines(Response response){
+ return this.getLines(response,true);
+ }
+ List<String> getLines(Response response,boolean ignoreEmpty) {
+ try {
+ String sresponse = EntityUtils.toString(response.getEntity());
+ LOG.debug("parsing response={}", sresponse);
+ String[] hlp = sresponse.split("\n");
+ List<String> lines=new ArrayList<String>();
+ for(String h:hlp) {
+ if(ignoreEmpty && h.trim().length()==0) {
+ continue;
+ }
+ lines.add(h);
+ }
+ return lines;
+ } catch (UnsupportedOperationException | IOException e) {
+ LOG.warn("error parsing es response: {}", e.getMessage());
+ return null;
+ }
+
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
index 3f47ac286..b90bbbce2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
@@ -24,53 +24,54 @@ import org.json.JSONObject;
public class ClusterHealthResponse extends BaseResponse {
- public static final String HEALTHSTATUS_GREEN = "green";
- public static final String HEALTHSTATUS_YELLOW = "yellow";
- public static final String HEALTSTATUS_RED = "red";
+ public static final String HEALTHSTATUS_GREEN = "green";
+ public static final String HEALTHSTATUS_YELLOW = "yellow";
+ public static final String HEALTSTATUS_RED = "red";
- private String status;
- private boolean timedOut;
+ private String status;
+ private boolean timedOut;
- /*
- * "cluster_name": "docker-cluster", "status": "yellow", "timed_out": false,
- * "number_of_nodes": 1, "number_of_data_nodes": 1, "active_primary_shards": 5,
- * "active_shards": 5, "relocating_shards": 0, "initializing_shards": 0,
- * "unassigned_shards": 5, "delayed_unassigned_shards": 0,
- * "number_of_pending_tasks": 0, "number_of_in_flight_fetch": 0,
- * "task_max_waiting_in_queue_millis": 0, "active_shards_percent_as_number": 50
- */
- public ClusterHealthResponse(Response response) throws UnsupportedOperationException, IOException, JSONException {
- super(response);
-
- JSONObject o = this.getJson(response);
- if (o != null) {
- this.status = o.getString("status");
- this.timedOut = o.getBoolean("timed_out");
- }
- }
+ /*
+ * "cluster_name": "docker-cluster", "status": "yellow", "timed_out": false,
+ * "number_of_nodes": 1, "number_of_data_nodes": 1, "active_primary_shards": 5,
+ * "active_shards": 5, "relocating_shards": 0, "initializing_shards": 0,
+ * "unassigned_shards": 5, "delayed_unassigned_shards": 0,
+ * "number_of_pending_tasks": 0, "number_of_in_flight_fetch": 0,
+ * "task_max_waiting_in_queue_millis": 0, "active_shards_percent_as_number": 50
+ */
+ public ClusterHealthResponse(Response response) throws UnsupportedOperationException, IOException, JSONException {
+ super(response);
- public boolean isTimedOut() {
- return this.timedOut;
- }
- public boolean isStatusMinimal(String status) {
- if (status == null) {
- return true;
- }
- if (this.status.equals(HEALTHSTATUS_GREEN)) {
- return true;
- }
- if (this.status.equals(HEALTHSTATUS_YELLOW) && !status.equals(HEALTHSTATUS_GREEN)) {
- return true;
- }
- if (this.status.equals(status)) {
- return true;
- }
- return false;
+ JSONObject o = this.getJson(response);
+ if (o != null) {
+ this.status = o.getString("status");
+ this.timedOut = o.getBoolean("timed_out");
+ }
+ }
- }
+ public boolean isTimedOut() {
+ return this.timedOut;
+ }
+ @SuppressWarnings("hiding")
+ public boolean isStatusMinimal(String status) {
+ if (status == null) {
+ return true;
+ }
+ if (this.status.equals(HEALTHSTATUS_GREEN)) {
+ return true;
+ }
+ if (this.status.equals(HEALTHSTATUS_YELLOW) && !status.equals(HEALTHSTATUS_GREEN)) {
+ return true;
+ }
+ if (this.status.equals(status)) {
+ return true;
+ }
+ return false;
- public String getStatus() {
- return this.status;
- }
+ }
+
+ public String getStatus() {
+ return this.status;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CountResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java
index 429c3394d..280ce3999 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CountResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java
@@ -19,12 +19,10 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
import org.elasticsearch.client.Response;
-public class CountResponse extends BaseResponse {
+public class CreateAliasResponse extends AcknowledgedResponse {
- private long count;
-
- public CountResponse(Response response) {
+ public CreateAliasResponse(Response response) {
super(response);
-
}
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java
new file mode 100644
index 000000000..291aff0f5
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
+
+import org.elasticsearch.client.Response;
+
+public class DeleteAliasResponse extends AcknowledgedResponse {
+
+ public DeleteAliasResponse(Response response) {
+ super(response);
+ }
+
+} \ No newline at end of file
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java
new file mode 100644
index 000000000..9b579f5c4
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
+
+import org.elasticsearch.client.Response;
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
+
+public class GetInfoResponse extends BaseResponse {
+
+ /**
+ * {
+ * "name" : "kpOdXt-",
+ * "cluster_name" : "docker-cluster",
+ * "cluster_uuid" : "qags6CGGTrS75iBhrAdsgg",
+ * "version" : {
+ * "number" : "6.4.3",
+ * "build_flavor" : "default",
+ * "build_type" : "tar",
+ * "build_hash" : "fe40335",
+ * "build_date" : "2018-10-30T23:17:19.084789Z",
+ * "build_snapshot" : false,
+ * "lucene_version" : "7.4.0",
+ * "minimum_wire_compatibility_version" : "5.6.0",
+ * "minimum_index_compatibility_version" : "5.0.0"
+ * },
+ * "tagline" : "You Know, for Search"
+ *}
+ */
+ private final String clusterName;
+ private final String name;
+
+ private final EsVersion version;
+ public GetInfoResponse(Response response) throws Exception {
+ super(response);
+ JSONObject o = this.getJson(response);
+ if(o==null) {
+ throw new Exception("unable to read response");
+ }
+ this.name = o.getString("name");
+ this.clusterName = o.getString("cluster_name");
+ this.version = new EsVersion(o.getJSONObject("version").getString("number"));
+ }
+ public String getClusterName() {
+ return clusterName;
+ }
+ public String getName() {
+ return name;
+ }
+ public EsVersion getVersion() {
+ return version;
+ }
+
+
+
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java
new file mode 100644
index 000000000..29e51fe8c
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
+
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.elasticsearch.client.Response;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntryList;
+
+public class ListAliasesResponse extends BaseResponse {
+
+ /*
+ * eventlog eventlog-v1 - - -
+ * faultlog faultlog-v1 - - -
+ * inventoryequipment inventoryequipment-v1 - - -
+ * historicalperformance24h historicalperformance24h-v1 - - -
+ * mediator-server mediator-server-v1 - - -
+ * networkelement-connection networkelement-connection-v1 - - -
+ * maintenancemode maintenancemode-v1 - - -
+ * historicalperformance15min historicalperformance15min-v1 - - -
+ * faultcurrent faultcurrent-v1 - - -
+ * connectionlog connectionlog-v1 - - -
+ */
+ private final AliasesEntryList entries;
+ public ListAliasesResponse(Response response) throws ParseException {
+ super(response);
+ List<String> lines=this.getLines(response);
+ this.entries = new AliasesEntryList();
+ if(lines!=null) {
+ for(String line:lines) {
+ this.entries.add(new AliasesEntry(line));
+ }
+ }
+ }
+ /**
+ *
+ * @return null if parsing failed otherwise valid (=>no entries may also be valid)
+ */
+ public AliasesEntryList getEntries(){
+ return this.entries;
+ }
+
+
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java
new file mode 100644
index 000000000..cfbe1599a
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ ******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
+
+import java.text.ParseException;
+import java.util.List;
+
+import org.elasticsearch.client.Response;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntry;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
+
+public class ListIndicesResponse extends BaseResponse {
+
+ /*
+ * yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb
+ * yellow open eventlog-v1 8lkfX97iT86dZdUlgVAktg 5 1 0 0 1.2kb 1.2kb
+ * yellow open mediator-server-v1 8T4hNo61SgulupKntivY4Q 5 1 0 0 1.2kb 1.2kb
+ * yellow open historicalperformance24h-v1 fRCGb7JYRdiry23HKWg0Hw 5 1 0 0 1.2kb 1.2kb
+ * yellow open faultlog-v1 kjsb50boTPOAzXMYdnfv4A 5 1 0 0 1.2kb 1.2kb
+ * yellow open maintenancemode-v1 Q9ZsCgW0Q9m6nk49iOFNhA 5 1 0 0 1.2kb 1.2kb
+ * yellow open historicalperformance15min-v1 BdEOe7X2RK2o5yTwNH5QQg 5 1 0 0 1.2kb 1.2kb
+ * yellow open faultcurrent-v1 BdikWk9HQtS5aFpYEAac2g 5 1 0 0 1.2kb 1.2kb
+ * yellow open networkelement-connection-v1 YT3lj0AKRoOmtN30Zbdfqw 5 1 0 0 1.2kb 1.2kb
+ * yellow open connectionlog-v1 7yrVaaM1QjyO5eMsCUHNHQ 5 1 0 0 1.2kb 1.2kb
+ */
+ private final IndicesEntryList entries;
+ public ListIndicesResponse(Response response) throws ParseException {
+ super(response);
+ List<String> lines=this.getLines(response);
+ this.entries = new IndicesEntryList();
+ if(lines!=null) {
+ for(String line:lines) {
+ this.entries.add(new IndicesEntry(line));
+ }
+ }
+
+ }
+ /**
+ * @return
+ */
+ public IndicesEntryList getEntries() {
+ return this.entries;
+ }
+
+
+
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
index 63c1f15ba..11e6cb877 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
@@ -1,26 +1,21 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk features
- * ================================================================================
- * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
- * All rights reserved.
- * ================================================================================
- * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
+ * =================================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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=======================================================
- *
- */
+ * 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.common.file;
import java.io.File;