More bugfixes

Former-commit-id: 4d29b4d813ee2e9dba063afeb081742e9537125a
This commit is contained in:
Ziver Koc 2016-01-14 20:25:50 +01:00
parent fa9223c653
commit 61c88ed4ca
6 changed files with 14 additions and 12 deletions

View file

@ -102,9 +102,9 @@ public class PCDataSynchronizationClient implements HalDaemon {
in.close(); in.close();
s.close(); s.close();
} catch (NoRouteToHostException |UnknownHostException|ConnectException e) { } catch (NoRouteToHostException|UnknownHostException|ConnectException e) {
logger.warning("Unable to connect to "+ user.getHostname()+":"+user.getPort() +", "+ e.getMessage()); logger.warning("Unable to connect to "+ user.getHostname()+":"+user.getPort() +", "+ e.getMessage());
} catch (ClassNotFoundException|IOException e) { } catch (Exception e) {
logger.log(Level.SEVERE, null, e); logger.log(Level.SEVERE, null, e);
} }

View file

@ -129,7 +129,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem
in.close(); in.close();
s.close(); s.close();
} catch (ClassNotFoundException|IOException|SQLException e) { } catch (Exception e) {
logger.log(Level.SEVERE, null, e); logger.log(Level.SEVERE, null, e);
} }
logger.fine("User disconnected: "+ s.getInetAddress().getHostName()); logger.fine("User disconnected: "+ s.getInetAddress().getHostName());

View file

@ -43,8 +43,8 @@ public class SensorDataAggregatorDaemon implements HalDaemon {
} }
public void aggregateSensor(Sensor sensor) { public void aggregateSensor(Sensor sensor) {
//if(sensor instanceof PowerConsumptionSensor){ //if(sensor.getSensorData() instanceof PowerConsumptionSensor){
logger.fine("The sensor is of type: " + PowerConsumptionSensor.class.getSimpleName()); logger.fine("The sensor is of type: " + sensor.getSensorData().getClass().getName());
logger.fine("aggregating raw data to five minute periods"); logger.fine("aggregating raw data to five minute periods");
aggregateRawData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, 5); aggregateRawData(sensor, TimeUtility.FIVE_MINUTES_IN_MS, 5);
logger.fine("aggregating five minute periods into hour periods"); logger.fine("aggregating five minute periods into hour periods");
@ -52,7 +52,7 @@ public class SensorDataAggregatorDaemon implements HalDaemon {
logger.fine("aggregating one hour periods into one day periods"); logger.fine("aggregating one hour periods into one day periods");
aggrigateAggregatedData(sensor, TimeUtility.HOUR_IN_MS, TimeUtility.DAY_IN_MS); aggrigateAggregatedData(sensor, TimeUtility.HOUR_IN_MS, TimeUtility.DAY_IN_MS);
//}else{ //}else{
// logger.fine("The sensor type is not supported by the aggregation daemon. Ignoring"); // logger.fine("The sensor type("+ sensor.getSensorData().getClass().getName() +") is not supported by the aggregation daemon. Ignoring");
//} //}
} }

View file

@ -43,7 +43,7 @@ public class SensorDataCleanupDaemon implements HalDaemon {
public void cleanupSensor(Sensor sensor) { public void cleanupSensor(Sensor sensor) {
//if(sensor instanceof PowerConsumptionSensor){ //if(sensor instanceof PowerConsumptionSensor){
logger.fine("The sensor is of type: " + PowerConsumptionSensor.class.getSimpleName()); logger.fine("The sensor is of type: " + sensor.getSensorData().getClass().getName());
if(sensor.getUser().isExternal()){ if(sensor.getUser().isExternal()){
cleanupExternalSensorData(sensor.getId(), TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS); cleanupExternalSensorData(sensor.getId(), TimeUtility.FIVE_MINUTES_IN_MS, TimeUtility.DAY_IN_MS);
cleanupExternalSensorData(sensor.getId(), TimeUtility.DAY_IN_MS, TimeUtility.WEEK_IN_MS); cleanupExternalSensorData(sensor.getId(), TimeUtility.DAY_IN_MS, TimeUtility.WEEK_IN_MS);
@ -58,6 +58,7 @@ public class SensorDataCleanupDaemon implements HalDaemon {
/** /**
* Will clear periods only if it has been aggregated and are too old. * Will clear periods only if it has been aggregated and are too old.
*
* @param sensorId * @param sensorId
* @Param referencePeriodlength Will only clear periods older than the newest period of this length. * @Param referencePeriodlength Will only clear periods older than the newest period of this length.
* @Param clearPeriodlength Will clear periods with this length * @Param clearPeriodlength Will clear periods with this length
@ -94,6 +95,7 @@ public class SensorDataCleanupDaemon implements HalDaemon {
/** /**
* Will clear periods if they are too old. * Will clear periods if they are too old.
*
* @param sensorId * @param sensorId
* @Param clearPeriodlength Will clear periods with this length * @Param clearPeriodlength Will clear periods with this length
* @param olderThan Data must be older than this many ms to be cleared from the DB * @param olderThan Data must be older than this many ms to be cleared from the DB

View file

@ -56,7 +56,7 @@ public class Event extends DBBean{
updateConfig(); updateConfig();
} }
public HalEvent getEventData(){ public HalEvent getEventData(){
if(config !=null && eventData == null) { if(eventData == null) {
try { try {
Class c = Class.forName(type); Class c = Class.forName(type);
eventData = (HalEvent) c.newInstance(); eventData = (HalEvent) c.newInstance();
@ -92,7 +92,7 @@ public class Event extends DBBean{
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
if( ! this.type.equals(type)) { if( !this.type.equals(type)) {
this.type = type; this.type = type;
this.eventData = null; // invalidate current sensor data object this.eventData = null; // invalidate current sensor data object
} }
@ -101,7 +101,7 @@ public class Event extends DBBean{
return config; return config;
} }
public void setConfig(String config) { public void setConfig(String config) {
if( ! this.config.equals(config)) { if(this.config == null || !this.config.equals(config)) {
this.config = config; this.config = config;
this.eventData = null; // invalidate current sensor data object this.eventData = null; // invalidate current sensor data object
} }

View file

@ -124,7 +124,7 @@ public class Sensor extends DBBean{
return type; return type;
} }
public void setType(String type) { public void setType(String type) {
if( ! this.type.equals(type)) { if( !this.type.equals(type)) {
this.type = type; this.type = type;
this.sensorData = null; // invalidate current sensor data object this.sensorData = null; // invalidate current sensor data object
} }
@ -133,7 +133,7 @@ public class Sensor extends DBBean{
return config; return config;
} }
public void setConfig(String config) { public void setConfig(String config) {
if( ! this.config.equals(config)) { if(this.config == null || !this.config.equals(config)) {
this.config = config; this.config = config;
this.sensorData = null; // invalidate current sensor data object this.sensorData = null; // invalidate current sensor data object
} }