Former-commit-id: 79a19214015b2d284c63773746a46707891335b8
This commit is contained in:
Daniel Collin 2016-02-02 14:33:02 +01:00
parent ea5c991824
commit 84fba20500
2 changed files with 4 additions and 4 deletions

View file

@ -94,7 +94,7 @@ public class PCDataSynchronizationClient implements HalDaemon {
out.writeObject(req); out.writeObject(req);
SensorDataListDTO dataList = (SensorDataListDTO) in.readObject(); SensorDataListDTO dataList = (SensorDataListDTO) in.readObject();
if(dataList.aggregationVersion != -1 && dataList.aggregationVersion != sensor.getAggregationVersion()){ if(dataList.aggregationVersion != 0 && dataList.aggregationVersion != sensor.getAggregationVersion()){
logger.fine("The peer has modified its aggregated data in such a way that we need to reset the sync and start over on this side. oldAggregationVersion:"+sensor.getAggregationVersion()+" , newAggregationVersion:"+dataList.aggregationVersion); logger.fine("The peer has modified its aggregated data in such a way that we need to reset the sync and start over on this side. oldAggregationVersion:"+sensor.getAggregationVersion()+" , newAggregationVersion:"+dataList.aggregationVersion);
//clear old aggregated data for sensor //clear old aggregated data for sensor
@ -151,6 +151,6 @@ public class PCDataSynchronizationClient implements HalDaemon {
public long sensorId; public long sensorId;
public long offsetSequenceId; // highest known sequence id public long offsetSequenceId; // highest known sequence id
public long aggregationVersion = -1; public long aggregationVersion = 0;
} }
} }

View file

@ -102,7 +102,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem
PreparedStatement stmt = db.getPreparedStatement("SELECT * FROM sensor_data_aggr WHERE sensor_id == ? AND sequence_id > ?"); PreparedStatement stmt = db.getPreparedStatement("SELECT * FROM sensor_data_aggr WHERE sensor_id == ? AND sequence_id > ?");
stmt.setLong(1, sensor.getId()); stmt.setLong(1, sensor.getId());
logger.fine("Client requesting sensor data: sensorId: " + req.sensorId + ", offset: " + req.offsetSequenceId + ", " + req.aggregationVersion); logger.fine("Client requesting sensor data: sensorId: " + req.sensorId + ", offset: " + req.offsetSequenceId + ", " + req.aggregationVersion);
if(req.aggregationVersion != -1 && req.aggregationVersion != sensor.getAggregationVersion()){ if(req.aggregationVersion != 0 && req.aggregationVersion != sensor.getAggregationVersion()){
logger.fine("The requested aggregation version does not match the local version: " + sensor.getAggregationVersion() + ". Will re-send all aggregated data."); logger.fine("The requested aggregation version does not match the local version: " + sensor.getAggregationVersion() + ". Will re-send all aggregated data.");
stmt.setLong(2, 0); //0 since we want to re-send all data to the peer stmt.setLong(2, 0); //0 since we want to re-send all data to the peer
}else{ }else{
@ -165,7 +165,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem
protected static class SensorDataListDTO extends ArrayList<SensorDataDTO> implements Serializable{ protected static class SensorDataListDTO extends ArrayList<SensorDataDTO> implements Serializable{
private static final long serialVersionUID = -5701618637734020691L; private static final long serialVersionUID = -5701618637734020691L;
public long aggregationVersion = -1; public long aggregationVersion = 0;
} }
protected static class SensorDataDTO implements Serializable{ protected static class SensorDataDTO implements Serializable{
private static final long serialVersionUID = 8494331502087736809L; private static final long serialVersionUID = 8494331502087736809L;