Example #1
1
    @Override
    public void run() {
      while (true) {
        if (istWindows()) aktuell = holeLaufwerkeWindows();
        else aktuell = holeLaufwerkeUnix();

        if (initial.size() != aktuell.size()) {
          if (!initial.containsAll(aktuell)) {
            neuesLaufwerk = holePathVonNeuemLaufwerk(initial, aktuell);
            textArea.append("Neues Laufwerk endeckt:  " + neuesLaufwerk + System.lineSeparator());
            this.initial = (ArrayList<Path>) aktuell.clone();
            neuesLaufwerkDialog();

          } else {
            this.initial = (ArrayList<Path>) aktuell.clone();
            textArea.append("Laufwerk wurde entfernt" + System.lineSeparator());
          }
        }

        try {
          Thread.sleep(5000);
        } catch (InterruptedException e) {
          System.out.println("Laufwerkspr├╝fung wird abgebrochen");
        }
      }
    }
Example #2
1
 private Path holePathVonNeuemLaufwerk(ArrayList<Path> initial, ArrayList<Path> aktuell) {
   ArrayList<Path> test, test1;
   test = (ArrayList<Path>) aktuell.clone();
   test1 = (ArrayList<Path>) initial.clone();
   test.removeAll(test1);
   return test.get(test.size() - 1);
 }
Example #3
0
  public static void doIt() throws Exception {
    Scanner scanner = new Scanner(System.in);
    Integer currentBalance = scanner.nextInt();
    int removeLast, removePenultimate;
    StringBuffer buf = new StringBuffer();

    ArrayList<Character> chars = new ArrayList<Character>();
    for (Character c : currentBalance.toString().toCharArray()) chars.add(c);

    ArrayList<Character> c1 = (ArrayList<Character>) chars.clone();
    c1.remove(c1.size() - 1);

    for (Character cc : c1) buf.append(cc);

    removeLast = new Integer(buf.toString());
    buf = new StringBuffer();

    ArrayList<Character> c2 = (ArrayList<Character>) chars.clone();
    c2.remove(c2.size() - 2);

    for (Character cc : c2) buf.append(cc);
    removePenultimate = new Integer(buf.toString());

    System.out.println(Math.max(currentBalance, Math.max(removeLast, removePenultimate)));
  }
  /** Fire hostDisconnectEvent events. */
  void fireDisconnectedEvents() {
    ArrayList registered = null;
    HostEvent ev = null;

    synchronized (listeners) {
      registered = (ArrayList) listeners.clone();
    }

    for (Iterator i = registered.iterator(); i.hasNext(); /* empty */ ) {
      HostListener l = (HostListener) i.next();
      if (ev == null) {
        ev = new HostEvent(this);
      }
      l.disconnected(ev);
    }
  }
  /**
   * Fire VmStatusChangeEvent events to HostListener objects
   *
   * @param active Set of Integer objects containing the local Vm Identifiers of the active JVMs
   * @param started Set of Integer objects containing the local Vm Identifiers of new JVMs started
   *     since last interval.
   * @param terminated Set of Integer objects containing the local Vm Identifiers of terminated JVMs
   *     since last interval.
   */
  private void fireVmStatusChangedEvents(Set active, Set started, Set terminated) {
    ArrayList registered = null;
    VmStatusChangeEvent ev = null;

    synchronized (listeners) {
      registered = (ArrayList) listeners.clone();
    }

    for (Iterator i = registered.iterator(); i.hasNext(); /* empty */ ) {
      HostListener l = (HostListener) i.next();
      if (ev == null) {
        ev = new VmStatusChangeEvent(this, active, started, terminated);
      }
      l.vmStatusChanged(ev);
    }
  }
Example #6
0
  // Fill in weights for specific counting aggregator approaches
  //
  // Basis function 1: Count of computers running
  // Basis function 2: Count of computers running and connected to
  //                   one other running computer
  //
  // Assuming action succeeds... compute next-state value based on action,
  // choose best action.
  public Action getBasisAction() {

    int best_reboot = -1;
    double best_reboot_val = -1d;
    for (int c = 1; c <= _nVars; c++) {
      ArrayList test_state = (ArrayList) _state.clone();
      test_state.set(c - 1 + _nVars, TRUE);
      double test_val = evalBasisState(test_state, W_BASIS_1, W_BASIS_2);
      if (test_val > best_reboot_val) {
        best_reboot_val = test_val;
        best_reboot = c;
      }
    }

    return (Action) _mdp._hmName2Action.get("reboot" + best_reboot);
  }
Example #7
0
  /**
   * writes table directory.
   *
   * @throws IOException
   */
  private void writeTableDirectory() throws IOException {
    int headerLength = m_tables.size() * 16 + 16;
    int tableOffset = headerLength;
    for (FontFormatWriter table : m_tables) {
      table.setOffset(tableOffset);
      tableOffset += table.size();
    } // for table

    ArrayList<FontFormatWriter> tables = (ArrayList<FontFormatWriter>) m_tables.clone();
    Collections.sort(
        tables,
        new Comparator<FontFormatWriter>() {
          public int compare(FontFormatWriter a_lhs, FontFormatWriter a_rhs) {
            return a_lhs.getTag().compareTo(a_rhs.getTag());
          }

          public boolean equals(Object a_value) {
            return false;
          }
        });

    writeFixed32(1.0);

    int numOfTables = tables.size();
    writeUInt16(numOfTables);
    int searchRange = getSearchRange(numOfTables);
    writeUInt16(searchRange);
    int entrySelector = getEntrySelector(numOfTables);
    writeUInt16(entrySelector);
    writeUInt16(numOfTables * 16 - searchRange);

    for (FontFormatWriter table : tables) {
      writeTag(table.getTag());
      writeUInt32(table.getCheckSum());
      writeUInt32(table.getOffset());
      writeUInt32(table.size());
    } // for

    // padding is always 4 zeros
    for (int i = 0; i < 4; i++) {
      writeUInt8(0);
    } // for i
  }