Esempio n. 1
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();
        }
      }
    }
  }
Esempio n. 2
0
 /**
  * Set the base experiment. A sub experiment will be created for each run in the base experiment.
  *
  * @param base the base experiment to use.
  * @throws Exception if supplied base experiment is null
  */
 public void setBaseExperiment(Experiment base) throws Exception {
   if (base == null) {
     throw new Exception("Base experiment is null!");
   }
   m_baseExperiment = base;
   setRunLower(m_baseExperiment.getRunLower());
   setRunUpper(m_baseExperiment.getRunUpper());
   setResultListener(m_baseExperiment.getResultListener());
   setResultProducer(m_baseExperiment.getResultProducer());
   setDatasets(m_baseExperiment.getDatasets());
   setUsePropertyIterator(m_baseExperiment.getUsePropertyIterator());
   setPropertyPath(m_baseExperiment.getPropertyPath());
   setPropertyArray(m_baseExperiment.getPropertyArray());
   setNotes(m_baseExperiment.getNotes());
   m_ClassFirst = m_baseExperiment.m_ClassFirst;
   m_AdvanceDataSetFirst = m_baseExperiment.m_AdvanceDataSetFirst;
 }
Esempio n. 3
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()));
      }
    }
  }