Commit 5ee5ce5998bd1934e60c2dfc1dabff1e2e3f6a93

Authored by xp.Huang
1 parent 12c79ac0

revert: 还原设备上下逻辑

... ... @@ -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 516 Set<DeviceId> deviceIds = partitionedEntities.get(tpi);
517 517 if (deviceIds != null) {
518 518 deviceIds.add(state.getDeviceId());
... ... @@ -544,7 +544,7 @@ public class DefaultDeviceStateService extends AbstractPartitionBasedService<Dev
544 544 if (e instanceof TenantNotFoundException) {
545 545 idsFromRemovedTenant.add(deviceId);
546 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 589 if (!isActive(ts, state)
590 590 && (state.getLastInactivityAlarmTime() == 0L || state.getLastInactivityAlarmTime() <= state.getLastActivityTime())
591 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 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 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 603 cleanupEntity(deviceId);
607 604 }
608 605 }
... ...