diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogLevelCountIndicator.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogLevelCountIndicator.java index 9120d22a..ce89c669 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogLevelCountIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogLevelCountIndicator.java @@ -74,8 +74,10 @@ public abstract class AbstractLogLevelCountIndicator extends AbstractLogIndicato .execute(); // update active indicator value record on persistent when caching is not enabled - if (!this.cachingEnabled && this.active && this.ditributedIndicatorValueRecordId != null) { - this.distributedPingCache.updateIndicatorValue(this.connectionId, numberOfLogs.longValue()); + if (this.active && this.ditributedIndicatorValueRecordId != null) { + this.distributedPingCache.updateIndicatorValue( + this.ditributedIndicatorValueRecordId, + numberOfLogs.longValue()); } return numberOfLogs.doubleValue(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogNumberIndicator.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogNumberIndicator.java index a12f48f7..af05e7e5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogNumberIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/AbstractLogNumberIndicator.java @@ -99,8 +99,10 @@ public abstract class AbstractLogNumberIndicator extends AbstractLogIndicator { if (numericValue != null) { // update active indicator value record on persistent when caching is not enabled - if (!this.cachingEnabled && this.active && this.ditributedIndicatorValueRecordId != null) { - this.distributedPingCache.updateIndicatorValue(this.connectionId, numericValue.longValue()); + if (this.active && this.ditributedIndicatorValueRecordId != null) { + this.distributedPingCache.updateIndicatorValue( + this.ditributedIndicatorValueRecordId, + numericValue.longValue()); } return numericValue.doubleValue(); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/DistributedIndicatorValueService.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/DistributedIndicatorValueService.java index 428b3e65..a7379e01 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/DistributedIndicatorValueService.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/DistributedIndicatorValueService.java @@ -361,7 +361,7 @@ public class DistributedIndicatorValueService implements DisposableBean { pingRecord, Utils.getMillisecondsNow())); } catch (final Exception e) { - if (log.isDebugEnabled()) { + if (log.isTraceEnabled()) { log.warn("Failed to schedule ping task: {}" + e.getMessage()); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java index d79c9dae..ba933dd9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/indicator/PingIntervalClientIndicator.java @@ -81,12 +81,19 @@ public final class PingIntervalClientIndicator extends AbstractPingIndicator { if (!this.initialized) { return Double.NaN; } - final long currentTimeMillis = DateTimeUtils.currentTimeMillis(); + if (this.initialized && !this.cachingEnabled && this.active && this.lastUpdate != this.distributedPingCache.lastUpdate()) { + + final long currentTimeMillis = DateTimeUtils.currentTimeMillis(); this.currentValue = computeValueAt(currentTimeMillis); + return (currentTimeMillis < this.currentValue) + ? DateTimeUtils.currentTimeMillis() - this.currentValue + : currentTimeMillis - this.currentValue; + + } else { + return DateTimeUtils.currentTimeMillis() - this.currentValue; } - return currentTimeMillis - this.currentValue; } @Override @@ -101,17 +108,14 @@ public final class PingIntervalClientIndicator extends AbstractPingIndicator { @Override public final double computeValueAt(final long timestamp) { - if (!this.cachingEnabled && super.ditributedIndicatorValueRecordId != null) { + if (super.ditributedIndicatorValueRecordId != null) { final Long lastPing = this.distributedPingCache .getIndicatorValue(super.ditributedIndicatorValueRecordId); - if (lastPing != null) { - final double doubleValue = lastPing.doubleValue(); - return Math.max(Double.isNaN(this.currentValue) ? doubleValue : this.currentValue, doubleValue); - } - - return this.currentValue; + return (lastPing != null) + ? lastPing.doubleValue() + : this.currentValue; } return !this.initialized ? timestamp : this.currentValue;