Ejemplo n.º 1
0
  public void testNamePollTally() throws Exception {
    V1NamePoll np;
    // test a name poll we won
    np = makeCompletedNamePoll(4, 1, 0);
    assertEquals(5, np.m_tally.numAgree);
    assertEquals(1, np.m_tally.numDisagree);
    assertEquals(Tallier.RESULT_WON, np.m_tally.getTallyResult());

    // test a name poll we lost with a dissenting vote
    np = makeCompletedNamePoll(1, 8, 1);

    assertEquals(2, np.m_tally.numAgree);
    assertEquals(9, np.m_tally.numDisagree);

    // build a master list
    np.buildPollLists(np.m_tally.pollVotes.iterator());

    // these should be different since we lost the poll
    assertFalse(CollectionUtil.isIsomorphic(np.m_tally.localEntries, np.m_tally.votedEntries));

    // the expected "correct" set is in our disagree msg
    assertTrue(CollectionUtil.isIsomorphic(disagree_entries, np.m_tally.votedEntries));
  }
Ejemplo n.º 2
0
 /**
  * An alternative constructor that allows one to specify whether or not to show columns which are
  * entirely empty. If <code>omitEmptyFields</code> is true, the <code>emptyFields</code> set is
  * filled with the names of the empty fields. This is an expensive operation which requires
  * iteration over potentially all of the titles, so is performed here at construction.
  *
  * <p>Due to this processing, it is not possible to accept an iterator instead of a list, which
  * would be less memory intensive.
  *
  * @param titles the titles to be exported
  * @param ordering an ordering to impose on the fields of each title
  * @param omitEmptyFields whether to omit empty field columns from the output
  */
 public KbartExportFilter(
     List<KbartTitle> titles,
     ColumnOrdering ordering,
     boolean omitEmptyFields,
     boolean omitHeader,
     boolean excludeNoIdTitles,
     boolean showHealthRatings) {
   this.titles = titles;
   this.columnOrdering = ordering;
   this.omitEmptyFields = omitEmptyFields;
   this.omitHeaderRow = omitHeader;
   this.excludeNoIdTitles = excludeNoIdTitles;
   this.showHealthRatings = showHealthRatings;
   // Work out the list of empty fields if necessary
   this.emptyFields = omitEmptyFields ? findEmptyFields() : EnumSet.noneOf(Field.class);
   // Create a list of the visible (non-omitted) fields out of the supplied ordering
   this.visibleColumnOrdering =
       CustomColumnOrdering.copy(columnOrdering).removeFields(emptyFields);
   this.rangeFieldsIncludedInDisplay =
       !CollectionUtil.isDisjoint(visibleColumnOrdering.getFields(), rangeFields);
   this.idFieldsIncludedInDisplay =
       !CollectionUtil.isDisjoint(visibleColumnOrdering.getFields(), idFields);
 }
Ejemplo n.º 3
0
    public void lockssRun() {
      setPriority(PRIORITY_PARAM_SIZE_CALC, PRIORITY_DEFAULT_SIZE_CALC);
      startWDog(WDOG_PARAM_SIZE_CALC, WDOG_DEFAULT_SIZE_CALC);
      triggerWDogOnExit(true);
      nowRunning();

      while (goOn) {
        try {
          pokeWDog();
          if (sizeCalcQueue.isEmpty()) {
            Deadline timeout = Deadline.in(Constants.HOUR);
            sizeCalcSem.take(timeout);
          }
          RepositoryNode node;
          synchronized (sizeCalcQueue) {
            node = (RepositoryNode) CollectionUtil.getAnElement(sizeCalcQueue);
          }
          if (node != null) {
            long start = TimeBase.nowMs();
            log.debug2("CalcSize start: " + node);
            long dur = 0;
            try {
              doSizeCalc(node);
              dur = TimeBase.nowMs() - start;
              log.debug2("CalcSize finish (" + StringUtil.timeIntervalToString(dur) + "): " + node);
            } catch (RuntimeException e) {
              log.warning("doSizeCalc: " + node, e);
            }
            synchronized (sizeCalcQueue) {
              sizeCalcQueue.remove(node);
            }
            pokeWDog();
            long sleep = sleepTimeToAchieveLoad(dur, sizeCalcMaxLoad);
            Deadline.in(sleep).sleep();
          }
        } catch (InterruptedException e) {
          // just wakeup and check for exit
        }
      }
      if (!goOn) {
        triggerWDogOnExit(false);
      }
    }
Ejemplo n.º 4
0
 /**
  * Whether there are fields included in the given set which provide range information for a title.
  *
  * @param fields a set of fields to check
  * @return whether the list includes any range fields
  */
 public static boolean includesRangeFields(Set<Field> fields) {
   return !CollectionUtil.isDisjoint(fields, rangeFields);
 }