Update get operation status part
[vfc/nfvo/driver/vnfm/svnfm.git] / nokia / vnfmdriver / vfcadaptorservice / vfcadaptor / src / main / java / org / onap / vfc / nfvo / driver / vnfm / svnfm / adaptor / OperateTaskProgress.java
1 /*
2  * Copyright 2016-2017, Nokia Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.adaptor;
18
19 import java.util.List;
20 import java.util.Timer;
21 import java.util.TimerTask;
22 import java.util.concurrent.atomic.AtomicInteger;
23
24 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc;
25
26 public class OperateTaskProgress {
27         private static AtomicInteger instantiate_progress = new AtomicInteger(10);
28         private static AtomicInteger terminate_progress = new AtomicInteger(20);
29         
30         private static Timer instantiateTimer;
31         private static Timer terminateTimer;
32         
33         private static List<AffectedVnfc> affectedVnfc;
34         
35         public static int getInstantiateProgress() {
36                 return instantiate_progress.intValue();
37         }
38         
39         public static int getTerminateProgress() {
40                 return terminate_progress.intValue();
41         }
42         
43         public static void incrementInstantiateProgress() {
44                 instantiate_progress.incrementAndGet();
45         }
46         
47         public static void incrementTerminateProgress() {
48                 terminate_progress.incrementAndGet();
49         }
50         
51         public static void startInstantiateTimerTask() {
52                 instantiateTimer = new Timer();
53                 instantiate_progress.set(10);
54                 instantiateTimer.schedule(new TimerTask() {
55
56                         @Override
57                         public void run() {
58                                 if(instantiate_progress.intValue() < 96) {
59                                         instantiate_progress.incrementAndGet();
60                                 }
61                         }
62                         
63                 }, 1000, 60000);
64         }
65         
66         public static void startTerminateTimerTask() {
67                 terminateTimer = new Timer();
68                 terminate_progress.set(20);
69                 terminateTimer.schedule(new TimerTask() {
70                         
71                         @Override
72                         public void run() {
73                                 if(terminate_progress.intValue() < 96) {
74                                     terminate_progress.incrementAndGet();
75                                 }
76                         }
77                         
78                 }, 1000, 8000);
79         } 
80         
81         public static void stopTerminateTimerTask() {
82                 terminateTimer.cancel();
83                 terminate_progress.set(100);
84         }
85         
86         public static void stopInstantiateTimerTask() {
87                 instantiateTimer.cancel();
88                 instantiate_progress.set(100);
89         }
90
91         public static List<AffectedVnfc> getAffectedVnfc() {
92                 return affectedVnfc;
93         }
94
95         public static void setAffectedVnfc(List<AffectedVnfc> affectedVnfc) {
96                 OperateTaskProgress.affectedVnfc = affectedVnfc;
97         }
98 }