From 84fba205005795333358437692e2f21e7f4735c9 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Tue, 2 Feb 2016 14:33:02 +0100 Subject: [PATCH] Bug fix. Former-commit-id: 79a19214015b2d284c63773746a46707891335b8 --- src/se/hal/deamon/PCDataSynchronizationClient.java | 4 ++-- src/se/hal/deamon/PCDataSynchronizationDaemon.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/se/hal/deamon/PCDataSynchronizationClient.java b/src/se/hal/deamon/PCDataSynchronizationClient.java index 9dadd17c..8ada2ed3 100755 --- a/src/se/hal/deamon/PCDataSynchronizationClient.java +++ b/src/se/hal/deamon/PCDataSynchronizationClient.java @@ -94,7 +94,7 @@ public class PCDataSynchronizationClient implements HalDaemon { out.writeObject(req); 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); //clear old aggregated data for sensor @@ -151,6 +151,6 @@ public class PCDataSynchronizationClient implements HalDaemon { public long sensorId; public long offsetSequenceId; // highest known sequence id - public long aggregationVersion = -1; + public long aggregationVersion = 0; } } diff --git a/src/se/hal/deamon/PCDataSynchronizationDaemon.java b/src/se/hal/deamon/PCDataSynchronizationDaemon.java index d37132ea..1a7b38a5 100755 --- a/src/se/hal/deamon/PCDataSynchronizationDaemon.java +++ b/src/se/hal/deamon/PCDataSynchronizationDaemon.java @@ -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 > ?"); stmt.setLong(1, sensor.getId()); 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."); stmt.setLong(2, 0); //0 since we want to re-send all data to the peer }else{ @@ -165,7 +165,7 @@ public class PCDataSynchronizationDaemon extends ThreadedTCPNetworkServer implem protected static class SensorDataListDTO extends ArrayList implements Serializable{ private static final long serialVersionUID = -5701618637734020691L; - public long aggregationVersion = -1; + public long aggregationVersion = 0; } protected static class SensorDataDTO implements Serializable{ private static final long serialVersionUID = 8494331502087736809L;