List of usage examples for weka.experiment TaskStatusInfo PROCESSING
int PROCESSING
To view the source code for weka.experiment TaskStatusInfo PROCESSING.
Click Source Link
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. *///w ww. j av a 2s .co 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(); } }
From source file:milk.experiment.MIRemoteExperiment.java
License:Open Source License
/** * Launch a sub experiment on a remote host * @param wexp the index of the sub experiment to launch * @param ah the index of the available host to launch on *///from w w w . j av a2s . com public void launchNext(final int wexp, final int ah) { Thread subExpThread; subExpThread = new Thread() { public void run() { m_remoteHostsStatus[ah] = IN_USE; m_subExpComplete[wexp] = TaskStatusInfo.PROCESSING; MIRemoteExperimentSubTask expSubTsk = new MIRemoteExperimentSubTask(); expSubTsk.setExperiment(m_subExperiments[wexp]); String subTaskType = (getSplitByDataSet()) ? "dataset :" + ((File) m_subExperiments[wexp].getDatasets().elementAt(0)).getName() : "run :" + m_subExperiments[wexp].getRunLower(); try { String name = "//" + ((String) m_remoteHosts.elementAt(ah)) + "/RemoteEngine"; Compute comp = (Compute) Naming.lookup(name); // assess the status of the sub-exp notifyListeners(false, true, false, "Starting " + subTaskType + " on host " + ((String) m_remoteHosts.elementAt(ah))); Object subTaskId = comp.executeTask(expSubTsk); boolean finished = false; TaskStatusInfo is = null; while (!finished) { try { Thread.sleep(2000); TaskStatusInfo cs = (TaskStatusInfo) comp.checkStatus(subTaskId); if (cs.getExecutionStatus() == TaskStatusInfo.FINISHED) { // push host back onto queue and try launching any waiting // sub-experiments notifyListeners(false, true, false, cs.getStatusMessage()); m_remoteHostsStatus[ah] = AVAILABLE; incrementFinished(); availableHost(ah); finished = true; } else if (cs.getExecutionStatus() == TaskStatusInfo.FAILED) { // a non connection related error---possibly host doesn't have // access to data sets or security policy is not set up // correctly or classifier(s) failed for some reason notifyListeners(false, true, false, cs.getStatusMessage()); m_remoteHostsStatus[ah] = SOME_OTHER_FAILURE; m_subExpComplete[wexp] = TaskStatusInfo.FAILED; notifyListeners(false, true, false, subTaskType + " " + cs.getStatusMessage() + ". Scheduling for execution on another host."); incrementFailed(ah); // push experiment back onto queue waitingExperiment(wexp); // push host back onto queue and try launching any waiting // sub-experiments. Host is pushed back on the queue as the // failure may be temporary---eg. with InstantDB using the // RMI bridge, two or more threads may try to create the // experiment index or results table simultaneously; all but // one will throw an exception. These hosts are still usable // however. availableHost(ah); finished = true; } else { if (is == null) { is = cs; notifyListeners(false, true, false, cs.getStatusMessage()); } else { if (cs.getStatusMessage().compareTo(is.getStatusMessage()) != 0) { notifyListeners(false, true, false, cs.getStatusMessage()); } is = cs; } } } catch (InterruptedException ie) { } } } catch (Exception ce) { m_remoteHostsStatus[ah] = CONNECTION_FAILED; m_subExpComplete[wexp] = TaskStatusInfo.TO_BE_RUN; System.err.println(ce); ce.printStackTrace(); notifyListeners(false, true, false, "Connection to " + ((String) m_remoteHosts.elementAt(ah)) + " failed. Scheduling " + subTaskType + " for execution on another host."); checkForAllFailedHosts(); waitingExperiment(wexp); } finally { if (isInterrupted()) { System.err.println("Sub exp Interupted!"); } } } }; subExpThread.setPriority(Thread.MIN_PRIORITY); subExpThread.start(); }