@Override public String execute(final String commandLine) { try { final Task task = CLI.parseTask(_persistit, commandLine); if (task == null) { return "Invalid task " + commandLine; } task.runTask(); task.setPersistit(null); return task.getStatusDetail(); } catch (final Exception ex) { return "Failed: " + ex.toString(); } }
/** * Starts a long-running utility task, such as the integrity checker. The supplied className must * identify a subclass of {@link com.persistit.Task} . The number and format of the arguments is * specific to the utility task. The returned long value is a unique task ID value used in * subsequent calls to {@link #queryTaskStatus}. * * @param description Readable description of this task * @param owner Hostname or username of the user who requested this task * @param className Class name of task to run, e.g., <code>com.persistit.IntegrityCheck</code>. * @param args Task-specific parameters * @param maximumTime Maximum wall-clock time (in milliseconds) this Task will be allowed to run, * or 0 for unbounded time * @param verbosity Verbosity level, one of {@link Task#LOG_NORMAL} or {@link Task#LOG_NORMAL}. * @return Task identifier Unique ID for the running task * @throws RemoteException */ @Override public synchronized long startTask( final String description, final String owner, final String commandLine, final long maximumTime, final int verbosity) throws RemoteException { try { final Task task = CLI.parseTask(_persistit, commandLine); if (task == null) { throw new WrappedRemoteException( new IllegalArgumentException("Unknown task " + commandLine)); } final long taskId = ++_taskIdCounter; task.setPersistit(_persistit); task.setup(taskId, description, owner, maximumTime, verbosity); _tasks.put(new Long(taskId), task); task.start(); return taskId; } catch (final Exception ex) { throw new WrappedRemoteException(ex); } }