added defaultInactivityTimeoutMs param to device state svc
This commit is contained in:
parent
4ca140f306
commit
aefef78fda
@ -157,6 +157,9 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
|||||||
@Setter
|
@Setter
|
||||||
private long defaultInactivityTimeoutInSec;
|
private long defaultInactivityTimeoutInSec;
|
||||||
|
|
||||||
|
@Value("#{${state.defaultInactivityTimeoutInSec} * 1000}")
|
||||||
|
private long defaultInactivityTimeoutMs;
|
||||||
|
|
||||||
@Value("${state.defaultStateCheckIntervalInSec}")
|
@Value("${state.defaultStateCheckIntervalInSec}")
|
||||||
@Getter
|
@Getter
|
||||||
private int defaultStateCheckIntervalInSec;
|
private int defaultStateCheckIntervalInSec;
|
||||||
@ -544,7 +547,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
|||||||
|
|
||||||
private ListenableFuture<DeviceStateData> transformInactivityTimeout(ListenableFuture<DeviceStateData> future) {
|
private ListenableFuture<DeviceStateData> transformInactivityTimeout(ListenableFuture<DeviceStateData> future) {
|
||||||
return Futures.transformAsync(future, deviceStateData -> {
|
return Futures.transformAsync(future, deviceStateData -> {
|
||||||
if (!persistToTelemetry || deviceStateData.getState().getInactivityTimeout() != TimeUnit.SECONDS.toMillis(defaultInactivityTimeoutInSec)) {
|
if (!persistToTelemetry || deviceStateData.getState().getInactivityTimeout() != defaultInactivityTimeoutMs) {
|
||||||
return future; //fail fast
|
return future; //fail fast
|
||||||
}
|
}
|
||||||
var attributesFuture = attributesService.find(TenantId.SYS_TENANT_ID, deviceStateData.getDeviceId(), SERVER_SCOPE, INACTIVITY_TIMEOUT);
|
var attributesFuture = attributesService.find(TenantId.SYS_TENANT_ID, deviceStateData.getDeviceId(), SERVER_SCOPE, INACTIVITY_TIMEOUT);
|
||||||
@ -567,7 +570,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
|||||||
try {
|
try {
|
||||||
long lastActivityTime = getEntryValue(data, LAST_ACTIVITY_TIME, 0L);
|
long lastActivityTime = getEntryValue(data, LAST_ACTIVITY_TIME, 0L);
|
||||||
long inactivityAlarmTime = getEntryValue(data, INACTIVITY_ALARM_TIME, 0L);
|
long inactivityAlarmTime = getEntryValue(data, INACTIVITY_ALARM_TIME, 0L);
|
||||||
long inactivityTimeout = getEntryValue(data, INACTIVITY_TIMEOUT, TimeUnit.SECONDS.toMillis(defaultInactivityTimeoutInSec));
|
long inactivityTimeout = getEntryValue(data, INACTIVITY_TIMEOUT, defaultInactivityTimeoutMs);
|
||||||
//Actual active state by wall-clock will updated outside this method. This method is only for fetch persistent state
|
//Actual active state by wall-clock will updated outside this method. This method is only for fetch persistent state
|
||||||
final boolean active = getEntryValue(data, ACTIVITY_STATE, false);
|
final boolean active = getEntryValue(data, ACTIVITY_STATE, false);
|
||||||
DeviceState deviceState = DeviceState.builder()
|
DeviceState deviceState = DeviceState.builder()
|
||||||
@ -641,11 +644,11 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
|
|||||||
DeviceStateData toDeviceStateData(EntityData ed, DeviceIdInfo deviceIdInfo) {
|
DeviceStateData toDeviceStateData(EntityData ed, DeviceIdInfo deviceIdInfo) {
|
||||||
long lastActivityTime = getEntryValue(ed, getKeyType(), LAST_ACTIVITY_TIME, 0L);
|
long lastActivityTime = getEntryValue(ed, getKeyType(), LAST_ACTIVITY_TIME, 0L);
|
||||||
long inactivityAlarmTime = getEntryValue(ed, getKeyType(), INACTIVITY_ALARM_TIME, 0L);
|
long inactivityAlarmTime = getEntryValue(ed, getKeyType(), INACTIVITY_ALARM_TIME, 0L);
|
||||||
long inactivityTimeout = getEntryValue(ed, getKeyType(), INACTIVITY_TIMEOUT, TimeUnit.SECONDS.toMillis(defaultInactivityTimeoutInSec));
|
long inactivityTimeout = getEntryValue(ed, getKeyType(), INACTIVITY_TIMEOUT, defaultInactivityTimeoutMs);
|
||||||
if (persistToTelemetry && inactivityTimeout == TimeUnit.SECONDS.toMillis(defaultInactivityTimeoutInSec)) {
|
if (persistToTelemetry && inactivityTimeout == defaultInactivityTimeoutMs) {
|
||||||
log.trace("[{}] default value for inactivity timeout fetched {}, going to fetch inactivity timeout from attributes",
|
log.trace("[{}] default value for inactivity timeout fetched {}, going to fetch inactivity timeout from attributes",
|
||||||
deviceIdInfo.getDeviceId(), inactivityTimeout);
|
deviceIdInfo.getDeviceId(), inactivityTimeout);
|
||||||
inactivityTimeout = getEntryValue(ed, EntityKeyType.SERVER_ATTRIBUTE, INACTIVITY_TIMEOUT, TimeUnit.SECONDS.toMillis(defaultInactivityTimeoutInSec));
|
inactivityTimeout = getEntryValue(ed, EntityKeyType.SERVER_ATTRIBUTE, INACTIVITY_TIMEOUT, defaultInactivityTimeoutMs);
|
||||||
}
|
}
|
||||||
//Actual active state by wall-clock will updated outside this method. This method is only for fetch persistent state
|
//Actual active state by wall-clock will updated outside this method. This method is only for fetch persistent state
|
||||||
final boolean active = getEntryValue(ed, getKeyType(), ACTIVITY_STATE, false);
|
final boolean active = getEntryValue(ed, getKeyType(), ACTIVITY_STATE, false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user