Showing
1 changed file
with
11 additions
and
14 deletions
@@ -512,7 +512,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | @@ -512,7 +512,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | ||
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | - private boolean addDeviceUsingState(TopicPartitionInfo tpi, final DeviceStateData state) { | 515 | + private boolean addDeviceUsingState(TopicPartitionInfo tpi, DeviceStateData state) { |
516 | Set<DeviceId> deviceIds = partitionedEntities.get(tpi); | 516 | Set<DeviceId> deviceIds = partitionedEntities.get(tpi); |
517 | if (deviceIds != null) { | 517 | if (deviceIds != null) { |
518 | deviceIds.add(state.getDeviceId()); | 518 | deviceIds.add(state.getDeviceId()); |
@@ -544,7 +544,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | @@ -544,7 +544,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | ||
544 | if (e instanceof TenantNotFoundException) { | 544 | if (e instanceof TenantNotFoundException) { |
545 | idsFromRemovedTenant.add(deviceId); | 545 | idsFromRemovedTenant.add(deviceId); |
546 | } else { | 546 | } else { |
547 | - log.error("[{}] Failed to update inactivity state [{}]", deviceId, e.getMessage()); | 547 | + log.warn("[{}] Failed to update inactivity state [{}]", deviceId, e.getMessage()); |
548 | } | 548 | } |
549 | } | 549 | } |
550 | } | 550 | } |
@@ -589,20 +589,17 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | @@ -589,20 +589,17 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev | ||
589 | if (!isActive(ts, state) | 589 | if (!isActive(ts, state) |
590 | && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() <= state.getLastActivityTime()) | 590 | && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() <= state.getLastActivityTime()) |
591 | && stateData.getDeviceCreationTime() + state.getInactivityTimeout() <= ts) { | 591 | && stateData.getDeviceCreationTime() + state.getInactivityTimeout() <= ts) { |
592 | - | ||
593 | - //thingskit code使设备下线,不必判断partition是不是isMyPartition,因为我也不知道if (partitionService.resolve(ServiceType.TB_CORE, stateData.getTenantId(), deviceId).isMyPartition())是干嘛的 | ||
594 | - reportInactivity(ts, deviceId, stateData); | ||
595 | - if(stateData.getState().getLastActivityTime()>0){ | ||
596 | - String tenantId = stateData.getTenantId().getId().toString(); | ||
597 | - String tbDeviceId = deviceId.getId().toString(); | ||
598 | - saveDeviceStateLog(tenantId,tbDeviceId, FastIotConstants.StateValue.OFFLINE); | ||
599 | - channelService.updateVideoChannelState(deviceId.getId().toString(), StatusEnum.OFFLINE); | ||
600 | - } | ||
601 | - | ||
602 | if (partitionService.resolve(ServiceType.TB_CORE, stateData.getTenantId(), deviceId).isMyPartition()) { | 592 | if (partitionService.resolve(ServiceType.TB_CORE, stateData.getTenantId(), deviceId).isMyPartition()) { |
603 | - | 593 | + reportInactivity(ts, deviceId, stateData); |
594 | + //thingskit | ||
595 | + if(stateData.getState().getLastActivityTime()>0){ | ||
596 | + String tenantId = stateData.getTenantId().getId().toString(); | ||
597 | + String tbDeviceId = deviceId.getId().toString(); | ||
598 | + saveDeviceStateLog(tenantId,tbDeviceId, FastIotConstants.StateValue.OFFLINE); | ||
599 | + channelService.updateVideoChannelState(deviceId.getId().toString(), StatusEnum.OFFLINE); | ||
600 | + } | ||
604 | } else { | 601 | } else { |
605 | - log.error("updateInactivityStateIfExpired isMyPartition=false , serverType={},tenantId={},deviceId={}",ServiceType.TB_CORE,stateData.getTenantId(),deviceId); | 602 | + log.warn("updateInactivityStateIfExpired isMyPartition=false , serverType={},tenantId={},deviceId={}",ServiceType.TB_CORE,stateData.getTenantId(),deviceId); |
606 | cleanupEntity(deviceId); | 603 | cleanupEntity(deviceId); |
607 | } | 604 | } |
608 | } | 605 | } |