예제 #1
0
 /**
  * Mit dieser Methode kann der int-Wert des Feldes bestimmt werden.
  *
  * @return DOCUMENT ME!
  */
 public int getValue() {
   int retVal = 0;
   try {
     retVal = integerFormatter.parse(getText()).intValue();
   } catch (ParseException e) {
     // This should never happen because insertString allows
     // only properly formatted data to get in the field.
     toolkit.beep();
   }
   return retVal;
 }
예제 #2
0
  /**
   * Конвертация строки типа: 5 Minutes
   *
   * @param str
   * @return
   */
  private static int parseDuration(String str) throws ParseException {
    int idx = str.indexOf(' ');
    float num = DF.parse(str.substring(0, idx)).floatValue();
    switch (str.substring(idx + 1)) {
      case "Seconds":
        return Math.round(num);

      case "Minutes":
        return Math.round(num * 60);

      default:
        throw new ParseException("Неизвестный формат единиц: " + str, idx + 1);
    }
  }
예제 #3
0
  public void parse(Path file) throws IOException {
    clear();
    try (BufferedReader inp = Files.newBufferedReader(file)) {
      String line;
      while ((line = inp.readLine()) != null) {
        if (line.startsWith("Cpu ")) {
          PerfKey key = new PerfKey();
          PerfData data = new PerfData();
          // Cpu  0 NSE-AB         Init Lock Pgs     19          Mem Pages       4194304
          key.cpu = Integer.parseInt(line.substring(4, 6).trim());
          data.memPages = Integer.parseInt(line.substring(62).trim());

          line = inp.readLine();
          // Memory MB      65536  PCBs           12100          Pg Size    16384  Bytes
          if (line == null || !line.startsWith("Memory MB")) {
            throw new IOException("Строка должна начинаться с 'Memory MB': " + line);
          }

          line = inp.readLine();
          // IPUs    4
          if (line == null || !line.startsWith("IPUs")) {
            throw new IOException("Строка должна начинаться с 'IPUs': " + line);
          }

          line = inp.readLine();
          // Format Version:  H07  Data Version:  H07  Subsystem Version:  3
          if (line == null || !line.startsWith("Format Version:")) {
            throw new IOException("Строка должна начинаться с 'Format Version:': " + line);
          }

          line = inp.readLine();
          // Local System \KHAFE1  From   1 Oct 2016,  0:00:01   For   5.1 Minutes
          if (line == null || !line.startsWith("Local System")) {
            throw new IOException("Строка должна начинаться с 'Local System:': " + line);
          }
          key.system = line.substring(13, 21).trim();
          String str = line.substring(28, 49);
          try {
            key.date = DATETIME_SDF.parse(str);
            data.duration = parseDuration(line.substring(56).trim());
          } catch (ParseException e) {
            throw new IOException(
                "Ошибка декодирования строки (Позиция. "
                    + e.getErrorOffset()
                    + "): "
                    + str
                    + ". Строка:"
                    + line,
                e);
          } catch (NumberFormatException e) {
            throw new IOException("Ошибка декодирования строки : " + str + ". Строка:" + line, e);
          }

          line = inp.readLine();
          // ----------------------------------------------------------------------------
          if (line == null || !line.startsWith("---------")) {
            throw new IOException("Строка должна начинаться с '---------:': " + line);
          }

          line = inp.readLine();
          // Cpu-Busy-Time               79.99 %    Dispatches                115,637 /s
          if (line == null || !line.startsWith("Cpu-Busy-Time")) {
            throw new IOException("Строка должна начинаться с 'Cpu-Busy-Time': " + line);
          }
          str = line.substring(25, 33).trim();
          try {
            data.cpuBusyTime = DF.parse(str).floatValue();
          } catch (ParseException e) {
            throw new IOException("Ошибка декодирования Cpu-Busy-Time: " + str, e);
          }

          line = inp.readLine();
          // Cpu-Qtime                   13.89 AQL  Intr-Busy-Time              14.41 %
          if (line == null || !line.startsWith("Cpu-Qtime")) {
            throw new IOException("Строка должна начинаться с 'Cpu-Qtime': " + line);
          }

          line = inp.readLine();
          // Starting-Free-Mem       3,267,922 #    Ending-Free-Mem         3,267,951 #
          if (line == null || !line.startsWith("Starting-Free-Mem")) {
            throw new IOException("Строка должна начинаться с 'Starting-Free-Mem': " + line);
          }
          str = line.substring(55, 73).trim();
          try {
            data.endingFreeMem = DF.parse(str).intValue();
          } catch (ParseException e) {
            throw new IOException("Ошибка декодирования Ending-Free-Mem: " + str, e);
          }

          line = inp.readLine();
          // Swaps                        1.10 /s   Page-Requests                2.19 /s
          if (line == null || !line.startsWith("Swaps")) {
            throw new IOException("Строка должна начинаться с 'Swaps': " + line);
          }

          line = inp.readLine();
          // Disc-IOs                    49.79 /s   Cache-Hits                 946.87 /s
          if (line == null || !line.startsWith("Disc-IOs")) {
            throw new IOException("Строка должна начинаться с 'Disc-IOs': " + line);
          }

          this.stat.addPerfData(key, data);
        }
      }
    }
  }