bug fix
Former-commit-id: cc32837aa622271c375ce50add3fb43136c32fc1
This commit is contained in:
parent
5036ec90e9
commit
d635888742
3 changed files with 15 additions and 13 deletions
|
|
@ -2,7 +2,7 @@ package se.koc.hal;
|
|||
|
||||
|
||||
import se.koc.hal.deamon.DataAggregatorDaemon;
|
||||
import se.koc.hal.deamon.DataDeletionDaemon;
|
||||
import se.koc.hal.deamon.DataCleanupDaemon;
|
||||
import se.koc.hal.deamon.DataSynchronizationClient;
|
||||
import se.koc.hal.deamon.DataSynchronizationDaemon;
|
||||
import se.koc.hal.intf.HalDaemon;
|
||||
|
|
@ -45,7 +45,7 @@ public class PowerChallenge {
|
|||
new DataAggregatorDaemon(),
|
||||
new DataSynchronizationDaemon(),
|
||||
new DataSynchronizationClient(),
|
||||
new DataDeletionDaemon()
|
||||
new DataCleanupDaemon()
|
||||
};
|
||||
Timer daemonTimer = new Timer();
|
||||
for(HalDaemon daemon : daemons){
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import se.koc.hal.HalContext;
|
|||
import se.koc.hal.intf.HalDaemon;
|
||||
import se.koc.hal.struct.HalSensor;
|
||||
import se.koc.hal.struct.HalSensor.AggregationMethod;
|
||||
import se.koc.hal.struct.PowerConsumptionSensor;
|
||||
import se.koc.hal.util.TimeUtility;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.SQLResultHandler;
|
||||
|
|
@ -42,17 +43,17 @@ public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
|||
}
|
||||
|
||||
public void aggregateSensor(HalSensor sensor) {
|
||||
logger.fine("The sensor is of type: " + sensor.getType());
|
||||
if(sensor.getType().equals("PowerMeter")){
|
||||
//if(sensor instanceof PowerConsumptionSensor){
|
||||
logger.fine("The sensor is of type: " + PowerConsumptionSensor.class.getSimpleName());
|
||||
logger.fine("aggregating raw data to five minute periods");
|
||||
aggregateRawData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, 5);
|
||||
logger.fine("aggregating five minute periods into hour periods");
|
||||
aggrigateAggregatedData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.HOUR_IN_MS);
|
||||
logger.fine("aggregating one hour periods into one day periods");
|
||||
aggrigateAggregatedData(sensor, TimeUtility.HOUR_IN_MS, TimeUtility.DAY_IN_MS);
|
||||
}else{
|
||||
logger.fine("The sensor type is not supported by the aggregation daemon. Ignoring");
|
||||
}
|
||||
//}else{
|
||||
// logger.fine("The sensor type is not supported by the aggregation daemon. Ignoring");
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ import java.util.logging.Logger;
|
|||
import se.koc.hal.HalContext;
|
||||
import se.koc.hal.intf.HalDaemon;
|
||||
import se.koc.hal.struct.HalSensor;
|
||||
import se.koc.hal.struct.PowerConsumptionSensor;
|
||||
import se.koc.hal.util.TimeUtility;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.SQLResultHandler;
|
||||
import zutil.db.handler.SimpleSQLResult;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
public class DataDeletionDaemon extends TimerTask implements HalDaemon {
|
||||
public class DataCleanupDaemon extends TimerTask implements HalDaemon {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
public void initiate(Timer timer){
|
||||
|
|
@ -41,8 +42,8 @@ public class DataDeletionDaemon extends TimerTask implements HalDaemon {
|
|||
}
|
||||
|
||||
public void cleanupSensor(HalSensor sensor) {
|
||||
logger.fine("The sensor is of type: " + sensor.getType());
|
||||
if(sensor.getType().equals("PowerMeter")){ //TODO: use instanceof instead
|
||||
//if(sensor instanceof PowerConsumptionSensor){
|
||||
logger.fine("The sensor is of type: " + PowerConsumptionSensor.class.getSimpleName());
|
||||
if(sensor.getUser().isExternal()){
|
||||
cleanupExternalSensorData(sensor.getId(), TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS);
|
||||
cleanupExternalSensorData(sensor.getId(), TimeUtility.DAY_IN_MS, TimeUtility.WEEK_IN_MS);
|
||||
|
|
@ -50,9 +51,9 @@ public class DataDeletionDaemon extends TimerTask implements HalDaemon {
|
|||
cleanupInternalSensorData(sensor.getId(), TimeUtility.HOUR_IN_MS, TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS);
|
||||
cleanupInternalSensorData(sensor.getId(), TimeUtility.DAY_IN_MS, TimeUtility.HOUR_IN_MS, TimeUtility.WEEK_IN_MS);
|
||||
}
|
||||
}else{
|
||||
logger.fine("The sensor type is not supported by the cleanup deamon. Ignoring");
|
||||
}
|
||||
//}else{
|
||||
// logger.fine("The sensor type is not supported by the cleanup deamon. Ignoring");
|
||||
//}
|
||||
}
|
||||
|
||||
/**
|
||||
Loading…
Add table
Add a link
Reference in a new issue