/** * Execute Task locally and wait * * @param cmd command * @return execution info */ public String executeLocal(String cmd) { log.config(cmd); if (m_task != null && m_task.isAlive()) m_task.interrupt(); m_task = new Task(cmd); m_task.start(); StringBuffer sb = new StringBuffer(); while (true) { // Give it a bit of time try { Thread.sleep(500); } catch (InterruptedException ioe) { log.log(Level.SEVERE, cmd, ioe); } // Info to user sb.append(m_task.getOut()) .append("\n-----------\n") .append(m_task.getErr()) .append("\n-----------"); // Are we done? if (!m_task.isAlive()) break; } log.config("done"); return sb.toString(); } // executeLocal
public boolean tell_finished_prerequisite(int t) { finished_predecessors++; if (finished_predecessors == cntPredecessors) { start(t); return true; } return false; }
public void run() { if (!checkRealizeable()) { System.out.println("Project is not realizeable, quitting"); System.exit(1); } int t = 0; ArrayList<Task> active_tasks = findTaskWithIndegreeZero(); System.out.println("---------------- Starting project from"); for (Task task : active_tasks) { System.out.println(task.toString()); task.start(t); } boolean finished = false; while (true) { ArrayList<Task> to_be_removed = new ArrayList<>(); ArrayList<Task> to_be_added = new ArrayList<>(); for (Task task : active_tasks) { if (task.isFinished(t)) { for (Edge edge : task.outEdges) { if (edge.w.tell_finished_prerequisite(t)) { to_be_added.add(edge.w); } } to_be_removed.add(task); } } active_tasks.removeAll(to_be_removed); active_tasks.addAll(to_be_added); int current_staff = 0; for (Task task : active_tasks) { current_staff += task.staff; } System.out.println("Current staff: " + Integer.toString(current_staff)); if (active_tasks.size() == 0) { for (Task task : tasks) { if (task.finished_at == -1) { System.out.println("Task " + Integer.toString(task.id) + " was not able to finish!"); } } break; } t++; System.out.println(" "); System.out.println("t: " + Integer.toString(t)); } minimum_completion_time = t; System.out.println( "*** Shortest possible execution time is " + Integer.toString(minimum_completion_time) + " ***"); setSlack(); }
@Test public void RawSubtransactionAwareResources02_1_Test002() { setTestName("Test002"); Task server1 = createTask( "server1", org.jboss.jbossts.qa.RawSubtransactionAwareResources02Servers.Server01.class, Task.TaskType.EXPECT_READY, 480); server1.start("$(1)"); Task client0 = createTask( "client0", org.jboss.jbossts.qa.RawSubtransactionAwareResources02Clients1.Client002.class, Task.TaskType.EXPECT_PASS_FAIL, 480); client0.start("$(1)"); client0.waitFor(); server1.terminate(); }
@Before public void setUp() { super.setUp(); server0 = createTask( "server0", com.arjuna.ats.arjuna.recovery.RecoveryManager.class, Task.TaskType.EXPECT_READY, 480); server0.start("-test"); }
@Override public synchronized String launch(final Task task, final String description) throws RemoteException { try { final long taskId = taskId(); task.setup(taskId, description, Thread.currentThread().getName(), 0, 5); _tasks.put(new Long(taskId), task); task.start(); return Long.toString(taskId); } 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); } }