Skip to content
Snippets Groups Projects
Commit 27bb9128 authored by Vincent Hardion's avatar Vincent Hardion
Browse files

* Version 2.0

parent 1eba4378
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
<parent>
<groupId>fr.soleil</groupId>
<artifactId>super-pom</artifactId>
<version>1.0</version>
<version>1.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>fr.soleil.deviceservers</groupId>
......@@ -44,7 +44,7 @@
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>dtu</artifactId>
<version>0.4.5</version>
<version>[0.4.5,)</version>
</dependency>
<dependency>
<groupId>org.nfunk</groupId>
......
/*
* TangoParserStats.java
*
* Created on 11 fvrier 2008, 15:24
*/
package fr.soleil.management;
import javax.management.*;
/**
* Class TangoParserStats
*
* @author HARDION
*/
public class TangoParserStats implements TangoParserStatsMBean, NotificationEmitter {
private NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
private long seqNumber;
/**
* Attribute : MeanResponseTime
*/
private double meanResponseTime;
/**
* Attribute : MinResponseTime
*/
private double minResponseTime;
/**
* Attribute : MaxResponseTime
*/
private double maxResponseTime;
/**
* Attribute : LastResponseTime
*/
private double lastResponseTime;
/**
* Attribute : numberOfReading
*/
private long numberOfReading;
public TangoParserStats(){
}
/**
* Get Response time of the last read_attributes
*/
public double getLastResponseTime() {
return lastResponseTime;
}
/**
* Get Mean response of read attributes
*/
public double getMeanResponseTime() {
double result = 0.0D;
if(numberOfReading!=0){
result = meanResponseTime/numberOfReading;
}
return result;
}
/**
* Get Min response of read attributes
*/
public double getMinResponseTime() {
return minResponseTime;
}
/**
* Get Max response of read attributes
*/
public double getMaxResponseTime() {
return maxResponseTime;
}
/**
* Reset Statistic
*/
public void resetAll() {
meanResponseTime=0;
minResponseTime=0;
maxResponseTime=0;
lastResponseTime=0;
numberOfReading=0;
}
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
broadcaster.addNotificationListener(listener, filter, handback);
}
public MBeanNotificationInfo[] getNotificationInfo() {
return new MBeanNotificationInfo[]{new MBeanNotificationInfo(new String[]{AttributeChangeNotification.ATTRIBUTE_CHANGE}, javax.management.AttributeChangeNotification.class.getName(), "Attributes has been reading")};
}
public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener);
}
public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
broadcaster.removeNotificationListener(listener, filter, handback);
}
public synchronized long getNextSeqNumber() {
return seqNumber++;
}
/*
* Methods exposed to Anagrams application to feed management with data.
*/
//Stores the time at which a new anagram is proposed to the user.
private long startTime;
/**
* A new Anagram is proposed to the user: store current time.
*/
public void startReading() {
startTime = System.currentTimeMillis();
System.out.println("StartReading");
}
/**
* An Anagram has been resolved.
*/
public void stopReading() {
System.out.println("StopReading");
//Update the number of resolved anagrams
numberOfReading++;
// Compute last, min and max thinking times
lastResponseTime = ((double)(System.currentTimeMillis() - startTime))/1000.0 ;
minResponseTime = (lastResponseTime < minResponseTime || minResponseTime == 0) ?
lastResponseTime :
minResponseTime;
maxResponseTime = (lastResponseTime > maxResponseTime) ?
lastResponseTime :
maxResponseTime;
meanResponseTime += lastResponseTime;
//Create a JMX Notification
Notification notification = new Notification(AttributeChangeNotification.ATTRIBUTE_CHANGE,
this,
getNextSeqNumber(),
"" +
"" +
"Attributes read: " + numberOfReading);
// Send a JMX notification.
broadcaster.sendNotification(notification);
}
}
/*
* TangoParserStatsMBean.java
*
* Created on 11 fvrier 2008, 15:24
*/
package fr.soleil.management;
/**
* Interface TangoParserStatsMBean
*
* @author HARDION
*/
public interface TangoParserStatsMBean
{
/**
* Get Response time of the last read_attributes
*/
public double getLastResponseTime();
/**
* Get Mean response of read attributes
*/
public double getMeanResponseTime();
/**
* Get Min response of read attributes
*/
public double getMinResponseTime();
/**
* Get Max response of read attributes
*/
public double getMaxResponseTime();
/**
* Reset Statistic
*/
public void resetAll();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment