de.mcs.jmeasurement.jmx.JmxPoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JMeasurement Show documentation
Show all versions of JMeasurement Show documentation
JMeasurement profiling programs in production enviroment
/*
* MCS Media Computer Software Copyright (c) 2007 by MCS
* -------------------------------------- Created on 11.01.2007 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.jmx;
import java.util.Date;
import de.mcs.jmeasurement.DefaultMeasurePoint;
import de.mcs.jmeasurement.MeasureFactory;
import de.mcs.jmeasurement.MeasurePoint;
/**
* Proxy class for accessing the real measure point data. Because of the
* autosaving feature we needed to determine the real measure point instance for
* every data access. So we only save the point name in this class and get the
* point by using MeasureFactory.getMeasurePoint(pointName)
method.
*
* @author W.Klaas
*
*/
public class JmxPoint {
/** name of the point to use. */
private String pointName;
/**
* Constructor of this proxy class. Only the name will be delivered.
*
* @param name
* name of the point to use.
*/
public JmxPoint(final String name) {
this.pointName = name;
}
/**
* getting the name of the point.
*
* @return name
*/
public final String getName() {
return pointName;
}
/**
* dynamic access to the measure point.
*
* @return MeasurePoint.
*/
private MeasurePoint getPoint() {
return MeasureFactory.getMeasurePoint(pointName);
}
/**
* @return the avverafe msec of all monitors of this measure point.
*/
public final long getAverageMSec() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_AVERAGE_MSEC).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the minimum msec of a monitor of this measure point.
*/
public final long getMinMSec() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_MIN_MSEC).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the maximum msec of a monitor of this measure point.
*/
public final long getMaxMSec() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_MAX_MSEC).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the count of exception of this measure point.
*/
public final String getExceptionList() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_EXCEPTION_LIST).getAsString();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* @return the count of exception of this measure point.
*/
public final long getExceptionCount() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_EXCEPTION_COUNT).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the last activation of this measure point.
*/
public final Date getLastActivation() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_LAST_ACTIVATION).getAsDate();
} catch (Exception e) {
e.printStackTrace();
}
return new Date(0);
}
/**
* @return the count of death monitors of this measure point.
*/
public final long getDeathCount() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_DEATH_COUNT).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the maximum active monitors of this measure point.
*/
public final long getMaxActive() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_MAX_ACTIVE).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the active monitors of this measure point.
*/
public final long getActive() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_ACTIVE).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* @return the total milli seconds of this measure point.
*/
public final long getTotalMSec() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_TOTAL_MSEC).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
/**
* @return the deviation of this measure point.
*/
public final Float getDeviation() {
try {
return (Float) getPoint().getData(DefaultMeasurePoint.DATA_KEY_DEVIATION).getValue();
} catch (Exception e) {
e.printStackTrace();
}
return new Float(0.0);
}
/**
* @return the access count of this measure point.
*/
public final long getAccessCount() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_ACCESS_COUNT).getAsLong();
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
/**
* @return the priority of this measure point.
*/
public final String getPriority() {
try {
return getPoint().getData(DefaultMeasurePoint.DATA_KEY_PRIORITY).getAsString();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}