b4c5abd7d79445557ffba35f6c38415f5baa880c
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  * 
10  * http://www.apache.org/licenses/LICENSE-2.0
11  * 
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl;
19
20 import javax.annotation.Nullable;
21 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElementRepresentation;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.performancemanager.impl.database.service.MicrowaveHistoricalPerformanceWriterService;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 public class PerformanceManagerImpl implements AutoCloseable {
27
28     private static final Logger LOG = LoggerFactory.getLogger(PerformanceManagerImpl.class);
29
30     private @Nullable PerformanceManagerTask task;
31
32     public PerformanceManagerImpl(long seconds, MicrowaveHistoricalPerformanceWriterService databaseService) {
33
34         LOG.info("Construct begin {} with {} Seconds",PerformanceManagerImpl.class.getSimpleName(), seconds);
35
36         if (MicrowaveHistoricalPerformanceWriterService.isAvailable(databaseService)) {
37
38             LOG.info("Do start of PM task");
39             task = new PerformanceManagerTask(seconds, databaseService);
40             task.start();
41             LOG.info("PM task scheduled");
42
43         } else {
44             LOG.info("Database not available. Do not start PM task");
45         }
46
47         LOG.info("Construct end {}",PerformanceManagerImpl.class.getSimpleName());
48     }
49
50     @Override
51         public void close() {
52         LOG.info("Close {}", PerformanceManagerImpl.class.getSimpleName());
53         if (task != null) {
54             task.stop();
55         }
56     }
57
58     public void registration(String mountPointNodeName, ONFCoreNetworkElementRepresentation ne) {
59         LOG.debug("Register {}",mountPointNodeName);
60         if (task != null) {
61                         task.registration(mountPointNodeName, ne);
62                 }
63     }
64
65     public void deRegistration(String mountPointNodeName) {
66         LOG.debug("Deregister {}",mountPointNodeName);
67         if (task != null) {
68                         task.deRegistration(mountPointNodeName);
69                 }
70     }
71
72 }