|
|
|
@ -17,6 +17,7 @@ package org.thingsboard.server.service.ota; |
|
|
|
|
|
|
|
import com.google.common.util.concurrent.FutureCallback; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Required; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.thingsboard.rule.engine.api.RuleEngineTelemetryService; |
|
|
|
@ -49,6 +50,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.ToOtaPackageStateSer |
|
|
|
import org.thingsboard.server.queue.TbQueueProducer; |
|
|
|
import org.thingsboard.server.queue.common.TbProtoQueueMsg; |
|
|
|
import org.thingsboard.server.queue.provider.TbCoreQueueFactory; |
|
|
|
import org.thingsboard.server.queue.provider.TbRuleEngineQueueFactory; |
|
|
|
import org.thingsboard.server.queue.util.TbCoreComponent; |
|
|
|
import org.thingsboard.server.cluster.TbClusterService; |
|
|
|
|
|
|
|
@ -57,6 +59,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.function.Consumer; |
|
|
|
@ -78,7 +81,6 @@ import static org.thingsboard.server.common.data.ota.OtaPackageUtil.getTelemetry |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@TbCoreComponent |
|
|
|
public class DefaultOtaPackageStateService implements OtaPackageStateService { |
|
|
|
|
|
|
|
private final TbClusterService tbClusterService; |
|
|
|
@ -93,13 +95,18 @@ public class DefaultOtaPackageStateService implements OtaPackageStateService { |
|
|
|
DeviceService deviceService, |
|
|
|
DeviceProfileService deviceProfileService, |
|
|
|
@Lazy RuleEngineTelemetryService telemetryService, |
|
|
|
TbCoreQueueFactory coreQueueFactory) { |
|
|
|
Optional<TbCoreQueueFactory> coreQueueFactory, |
|
|
|
Optional<TbRuleEngineQueueFactory> reQueueFactory) { |
|
|
|
this.tbClusterService = tbClusterService; |
|
|
|
this.otaPackageService = otaPackageService; |
|
|
|
this.deviceService = deviceService; |
|
|
|
this.deviceProfileService = deviceProfileService; |
|
|
|
this.telemetryService = telemetryService; |
|
|
|
this.otaPackageStateMsgProducer = coreQueueFactory.createToOtaPackageStateServiceMsgProducer(); |
|
|
|
if (coreQueueFactory.isPresent()) { |
|
|
|
this.otaPackageStateMsgProducer = coreQueueFactory.get().createToOtaPackageStateServiceMsgProducer(); |
|
|
|
} else { |
|
|
|
this.otaPackageStateMsgProducer = reQueueFactory.get().createToOtaPackageStateServiceMsgProducer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|