Add a new scheduled cleanup.
@param timer The new timer to set.
@return True if the command was received successfully.
@throws CommandExecutionException When there has been a error during the communication or the response was invalid.
485279
public boolean addTimer(VacuumTimer timer) throws CommandExecutionException {
        if (timer == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
        JSONArray tm = timer.construct();
        if (tm == null) return false;
        JSONArray payload = new JSONArray();
        payload.put(tm);
        return sendOk("set_timer", payload);
    }
410914
static function timer_delete($timer)
    {
        if (isset(self::$timers[$timer]))
        {
            unset(self::$timers[$timer]);
            return true;
        }
        return false;
    }
735122
def update_timer(self, timer, action, usecs):
        
        if action == PYCBC_EVACTION_WATCH:
            timer.schedule(usecs, self.reactor)

        elif action == PYCBC_EVACTION_UNWATCH:
            timer.cancel()

        elif action == PYCBC_EVACTION_CLEANUP:
            timer.cleanup()
908686
public ScheduledFuture<?> executePeriodically(Runnable command, long delay)
   {
      return executor.scheduleWithFixedDelay(command, 0, delay, TimeUnit.MILLISECONDS);
   }
433535
void addAutomaticTimer(AutomaticTimer timer)
    {
        timer.ivMethod = this;
        ivAutomaticTimers.add(timer);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "added automatic timer: " + timer);
    }
165845
public synchronized void execute(Runnable command) {
        if (active.get()) {
            stop();
            this.command = command;
            start();
        } else {
            this.command = command;
        }
    }
519502
public <T> CompletableFuture<T> submit(Command<T> command) {
    CompletableFuture<T> future = new CompletableFuture<>();
    context.executor().execute(() -> submitCommand(command, future));
    return future;
  }
189875
void execute(ExecutableBuilder builder,
            int timeout,
            TimeUnit unit) throws
            CommandLineException,
            InterruptedException, ExecutionException, TimeoutException {
        Future<Void> task = executorService.submit(() -> {
            builder.build().execute();
            return null;
        });
        try {
            if (timeout <= 0) { //Synchronous
                task.get();
            } else { // Guarded execution
                try {
                    task.get(timeout, unit);
                } catch (TimeoutException ex) {
                    // First make the context unusable
                    CommandContext c = builder.getCommandContext();
                    if (c instanceof TimeoutCommandContext) {
                        ((TimeoutCommandContext) c).timeout();
                    }
                    // Then cancel the task.
                    task.cancel(true);
                    throw ex;
                }
            }
        } catch (InterruptedException ex) {
            // Could have been interrupted by user (Ctrl-C)
            Thread.currentThread().interrupt();
            cancelTask(task, builder.getCommandContext(), null);
            // Interrupt running operation.
            CommandContext c = builder.getCommandContext();
            if (c instanceof TimeoutCommandContext) {
                ((TimeoutCommandContext) c).interrupted();
            }
            throw ex;
        }
    }
957999
public void process(final T command) {
        boolean traceStarted = false;
        incrementCommandsProcessed();
		DehydratedExecutionContext ctx = null;
		try {
            validateCommand(command);
			CommandResolver<T> resolver = createCommandResolver(command, tracer);
			ctx = resolver.resolveExecutionContext();
            List<ExecutionCommand> executionCommands = resolver.resolveExecutionCommands();
            if (executionCommands.size() > 1) {
                throw new CougarFrameworkException("Resolved >1 command in a non-batch call!");
            }
            ExecutionCommand exec = executionCommands.get(0);
            tracer.start(ctx.getRequestUUID(), exec.getOperationKey());
            traceStarted = true;
			executeCommand(exec, ctx);
		} catch(CougarException ce) {
            executeError(command, ctx, ce, traceStarted);
		} catch (Exception e) {
            executeError(command, ctx, new CougarFrameworkException("Unexpected exception while processing transport command", e), traceStarted);
		}
	}
959448
public static void removeTimer(ScheduledTimer timer) {
    Preconditions.checkNotNull(timer, "timer");
    try (LockResource r = new LockResource(sLock)) {
      ScheduledTimer removedTimer = sTimers.remove(timer.getThreadName());
      Preconditions.checkNotNull(removedTimer, "sTimers should contain %s", timer.getThreadName());
      Preconditions.checkState(removedTimer == timer,
          "sTimers should contain the timer being removed");
    }
  }
504328
public boolean setTimezone(TimeZone zone) throws CommandExecutionException {
        if (zone == null) throw new CommandExecutionException(CommandExecutionException.Error.INVALID_PARAMETERS);
        JSONArray tz = new JSONArray();
        tz.put(zone.getID());
        return sendOk("set_timezone", tz);
    }
591904
private static void doExecute(Executor executor, Runnable runnable) {
    try {
      executor.execute(runnable);
    } catch (Throwable th) {
      log.log(Level.SEVERE, "Failed to execute PingCallback", th);
    }
  }
1319888
@Override
    public void execute(final ReplaceInList command) {
        referenceKeeper.cleanReferenceCache();
        if (couldBeExecuted(command)) {
            executor.execute(command);
        } else {
            keepReferenceIfObservable(command.getValue());
        }
    }
1370207
@Override
    public void execute(Runnable command)
    {
        super.execute(isTracing() && !(command instanceof TraceSessionWrapper)
                      ? new TraceSessionWrapper<Object>(Executors.callable(command, null))
                      : command);
    }
196268
public void run(CallURL args) {

        logger = LoggerUtil.getStandardLogger();

        logger.info("methodEntry-->ProcessCleanup.run()");
        int processExpirationDays = 0;
        int maxProcesses = 0;
        int eventExpirationDays = 0;
        int commitInterval = 10000;
        String cleanupScript = null;

        if (PropertyManager.isYaml()) {
            try {
                Properties cleanupTaskProperties = PropertyManager.getInstance().getProperties(PropertyNames.MDW_TIMER_TASK);
                processExpirationDays = Integer.parseInt(cleanupTaskProperties.getProperty(PropertyNames.MDW_TIMER_TASK + ".ProcessCleanup.ProcessExpirationAgeInDays", "0"));
                maxProcesses = Integer.parseInt(cleanupTaskProperties.getProperty(PropertyNames.MDW_TIMER_TASK + ".ProcessCleanup.MaximumProcessExpiration", "0"));
                eventExpirationDays = Integer.parseInt(cleanupTaskProperties.getProperty(PropertyNames.MDW_TIMER_TASK + ".ProcessCleanup.ExternalEventExpirationAgeInDays", "0"));
                commitInterval = Integer.parseInt(cleanupTaskProperties.getProperty(PropertyNames.MDW_TIMER_TASK + ".ProcessCleanup.CommitInterval", "10000"));
                cleanupScript = cleanupTaskProperties.getProperty(PropertyNames.MDW_TIMER_TASK + ".ProcessCleanup.RuntimeCleanupScript", "Cleanup-Runtime.sql");
            }
            catch (PropertyException e) {
                logger.info("ProcessCleanup.run() : Properties not found" + e.getMessage());
            }
        } else {
            processExpirationDays = PropertyManager.getIntegerProperty(
                    PropertyNames.PROCESS_CLEANUP + "/ProcessExpirationAgeInDays", 0);
            maxProcesses = PropertyManager.getIntegerProperty(
                    PropertyNames.PROCESS_CLEANUP + "/MaximumProcessExpiration", 0);
            eventExpirationDays = PropertyManager.getIntegerProperty(
                    PropertyNames.PROCESS_CLEANUP + "/ExternalEventExpirationAgeInDays", 0);
            commitInterval = PropertyManager
                    .getIntegerProperty(PropertyNames.PROCESS_CLEANUP + "/CommitInterval", 10000);
            cleanupScript = PropertyManager
                    .getProperty(PropertyNames.PROCESS_CLEANUP + "/RuntimeCleanupScript");
        }
        if (cleanupScript == null) {
            cleanupScript = "Cleanup-Runtime.sql";
        }

        DatabaseAccess db = new DatabaseAccess(null);
        cleanup(db, cleanupScript, maxProcesses, processExpirationDays, eventExpirationDays,
                commitInterval, null);

        logger.info("methodExit-->ProcessCleanup.run()");
    }
445922
public void reportTimer(Timer timer) {
    LOGGER.debug("+++ entering UnsortedWriterReportVisitor.reportTimer +++");

    long count = timer.getCount();
    long timersum = timer.getTimerSum();
    String result = timer.getName() + " timer : count = " + count + ", timerSum = " + timersum + ", mean = " +
      ((double) timersum / count);
    writeStringToWriter(result);
  }
1258149
public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) {
      cancelTimeoutTask();
      ScheduledFuture<Void> timeoutFuture = timeoutExecutor.schedule(this, timeout, unit);
      setTimeoutFuture(timeoutFuture);
   }