Ejemplo n.º 1
1
  /** {@inheritDoc} */
  protected void getNewMonitors(Map<String, Monitor> map) throws MonitorException {
    assert Thread.holdsLock(this);

    int used = prologue.getUsed();
    long modificationTime = prologue.getModificationTimeStamp();

    if ((used > lastUsed) || (lastModificationTime > modificationTime)) {

      lastUsed = used;
      lastModificationTime = modificationTime;

      Monitor monitor = getNextMonitorEntry();
      while (monitor != null) {
        String name = monitor.getName();

        // guard against duplicate entries
        if (!map.containsKey(name)) {
          map.put(name, monitor);

          /*
           * insertedMonitors is null when called from pollFor()
           * via buildMonitorMap(). Since we update insertedMonitors
           * at the end of buildMonitorMap(), it's ok to skip the
           * add here.
           */
          if (insertedMonitors != null) {
            insertedMonitors.add(monitor);
          }
        }
        monitor = getNextMonitorEntry();
      }
    }
  }
Ejemplo n.º 2
0
  /** Method to dump debugging information */
  private void dumpAll(Map map, int lvmid) {
    if (DEBUG) {
      Set keys = map.keySet();

      System.err.println("Dump for " + lvmid);
      int j = 0;
      for (Iterator i = keys.iterator(); i.hasNext(); j++) {
        Monitor monitor = (Monitor) map.get(i.next());
        System.err.println(j + "\t" + monitor.getName() + "=" + monitor.getValue());
      }
      System.err.println("nextEntry = " + nextEntry + " pollForEntry = " + pollForEntry);
      System.err.println("Buffer info:");
      System.err.println("buffer = " + buffer);
    }
  }
Ejemplo n.º 3
0
  /*
   * evaluate the given expression.
   */
  public Object evaluate(Expression e) {
    if (e == null) {
      return null;
    }

    if (debug) {
      System.out.println("Evaluating expression: " + e);
    }

    if (e instanceof Literal) {
      return ((Literal) e).getValue();
    }

    if (e instanceof Identifier) {
      Identifier id = (Identifier) e;
      if (map.containsKey(id.getName())) {
        return map.get(id.getName());
      } else {
        // cache the data values for coherency of the values over
        // the life of this expression executer.
        Monitor m = (Monitor) id.getValue();
        Object v = m.getValue();
        map.put(id.getName(), v);
        return v;
      }
    }

    Expression l = e.getLeft();
    Expression r = e.getRight();

    Operator op = e.getOperator();

    if (op == null) {
      return evaluate(l);
    } else {
      Double lval = new Double(((Number) evaluate(l)).doubleValue());
      Double rval = new Double(((Number) evaluate(r)).doubleValue());
      double result = op.eval(lval.doubleValue(), rval.doubleValue());
      if (debug) {
        System.out.println("Performed Operation: " + lval + op + rval + " = " + result);
      }
      return new Double(result);
    }
  }
Ejemplo n.º 4
0
  /** {@inheritDoc} */
  protected void buildMonitorMap(Map<String, Monitor> map) throws MonitorException {
    assert Thread.holdsLock(this);

    // start at the beginning of the buffer
    buffer.rewind();

    // create pseudo monitors
    buildPseudoMonitors(map);

    // position buffer to start of the data section
    buffer.position(prologue.getSize());
    nextEntry = buffer.position();
    perfDataItem = 0;

    int used = prologue.getUsed();
    long modificationTime = prologue.getModificationTimeStamp();

    Monitor m = getNextMonitorEntry();
    while (m != null) {
      map.put(m.getName(), m);
      m = getNextMonitorEntry();
    }

    /*
     * set the last modification data. These are set to the values
     * recorded before parsing the data structure. This allows the
     * the data structure to be modified while the Map is being built.
     * The Map may contain more entries than indicated based on the
     * time stamp, but this is handled by ignoring duplicate entries
     * when the Map is updated in getNewMonitors().
     */
    lastUsed = used;
    lastModificationTime = modificationTime;

    // synchronize with the target jvm
    synchWithTarget(map);

    // work around 1.4.2 counter inititization bugs
    kludge(map);

    insertedMonitors = new ArrayList<Monitor>(map.values());
  }
Ejemplo n.º 5
0
 public int compare(Monitor o1, Monitor o2) {
   String name1 = o1.getName();
   String name2 = o2.getName();
   return name2.compareTo(name1);
 }