List of usage examples for weka.experiment TaskStatusInfo setStatusMessage
public void setStatusMessage(String newMessage)
From source file:core.utils.ui.RemoteEngine.java
License:Open Source License
/** * Returns status information on a particular task * * @param taskId the ID of the task to check * @return a <code>TaskStatusInfo</code> encapsulating task status info * @exception Exception if an error occurs *//*from w ww . j av a 2 s. c om*/ public Object checkStatus(Object taskId) throws Exception { TaskStatusInfo inf = (TaskStatusInfo) m_TaskStatus.get(taskId); if (inf == null) { throw new Exception("RemoteEngine (" + m_HostName + ") : Task not found."); } TaskStatusInfo result = new TaskStatusInfo(); result.setExecutionStatus(inf.getExecutionStatus()); result.setStatusMessage(inf.getStatusMessage()); result.setTaskResult(inf.getTaskResult()); if (inf.getExecutionStatus() == TaskStatusInfo.FINISHED || inf.getExecutionStatus() == TaskStatusInfo.FAILED) { System.err.println("Finished/failed Task id : " + taskId + " checked by client. Removing."); inf.setTaskResult(null); inf = null; m_TaskStatus.remove(taskId); } inf = null; return result; }
From source file:core.utils.ui.RemoteEngine.java
License:Open Source License
/** * Adds a new task to the queue.//w ww .j a v a 2 s.c om * * @param t a <code>Task</code> value to be added * @param taskId the id of the task to be added */ private synchronized void addTaskToQueue(Task t, String taskId) { TaskStatusInfo newTask = t.getTaskStatus(); if (newTask == null) { newTask = new TaskStatusInfo(); } m_TaskQueue.push(t); m_TaskIdQueue.push(taskId); newTask.setStatusMessage( "RemoteEngine (" + m_HostName + ") : task " + taskId + " queued at postion: " + m_TaskQueue.size()); // add task status to HashTable m_TaskStatus.put(taskId, newTask); System.err.println("Task id : " + taskId + " Queued."); if (m_TaskRunning == false) { startTask(); } }
From source file:core.utils.ui.RemoteEngine.java
License:Open Source License
/** * Checks to see if there are any waiting tasks, and if no task is * currently running starts a waiting task. *///from w ww.j ava 2 s. c o m private void startTask() { if (m_TaskRunning == false && m_TaskQueue.size() > 0) { Thread activeTaskThread; activeTaskThread = new Thread() { public void run() { m_TaskRunning = true; Task currentTask = (Task) m_TaskQueue.pop(); String taskId = (String) m_TaskIdQueue.pop(); TaskStatusInfo tsi = (TaskStatusInfo) m_TaskStatus.get(taskId); tsi.setExecutionStatus(TaskStatusInfo.PROCESSING); tsi.setStatusMessage("RemoteEngine (" + m_HostName + ") : task " + taskId + " running..."); try { System.err.println("Launching task id : " + taskId + "..."); currentTask.execute(); TaskStatusInfo runStatus = currentTask.getTaskStatus(); tsi.setExecutionStatus(runStatus.getExecutionStatus()); tsi.setStatusMessage( "RemoteExperiment (" + m_HostName + ") " + runStatus.getStatusMessage()); tsi.setTaskResult(runStatus.getTaskResult()); } catch (Error er) { // Object initialization can raise Error, which are not subclass of Exception tsi.setExecutionStatus(TaskStatusInfo.FAILED); if (er.getCause() instanceof java.security.AccessControlException) { tsi.setStatusMessage("RemoteEngine (" + m_HostName + ") : security error, check remote policy file."); System.err.println("Task id " + taskId + " Failed! Check remote policy file"); } else { tsi.setStatusMessage( "RemoteEngine (" + m_HostName + ") : unknown initialization error."); System.err.println("Task id " + taskId + " Unknown initialization error"); } } catch (Exception ex) { tsi.setExecutionStatus(TaskStatusInfo.FAILED); if (ex instanceof java.io.FileNotFoundException) { tsi.setStatusMessage("RemoteEngine (" + m_HostName + ") : " + ex.getMessage()); System.err.println("Task id " + taskId + " Failed, " + ex.getMessage()); } else { tsi.setStatusMessage("RemoteEngine (" + m_HostName + ") : task " + taskId + " failed."); System.err.println("Task id " + taskId + " Failed!"); } } finally { if (m_TaskStatus.size() == 0) { purgeClasses(); } m_TaskRunning = false; // start any waiting tasks startTask(); } } }; activeTaskThread.setPriority(Thread.MIN_PRIORITY); activeTaskThread.start(); } }