/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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.
 */
package org.smartdata.action;

import org.smartdata.action.annotation.ActionSignature;

@ActionSignature(
    actionId = "sleep",
    displayName = "sleep",
    usage = SleepAction.TIME_IN_MS + " $timeToSleepInMs"
)
public class SleepAction extends SmartAction {
  public static final String TIME_IN_MS = "-ms";

  @Override
  protected void execute() throws Exception {
    if (!getArguments().containsKey(TIME_IN_MS)) {
      throw new IllegalArgumentException("Time to sleep not specified (through option '"
          + TIME_IN_MS + "').");
    }
    long tm = Long.valueOf(getArguments().get(TIME_IN_MS));
    if (tm != 0) {
      Thread.sleep(tm);
    }
  }
}

@@ -1111,16 +1111,99 @@
 = %22-ms%22;
+%0A  private boolean started = false;%0A  private long toSleep;%0A  private long startTm;
 %0A%0A  @Ove
@@ -1441,15 +1441,15 @@
     
-long tm
+toSleep
  = L
@@ -1506,11 +1506,16 @@
 f (t
-m !
+oSleep =
 = 0)
@@ -1527,31 +1527,319 @@
     
-Thread.sleep(tm);%0A    %7D
+return;%0A    %7D%0A    startTm = System.currentTimeMillis();%0A    started = true;%0A    Thread.sleep(toSleep);%0A  %7D%0A%0A  @Override%0A  public float getProgress() %7B%0A    if (!started) %7B%0A      return 0;%0A    %7D%0A    if (isSuccessful()) %7B%0A      return 1.0f;%0A    %7D%0A    return (System.currentTimeMillis() - startTm) * 1.0f / toSleep;
 %0A  %7D

Fix #1513, Progress update for sleep action (#1514)