Merge pull request #13240 from dskarzh/cleanup-deprecation
Cleanup deprecated API in SubscriptionManagerService
This commit is contained in:
		
						commit
						d3365483da
					
				@ -552,19 +552,10 @@ public class DefaultTbCoreConsumerService extends AbstractConsumerService<ToCore
 | 
			
		||||
                    proto.getScope(), KvProtoUtil.toAttributeKvList(proto.getDataList()), callback);
 | 
			
		||||
        } else if (msg.hasAttrDelete()) {
 | 
			
		||||
            TbAttributeDeleteProto proto = msg.getAttrDelete();
 | 
			
		||||
            if (proto.hasNotifyDevice()) {
 | 
			
		||||
                // handles old messages with deprecated 'notifyDevice'
 | 
			
		||||
                subscriptionManagerService.onAttributesDelete(
 | 
			
		||||
                        toTenantId(proto.getTenantIdMSB(), proto.getTenantIdLSB()),
 | 
			
		||||
                        TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()),
 | 
			
		||||
                        proto.getScope(), proto.getKeysList(), proto.getNotifyDevice(), callback);
 | 
			
		||||
            } else {
 | 
			
		||||
                // handles new messages without 'notifyDevice'
 | 
			
		||||
                subscriptionManagerService.onAttributesDelete(
 | 
			
		||||
                        toTenantId(proto.getTenantIdMSB(), proto.getTenantIdLSB()),
 | 
			
		||||
                        TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()),
 | 
			
		||||
                        proto.getScope(), proto.getKeysList(), callback);
 | 
			
		||||
            }
 | 
			
		||||
            subscriptionManagerService.onAttributesDelete(
 | 
			
		||||
                    toTenantId(proto.getTenantIdMSB(), proto.getTenantIdLSB()),
 | 
			
		||||
                    TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()),
 | 
			
		||||
                    proto.getScope(), proto.getKeysList(), callback);
 | 
			
		||||
        } else if (msg.hasTsDelete()) {
 | 
			
		||||
            TbTimeSeriesDeleteProto proto = msg.getTsDelete();
 | 
			
		||||
            subscriptionManagerService.onTimeSeriesDelete(
 | 
			
		||||
 | 
			
		||||
@ -20,10 +20,7 @@ import lombok.RequiredArgsConstructor;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.springframework.context.event.EventListener;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.thingsboard.server.cluster.TbClusterService;
 | 
			
		||||
import org.thingsboard.server.common.data.EntityType;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.AlarmInfo;
 | 
			
		||||
import org.thingsboard.server.common.data.id.DeviceId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.EntityId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
			
		||||
import org.thingsboard.server.common.data.id.UserId;
 | 
			
		||||
@ -36,7 +33,6 @@ import org.thingsboard.server.common.data.kv.TsKvEntry;
 | 
			
		||||
import org.thingsboard.server.common.msg.queue.ServiceType;
 | 
			
		||||
import org.thingsboard.server.common.msg.queue.TbCallback;
 | 
			
		||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
 | 
			
		||||
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
 | 
			
		||||
import org.thingsboard.server.gen.transport.TransportProtos.ToCoreNotificationMsg;
 | 
			
		||||
import org.thingsboard.server.queue.TbQueueProducer;
 | 
			
		||||
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
 | 
			
		||||
@ -73,7 +69,6 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene
 | 
			
		||||
    private final TbServiceInfoProvider serviceInfoProvider;
 | 
			
		||||
    private final TbQueueProducerProvider producerProvider;
 | 
			
		||||
    private final TbLocalSubscriptionService localSubscriptionService;
 | 
			
		||||
    private final TbClusterService clusterService;
 | 
			
		||||
    private final SubscriptionSchedulerComponent scheduler;
 | 
			
		||||
 | 
			
		||||
    private final Lock subsLock = new ReentrantLock();
 | 
			
		||||
@ -204,15 +199,14 @@ public class DefaultSubscriptionManagerService extends TbApplicationEventListene
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onAttributesDelete(TenantId tenantId, EntityId entityId, String scope, List<String> keys, TbCallback callback) {
 | 
			
		||||
        onAttributesDelete(tenantId, entityId, scope, keys, false, callback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onAttributesDelete(TenantId tenantId, EntityId entityId, String scope, List<String> keys, boolean notifyDevice, TbCallback callback) {
 | 
			
		||||
        processAttributesUpdate(entityId, scope,
 | 
			
		||||
                keys.stream().map(key -> new BaseAttributeKvEntry(0, new StringDataEntry(key, ""))).collect(Collectors.toList()));
 | 
			
		||||
        if (entityId.getEntityType() == EntityType.DEVICE && TbAttributeSubscriptionScope.SHARED_SCOPE.name().equalsIgnoreCase(scope) && notifyDevice) {
 | 
			
		||||
            clusterService.pushMsgToCore(DeviceAttributesEventNotificationMsg.onDelete(tenantId, new DeviceId(entityId.getId()), scope, keys), null);
 | 
			
		||||
        try {
 | 
			
		||||
            List<AttributeKvEntry> deletedEntries = keys.stream()
 | 
			
		||||
                    .<AttributeKvEntry>map(key -> new BaseAttributeKvEntry(0L, new StringDataEntry(key, "")))
 | 
			
		||||
                    .toList();
 | 
			
		||||
            processAttributesUpdate(entityId, scope, deletedEntries);
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            callback.onFailure(e);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        callback.onSuccess();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -41,15 +41,6 @@ public interface SubscriptionManagerService extends ApplicationListener<Partitio
 | 
			
		||||
 | 
			
		||||
    void onAttributesDelete(TenantId tenantId, EntityId entityId, String scope, List<String> keys, TbCallback empty);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method is retained solely for backwards compatibility, specifically to handle
 | 
			
		||||
     * legacy proto messages that include the notifyDevice field.
 | 
			
		||||
     *
 | 
			
		||||
     * @deprecated as of 4.0, this method will be removed in future releases.
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated(forRemoval = true, since = "4.0")
 | 
			
		||||
    void onAttributesDelete(TenantId tenantId, EntityId entityId, String scope, List<String> keys, boolean notifyDevice, TbCallback empty);
 | 
			
		||||
 | 
			
		||||
    void onTimeSeriesDelete(TenantId tenantId, EntityId entityId, List<String> keys, TbCallback callback);
 | 
			
		||||
 | 
			
		||||
    void onAlarmUpdate(TenantId tenantId, EntityId entityId, AlarmInfo alarm, TbCallback callback);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user