Exemplo n.º 1
0
  /**
   * Adds an output instance to the queue. The derived class should use this method for each output
   * instance it makes available.
   *
   * @param instance the instance to be added to the queue.
   */
  protected void push(Instance instance) {

    if (instance != null) {
      if (instance.dataset() != null) copyValues(instance, false);
      instance.setDataset(m_OutputFormat);
      m_OutputQueue.push(instance);
    }
  }
Exemplo n.º 2
0
  /**
   * Pushes a host back onto the queue of available hosts and attempts to launch a waiting
   * experiment (if any).
   *
   * @param hostNum the index of the host to push back onto the queue of available hosts
   */
  protected synchronized void availableHost(int hostNum) {
    if (hostNum >= 0) {
      if (m_remoteHostFailureCounts[hostNum] < MAX_FAILURES) {
        m_remoteHostsQueue.push(new Integer(hostNum));
      } else {
        notifyListeners(
            false,
            true,
            false,
            "Max failures exceeded for host "
                + ((String) m_remoteHosts.elementAt(hostNum))
                + ". Removed from host list.");
        m_removedHosts++;
      }
    }

    // check for all sub exp complete or all hosts failed or failed count
    // exceeded
    if (m_failedCount == (MAX_FAILURES * m_remoteHosts.size())) {
      abortExperiment();
      notifyListeners(
          false, true, true, "Experiment aborted! Max failures " + "exceeded on all remote hosts.");
      return;
    }

    if ((getSplitByDataSet() && (m_baseExperiment.getDatasets().size() == m_finishedCount))
        || (getSplitByProperty() && (m_baseExperiment.getPropertyArrayLength() == m_finishedCount))
        || (!getSplitByDataSet()
            && !getSplitByProperty()
            && (getRunUpper() - getRunLower() + 1) == m_finishedCount)) {
      notifyListeners(false, true, false, "Experiment completed successfully.");
      notifyListeners(false, true, true, postExperimentInfo());
      return;
    }

    if (checkForAllFailedHosts()) {
      return;
    }

    if (m_experimentAborted
        && (m_remoteHostsQueue.size() + m_removedHosts) == m_remoteHosts.size()) {
      notifyListeners(false, true, true, "Experiment aborted. All remote tasks " + "finished.");
    }

    if (!m_subExpQueue.empty() && !m_experimentAborted) {
      if (!m_remoteHostsQueue.empty()) {
        int availHost, waitingExp;
        try {
          availHost = ((Integer) m_remoteHostsQueue.pop()).intValue();
          waitingExp = ((Integer) m_subExpQueue.pop()).intValue();
          launchNext(waitingExp, availHost);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
    }
  }
Exemplo n.º 3
0
 /**
  * Push an experiment back on the queue of waiting experiments
  *
  * @param expNum the index of the experiment to push onto the queue
  */
 protected synchronized void waitingExperiment(int expNum) {
   m_subExpQueue.push(new Integer(expNum));
 }
Exemplo n.º 4
0
  /**
   * Prepares a remote experiment for running, creates sub experiments
   *
   * @throws Exception if an error occurs
   */
  @Override
  public void initialize() throws Exception {
    if (m_baseExperiment == null) {
      throw new Exception("No base experiment specified!");
    }

    m_experimentAborted = false;
    m_finishedCount = 0;
    m_failedCount = 0;
    m_RunNumber = getRunLower();
    m_DatasetNumber = 0;
    m_PropertyNumber = 0;
    m_CurrentProperty = -1;
    m_CurrentInstances = null;
    m_Finished = false;

    if (m_remoteHosts.size() == 0) {
      throw new Exception("No hosts specified!");
    }
    // initialize all remote hosts to available
    m_remoteHostsStatus = new int[m_remoteHosts.size()];
    m_remoteHostFailureCounts = new int[m_remoteHosts.size()];

    m_remoteHostsQueue = new Queue();
    // prime the hosts queue
    for (int i = 0; i < m_remoteHosts.size(); i++) {
      m_remoteHostsQueue.push(new Integer(i));
    }

    // set up sub experiments
    m_subExpQueue = new Queue();
    int numExps;
    if (getSplitByDataSet()) {
      numExps = m_baseExperiment.getDatasets().size();
    } else if (getSplitByProperty()) {
      numExps = m_baseExperiment.getPropertyArrayLength();
    } else {
      numExps = getRunUpper() - getRunLower() + 1;
    }
    m_subExperiments = new Experiment[numExps];
    m_subExpComplete = new int[numExps];
    // create copy of base experiment
    SerializedObject so = new SerializedObject(m_baseExperiment);

    if (getSplitByDataSet()) {
      for (int i = 0; i < m_baseExperiment.getDatasets().size(); i++) {
        m_subExperiments[i] = (Experiment) so.getObject();
        // one for each data set
        DefaultListModel temp = new DefaultListModel();
        temp.addElement(m_baseExperiment.getDatasets().get(i));
        m_subExperiments[i].setDatasets(temp);
        m_subExpQueue.push(new Integer(i));
      }
    } else if (getSplitByProperty()) {
      for (int i = 0; i < m_baseExperiment.getPropertyArrayLength(); i++) {
        m_subExperiments[i] = (Experiment) so.getObject();
        Object[] a = new Object[1];
        a[0] = m_baseExperiment.getPropertyArrayValue(i);
        m_subExperiments[i].setPropertyArray(a);
        m_subExpQueue.push(new Integer(i));
      }
    } else {
      for (int i = getRunLower(); i <= getRunUpper(); i++) {
        m_subExperiments[i - getRunLower()] = (Experiment) so.getObject();
        // one run for each sub experiment
        m_subExperiments[i - getRunLower()].setRunLower(i);
        m_subExperiments[i - getRunLower()].setRunUpper(i);

        m_subExpQueue.push(new Integer(i - getRunLower()));
      }
    }
  }