summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main')
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanProvider.java39
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java155
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java29
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java4
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java3
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java21
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java4
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java52
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java5
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java147
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java27
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java53
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java14
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java13
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java30
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java7
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java1
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/database/types/EsEventOdluxLog.java92
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java50
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/index/mwtn/modelDescription/maintenancemode.json23
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml5
22 files changed, 637 insertions, 139 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanProvider.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanProvider.java
new file mode 100644
index 000000000..44fae6d61
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanProvider.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * ============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.devicemanager.archiveservice;
+
+import java.util.Date;
+
+public interface ArchiveCleanProvider {
+
+ /**
+ * Remove all index data older, than specified
+ * @param olderAreOutdated time to specify older elements
+ * @return number of removed elements
+ */
+ int doIndexClean(Date olderAreOutdated);
+
+ /**
+ * Get number of elements older then
+ * @param olderAreOutdated date to compare with and specify older elements
+ * @return number of elements
+ */
+ public int getNumberOfOldObjects(Date olderAreOutdated);
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java
new file mode 100644
index 000000000..eb48b87c4
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/archiveservice/ArchiveCleanService.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * ============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.devicemanager.archiveservice;
+
+import java.util.Date;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.HtDevicemanagerConfiguration;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.IConfigChangedListener;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.EsConfig;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
+import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class ArchiveCleanService implements AutoCloseable, IConfigChangedListener, Runnable,ClusterSingletonService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class);
+ private static final ServiceGroupIdentifier IDENT = ServiceGroupIdentifier.create("ElasticSearchArchiveCleanService");
+
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+ private final ArchiveCleanProvider[] indexCleanList;
+ private final HtDevicemanagerConfiguration htconfig;
+ private final Runnable doClean;
+
+ private EsConfig config;
+ private Future<?> taskReference;
+ private boolean isMaster;
+
+ public ArchiveCleanService(HtDevicemanagerConfiguration config, ArchiveCleanProvider... indexCleanList) {
+ this.config = config.getEs();
+ this.htconfig = config;
+ this.htconfig.registerConfigChangedListener(this);
+ this.indexCleanList = indexCleanList;
+ this.doClean = this;
+ this.taskReference = null;
+
+ this.reinit();
+ }
+
+ private void reinit() {
+
+ if (taskReference != null) {
+ taskReference.cancel(false);
+ }
+ if(this.isMaster) {
+ if (this.config.getArchiveCheckIntervalSeconds() > 0) {
+ LOG.info("DBCleanService is turned on for entries older than {} seconds",
+ this.config.getArchiveLifetimeSeconds());
+ taskReference = this.scheduler.scheduleAtFixedRate(doClean, 0,
+ this.config.getArchiveCheckIntervalSeconds(), TimeUnit.SECONDS);
+ } else {
+ LOG.info("DBCleanService is turned off");
+ }
+ }
+ else {
+ LOG.info("service is inactive on this node. active on another node.");
+ }
+ }
+
+ public Date getDateForOldElements() {
+ return new Date(System.currentTimeMillis() - config.getArchiveLifetimeSeconds() * 1000);
+ }
+
+ public int countOldEntries() {
+ int cnt = 0;
+ Date olderAreOutdated = getDateForOldElements();
+ for (ArchiveCleanProvider indexCleanElement : indexCleanList) {
+ if (indexCleanElement != null) {
+ indexCleanElement.getNumberOfOldObjects(olderAreOutdated);
+ }
+ }
+ return cnt;
+ }
+
+ @Override
+ public void run() {
+
+ try {
+ int removed = 0;
+ Date olderElementToBeRemoved = getDateForOldElements();
+ LOG.trace("cleaning logs from entries older than {}", olderElementToBeRemoved);
+
+ for (ArchiveCleanProvider indexCleanElement : indexCleanList) {
+ if (indexCleanElement != null) {
+ removed += indexCleanElement.doIndexClean(olderElementToBeRemoved);
+ }
+ }
+ if (removed > 0) {
+ LOG.trace("Removed elements: {}",removed);
+ }
+ } catch (Exception e) {
+ LOG.warn("problem executing dbclean", e);
+ }
+ }
+
+ @Override
+ public void onConfigChanged() {
+ LOG.debug("config changed. reninit timer");
+ ArchiveCleanService.this.config = EsConfig.reload();
+ ArchiveCleanService.this.reinit();
+ };
+
+ @Override
+ public void close() throws Exception {
+ this.htconfig.unregisterConfigChangedListener(this);
+ this.scheduler.shutdown();
+ }
+
+ @Override
+ public String toString() {
+ return "ArchivCleanService [ArchiveCheckIntervalSeconds=" + config.getArchiveCheckIntervalSeconds()
+ + "ArchiveLifetimeSeconds=" + config.getArchiveLifetimeSeconds() + "]";
+ }
+
+ @Override
+ public ServiceGroupIdentifier getIdentifier() {
+ return IDENT;
+ }
+
+ @Override
+ public void instantiateServiceInstance() {
+ LOG.info("We take Leadership");
+ this.isMaster=true;
+ this.reinit();
+ }
+
+ @Override
+ public ListenableFuture<? extends Object> closeServiceInstance() {
+ LOG.info("We lost Leadership");
+ this.isMaster=false;
+ this.reinit();
+ return Futures.immediateFuture(null);
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java
index f13b1066f..a742a94b0 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDataBaseReaderAndWriter.java
@@ -54,7 +54,12 @@ public class HtDataBaseReaderAndWriter<T extends IsEsObject> {
this.mapper = new HtMapper<>( clazz );
}
-
+ /**
+ * @return dataTypeName
+ */
+ public String getDataTypeName() {
+ return this.dataTypeName;
+ }
/**
* Remove Object from database
* @param object Object with content
@@ -201,23 +206,33 @@ public class HtDataBaseReaderAndWriter<T extends IsEsObject> {
}
return res;
}
-
-
+ /**
+ * Get all elements of related type
+ * @return all Elements
+ */
+ public List<T> doReadAll() {
+ return doReadAll(null);
+ }
/**
* Read all existing objects of a type
+ * @param query for the elements
* @return the list of all objects
*/
- public List<T> doReadAll() {
+ public List<T> doReadAll(QueryBuilder query) {
List<T> res = new ArrayList<>();
int idx = 0; //Idx for getAll
int iterateLength = 100; //Step width for iterate
SearchHit hits[];
-
-
do {
- hits = db.doReadAllJsonData(idx, iterateLength, dataTypeName);
+ if(query!=null) {
+ log.trace("read data in {} {} with query {}",db.getNetworkIndex(),dataTypeName,query);
+ hits=db.doReadByQueryJsonData(0, 99999, dataTypeName, query);
+ }
+ else {
+ hits = db.doReadAllJsonData(idx, iterateLength, dataTypeName);
+ }
log.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.length, mapper.getMappingFailures());
T object;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java
index 25930791a..ed09d34cd 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseWebAPIClient.java
@@ -95,4 +95,8 @@ public class HtDatabaseWebAPIClient {
return sresponse;
}
+
+ public void insertEntry(String index, String type, JSONObject data) throws IOException {
+ this.sendRequest(String.format("/%s/%s/", index,type), "POST", data);
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java
index 330ff8df0..3a899f884 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java
@@ -255,7 +255,7 @@ public class Resources {
}
private static Enumeration<URL> getResourceFolderFiles(String folder) {
- LOG.info("Get ressource: {}", folder);
+ LOG.debug("Get resource: {}", folder);
URL url = getUrlForRessource(folder);
String path = url.getPath();
File[] files = new File(path).listFiles();
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java
index bda77f223..2ed02c18c 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java
@@ -18,7 +18,6 @@
package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf;
import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
@@ -50,7 +49,6 @@ public class ONFCoreNetworkElementFactory {
private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElementFactory.class);
- @SuppressWarnings("deprecation")
public static @Nonnull ONFCoreNetworkElementRepresentation create(String mountPointNodeName, DataBroker dataBroker,
WebSocketServiceClient webSocketService, HtDatabaseEventsService databaseService,
InstanceIdentifier<Node> instanceIdentifier, DataBroker mountpointDataBroker, ProviderClient dcaeProvider,
@@ -59,7 +57,6 @@ public class ONFCoreNetworkElementFactory {
ONFCoreNetworkElementRepresentation res = null;
try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();){
- CheckedFuture<Optional<Node>, ReadFailedException> checkedFuture = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
Optional<Node> nodeOption = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).checkedGet();
if (nodeOption.isPresent()) {
Node node = nodeOption.get();
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java
index a9e451a39..0dc6f0304 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/NetconfTimeStamp.java
@@ -101,10 +101,18 @@ public class NetconfTimeStamp {
* @return String with Date in NETCONF/YANG Format Version 1.0.
*/
public String getTimeStampAsNetconfString() {
- return getRightFormattedDate(new Date().getTime());
+ return this.getRightFormattedDate(new Date().getTime());
}
/**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ public String getTimeStampAsNetconfString(Date date) {
+ return getRightFormattedDate(date.getTime());
+ }
+ /**
* Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
*
* @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
@@ -113,6 +121,15 @@ public class NetconfTimeStamp {
return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString());
}
+ /**
+ * Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ * @param date specifying the date and time
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ public DateAndTime getTimeStamp(Date date) {
+ return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString(date));
+ }
+
/**
* Return the String with a NETCONF time converted to long
@@ -252,4 +269,6 @@ public class NetconfTimeStamp {
}
}
+
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java
index 55d5b9a11..eeccf601f 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java
@@ -59,6 +59,10 @@ public class AkkaConfig {
return this.cluserConfig != null ? this.cluserConfig.isCluster() : false;
}
+ public boolean isClusterAndFirstNode() {
+ return isSingleNode() || isCluster() && getClusterConfig().getRoleMemberIndex() == 1;
+ }
+
public static AkkaConfig load() throws Exception {
return load(DEFAULT_FILENAME);
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java
index 958a0dfd3..bdfbf655d 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/EsConfig.java
@@ -29,13 +29,29 @@ public class EsConfig extends BaseSubConfig {
public static final String ESDATATYPENAME = "database";
private static final String EMPTY = "empty";
private static final String PROPERTY_KEY_CLUSTER = "esCluster";
+ private static final String PROPERTY_KEY_ARCHIVE_INTERVAL = "esArchiveCheckIntervalSeconds";
+ private static final String PROPERTY_KEY_ARCHIVE_LIMIT = "esArchiveLifetimeSeconds";
+
private static final String DEFAULT_VALUE_CLUSTER = "";
+ /**
+ * check db data in this interval [in seconds]
+ * 0 deactivated
+ */
+ private static final long DEFAULT_ARCHIVE_INTERVAL_SEC = 0;
+ /**
+ * keep data for this time [in seconds]
+ * 30 days
+ */
+ private static final long DEFAULT_ARCHIVE_LIMIT_SEC = 60 * 60 * 24 * 30;
+
private static EsConfig esConfig;
private String cluster;
private String host;
private String node;
private String index;
+ private long archiveCheckIntervalSeconds;
+ private long archiveLifetimeSeconds;
private EsConfig() {
super();
@@ -43,6 +59,8 @@ public class EsConfig extends BaseSubConfig {
this.node = EMPTY;
this.index = EMPTY;
this.cluster = DEFAULT_VALUE_CLUSTER;
+ this.archiveCheckIntervalSeconds = DEFAULT_ARCHIVE_INTERVAL_SEC;
+ this.archiveLifetimeSeconds = DEFAULT_ARCHIVE_LIMIT_SEC;
}
public EsConfig cloneWithIndex(String _index) {
@@ -51,6 +69,8 @@ public class EsConfig extends BaseSubConfig {
c.host = this.host;
c.node = this.node;
c.cluster = this.cluster;
+ c.archiveCheckIntervalSeconds = this.archiveCheckIntervalSeconds;
+ c.archiveLifetimeSeconds = this.archiveLifetimeSeconds;
return c;
}
@@ -90,6 +110,22 @@ public class EsConfig extends BaseSubConfig {
this.index = index;
}
+ public long getArchiveCheckIntervalSeconds() {
+ return this.archiveCheckIntervalSeconds;
+ }
+
+ public void setArchiveCheckIntervalSeconds(long x) {
+ this.archiveCheckIntervalSeconds = x;
+ }
+
+ public long getArchiveLifetimeSeconds() {
+ return this.archiveLifetimeSeconds;
+ }
+
+ public void setArchiveLimit(long x) {
+ this.archiveLifetimeSeconds = x;
+ }
+
@Override
public String toString() {
return "EsConfig [cluster=" + cluster + ", host=" + host + ", node=" + node + ", index=" + index + "]";
@@ -112,9 +148,13 @@ public class EsConfig extends BaseSubConfig {
this.cluster = c;
this.node = String.format("%s%s", this.cluster, "n1");
this.host = "localhost";
+ this.archiveCheckIntervalSeconds = this.getLong(PROPERTY_KEY_ARCHIVE_INTERVAL, DEFAULT_ARCHIVE_INTERVAL_SEC);
+ this.archiveLifetimeSeconds = this.getLong(PROPERTY_KEY_ARCHIVE_LIMIT, DEFAULT_ARCHIVE_LIMIT_SEC);
if (save) {
config.setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_CLUSTER, this.cluster);
+ config.setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_ARCHIVE_INTERVAL, this.archiveCheckIntervalSeconds);
+ config.setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_ARCHIVE_LIMIT, this.archiveLifetimeSeconds);
this.save();
}
}
@@ -170,15 +210,21 @@ public class EsConfig extends BaseSubConfig {
} else if (!node.equals(other.node)) {
return false;
}
+ if (archiveCheckIntervalSeconds != other.archiveCheckIntervalSeconds) {
+ return false;
+ }
+ if (archiveLifetimeSeconds != other.archiveLifetimeSeconds) {
+ return false;
+ }
return true;
}
@Override
- public void save()
- {
+ public void save() {
this.getConfig().setProperty(SECTION_MARKER_ES + "." + PROPERTY_KEY_CLUSTER, this.cluster);
super.save();
}
+
public static boolean isInstantiated() {
return esConfig != null;
}
@@ -213,7 +259,7 @@ public class EsConfig extends BaseSubConfig {
}
public static void clear() {
- esConfig=null;
+ esConfig = null;
}
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
index 0141b2663..89ee376da 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
@@ -6,9 +6,9 @@
* =================================================================================================
* 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
@@ -61,6 +61,7 @@ import org.slf4j.LoggerFactory;
* @author herbert
*/
+@SuppressWarnings("deprecation")
public class DeviceMonitorImpl implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DeviceMonitorImpl.class);
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
index f0efe7aa4..97595ddac 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementFactory;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
@@ -71,6 +72,8 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
@SuppressWarnings("deprecation")
public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, ResyncNetworkElementsListener {
@@ -92,6 +95,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
private RpcProviderRegistry rpcProviderRegistry = null;
@SuppressWarnings("unused")
private NotificationPublishService notificationPublishService = null;
+ private ClusterSingletonServiceProvider clusterSingletonServiceProvider;
private final ConcurrentHashMap<String, ONFCoreNetworkElementRepresentation> networkElementRepresentations =
new ConcurrentHashMap<>();
@@ -116,6 +120,9 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
private Thread threadDoClearCurrentFaultByNodename = null;
private int refreshCounter = 0;
private AkkaConfig akkaConfig;
+ private ArchiveCleanService archiveCleanService;
+ @SuppressWarnings("unused")
+ private ClusterSingletonServiceRegistration cssRegistration;
// Blueprint 1
public DeviceManagerImpl() {
@@ -137,7 +144,9 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
public void setMountPointService(MountPointService mountPointService) {
this.mountPointService = mountPointService;
}
-
+ public void setClusterSingletonService(ClusterSingletonServiceProvider clusterSingletonService) {
+ this.clusterSingletonServiceProvider = clusterSingletonService;
+ }
public void init() {
LOG.info("Session Initiated start {}", APPLICATION_NAME);
@@ -146,11 +155,11 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
this.rpcApiService = new DeviceManagerApiServiceImpl(rpcProviderRegistry);
// Get configuration
HtDevicemanagerConfiguration config = HtDevicemanagerConfiguration.getConfiguration();
- this.akkaConfig = null;
try {
this.akkaConfig = AkkaConfig.load();
LOG.debug("akka.conf loaded: " + akkaConfig.toString());
} catch (Exception e1) {
+ this.akkaConfig = null;
LOG.warn("problem loading akka.conf: " + e1.getMessage());
}
GeoConfig geoConfig = null;
@@ -180,8 +189,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
LOG.error("Can only run with local database. Stop initialization of devicemanager.");
} else {
// init Database Values only if singleNode or clusterMember=1
- if (akkaConfig == null || akkaConfig.isSingleNode() || akkaConfig != null && akkaConfig.isCluster()
- && akkaConfig.getClusterConfig().getRoleMemberIndex() == 1) {
+ if (akkaConfig == null || akkaConfig.isClusterAndFirstNode()) {
// Create DB index if not existing and if database is running
try {
this.configService = new IndexConfigService(htDatabase);
@@ -192,6 +200,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
}
// start service for device maintenance service
this.maintenanceService = new MaintenanceServiceImpl(htDatabase);
+
// Websockets
try {
this.webSocketService = new WebSocketServiceClientImpl2(rpcProviderRegistry);
@@ -210,14 +219,17 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
LOG.warn("No configuration available. Don't start event manager");
} else {
this.databaseClientEvents = new HtDatabaseEventsService(htDatabase);
+ //Make sure to start for one cluster node only
+ if (akkaConfig == null || akkaConfig.isClusterAndFirstNode() || akkaConfig.isSingleNode()) {
+ }
String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + dbConfig.getCluster();
-
this.odlEventListener = new ODLEventListener(myDbKeyNameExtended, webSocketService,
databaseClientEvents, dcaeProviderClient, aotsMProvider, maintenanceService);
}
-
+ this.archiveCleanService = new ArchiveCleanService(config, databaseClientEvents, mwtnService);
+ this.cssRegistration = this.clusterSingletonServiceProvider.registerClusterSingletonService(this.archiveCleanService);
// PM
PmConfig configurationPM = config.getPm();
LOG.info("Performance manager configuration: {}", configurationPM);
@@ -275,7 +287,7 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
close(maintenanceService);
close(rpcApiService);
close(notificationDelayService);
-
+ close(archiveCleanService);
LOG.info("DeviceManagerImpl closing done");
}
@@ -300,8 +312,11 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
/**
* For each mounted device a mountpoint is created and this listener is called.
+ * Mountpoint was created or existing. Managed device is now fully connected to node/mountpoint.
+ * @param action provide action
+ * @param nNodeId id of the mountpoint
+ * @param nNode mountpoint contents
*/
- @Override
public void startListenerOnNodeForConnectedState(Action action, NodeId nNodeId, NetconfNode nNode) {
String mountPointNodeName = nNodeId.getValue();
@@ -384,7 +399,8 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
ne.initSynchronizationExtension();
// Setup Service that monitors registration/ deregistration of session
- odlEventListener.registration(mountPointNodeName);
+ ConnectionStatus csts = nNode.getConnectionStatus();
+ sendCreateOrUpdateNotification(mountPointNodeName, action, csts);
if (aaiProviderClient != null) {
aaiProviderClient.onDeviceRegistered(mountPointNodeName);
@@ -399,52 +415,121 @@ public class DeviceManagerImpl implements DeviceManagerService, AutoCloseable, R
LOG.info("Starting Event listener on Netconf device :: Name : {} finished", mountPointNodeName);
}
- @Override
- public void enterNonConnectedState(NodeId nNodeId, NetconfNode nNode) {
+ /**
+ * Mountpoint created or existing. Managed device is actually disconnected from node/ mountpoint.
+ * Origin state: Connecting, Connected
+ * Target state: are UnableToConnect or Connecting
+ * @param action create or update
+ * @param nNodeId id of the mountpoint
+ * @param nNode mountpoint contents
+ */
+ public void enterNonConnectedState(Action action, NodeId nNodeId, NetconfNode nNode) {
+ String mountPointNodeName = nNodeId.getValue();
+ ConnectionStatus csts = nNode.getConnectionStatus();
+
+ sendCreateOrUpdateNotification(mountPointNodeName, action, csts);
+
+ // Handling if mountpoint exist. connected -> connecting/UnableToConnect
+ stopListenerOnNodeForConnectedState(mountPointNodeName);
+
+ if (deviceMonitor != null) {
+ deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
+ }
+
+ }
+
+ /**
+ * Mountpoint removed indication.
+ * @param nNodeId id of the mountpoint
+ */
+ public void removeMountpointState(NodeId nNodeId) {
String mountPointNodeName = nNodeId.getValue();
- LOG.info("enter Non ConnectedState for device :: Name : {}", mountPointNodeName);
+ LOG.info("mountpointNodeRemoved {}", nNodeId.getValue());
+ stopListenerOnNodeForConnectedState(mountPointNodeName);
+ deviceMonitor.removeMountpointIndication(mountPointNodeName);
+ if (odlEventListener != null) {
+ odlEventListener.deRegistration(mountPointNodeName);
+ }
+ }
+
+ /**
+ * Do all tasks necessary to move from mountpoint state connected -> connecting
+ * @param mountPointNodeName provided
+ * @param ne representing the device connected to mountpoint
+ */
+ private void stopListenerOnNodeForConnectedState( String mountPointNodeName) {
ONFCoreNetworkElementRepresentation ne = networkElementRepresentations.remove(mountPointNodeName);
if (ne != null) {
- // Handling transition mountpoint connected -> connecting
this.maintenanceService.deleteIfNotRequired(mountPointNodeName);
int problems = ne.removeAllCurrentProblemsOfNode();
LOG.debug("Removed all {} problems from database at deregistration for {}", problems, mountPointNodeName);
- if (odlEventListener != null) {
- odlEventListener.deRegistration(mountPointNodeName);
- }
if (performanceManager != null) {
performanceManager.deRegistration(mountPointNodeName);
}
if (aaiProviderClient != null) {
aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
}
- } else {
- // Handling -> create not connected mountpoint, or change other beside connected.
- ConnectionStatus csts = nNode.getConnectionStatus();
- if (csts != null) {
- odlEventListener.updateRegistration(mountPointNodeName, csts.getClass().getSimpleName(), csts.getName());
- } else {
- LOG.info("Unknown connection status");
- }
- }
- if (deviceMonitor != null) {
- deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
}
+ }
+ private void sendCreateOrUpdateNotification(String mountPointNodeName, Action action, ConnectionStatus csts) {
+ LOG.info("enter Non ConnectedState for device :: Name : {} Action {} ConnectionStatus {}", mountPointNodeName, action, csts);
+ if (action == Action.CREATE) {
+ odlEventListener.registration(mountPointNodeName);
+ } else {
+ odlEventListener.updateRegistration(mountPointNodeName, ConnectionStatus.class.getSimpleName(), csts != null ? csts.getName() : "null");
+ }
}
+ /**
+ * Handle netconf/mountpoint changes
+ */
@Override
- public void removeMountpointState(NodeId nNodeId) {
- String mountPointNodeName = nNodeId.getValue();
- LOG.info("mountpointNodeRemoved {}", nNodeId.getValue());
- deviceMonitor.removeMountpointIndication(mountPointNodeName);
+ public void netconfChangeHandler(Action action, @Nullable ConnectionStatus csts, NodeId nodeId, NetconfNode nnode) {
+ switch (action) {
+ case REMOVE:
+ removeMountpointState(nodeId); // Stop Monitor
+ //deviceManagerService.enterNonConnectedState(nodeId, nnode); // Remove Mountpoint handler
+ break;
+
+ case UPDATE:
+ case CREATE:
+ if (csts != null) {
+ switch (csts) {
+ case Connected: {
+ startListenerOnNodeForConnectedState(action, nodeId, nnode);
+ break;
+ }
+ case UnableToConnect:
+ case Connecting: {
+ enterNonConnectedState(action, nodeId, nnode);
+ break;
+ }
+ }
+ } else {
+ LOG.debug("NETCONF Node handled with null status for action", action);
+ }
+ break;
+ }
}
/*-------------------------------------------------------------------------------------------
* Functions
*/
+ public ArchiveCleanService getArchiveCleanService() {
+ return this.archiveCleanService;
+ }
+
+ public HtDatabaseEventsService getDatabaseClientEvents() {
+ return databaseClientEvents;
+ }
+
+ public IndexMwtnService getMwtnService() {
+ return mwtnService;
+ }
+
/**
* Async RPC Interface implementation
*/
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java
index 13fbc644e..ce34401d8 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerService.java
@@ -16,8 +16,9 @@
* ============LICENSE_END==========================================================================
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
-import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeConnectionStatus.ConnectionStatus;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
public interface DeviceManagerService {
@@ -28,23 +29,11 @@ public interface DeviceManagerService {
UPDATE
}
/**
- * Mountpoint was created or existing. Managed device is now fully connected to node/mountpoint.
- * @param action provide action
- * @param nNodeId id of the mountpoint
- * @param nNode mountpoint contents
+ * MountpointChangeHandler, called to indicate change to DeviceManager
+ * @param action provided
+ * @param csts provided
+ * @param nodeId provided
+ * @param nnode provided
*/
- void startListenerOnNodeForConnectedState(@Nonnull Action action, @Nonnull NodeId nNodeId, @Nonnull NetconfNode nNode);
-
- /**
- * Mountpoint created or existing. Managed device is actually disconnected from node/ mountpoint.
- * @param nNodeId id of the mountpoint
- * @param nNode mountpoint contents
- */
- void enterNonConnectedState(@Nonnull NodeId nNodeId, @Nonnull NetconfNode nNode);
-
- /**
- * Mountpoint removed indication.
- * @param nNodeId id of the mountpoint
- */
- void removeMountpointState(@Nonnull NodeId nNodeId);
+ void netconfChangeHandler(Action action, @Nullable ConnectionStatus csts, NodeId nodeId, NetconfNode nnode);
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java
index 90b07999c..0a38e0f60 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/service/HtDatabaseEventsService.java
@@ -18,23 +18,24 @@
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import javax.annotation.Nonnull;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDataBaseReaderAndWriter;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12Equipment;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsEventBase;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsFaultCurrent;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.EsFaultLog;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.EsEquipment;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.EsToplevelEquipment;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types.equipment.ExtendedEquipment;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.MwtNotificationBase;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,9 +45,11 @@ import org.slf4j.LoggerFactory;
*
* @author herbert
*/
-public class HtDatabaseEventsService {
+public class HtDatabaseEventsService implements ArchiveCleanProvider {
private static final Logger LOG = LoggerFactory.getLogger(HtDatabaseEventsService.class);
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+
///** Filename in the resources with maven initialized version information */
//private static final String RESOURCENAME = "version.properties"; // could also be a constant
///** Index name to be used */
@@ -88,19 +91,7 @@ public class HtDatabaseEventsService {
// --- Function
- public void writeEventLog(ObjectCreationNotificationXml event) {
- writeEventGeneric(event);
- }
-
- public void writeEventLog(ObjectDeletionNotificationXml event) {
- writeEventGeneric(event);
- }
-
- public void writeEventLog(AttributeValueChangedNotificationXml event) {
- writeEventGeneric(event);
- }
-
- private void writeEventGeneric(MwtNotificationBase event) {
+ public void writeEventLog(MwtNotificationBase event) {
if (client == null) {
LOG.debug("No DB, can not write: {}",event.toString());
return;
@@ -224,5 +215,33 @@ public class HtDatabaseEventsService {
}
}
+ @Override
+ public int doIndexClean(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+ int removed = 0;
+
+ QueryBuilder queryEventBase = EsEventBase.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWEventLog.doRemoveByQuery(queryEventBase);
+
+ QueryBuilder queryFaultLog = EsFaultLog.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWFaultLog.doRemoveByQuery(queryFaultLog);
+ return removed;
+ }
+
+ @Override
+ public int getNumberOfOldObjects(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+ int numberOfElements = 0;
+
+ QueryBuilder queryEventBase = EsEventBase.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWEventLog.doReadAll(queryEventBase).size();
+
+ QueryBuilder queryFaultLog = EsFaultLog.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWFaultLog.doReadAll(queryFaultLog).size();
+
+ return numberOfElements;
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java
index bcd2849d2..568e01f88 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java
@@ -17,6 +17,8 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.RangeQueryBuilder;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.MwtNotificationBase;
@@ -30,6 +32,9 @@ public class EsEventBase extends EsObject {
public static final String ESDATATYPENAME = "eventlog";
+ private static final String EVENTLOG_FIELD_TIMESTAMP = "event.timeStamp";
+
+
private MwtNotificationBase event;
public MwtNotificationBase getProblem() {
@@ -40,4 +45,13 @@ public class EsEventBase extends EsObject {
this.event = event;
}
+ /**
+ * Query to get older Elements
+ * @param netconfTimeStamp to identify older Elements
+ * @return QueryBuilder for older elements related to timestamp
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder(EVENTLOG_FIELD_TIMESTAMP).lt(netconfTimeStamp);
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java
index 06a893ad7..e15aba5b2 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java
@@ -17,6 +17,8 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.RangeQueryBuilder;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
@@ -30,6 +32,8 @@ public class EsFaultLog extends EsObject {
public static final String ESDATATYPENAME = "faultlog";
+ private static final String FAULTLOG_FIELD_TIMESTAMP = "fault.timeStamp";
+
private ProblemNotificationXml fault;
public ProblemNotificationXml getProblem() {
@@ -40,4 +44,13 @@ public class EsFaultLog extends EsObject {
this.fault = fault;
}
+ /**
+ * Get older Elements
+ * @param netconfTimeStamp to identify query elements older than this timestamp.
+ * @return QueryBuilder for related elements
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder(FAULTLOG_FIELD_TIMESTAMP).lt(netconfTimeStamp);
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
index fc5607557..a521bb94c 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
// 07.09.18 Switched to DataTreeChangeListener from ClusteredDataTreeChangeListener -> DM Service is
// running at all nodes
// This is not correct
+@SuppressWarnings("deprecation")
public class NetconfChangeListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NetconfChangeListener.class);
@@ -156,33 +157,8 @@ public class NetconfChangeListener implements ClusteredDataTreeChangeListener<No
if (nodeIdString.equals(CONTROLLER)) {
LOG.debug("Stop processing for [{}]", nodeIdString);
} else {
- // Action related to mountpoint status
- switch (action) {
- case REMOVE:
- deviceManagerService.removeMountpointState(nodeId); // Stop Monitor
- deviceManagerService.enterNonConnectedState(nodeId, nnode); // Remove Mountpoint handler
- break;
-
- case UPDATE:
- case CREATE:
- if (csts != null) {
- switch (csts) {
- case Connected: {
- deviceManagerService.startListenerOnNodeForConnectedState(action, nodeId,
- nnode);
- break;
- }
- case UnableToConnect:
- case Connecting: {
- deviceManagerService.enterNonConnectedState(nodeId, nnode);
- break;
- }
- }
- } else {
- LOG.debug("NETCONF Node handled with null status for action", action);
- }
- break;
- }
+ // Action forwarded to devicehandler
+ deviceManagerService.netconfChangeHandler(action, csts, nodeId, nnode);
}
}
} catch (NullPointerException e) {
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java
index ecaf06b55..4b87b5828 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/ODLEventListener.java
@@ -47,17 +47,18 @@ import org.slf4j.LoggerFactory;
public class ODLEventListener {
private static final Logger LOG = LoggerFactory.getLogger(ODLEventListener.class);
- private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
private final String ownKeyName;
-
private final WebSocketServiceClient webSocketService;
private final HtDatabaseEventsService databaseService;
private final ProviderClient dcaeProvider;
private final ProviderClient aotsMProvider;
- private int eventNumber;
private final MaintenanceService maintenanceService;
+
+ private int eventNumber;
+
/*---------------------------------------------------------------
* Construct
*/
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
index 6ca7a5c18..c8f769677 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
* Wrapper for forwarding web-socket notifications to the web-socket service, that is running as
* bundle.
*/
+@SuppressWarnings("deprecation")
public class WebSocketServiceClientImpl2 implements WebSocketServiceClient {
private static final Logger LOG = LoggerFactory.getLogger(ODLEventListener.class);
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/database/types/EsEventOdluxLog.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/database/types/EsEventOdluxLog.java
new file mode 100644
index 000000000..14f7d2447
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/database/types/EsEventOdluxLog.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * ============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.devicemanager.index.database.types;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.RangeQueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
+
+/**
+ * Event log, used by Odlux client.
+ * Not used for writing any data by devicemanager.
+ * Type introduced to implement IndexCleanService
+ */
+
+public class EsEventOdluxLog extends EsObject {
+
+ public static final String ESDATATYPENAME = "log";
+
+ private static final String LOG_FIELD_TIMESTAMP = "timestamp";
+
+ private String type;
+ private String component;
+ private String message;
+ private String timestamp;
+
+ /**
+ * For jackson
+ */
+ protected EsEventOdluxLog() {
+ }
+ /**
+ * Constructor
+ * @param type string
+ * @param component string
+ * @param message string
+ * @param timestamp string with netconf format string
+ */
+ public EsEventOdluxLog(String type, String component, String message, InternalDateAndTime timestamp) {
+ super();
+ this.type = type;
+ this.component = component;
+ this.message = message;
+ this.timestamp = timestamp.getValue();
+ }
+
+ @JsonProperty("type")
+ public String getType() {
+ return type;
+ }
+
+ @JsonProperty("component")
+ public String getComponent() {
+ return component;
+ }
+
+ @JsonProperty("message")
+ public String getMessage() {
+ return message;
+ }
+
+ @JsonProperty(LOG_FIELD_TIMESTAMP)
+ public String getTimestamp() {
+ return timestamp;
+ }
+
+ /**
+ * Query to get older Elements
+ * @param netconfTimeStamp to identify older Elements
+ * @return QueryBuilder for older elements related to timestamp
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder(LOG_FIELD_TIMESTAMP).lt(netconfTimeStamp);
+ }
+
+ }
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java
index e175515ae..0e6b03291 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java
@@ -17,9 +17,15 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.index.impl;
+import java.util.Date;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDataBaseReaderAndWriter;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseClientAbstract;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.HtDatabaseNode;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.IndexClientBuilder;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.NetconfTimeStamp;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.index.database.types.EsEventOdluxLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,9 +34,10 @@ import org.slf4j.LoggerFactory;
* @author herbert
*
*/
-public class IndexMwtnService implements AutoCloseable {
+public class IndexMwtnService implements AutoCloseable, ArchiveCleanProvider {
private static final Logger LOG = LoggerFactory.getLogger(IndexMwtnService.class);
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
/** Index name to be used */
public static final String INDEX = "mwtn";
@@ -39,6 +46,9 @@ public class IndexMwtnService implements AutoCloseable {
/** Location of configuration data **/
private static final String MODELDATA = "elasticsearch/index/mwtn/modelDescription";
+ private final HtDataBaseReaderAndWriter<EsEventOdluxLog> eventRWOdluxLog;
+
+
private final HtDatabaseClientAbstract client;
// --- Construct and initialize
@@ -46,11 +56,15 @@ public class IndexMwtnService implements AutoCloseable {
public IndexMwtnService(HtDatabaseNode database) throws Exception {
LOG.info("Create {} start", this.getClass().getSimpleName());
+
IndexClientBuilder clientBuilder = IndexClientBuilder.getBuilder(INDEX)
.setMappingSettingJsonFileName(MAPPING)
.setModelDataDirectory(MODELDATA);
client = clientBuilder.create(database);
clientBuilder.close();
+
+ eventRWOdluxLog = new HtDataBaseReaderAndWriter<>(client, EsEventOdluxLog.ESDATATYPENAME, EsEventOdluxLog.class);
+
LOG.info("Create {} finished. DB Service sucessfully started.", this.getClass().getSimpleName());
}
@@ -62,10 +76,42 @@ public class IndexMwtnService implements AutoCloseable {
return client;
}
+ /**
+ * Write into Odlux log, used by client
+ * @param logEntry as test data
+ */
+ public void writeOdluxEventForTestpurpose(EsEventOdluxLog logEntry) {
+ eventRWOdluxLog.doWrite(logEntry);
+ }
@Override
public void close() throws Exception {
- client.close();
+ if (client != null) {
+ client.close();
+ }
+ }
+
+ @Override
+ public int doIndexClean(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+
+ QueryBuilder queryOdluxLog = EsEventOdluxLog.getQueryForTimeStamp(netconfTimeStamp);
+ int removed = eventRWOdluxLog.doRemoveByQuery(queryOdluxLog);
+ return removed;
+
+ }
+
+ @Override
+ public int getNumberOfOldObjects(Date olderAreOutdated) {
+
+ String netconfTimeStamp = NETCONFTIME_CONVERTER.getTimeStampAsNetconfString(olderAreOutdated);
+ int numberOfElements = 0;
+
+ QueryBuilder queryOdluxLog = EsEventOdluxLog.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWOdluxLog.doReadAll(queryOdluxLog).size();
+
+ return numberOfElements;
}
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/index/mwtn/modelDescription/maintenancemode.json b/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/index/mwtn/modelDescription/maintenancemode.json
index 3d0a41424..9e26dfeeb 100644
--- a/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/index/mwtn/modelDescription/maintenancemode.json
+++ b/sdnr/wt/devicemanager/provider/src/main/resources/elasticsearch/index/mwtn/modelDescription/maintenancemode.json
@@ -1,22 +1 @@
-{
- "maintenancemode": {
- "DragonWave-Z3":{
- "node":"DragonWave-Z3",
- "filter": [{
- "definition":{},
- "description":"",
- "start":"2018-01-01T10:00+00:00",
- "end":"2018-10-10T10:00+00:00"
- }]
- },
- "MaintenanceMode":{
- "node":"MaintenanceMode",
- "filter": [{
- "definition":{},
- "description":"",
- "start":"2018-01-01T10:00+00:00",
- "end":"2018-10-10T10:00+00:00"
- }]
- }
- }
-} \ No newline at end of file
+{} \ No newline at end of file
diff --git a/sdnr/wt/devicemanager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/wt/devicemanager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
index a9a4e18ec..b946e1035 100644
--- a/sdnr/wt/devicemanager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
+++ b/sdnr/wt/devicemanager/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml
@@ -36,13 +36,16 @@ limitations under the License.
<reference id="rpcProviderRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
odl:type="default" />
-
+
+ <reference id="clusterSingletonService"
+ interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
<bean id="provider" class="org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl" init-method="init" destroy-method="close">
<property name="dataBroker" ref="dataBroker"/>
<property name="rpcProviderRegistry" ref="rpcProviderRegistry" />
<property name="notificationPublishService" ref="notificationPublishService" />
<property name="mountPointService" ref="mountPointService" />
+ <property name="clusterSingletonService" ref="clusterSingletonService" />
</bean>