Bug fix + incremented the sync deamon protocol version

Former-commit-id: 00a8667aed6d844df3b4ab7e2e0df2530f1f38b5
This commit is contained in:
Daniel Collin 2016-02-02 15:43:17 +01:00
parent 84fba20500
commit d36370b212
2 changed files with 3 additions and 3 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 != 0 && dataList.aggregationVersion != sensor.getAggregationVersion()){ if(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

View file

@ -28,7 +28,7 @@ import java.util.logging.Logger;
public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implements HalDaemon { public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implements HalDaemon {
private static final Logger logger = LogUtil.getLogger(); private static final Logger logger = LogUtil.getLogger();
public static final int PROTOCOL_VERSION = 3; public static final int PROTOCOL_VERSION = 4;
public PCDataSynchronizationDaemon() { public PCDataSynchronizationDaemon() {
@ -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 != 0 && req.aggregationVersion != sensor.getAggregationVersion()){ if(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{