2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.oam.processor;
27 import com.att.eelf.configuration.EELFLogger;
28 import org.openecomp.appc.exceptions.APPCException;
29 import org.openecomp.appc.i18n.Msg;
30 import org.openecomp.appc.oam.AppcOam;
31 import org.openecomp.appc.oam.util.AsyncTaskHelper;
32 import org.openecomp.appc.oam.util.ConfigurationHelper;
33 import org.openecomp.appc.oam.util.OperationHelper;
34 import org.openecomp.appc.oam.util.StateHelper;
35 import org.openecomp.appc.requesthandler.LCMStateManager;
36 import org.openecomp.appc.statemachine.impl.readers.AppcOamStates;
39 * Processor to handle start OAM API.
41 public class OamStartProcessor extends BaseProcessor {
46 * @param eelfLogger for logging
47 * @param configurationHelper for property reading
48 * @param stateHelper for APP-C OAM state checking
49 * @param asyncTaskHelper for scheduling async task
50 * @param operationHelper for operational helper
52 public OamStartProcessor(EELFLogger eelfLogger,
53 ConfigurationHelper configurationHelper,
54 StateHelper stateHelper,
55 AsyncTaskHelper asyncTaskHelper,
56 OperationHelper operationHelper) {
57 super(eelfLogger, configurationHelper, stateHelper, asyncTaskHelper, operationHelper);
59 rpc = AppcOam.RPC.start;
60 auditMsg = Msg.OAM_OPERATION_STARTING;
64 protected void scheduleAsyncTask() {
65 runnable = new MyRunnable(this);
66 super.scheduleAsyncTask();
70 * This runnable does the async handling for the start REST API. And it will be scheduled to run one time.
72 * <p>This runnable will the following operations: <br>
73 * - do APP-C OAM bundle start through BundlerHelper<br>
74 * - and always enable LCM operation handling (which can be disabled through maintenance mode API).<br>
75 * <p>Once above operations are done, the runnale will <br>
76 * - post message through operatonHelper <br>
77 * - set APP-C OAM state to started <br>
78 * - audit log the state <br>
80 class MyRunnable extends BaseActionRunnable {
82 private LCMStateManager lcmStateManager;
84 MyRunnable(BaseProcessor parent) {
86 actionName = "OAM Start";
87 auditMsg = Msg.OAM_OPERATION_STARTED;
88 finalState = AppcOamStates.Started;
92 * Do start action, include start bundle if needed and always enable LCM operation.
93 * @return true if action is successful, false when aciton is failed or aborted
97 logDebug(String.format("Executing %s task", actionName));
99 boolean isBundleOperationCompleted = true;
101 if (stateHelper.getState() != AppcOamStates.Started) {
102 logDebug("Start - APPC OAM state is not started, start the bundles");
103 isBundleOperationCompleted = bundleHelper.bundleOperations(
104 rpc, bundleNameToFuture, myParent.asyncTaskHelper, this);
107 if (isBundleOperationCompleted) {
112 } catch (APPCException e) {
114 stateHelper.setState(AppcOamStates.Error);
121 * With additional to get the LCMStateManager service
122 * @see BaseActionRunnable#checkState()
125 boolean checkState() {
127 lcmStateManager = operationHelper.getService(LCMStateManager.class);
128 return super.checkState();
129 } catch (APPCException e) {
130 logDebug("LCMStateManager is not available.");
137 * @param setState boolean to indicate if set OAM state or not
140 void postDoAction(boolean setState) {
141 AppcOamStates newState = null;
143 logDebug("Always enable LCM operation");
144 lcmStateManager.enableLCMOperations();
145 newState = finalState;
147 postAction(newState);
148 super.postDoAction(setState);