First part of onap rename
[appc.git] / appc-oam / appc-oam-bundle / src / main / java / org / openecomp / appc / oam / processor / OamMmodeProcessor.java
index 973d0af..23f9fd1 100644 (file)
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.appc.oam.processor;
+package org.onap.appc.oam.processor;
 
 import com.att.eelf.configuration.EELFLogger;
-import org.openecomp.appc.exceptions.APPCException;
-import org.openecomp.appc.exceptions.InvalidInputException;
-import org.openecomp.appc.exceptions.InvalidStateException;
-import org.openecomp.appc.i18n.Msg;
-import org.openecomp.appc.oam.AppcOam;
-import org.openecomp.appc.oam.OAMCommandStatus;
-import org.openecomp.appc.oam.util.AsyncTaskHelper;
-import org.openecomp.appc.oam.util.ConfigurationHelper;
-import org.openecomp.appc.oam.util.OperationHelper;
-import org.openecomp.appc.oam.util.StateHelper;
-import org.openecomp.appc.requesthandler.LCMStateManager;
-import org.openecomp.appc.requesthandler.RequestHandler;
-import org.openecomp.appc.statemachine.impl.readers.AppcOamStates;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.exceptions.InvalidInputException;
+import org.onap.appc.exceptions.InvalidStateException;
+import org.onap.appc.i18n.Msg;
+import org.onap.appc.oam.AppcOam;
+import org.onap.appc.oam.OAMCommandStatus;
+import org.onap.appc.oam.util.AsyncTaskHelper;
+import org.onap.appc.oam.util.ConfigurationHelper;
+import org.onap.appc.oam.util.OperationHelper;
+import org.onap.appc.oam.util.StateHelper;
+import org.onap.appc.requesthandler.LCMStateManager;
+import org.onap.appc.requesthandler.RequestHandler;
+import org.onap.appc.statemachine.impl.readers.AppcOamStates;
+
+import java.util.concurrent.TimeoutException;
 
 /**
  * Processor to handle maintenance mode OAM API.
@@ -65,7 +67,7 @@ public class OamMmodeProcessor extends BaseProcessor {
 
     @Override
     protected void preProcess(final Object requestInput)
-            throws InvalidInputException, InvalidStateException, APPCException {
+            throws InvalidInputException, InvalidStateException, APPCException, InterruptedException, TimeoutException {
         super.preProcess(requestInput);
 
         //Close the gate so that no more new LCM request will be excepted.
@@ -79,15 +81,26 @@ public class OamMmodeProcessor extends BaseProcessor {
         super.scheduleAsyncTask();
     }
 
+    /**
+     * {@inheritDoc}
+     * For maintenance mode we want a longer delay before initial execution of {@link BaseActionRunnable}
+     * so that any accepted LCM actions have time to git scheduled in the Dispatcher.
+     */
+    @Override
+    protected long getInitialDelayMillis(){
+        //wait ten seconds before
+        return 10000L;
+    }
+
     /**
      * This runnable does the async handling for the maintenance mode REST API, and will be scheduled to run
      * until terminating condition reaches.
      *
-     * <p>The runnable will conintue run if: <br>
+     * <p>The runnable will continue run if: <br>
      *   - the runnable is not canceled outside <br>
      *   - the in progress LCM request count is not zero<br>
      * <p> When LCM request count reaches to zero, this runnable will: <br>
-     *     - post message through operatonHelper <br>
+     *     - post message through operationHelper <br>
      *     - set APP-C OAM state to maintenance mode <br>
      *     - audit log the state <br>
      *     - terminate this runnable itself <br>
@@ -98,7 +111,7 @@ public class OamMmodeProcessor extends BaseProcessor {
         MyRunnable(BaseProcessor parent) {
             super(parent);
 
-            actionName = "OAM Maintanence mode";
+            actionName = "OAM Maintenance mode";
             auditMsg = Msg.OAM_OPERATION_MAINTENANCE_MODE;
             finalState = AppcOamStates.MaintenanceMode;
         }
@@ -113,12 +126,6 @@ public class OamMmodeProcessor extends BaseProcessor {
         boolean checkState() {
             logDebug(String.format("Executing %s task", actionName));
 
-            if (!myParent.isSameAsyncTask()) {
-                // cancel myself if I am not the current backgroundOamTask
-                myParent.cancelAsyncTask();
-                logDebug(String.format("Finished %s task due to task removed", actionName));
-                return true;
-            }
 
             boolean hasError = false;
             try {
@@ -156,8 +163,8 @@ public class OamMmodeProcessor extends BaseProcessor {
         @Override
         void keepWaiting() {
             logDebug("The application '%s' has '%s' outstanding LCM request to complete" +
-                            " before coming to a complete maintenance_mode.",
-                    configurationHelper.getAppcName(), inprogressRequestCount);
+                    " before coming to a complete maintenance_mode.",
+                configurationHelper.getAppcName(), inprogressRequestCount);
         }
     }
 }