All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.mcs.jmeasurement.DefaultMeasurePoint Maven / Gradle / Ivy

There is a newer version: 1.1.226
Show newest version
/*
 * MCS Media Computer Software Copyright (c) 2005 by MCS
 * -------------------------------------- Created on 23.04.2005 by w.klaas
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package de.mcs.jmeasurement;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.SoftReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

import com.megginson.sax.DataWriter;

import de.mcs.utils.StringUtils;
import de.mcs.utils.codecs.Base64;

/**
 * This is the implementing class of a measure point. This class stores all the
 * measured data.
 * 
 * @author w.klaas
 */
public class DefaultMeasurePoint implements MeasurePoint {
  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_USER_DATA = "userData";

  /**
   * key for the getData and setData methodes.
   * 
   * @since 0.64
   */
  public static final String DATA_KEY_EXCEPTION_LIST = "exceptionList";

  /**
   * key for the getData and setData methodes.
   * 
   * @since 0.64
   */
  public static final String DATA_KEY_EXCEPTION_COUNT = "exceptionCount";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_LAST_ACTIVATION = "lastActivation";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_DEATH_COUNT = "deathCount";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_MAX_ACTIVE = "maxActive";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_ACTIVE = "active";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_MAX_MSEC = "maxMSec";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_MIN_MSEC = "minMSec";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_TOTAL_MSEC = "totalMSec";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_AVERAGE_MSEC = "averageMSec";

  /**
   * key for the getData and setData methodes. *
   * 
   * @since 0.65
   */
  public static final String DATA_KEY_DEVIATION = "deviation";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_ACCESS_COUNT = "accessCount";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_PRIORITY = "priority";

  /** key for the getData and setData methodes. */
  public static final String DATA_KEY_POINT_NAME = "pointName";

  /** key for the getData and setData methodes. */
  private static final String DATA_KEY_SQUARESUM = "squaresum";

  /** default buffer size. */
  private static final int BUFFER_SIZE = 1024;

  /** default arraylist size. */
  private static final int DEFAULT_ARRAY_SIZE = 10;

  /** hashmap default init. */
  private static final int DEFAULT_MEASURE_POINT_COUNT = 100;

  /** serial id. Do not change manually. */
  private static final long serialVersionUID = -3842886735720219978L;

  /** date formatter needed for this. */
  private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat();

  /** how often is this point accessed. */
  private long accessCount;

  /** average time of all accesses. */
  private long averageMSec;

  /** total time of all measurements. */
  private long totalMSec;

  /** minimal time of all measurements. */
  private long minMSec;

  /** maxmimal time of all measurements. */
  private long maxMSec;

  /** number of actual active monitors. */
  private volatile long active;

  /** maxmimal time of all measurements. */
  private long maxActive;

  /** count of all death monitors. */
  private long deathMonitors;

  /** last activation of the start() methode. */
  private Date lastActivation;

  /** maxmimal time of all measurements. */
  private IUserData userData;

  /** full qualified name of this point. */
  private String pointName;

  /** priority of this point. */
  private PRIORITY priority;

  /**
   * square summm of all measure points data.
   * 
   * @since 0.65
   */
  private double squareSumm;

  /**
   * exception counter for proxy use.
   * 
   * @since 0.64
   */
  private long exceptionCount;

  /**
   * list of all exception descriptions.
   * 
   * @since 0.64
   */
  private ArrayList exceptionList;

  /** callback function of this measurepoint. */
  private transient MeasureDataCallback measureDataCallback;

  /** monitor map with softreferences. */
  private HashMap> hmMonitors;

  /** id of the last monitor. */
  private long monitorId;

  /** the reference queue. */
  private transient ReferenceQueue referenceQueue;

  /** last deviation calculated. */
  private float deviation;

  /** optional settings for this point. */
  private transient JMConfig config;

  /** calculating the deviation of every monitor. */
  private boolean bCalculationDeviation;

  /**
   * This class is our class to reference all monitors. If the garbage
   * collector removes a monitor we will notice it with the referenceQueue.
   * 
   * @author w.klaas
   */
  private static final class SoftEntry extends SoftReference {
    /** our key in the hashmap to find this Monitor. */
    private Object key;

    /**
     * Our Constructor, who will store the key into an internal field. All
     * other parameter will be handed over to the constructor of the
     * SoftReference.
     * 
     * @param aKey
     *            the key in our hashmap
     * @param value
     *            the monitor object
     * @param aQ
     *            the referenceQueue
     */
    private SoftEntry(final Object aKey, final T value, final ReferenceQueue aQ) {
      super(value, aQ);
      this.key = aKey;
    }
  }

  /**
   * create a new measurement point with the name pointName. Priority is set
   * to 0.
   * 
   * @param name
   *            name of this measurement point
   * @param aOptions
   *            options for this point
   */
  public DefaultMeasurePoint(final String name, final JMConfig aOptions) {
    pointName = name;
    priority = PRIORITY.MEDIUM;
    accessCount = 0;
    averageMSec = 0;
    totalMSec = 0;
    minMSec = 0;
    maxMSec = 0;
    active = 0;
    maxActive = 0;
    deathMonitors = 0;
    userData = null;
    monitorId = 0;
    referenceQueue = new ReferenceQueue();
    hmMonitors = new HashMap>(DEFAULT_MEASURE_POINT_COUNT);
    exceptionCount = 0;
    exceptionList = new ArrayList(DEFAULT_MEASURE_POINT_COUNT);
    squareSumm = 0.0;
    bCalculationDeviation = true;
    if (aOptions != null) {
      config = aOptions;
      processOptions();
    }
  }

  /**
   * create a new measurement point with the name pointName. Priority is set
   * to aPriority.
   * 
   * @param name
   *            name of this measurement point
   * @param aPriority
   *            priority of this point
   * @param aOptions
   *            options for this point
   */
  public DefaultMeasurePoint(final String name, final PRIORITY aPriority, final JMConfig aOptions) {
    this(name, aOptions);
    priority = aPriority;
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#getMonitor()
   * @return Monitor getting a new monitor for this measure point
   */
  public final Monitor getMonitor() {
    // process list of all death monitors
    processQueue();
    Monitor monitor;
    synchronized (this) {
      monitorId++;
      monitor = new DefaultMonitor(this, Long.toString(monitorId));
    }
    return monitor;
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#start()
   * @return Monitor Getting an monitor for this measurepoint and start it.
   */
  public final Monitor start() {
    // process list of all death monitors
    processQueue();
    Monitor monitor = getMonitor();
    monitor.start();
    return monitor;
  }

  /**
   * one monitor has to be activated.
   * 
   * @param monitor
   *            the monitor that has been activated
   */
  public final void activateMonitor(final Monitor monitor) {
    synchronized (this) {
      active++;
      if (active > maxActive) {
        maxActive = active;
      }
      lastActivation = new Date();
      // we add this monitor as SoftReference to our list of monitors
      Reference ref = new SoftEntry(monitor.getMonitoId(), monitor, referenceQueue);
      hmMonitors.put(monitor.getMonitoId(), ref);
    }
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#getName()
   * @return String Fully qualified name of this MeasurePoint.
   */
  public final String getName() {
    return pointName;
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#getPriority()
   * @return int Getting the priority of this MeasurePoint
   */
  public final PRIORITY getPriority() {
    return priority;
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#setPriority(PRIORITY)
   * @param aPriority
   *            Setting the priority of this MeasurePoint
   */
  public final void setPriority(final PRIORITY aPriority) {
    this.priority = aPriority;
  }

  /**
   * @see de.mcs.jmeasurement.MeasurePoint#processMonitor(de.mcs.jmeasurement.Monitor)
   * @param monitor
   *            the monitor to add the values to
   */
  public final void processMonitor(final Monitor monitor) {
    if (null != measureDataCallback) {
      measureDataCallback.setMonitor(this, monitor);
    }
    synchronized (this) {
      calculateTime(monitor);

      addException(monitor);

      removeMonitor(monitor.getMonitoId());
    }
    // process list of all death monitors
    processQueue();
  }

  /**
   * @param monitor
   */
  private void removeMonitor(final String monitorId) {
    hmMonitors.remove(monitorId);
  }

  /**
   * @param monitor
   */
  private void addException(final Monitor monitor) {
    if (monitor.hasException()) {
      exceptionCount++;
      String exceptionText = monitor.getException();
      if ((null != exceptionText) && (!exceptionText.equals(""))) {
        exceptionList.add(monitor.getException());
      }
    }
  }

  /**
   * @param monitor
   * @param accrued
   */
  private void calculateTime(final Monitor monitor) {
    long accrued = monitor.getAccrued();
    active--;
    accessCount++;
    totalMSec += accrued;
    averageMSec = totalMSec / accessCount;
    if (accrued > maxMSec) {
      maxMSec = accrued;
    }
    if ((accrued < minMSec) || (minMSec == 0)) {
      minMSec = accrued;
    }
    if (bCalculationDeviation) {
      squareSumm += Math.pow(accrued, 2);
    }
  }

  /** Processing the softreference queue. */
  private void processQueue() {
    synchronized (this) {
      Reference r;
      while ((r = referenceQueue.poll()) != null) {
        SoftEntry e = (SoftEntry) r;
        if (hmMonitors.containsKey(e.key)) {
          // if this key is in our monitor list, the monitor was not
          // stopped with stop().
          active--;
          deathMonitors++;
          removeMonitor((String) e.key);
        }
      }
    }
  }

  /**
   * @return Returns the userData.
   */
  public final IUserData getUserData() {
    return userData;
  }

  /**
   * @param aUserData
   *            The userData to set.
   */
  public final void setUserData(final IUserData aUserData) {
    this.userData = aUserData;
  }

  /**
   * Getting the data values of this measure point. 
* The following data value are present: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
nametype of valuedescription
pointNameStringfull qualified name of this point
priorityIntegerpriority of this point
accessCountLonghow often is this point accessed
averageMSecLongaverage time of all accesses
totalMSecLongtotal time of all measurements
minMSecLongminimal time of all measurements
maxMSecLongmaxmimal time of all measurements
activeLongnumber of actual active monitors
maxActiveLongmaxmimal time of all measurements
deathCountLongcounting of all death monitors
lastActivationDatelast activation of the measure point
deviationFloatstandard deviation of all measurements (if activate)
exceptionCountLongcount of exceptions, only set in use with proxies
exceptionListString[]list of all exceptions
userDataObjectuser data storage of this point
* * @see de.mcs.jmeasurement.MeasurePoint#getData() * @return Array of MeasureData objects */ public final MeasureData[] getData() { // process list of all death monitors processQueue(); ArrayList datas = new ArrayList(DEFAULT_ARRAY_SIZE); synchronized (this) { MeasureData data; data = new MeasureData(DATA_KEY_POINT_NAME, String.class, pointName, null, "full qualified name of this point"); datas.add(data); data = new MeasureData(DATA_KEY_PRIORITY, String.class, priority.name(), priority.name(), "priority of this point"); datas.add(data); data = new MeasureData(DATA_KEY_ACCESS_COUNT, Long.class, Long.valueOf(accessCount), Long.toString(accessCount), "how often is this point accessed"); datas.add(data); data = new MeasureData(DATA_KEY_AVERAGE_MSEC, Long.class, Long.valueOf(averageMSec), Long.toString(averageMSec), "average time of all accesses"); datas.add(data); data = new MeasureData(DATA_KEY_TOTAL_MSEC, Long.class, Long.valueOf(totalMSec), Long.toString(totalMSec), "total time of all measurements"); datas.add(data); data = new MeasureData(DATA_KEY_MIN_MSEC, Long.class, Long.valueOf(minMSec), Long.toString(minMSec), "minimal time of all measurements"); datas.add(data); data = new MeasureData(DATA_KEY_MAX_MSEC, Long.class, Long.valueOf(maxMSec), Long.toString(maxMSec), "maxmimal time of all measurements"); datas.add(data); data = new MeasureData(DATA_KEY_ACTIVE, Long.class, Long.valueOf(active), Long.toString(active), "number of actual active monitors"); datas.add(data); data = new MeasureData(DATA_KEY_MAX_ACTIVE, Long.class, Long.valueOf(maxActive), Long.toString(maxActive), "maxmimal time of all measurements"); datas.add(data); data = new MeasureData(DATA_KEY_DEATH_COUNT, Long.class, Long.valueOf(deathMonitors), Long.toString(deathMonitors), "counting of all death monitors"); datas.add(data); Date activation = new Date(0L); if (lastActivation != null) { activation = lastActivation; } data = new MeasureData(DATA_KEY_LAST_ACTIVATION, Date.class, activation, "no call has been executed.", "last activation of the measure point"); if (null != lastActivation) { try { data.setAsString(SIMPLE_DATE_FORMAT.format(lastActivation)); } catch (Exception e) { // nothing to do here } } datas.add(data); Float mydeviation = getDeviation(); data = new MeasureData(DATA_KEY_DEVIATION, Float.class, mydeviation, mydeviation.toString(), "standard deviation of all measurements."); datas.add(data); data = new MeasureData(DATA_KEY_SQUARESUM, Double.class, new Double(squareSumm), Double.toString(squareSumm), "square sum of all measurements."); datas.add(data); data = new MeasureData(DATA_KEY_EXCEPTION_COUNT, Long.class, Long.valueOf(exceptionCount), Long.toString(exceptionCount), "counting of all exceptions, thrown in a proxy."); datas.add(data); String[] exceptions = (String[]) exceptionList.toArray(new String[0]); data = new MeasureData(DATA_KEY_EXCEPTION_LIST, String[].class, exceptions, StringUtils.arrayToCSVString(exceptions, ',', '"'), "all exceptions as plaint text, stacktrace is desired."); datas.add(data); data = new MeasureData(DATA_KEY_USER_DATA, String.class, userData, "", "user data storage of this point"); if (null != userData) { data.setAsString(userData.toString()); } datas.add(data); } return (MeasureData[]) datas.toArray(new MeasureData[0]); } /** * @return Float standard deviation of the measurement. * * @since 0.65 */ private Float getDeviation() { if (bCalculationDeviation) { if (accessCount < 2) { return new Float(0.0); } else { if (squareSumm == 0) { return new Float(deviation); } double dev = Math .sqrt(((accessCount * squareSumm) - Math.pow(totalMSec, 2)) / (accessCount * (accessCount - 1))); deviation = (float) dev; return new Float(dev); } } else { return new Float(0.0); } } /** * Return the useradata as mime coded serilised object. Be aware of the * de/serilasation problems. * * @param data * the dataobject * @return String mimecoded userData as String * @throws IOException * serialisation of the user data could throw an exception. */ private String getUserDataAsString(final MeasureData data) throws IOException { String output = "null"; if (null != userData) { if (userData instanceof Serializable) { ByteArrayOutputStream bos = new ByteArrayOutputStream(BUFFER_SIZE); ObjectOutputStream oos; oos = new ObjectOutputStream(bos); oos.writeObject("class=" + userData.getClass()); oos.writeObject(userData); oos.close(); // output = Base64Encoder.encode(bos.toByteArray()); output = Base64.encodeBytes(bos.toByteArray()); bos.close(); } } return output; } /** * @see de.mcs.jmeasurement.MeasurePoint#setData(de.mcs.jmeasurement.MeasureData[]) * @param datas * the MeasureData list to add */ public final void setData(final MeasureData[] datas) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); synchronized (this) { for (int i = 0; i < datas.length; i++) { MeasureData data = datas[i]; if (data.getName().equals(DATA_KEY_POINT_NAME)) { pointName = data.getAsString(); } else if (data.getName().equals(DATA_KEY_PRIORITY)) { priority = PRIORITY.valueOf(data.getAsString()); } else if (data.getName().equals(DATA_KEY_ACCESS_COUNT)) { accessCount = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_AVERAGE_MSEC)) { averageMSec = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_TOTAL_MSEC)) { totalMSec = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_MIN_MSEC)) { minMSec = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_MAX_MSEC)) { maxMSec = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_ACTIVE)) { active = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_DEATH_COUNT)) { deathMonitors = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_MAX_ACTIVE)) { maxActive = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_LAST_ACTIVATION)) { try { lastActivation = simpleDateFormat.parse(data.getAsString()); } catch (Exception e) { // nothing to do here lastActivation = null; } } else if (data.getName().equals(DATA_KEY_EXCEPTION_COUNT)) { exceptionCount = Long.parseLong(data.getAsString()); } else if (data.getName().equals(DATA_KEY_SQUARESUM)) { squareSumm = Double.parseDouble(data.getAsString()); } else if (data.getName().equals(DATA_KEY_DEVIATION)) { String dataStr = data.getAsString(); if (dataStr.equalsIgnoreCase("nan")) { deviation = new Float(0.0); } else { deviation = Float.parseFloat(dataStr); } } else if (data.getName().equals(DATA_KEY_EXCEPTION_LIST)) { String[] exceptions = StringUtils.csvStringToArray(data.getAsString(), ',', '"'); for (int j = 0; j < exceptions.length; j++) { exceptionList.add(exceptions[j]); } } else if (data.getName().equals(DATA_KEY_USER_DATA)) { userData = getUserDataObject(data.getAsString()); } } } } /** * This methode will deserilise the user data object from the string. * * @param string * base64 coded user data object * @return Object */ private IUserData getUserDataObject(final String string) { IUserData myUserData = null; try { if (null != string) { if (!string.equals("null")) { ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(string)); // ByteArrayInputStream bis = new ByteArrayInputStream( // Base64Decoder.decode(string)); ObjectInputStream ois; ois = new ObjectInputStream(bis); ois.readObject(); Object objUserData = ois.readObject(); myUserData = (IUserData) objUserData; ois.close(); bis.close(); } } } catch (Exception e) { e.printStackTrace(); } return myUserData; } /** * Converting all parameters of this measurepoint into an xml structure. * * @param writer * the writer to use for XML writing * @throws SAXException * if something goes wrong in xml writing * @throws IOException * serialisation of the user data could throw an exception. */ public final void toXML(final DataWriter writer) throws SAXException, IOException { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "name", "", "String", pointName); atts.addAttribute("", "class", "", "String", DefaultMeasurePoint.class.getName()); writer.startElement("", "measurepoint", "", atts); MeasureData[] datas = getData(); for (int i = 0; i < datas.length; i++) { MeasureData data = datas[i]; if (data.getName().equals(DATA_KEY_USER_DATA)) { writer.dataElement(data.getName(), getUserDataAsString(data)); } else { writer.dataElement(data.getName(), data.getAsString()); } } writer.endElement("", "measurepoint", ""); } /** * This methode will return the call back object set with * setMeasureDataCallback(). This callback will be activate, * when monitor datas will be added to the measurement point. * * @return Returns the measureDataCallback. */ public final MeasureDataCallback getMeasureDataCallback() { return measureDataCallback; } /** * With this methode a call back object will be set. This callback will be * activate, when monitor datas will be added to the measurement point. * * @param aMeasureDataCallback * The measureDataCallback to set. */ public final void setMeasureDataCallback(final MeasureDataCallback aMeasureDataCallback) { measureDataCallback = aMeasureDataCallback; } /** * @see de.mcs.jmeasurement.MeasurePoint#getData(java.lang.String) * @param name * name of the data to get * @return MeasureData */ public final MeasureData getData(final String name) { MeasureData[] datas = getData(); for (int i = 0; i < datas.length; i++) { MeasureData data2 = datas[i]; if (data2.getName().equals(name)) { return data2; } } return null; } /** * @see de.mcs.jmeasurement.MeasurePoint#getData(java.lang.String) * @param name * name of the data to get * @return MeasureData */ public final Class getDataClass(final String name) { MeasureData[] datas = getData(); for (int i = 0; i < datas.length; i++) { MeasureData data2 = datas[i]; if (data2.getName().equals(name)) { return data2.getValueClass(); } } return String.class; } /** * Getting the measurement data as simple string. * * @return String with a key=value list of all measurement data */ public final String asString() { StringBuffer string = new StringBuffer(BUFFER_SIZE); MeasureData[] datas = getData(); MeasureData data = null; for (int i = 0; i < datas.length; i++) { data = datas[i]; string.append(data.getName()).append("=").append(data.getAsString()).append("\n"); } return string.toString(); } /** * This methode will be called from the DefaultMonitor if the monitor will * be finalized before stopped. Or is you explicit call this methode for a * monitor. The active counting will be reduced and the death counting will * be increased. * * @param monitor * the monitor which is death. * @see de.mcs.jmeasurement.MeasurePoint#deathMonitor(de.mcs.jmeasurement.Monitor) */ public final void deathMonitor(final Monitor monitor) { synchronized (this) { if (hmMonitors.containsKey(monitor.getMonitoId())) { active--; deathMonitors++; removeMonitor(monitor.getMonitoId()); } } } /** * cloning this Measure point. * * @return Object */ public final Object clone() { DefaultMeasurePoint newPoint = new DefaultMeasurePoint(this.pointName, this.priority, this.config); newPoint.accessCount = this.accessCount; newPoint.active = this.active; newPoint.averageMSec = this.averageMSec; newPoint.deathMonitors = this.deathMonitors; newPoint.lastActivation = this.lastActivation; newPoint.maxActive = this.maxActive; newPoint.maxMSec = this.maxMSec; newPoint.minMSec = this.minMSec; newPoint.totalMSec = this.totalMSec; newPoint.exceptionCount = this.exceptionCount; newPoint.exceptionList.addAll(this.exceptionList); if (this.userData != null) { newPoint.userData = (IUserData) this.userData.clone(); } return newPoint; } /** * getting all data as a hashmap with sting as keys and values. * * @return HashMap */ public final Map getMap() { HashMap map = new HashMap(); map.put("name", getName()); MeasureData[] datas = getData(); for (int i = 0; i < datas.length; i++) { MeasureData data = datas[i]; map.put(data.getName(), data.getAsString()); } return map; } /** * @return increasing the counter and get back the actual value. * @see de.mcs.jmeasurement.MeasurePoint#increaseCount() */ public final long increaseCount() { synchronized (this) { lastActivation = new Date(); accessCount++; return accessCount; } } /** * reading with the default methode all non transient fields and initialise * my rtansient fields. * * @param ois * the stream to read from. * @throws IOException * if something goesw rong. */ private void readObject(final ObjectInputStream ois) throws IOException { try { ois.defaultReadObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } referenceQueue = new ReferenceQueue(); } /** * reading and processing the options. */ private void processOptions() { bCalculationDeviation = !config.getBoolean(JMConfig.OPTION_DISABLE_DEVIATION); } /** * @return true if this measurepoint has actually active * monitors, otherwise false */ public final boolean hasActiveMonitors() { return !hmMonitors.isEmpty(); } /** * for deserialsation we must offer a methode to set the config to the right * one. * * @param aConfig * the config to be used. */ public final void setConfig(final JMConfig aConfig) { this.config = aConfig; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy