EDQS code cleanup
This commit is contained in:
parent
a48144d2bb
commit
347cb5bc36
@ -68,6 +68,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.ToEdqsMsg;
|
||||
import org.thingsboard.server.queue.TbQueueRequestTemplate;
|
||||
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
|
||||
import org.thingsboard.server.queue.discovery.HashPartitionService;
|
||||
import org.thingsboard.server.queue.discovery.TopicService;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueue;
|
||||
import org.thingsboard.server.queue.environment.DistributedLock;
|
||||
import org.thingsboard.server.queue.environment.DistributedLockService;
|
||||
@ -90,6 +91,7 @@ public class DefaultEdqsService implements EdqsService {
|
||||
private final DistributedLockService distributedLockService;
|
||||
private final AttributesService attributesService;
|
||||
private final EdqsPartitionService edqsPartitionService;
|
||||
private final TopicService topicService;
|
||||
@Autowired @Lazy
|
||||
private TbClusterService clusterService;
|
||||
@Autowired @Lazy
|
||||
@ -109,6 +111,7 @@ public class DefaultEdqsService implements EdqsService {
|
||||
eventsProducer = EdqsProducer.builder()
|
||||
.queue(EdqsQueue.EVENTS)
|
||||
.partitionService(edqsPartitionService)
|
||||
.topicService(topicService)
|
||||
.producer(queueFactory.createEdqsMsgProducer(EdqsQueue.EVENTS))
|
||||
.build();
|
||||
if (apiEnabled) {
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.thingsboard.server.service.edqs;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueue;
|
||||
@ -25,7 +24,6 @@ import org.thingsboard.server.queue.kafka.TbKafkaSettings;
|
||||
import java.util.Collections;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnExpression("'${queue.edqs.sync.enabled:true}' == 'true' && '${queue.type:null}' == 'kafka'")
|
||||
public class KafkaEdqsSyncService extends EdqsSyncService {
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@ public enum ObjectType {
|
||||
TENANT,
|
||||
TENANT_PROFILE,
|
||||
CUSTOMER,
|
||||
ADMIN_SETTINGS,
|
||||
QUEUE,
|
||||
RPC,
|
||||
RULE_CHAIN,
|
||||
@ -32,8 +31,6 @@ public enum ObjectType {
|
||||
EVENT,
|
||||
RULE_NODE,
|
||||
USER,
|
||||
USER_CREDENTIALS,
|
||||
USER_AUTH_SETTINGS,
|
||||
EDGE,
|
||||
WIDGETS_BUNDLE,
|
||||
WIDGET_TYPE,
|
||||
@ -54,7 +51,6 @@ public enum ObjectType {
|
||||
NOTIFICATION_TEMPLATE,
|
||||
NOTIFICATION_RULE,
|
||||
ALARM_COMMENT,
|
||||
ALARM_TYPE,
|
||||
API_USAGE_STATE,
|
||||
QUEUE_STATS,
|
||||
|
||||
@ -70,7 +66,10 @@ public enum ObjectType {
|
||||
public static final Set<ObjectType> edqsTypes = EnumSet.copyOf(edqsTenantTypes);
|
||||
public static final Set<ObjectType> edqsSystemTypes = EnumSet.of(TENANT, TENANT_PROFILE, USER, DASHBOARD,
|
||||
API_USAGE_STATE, ATTRIBUTE_KV, LATEST_TS_KV);
|
||||
public static final Set<ObjectType> unversionedTypes = EnumSet.of(QUEUE_STATS);
|
||||
public static final Set<ObjectType> unversionedTypes = EnumSet.of(
|
||||
QUEUE_STATS, // created once, never updated
|
||||
TENANT_PROFILE // only for total count calculation
|
||||
);
|
||||
|
||||
static {
|
||||
edqsTypes.addAll(List.of(RELATION, ATTRIBUTE_KV, LATEST_TS_KV));
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.common.data.alarm;
|
||||
|
||||
import lombok.Data;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
|
||||
@Data
|
||||
public class AlarmType {
|
||||
|
||||
private TenantId tenantId;
|
||||
private String type;
|
||||
|
||||
}
|
||||
@ -15,27 +15,15 @@
|
||||
*/
|
||||
package org.thingsboard.server.common.data.edqs.fields;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.thingsboard.server.common.data.edqs.fields.FieldsUtil.getText;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class GenericFields extends AbstractEntityFields {
|
||||
|
||||
private String additionalInfo;
|
||||
|
||||
public GenericFields(UUID id, long createdTime, UUID tenantId, String name, Long version, JsonNode additionalInfo) {
|
||||
super(id, createdTime, tenantId, name, version);
|
||||
this.additionalInfo = getText(additionalInfo);
|
||||
}
|
||||
|
||||
public GenericFields(UUID id, long createdTime, UUID tenantId, String name, Long version) {
|
||||
super(id, createdTime, tenantId, name, version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -56,7 +56,4 @@ public class TenantFields extends AbstractEntityFields {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public TenantFields(UUID id, Long version) {
|
||||
super(id, 0L, null, version);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import java.util.NoSuchElementException;
|
||||
public abstract class BasePageDataIterable<T> implements Iterable<T>, Iterator<T> {
|
||||
|
||||
private final int fetchSize;
|
||||
private SortOrder sortOrder;
|
||||
|
||||
private List<T> currentItems;
|
||||
private int currentIdx;
|
||||
@ -36,12 +35,6 @@ public abstract class BasePageDataIterable<T> implements Iterable<T>, Iterator<T
|
||||
this.fetchSize = fetchSize;
|
||||
}
|
||||
|
||||
public BasePageDataIterable(int fetchSize, SortOrder sortOrder) {
|
||||
super();
|
||||
this.fetchSize = fetchSize;
|
||||
this.sortOrder = sortOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return this;
|
||||
@ -50,7 +43,7 @@ public abstract class BasePageDataIterable<T> implements Iterable<T>, Iterator<T
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (!initialized) {
|
||||
fetch(new PageLink(fetchSize, 0, null, sortOrder));
|
||||
fetch(new PageLink(fetchSize));
|
||||
initialized = true;
|
||||
}
|
||||
if (currentIdx == currentItems.size()) {
|
||||
|
||||
@ -24,11 +24,6 @@ public class PageDataIterable<T> extends BasePageDataIterable<T> {
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
public PageDataIterable(FetchFunction<T> function, int fetchSize, SortOrder sortOrder) {
|
||||
super(fetchSize, sortOrder);
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@Override
|
||||
PageData<T> fetchPageData(PageLink link) {
|
||||
return function.fetch(link);
|
||||
|
||||
@ -39,7 +39,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
@JsonSubTypes.Type(value = AssetSearchQueryFilter.class, name = "assetSearchQuery"),
|
||||
@JsonSubTypes.Type(value = DeviceSearchQueryFilter.class, name = "deviceSearchQuery"),
|
||||
@JsonSubTypes.Type(value = EntityViewSearchQueryFilter.class, name = "entityViewSearchQuery"),
|
||||
@JsonSubTypes.Type(value = EdgeSearchQueryFilter.class, name = "edgeSearchQuery")})
|
||||
@JsonSubTypes.Type(value = EdgeSearchQueryFilter.class, name = "edgeSearchQuery")
|
||||
})
|
||||
public interface EntityFilter {
|
||||
|
||||
@JsonIgnore
|
||||
|
||||
@ -18,6 +18,7 @@ package org.thingsboard.server.edqs.data.dp;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.thingsboard.server.common.data.kv.DataType;
|
||||
import org.thingsboard.server.edqs.util.TbBytePool;
|
||||
import org.xerial.snappy.Snappy;
|
||||
|
||||
public class CompressedStringDataPoint extends AbstractDataPoint {
|
||||
@ -29,7 +30,7 @@ public class CompressedStringDataPoint extends AbstractDataPoint {
|
||||
@SneakyThrows
|
||||
public CompressedStringDataPoint(long ts, byte[] compressedValue) {
|
||||
super(ts);
|
||||
this.compressedValue = compressedValue;
|
||||
this.compressedValue = TbBytePool.intern(compressedValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -17,7 +17,7 @@ package org.thingsboard.server.edqs.data.dp;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.thingsboard.server.common.data.kv.DataType;
|
||||
import org.thingsboard.server.edqs.repo.TbStringPool;
|
||||
import org.thingsboard.server.edqs.util.TbStringPool;
|
||||
|
||||
public class JsonDataPoint extends AbstractDataPoint {
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ package org.thingsboard.server.edqs.data.dp;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.thingsboard.server.common.data.kv.DataType;
|
||||
import org.thingsboard.server.edqs.repo.TbStringPool;
|
||||
import org.thingsboard.server.edqs.util.TbStringPool;
|
||||
|
||||
public class StringDataPoint extends AbstractDataPoint {
|
||||
|
||||
|
||||
@ -24,12 +24,12 @@ import jakarta.annotation.PreDestroy;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.common.util.ExceptionUtil;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.common.util.ThingsBoardExecutors;
|
||||
import org.thingsboard.common.util.ThingsBoardThreadFactory;
|
||||
@ -46,7 +46,7 @@ import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.util.CollectionsUtil;
|
||||
import org.thingsboard.server.common.msg.queue.ServiceType;
|
||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
||||
import org.thingsboard.server.edqs.repo.EdqRepository;
|
||||
import org.thingsboard.server.edqs.repo.EdqsRepository;
|
||||
import org.thingsboard.server.edqs.state.EdqsPartitionService;
|
||||
import org.thingsboard.server.edqs.state.EdqsStateService;
|
||||
import org.thingsboard.server.edqs.util.EdqsConverter;
|
||||
@ -68,6 +68,7 @@ import org.thingsboard.server.queue.edqs.EdqsQueue;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueueFactory;
|
||||
import org.thingsboard.server.queue.util.AfterStartUp;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -85,7 +86,7 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
|
||||
private final EdqsQueueFactory queueFactory;
|
||||
private final EdqsConverter converter;
|
||||
private final EdqRepository repository;
|
||||
private final EdqsRepository repository;
|
||||
private final EdqsConfig config;
|
||||
private final EdqsPartitionService partitionService;
|
||||
private final ConfigurableApplicationContext applicationContext;
|
||||
@ -99,11 +100,10 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
private ExecutorService taskExecutor;
|
||||
private ScheduledExecutorService scheduler;
|
||||
private ListeningExecutorService requestExecutor;
|
||||
private ExecutorService repartitionExecutor;
|
||||
|
||||
private final VersionsStore versionsStore = new VersionsStore();
|
||||
|
||||
private final AtomicInteger counter = new AtomicInteger(); // FIXME: TMP
|
||||
private final AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
@Getter
|
||||
private Consumer<Throwable> errorHandler;
|
||||
@ -114,7 +114,6 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
taskExecutor = ThingsBoardExecutors.newWorkStealingPool(4, "edqs-consumer-task-executor");
|
||||
scheduler = ThingsBoardExecutors.newSingleThreadScheduledExecutor("edqs-scheduler");
|
||||
requestExecutor = MoreExecutors.listeningDecorator(ThingsBoardExecutors.newWorkStealingPool(12, "edqs-requests"));
|
||||
repartitionExecutor = Executors.newSingleThreadExecutor(ThingsBoardThreadFactory.forName("edqs-repartition"));
|
||||
errorHandler = error -> {
|
||||
if (error instanceof OutOfMemoryError) {
|
||||
log.error("OOM detected, shutting down");
|
||||
@ -135,7 +134,6 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
}
|
||||
try {
|
||||
ToEdqsMsg msg = queueMsg.getValue();
|
||||
log.trace("Processing message: {}", msg);
|
||||
process(msg, EdqsQueue.EVENTS);
|
||||
} catch (Exception t) {
|
||||
log.error("Failed to process message: {}", queueMsg, t);
|
||||
@ -195,27 +193,19 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
public ListenableFuture<TbProtoQueueMsg<FromEdqsMsg>> handle(TbProtoQueueMsg<ToEdqsMsg> queueMsg) {
|
||||
ToEdqsMsg toEdqsMsg = queueMsg.getValue();
|
||||
return requestExecutor.submit(() -> {
|
||||
EdqsResponse response = new EdqsResponse();
|
||||
EdqsRequest request;
|
||||
TenantId tenantId;
|
||||
CustomerId customerId;
|
||||
try {
|
||||
EdqsRequest request = JacksonUtil.fromString(toEdqsMsg.getRequestMsg().getValue(), EdqsRequest.class);
|
||||
TenantId tenantId = getTenantId(toEdqsMsg);
|
||||
CustomerId customerId = getCustomerId(toEdqsMsg);
|
||||
log.info("[{}] Handling request: {}", tenantId, request);
|
||||
|
||||
if (request.getEntityDataQuery() != null) {
|
||||
PageData<QueryResult> result = repository.findEntityDataByQuery(tenantId, customerId,
|
||||
request.getEntityDataQuery(), false);
|
||||
response.setEntityDataQueryResult(result.mapData(QueryResult::toOldEntityData));
|
||||
} else if (request.getEntityCountQuery() != null) {
|
||||
long result = repository.countEntitiesByQuery(tenantId, customerId, request.getEntityCountQuery(), tenantId.isSysTenantId());
|
||||
response.setEntityCountQueryResult(result);
|
||||
}
|
||||
|
||||
log.info("Answering with response: {}", response);
|
||||
} catch (Throwable e) {
|
||||
response.setError(ExceptionUtils.getStackTrace(e)); // TODO: return only the message
|
||||
log.info("Answering with error", e);
|
||||
request = Objects.requireNonNull(JacksonUtil.fromString(toEdqsMsg.getRequestMsg().getValue(), EdqsRequest.class));
|
||||
tenantId = getTenantId(toEdqsMsg);
|
||||
customerId = getCustomerId(toEdqsMsg);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to parse request msg: {}", toEdqsMsg, e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
EdqsResponse response = processRequest(tenantId, customerId, request);
|
||||
return new TbProtoQueueMsg<>(queueMsg.getKey(), FromEdqsMsg.newBuilder()
|
||||
.setResponseMsg(TransportProtos.EdqsResponseMsg.newBuilder()
|
||||
.setValue(JacksonUtil.toString(response))
|
||||
@ -224,7 +214,27 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
});
|
||||
}
|
||||
|
||||
private EdqsResponse processRequest(TenantId tenantId, CustomerId customerId, EdqsRequest request) {
|
||||
EdqsResponse response = new EdqsResponse();
|
||||
try {
|
||||
if (request.getEntityDataQuery() != null) {
|
||||
PageData<QueryResult> result = repository.findEntityDataByQuery(tenantId, customerId,
|
||||
request.getEntityDataQuery(), false);
|
||||
response.setEntityDataQueryResult(result.mapData(QueryResult::toOldEntityData));
|
||||
} else if (request.getEntityCountQuery() != null) {
|
||||
long result = repository.countEntitiesByQuery(tenantId, customerId, request.getEntityCountQuery(), tenantId.isSysTenantId());
|
||||
response.setEntityCountQueryResult(result);
|
||||
}
|
||||
log.trace("[{}] Request: {}, response: {}", tenantId, request, response);
|
||||
} catch (Throwable e) {
|
||||
log.error("[{}] Failed to process request: {}", tenantId, request, e);
|
||||
response.setError(ExceptionUtil.getMessage(e));
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public void process(ToEdqsMsg edqsMsg, EdqsQueue queue) {
|
||||
log.trace("Processing message: {}", edqsMsg);
|
||||
if (edqsMsg.hasEventMsg()) {
|
||||
EdqsEventMsg eventMsg = edqsMsg.getEventMsg();
|
||||
TenantId tenantId = getTenantId(edqsMsg);
|
||||
@ -290,7 +300,6 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
|
||||
taskExecutor.shutdownNow();
|
||||
scheduler.shutdownNow();
|
||||
requestExecutor.shutdownNow();
|
||||
repartitionExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import org.thingsboard.server.queue.TbQueueCallback;
|
||||
import org.thingsboard.server.queue.TbQueueMsgMetadata;
|
||||
import org.thingsboard.server.queue.TbQueueProducer;
|
||||
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
|
||||
import org.thingsboard.server.queue.discovery.TopicService;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueue;
|
||||
import org.thingsboard.server.queue.kafka.TbKafkaProducerTemplate;
|
||||
|
||||
@ -35,26 +36,27 @@ public class EdqsProducer {
|
||||
|
||||
private final EdqsQueue queue;
|
||||
private final EdqsPartitionService partitionService;
|
||||
private final TopicService topicService;
|
||||
|
||||
private final TbQueueProducer<TbProtoQueueMsg<ToEdqsMsg>> producer;
|
||||
|
||||
@Builder
|
||||
public EdqsProducer(EdqsQueue queue,
|
||||
EdqsPartitionService partitionService,
|
||||
TopicService topicService,
|
||||
TbQueueProducer<TbProtoQueueMsg<ToEdqsMsg>> producer) {
|
||||
this.queue = queue;
|
||||
this.partitionService = partitionService;
|
||||
this.topicService = topicService;
|
||||
this.producer = producer;
|
||||
}
|
||||
|
||||
// TODO: queue prefix!
|
||||
|
||||
public void send(TenantId tenantId, ObjectType type, String key, ToEdqsMsg msg) {
|
||||
String topic = queue.getTopic();
|
||||
String topic = topicService.buildTopicName(queue.getTopic());
|
||||
TbQueueCallback callback = new TbQueueCallback() {
|
||||
@Override
|
||||
public void onSuccess(TbQueueMsgMetadata metadata) {
|
||||
log.trace("[{}][{}][{}] Published msg to {}: {}", tenantId, type, key, topic, msg); // fixme log levels
|
||||
log.trace("[{}][{}][{}] Published msg to {}: {}", tenantId, type, key, topic, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -39,7 +39,7 @@ import java.util.function.Predicate;
|
||||
@AllArgsConstructor
|
||||
@Service
|
||||
@Slf4j
|
||||
public class InMemoryEdqRepository implements EdqRepository {
|
||||
public class DefaultEdqsRepository implements EdqsRepository {
|
||||
|
||||
private final static ConcurrentMap<TenantId, TenantRepo> repos = new ConcurrentHashMap<>();
|
||||
private final Optional<EdqsStatsService> statsService;
|
||||
@ -51,7 +51,7 @@ public class InMemoryEdqRepository implements EdqRepository {
|
||||
@Override
|
||||
public void processEvent(EdqsEvent event) {
|
||||
if (event.getEventType() == EdqsEventType.DELETED && event.getObjectType() == ObjectType.TENANT) {
|
||||
log.info("Deleting tenant repo: {}", event);
|
||||
log.info("Tenant {} deleted", event.getTenantId());
|
||||
repos.remove(event.getTenantId());
|
||||
} else {
|
||||
get(event.getTenantId()).processEvent(event);
|
||||
@ -62,25 +62,25 @@ public class InMemoryEdqRepository implements EdqRepository {
|
||||
public long countEntitiesByQuery(TenantId tenantId, CustomerId customerId, EntityCountQuery query, boolean ignorePermissionCheck) {
|
||||
long startNs = System.nanoTime();
|
||||
long result = 0;
|
||||
if (TenantId.SYS_TENANT_ID.equals(tenantId)) {
|
||||
if (!tenantId.isSysTenantId()) {
|
||||
result = get(tenantId).countEntitiesByQuery(customerId, query, ignorePermissionCheck);
|
||||
} else {
|
||||
for (TenantRepo repo : repos.values()) {
|
||||
result += repo.countEntitiesByQuery(customerId, query, ignorePermissionCheck);
|
||||
}
|
||||
} else {
|
||||
result = get(tenantId).countEntitiesByQuery(customerId, query, ignorePermissionCheck);
|
||||
}
|
||||
double timingMs = (double) (System.nanoTime() - startNs) / 1000_000;
|
||||
log.info("countEntitiesByQuery: {} ms", timingMs);
|
||||
log.info("countEntitiesByQuery done in {} ms", timingMs);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageData<QueryResult> findEntityDataByQuery(TenantId tenantId, CustomerId customerId,
|
||||
EntityDataQuery query, boolean ignorePermissionCheck) {
|
||||
EntityDataQuery query, boolean ignorePermissionCheck) {
|
||||
long startNs = System.nanoTime();
|
||||
var result = get(tenantId).findEntityDataByQuery(customerId, query, ignorePermissionCheck);
|
||||
double timingMs = (double) (System.nanoTime() - startNs) / 1000_000;
|
||||
log.info("findEntityDataByQuery: {} ms", timingMs);
|
||||
log.info("findEntityDataByQuery done in {} ms", timingMs);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -25,13 +25,10 @@ import org.thingsboard.server.common.data.query.EntityDataQuery;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public interface EdqRepository {
|
||||
public interface EdqsRepository {
|
||||
|
||||
void processEvent(EdqsEvent event);
|
||||
|
||||
@Deprecated
|
||||
default void addOrUpdate(TenantId tenantId, Object object) {}
|
||||
|
||||
long countEntitiesByQuery(TenantId tenantId, CustomerId customerId, EntityCountQuery query, boolean ignorePermissionCheck);
|
||||
|
||||
PageData<QueryResult> findEntityDataByQuery(TenantId tenantId, CustomerId customerId, EntityDataQuery query, boolean ignorePermissionCheck);
|
||||
@ -57,6 +57,7 @@ import org.thingsboard.server.edqs.query.processor.EntityQueryProcessor;
|
||||
import org.thingsboard.server.edqs.query.processor.EntityQueryProcessorFactory;
|
||||
import org.thingsboard.server.edqs.stats.EdqsStatsService;
|
||||
import org.thingsboard.server.edqs.util.RepositoryUtils;
|
||||
import org.thingsboard.server.edqs.util.TbStringPool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@ -33,6 +33,7 @@ import org.thingsboard.server.queue.common.consumer.PartitionedQueueConsumerMana
|
||||
import org.thingsboard.server.queue.common.consumer.QueueConsumerManager;
|
||||
import org.thingsboard.server.queue.common.consumer.QueueStateService;
|
||||
import org.thingsboard.server.queue.discovery.QueueKey;
|
||||
import org.thingsboard.server.queue.discovery.TopicService;
|
||||
import org.thingsboard.server.queue.edqs.EdqsConfig;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueue;
|
||||
import org.thingsboard.server.queue.edqs.EdqsQueueFactory;
|
||||
@ -52,6 +53,7 @@ public class KafkaEdqsStateService implements EdqsStateService {
|
||||
private final EdqsPartitionService partitionService;
|
||||
private final EdqsQueueFactory queueFactory;
|
||||
private final EdqsProcessor edqsProcessor;
|
||||
private final TopicService topicService;
|
||||
|
||||
private PartitionedQueueConsumerManager<TbProtoQueueMsg<ToEdqsMsg>> stateConsumer;
|
||||
private QueueStateService<TbProtoQueueMsg<ToEdqsMsg>, TbProtoQueueMsg<ToEdqsMsg>> queueStateService;
|
||||
@ -75,7 +77,6 @@ public class KafkaEdqsStateService implements EdqsStateService {
|
||||
}
|
||||
try {
|
||||
ToEdqsMsg msg = queueMsg.getValue();
|
||||
log.trace("Processing message: {}", msg);
|
||||
edqsProcessor.process(msg, EdqsQueue.STATE);
|
||||
if (stateReadCount.incrementAndGet() % 100000 == 0) {
|
||||
log.info("[state] Processed {} msgs", stateReadCount.get());
|
||||
@ -140,6 +141,7 @@ public class KafkaEdqsStateService implements EdqsStateService {
|
||||
stateProducer = EdqsProducer.builder()
|
||||
.queue(EdqsQueue.STATE)
|
||||
.partitionService(partitionService)
|
||||
.topicService(topicService)
|
||||
.producer(queueFactory.createEdqsMsgProducer(EdqsQueue.STATE))
|
||||
.build();
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ import org.thingsboard.server.edqs.data.dp.DoubleDataPoint;
|
||||
import org.thingsboard.server.edqs.data.dp.JsonDataPoint;
|
||||
import org.thingsboard.server.edqs.data.dp.LongDataPoint;
|
||||
import org.thingsboard.server.edqs.data.dp.StringDataPoint;
|
||||
import org.thingsboard.server.edqs.repo.TbBytePool;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||
import org.thingsboard.server.gen.transport.TransportProtos.DataPointProto;
|
||||
import org.xerial.snappy.Snappy;
|
||||
@ -161,11 +160,11 @@ public class EdqsConverter {
|
||||
} else if (proto.hasStringV()) {
|
||||
return new StringDataPoint(ts, proto.getStringV());
|
||||
} else if (proto.hasCompressedStringV()) {
|
||||
return new CompressedStringDataPoint(ts, TbBytePool.intern(proto.getCompressedStringV().toByteArray()));
|
||||
return new CompressedStringDataPoint(ts, proto.getCompressedStringV().toByteArray());
|
||||
} else if (proto.hasJsonV()) {
|
||||
return new JsonDataPoint(ts, proto.getJsonV());
|
||||
} else if (proto.hasCompressedJsonV()) {
|
||||
return new CompressedJsonDataPoint(ts, TbBytePool.intern(proto.getCompressedJsonV().toByteArray()));
|
||||
return new CompressedJsonDataPoint(ts, proto.getCompressedJsonV().toByteArray());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported data point proto: " + proto);
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.edqs.repo;
|
||||
package org.thingsboard.server.edqs.util;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.edqs.repo;
|
||||
package org.thingsboard.server.edqs.util;
|
||||
|
||||
import org.springframework.util.ConcurrentReferenceHashMap;
|
||||
|
||||
@ -27,6 +27,7 @@ import org.thingsboard.server.queue.TbQueueResponseTemplate;
|
||||
import org.thingsboard.server.queue.common.DefaultTbQueueResponseTemplate;
|
||||
import org.thingsboard.server.queue.common.TbProtoQueueMsg;
|
||||
import org.thingsboard.server.queue.discovery.TbServiceInfoProvider;
|
||||
import org.thingsboard.server.queue.discovery.TopicService;
|
||||
import org.thingsboard.server.queue.kafka.TbKafkaAdmin;
|
||||
import org.thingsboard.server.queue.kafka.TbKafkaConsumerStatsService;
|
||||
import org.thingsboard.server.queue.kafka.TbKafkaConsumerTemplate;
|
||||
@ -47,12 +48,13 @@ public class KafkaEdqsQueueFactory implements EdqsQueueFactory {
|
||||
private final EdqsConfig edqsConfig;
|
||||
private final TbServiceInfoProvider serviceInfoProvider;
|
||||
private final TbKafkaConsumerStatsService consumerStatsService;
|
||||
private final TopicService topicService;
|
||||
|
||||
private final AtomicInteger consumerCounter = new AtomicInteger();
|
||||
|
||||
public KafkaEdqsQueueFactory(TbKafkaSettings kafkaSettings, TbKafkaTopicConfigs topicConfigs,
|
||||
EdqsConfig edqsConfig, TbServiceInfoProvider serviceInfoProvider,
|
||||
TbKafkaConsumerStatsService consumerStatsService) {
|
||||
TbKafkaConsumerStatsService consumerStatsService, TopicService topicService) {
|
||||
this.edqsEventsAdmin = new TbKafkaAdmin(kafkaSettings, topicConfigs.getEdqsEventsConfigs());
|
||||
this.edqsRequestsAdmin = new TbKafkaAdmin(kafkaSettings, topicConfigs.getEdqsRequestsConfigs());
|
||||
this.edqsStateAdmin = new TbKafkaAdmin(kafkaSettings, topicConfigs.getEdqsStateConfigs());
|
||||
@ -60,6 +62,7 @@ public class KafkaEdqsQueueFactory implements EdqsQueueFactory {
|
||||
this.edqsConfig = edqsConfig;
|
||||
this.serviceInfoProvider = serviceInfoProvider;
|
||||
this.consumerStatsService = consumerStatsService;
|
||||
this.topicService = topicService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,11 +75,11 @@ public class KafkaEdqsQueueFactory implements EdqsQueueFactory {
|
||||
public TbQueueConsumer<TbProtoQueueMsg<ToEdqsMsg>> createEdqsMsgConsumer(EdqsQueue queue, String group) {
|
||||
return TbKafkaConsumerTemplate.<TbProtoQueueMsg<ToEdqsMsg>>builder()
|
||||
.settings(kafkaSettings)
|
||||
.topic(queue.getTopic())
|
||||
.topic(topicService.buildTopicName(queue.getTopic()))
|
||||
.readFromBeginning(queue.isReadFromBeginning())
|
||||
.stopWhenRead(queue.isStopWhenRead())
|
||||
.clientId("edqs-" + queue.name().toLowerCase() + "-" + consumerCounter.getAndIncrement() + "-consumer-" + serviceInfoProvider.getServiceId())
|
||||
.groupId(group)
|
||||
.groupId(topicService.buildTopicName(group))
|
||||
.decoder(msg -> new TbProtoQueueMsg<>(msg.getKey(), ToEdqsMsg.parseFrom(msg.getData()), msg.getHeaders()))
|
||||
.admin(queue == EdqsQueue.STATE ? edqsStateAdmin : edqsEventsAdmin)
|
||||
.statsService(consumerStatsService)
|
||||
@ -97,16 +100,16 @@ public class KafkaEdqsQueueFactory implements EdqsQueueFactory {
|
||||
String requestsConsumerGroup = "edqs-requests-consumer-group-" + edqsConfig.getLabel();
|
||||
var requestConsumer = TbKafkaConsumerTemplate.<TbProtoQueueMsg<TransportProtos.ToEdqsMsg>>builder()
|
||||
.settings(kafkaSettings)
|
||||
.topic(edqsConfig.getRequestsTopic())
|
||||
.topic(topicService.buildTopicName(edqsConfig.getRequestsTopic()))
|
||||
.clientId("edqs-requests-consumer-" + serviceInfoProvider.getServiceId())
|
||||
.groupId(requestsConsumerGroup)
|
||||
.groupId(topicService.buildTopicName(requestsConsumerGroup))
|
||||
.decoder(msg -> new TbProtoQueueMsg<>(msg.getKey(), TransportProtos.ToEdqsMsg.parseFrom(msg.getData()), msg.getHeaders()))
|
||||
.admin(edqsRequestsAdmin)
|
||||
.statsService(consumerStatsService);
|
||||
var responseProducer = TbKafkaProducerTemplate.<TbProtoQueueMsg<FromEdqsMsg>>builder()
|
||||
.settings(kafkaSettings)
|
||||
.clientId("edqs-response-producer-" + serviceInfoProvider.getServiceId())
|
||||
.defaultTopic(edqsConfig.getResponsesTopic())
|
||||
.defaultTopic(topicService.buildTopicName(edqsConfig.getResponsesTopic()))
|
||||
.admin(edqsRequestsAdmin);
|
||||
return DefaultTbQueueResponseTemplate.<TbProtoQueueMsg<ToEdqsMsg>, TbProtoQueueMsg<FromEdqsMsg>>builder()
|
||||
.requestTemplate(requestConsumer.build())
|
||||
|
||||
@ -522,7 +522,7 @@ public class KafkaMonolithQueueFactory implements TbCoreQueueFactory, TbRuleEngi
|
||||
var responseConsumer = TbKafkaConsumerTemplate.<TbProtoQueueMsg<FromEdqsMsg>>builder()
|
||||
.settings(kafkaSettings)
|
||||
.topic(topicService.buildTopicName(edqsConfig.getResponsesTopic() + "." + serviceInfoProvider.getServiceId()))
|
||||
.clientId(topicService.buildTopicName("monolith-edqs-response-consumer-" + serviceInfoProvider.getServiceId()))
|
||||
.clientId("monolith-edqs-response-consumer-" + serviceInfoProvider.getServiceId())
|
||||
.groupId(topicService.buildTopicName("monolith-edqs-response-consumer-" + serviceInfoProvider.getServiceId()))
|
||||
.decoder(msg -> new TbProtoQueueMsg<>(msg.getKey(), FromEdqsMsg.parseFrom(msg.getData()), msg.getHeaders()))
|
||||
.admin(edqsRequestsAdmin)
|
||||
|
||||
@ -471,7 +471,7 @@ public class KafkaTbCoreQueueFactory implements TbCoreQueueFactory {
|
||||
var responseConsumer = TbKafkaConsumerTemplate.<TbProtoQueueMsg<FromEdqsMsg>>builder()
|
||||
.settings(kafkaSettings)
|
||||
.topic(topicService.buildTopicName(edqsConfig.getResponsesTopic() + "." + serviceInfoProvider.getServiceId()))
|
||||
.clientId(topicService.buildTopicName("tb-core-edqs-response-consumer-" + serviceInfoProvider.getServiceId()))
|
||||
.clientId("tb-core-edqs-response-consumer-" + serviceInfoProvider.getServiceId())
|
||||
.groupId(topicService.buildTopicName("tb-core-edqs-response-consumer-" + serviceInfoProvider.getServiceId()))
|
||||
.decoder(msg -> new TbProtoQueueMsg<>(msg.getKey(), FromEdqsMsg.parseFrom(msg.getData()), msg.getHeaders()))
|
||||
.admin(edqsRequestsAdmin)
|
||||
|
||||
@ -64,4 +64,14 @@ public class ExceptionUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMessage(Throwable t) {
|
||||
String message = t.getMessage();
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
return message;
|
||||
} else {
|
||||
return t.getClass().getSimpleName();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.thingsboard.server.dao;
|
||||
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
@ -30,8 +29,4 @@ public interface TenantEntityDao<T> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
default ObjectType getType() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,9 +18,7 @@ package org.thingsboard.server.dao.entity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.dao.Dao;
|
||||
import org.thingsboard.server.dao.TenantEntityDao;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
@ -31,20 +29,14 @@ import java.util.Map;
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public class EntityDaoRegistry {
|
||||
|
||||
private final Map<ObjectType, TenantEntityDao<?>> tenantEntityDaos = new EnumMap<>(ObjectType.class);
|
||||
private final Map<EntityType, Dao<?>> entityDaos = new EnumMap<>(EntityType.class);
|
||||
|
||||
private EntityDaoRegistry(List<Dao<?>> entityDaos, List<TenantEntityDao<?>> tenantEntityDaos) {
|
||||
private EntityDaoRegistry(List<Dao<?>> entityDaos) {
|
||||
entityDaos.forEach(dao -> {
|
||||
if (dao.getEntityType() != null) {
|
||||
this.entityDaos.put(dao.getEntityType(), dao);
|
||||
}
|
||||
});
|
||||
tenantEntityDaos.forEach(dao -> {
|
||||
if (dao.getType() != null) {
|
||||
this.tenantEntityDaos.put(dao.getType(), dao);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public <T> Dao<T> getDao(EntityType entityType) {
|
||||
@ -55,12 +47,4 @@ public class EntityDaoRegistry {
|
||||
return dao;
|
||||
}
|
||||
|
||||
public <T> TenantEntityDao<T> getTenantEntityDao(ObjectType objectType) {
|
||||
TenantEntityDao<?> dao = tenantEntityDaos.get(objectType);
|
||||
if (dao == null) {
|
||||
throw new IllegalArgumentException("Missing tenant entity dao for entity type " + objectType);
|
||||
}
|
||||
return (TenantEntityDao<T>) dao;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.dao.model.sql;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.IdClass;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.dao.model.ModelConstants;
|
||||
import org.thingsboard.server.dao.model.ToData;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = ModelConstants.ALARM_TYPES_TABLE_NAME)
|
||||
@IdClass(AlarmTypeCompositeKey.class)
|
||||
public class AlarmTypeEntity implements ToData<AlarmType> {
|
||||
|
||||
@Id
|
||||
@Column(name = ModelConstants.TENANT_ID_PROPERTY, nullable = false)
|
||||
private UUID tenantId;
|
||||
|
||||
@Id
|
||||
@Column(name = ModelConstants.ALARM_TYPE_PROPERTY, nullable = false)
|
||||
private String type;
|
||||
|
||||
public AlarmTypeEntity() {}
|
||||
|
||||
public AlarmTypeEntity(AlarmType alarmType) {
|
||||
setTenantId(alarmType.getTenantId().getId());
|
||||
setType(alarmType.getType());
|
||||
}
|
||||
|
||||
public AlarmTypeEntity(UUID tenantId, String type) {
|
||||
this.tenantId = tenantId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlarmType toData() {
|
||||
AlarmType alarmType = new AlarmType();
|
||||
alarmType.setTenantId(TenantId.fromUUID(tenantId));
|
||||
alarmType.setType(type);
|
||||
return alarmType;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.dao.sql.alarm;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.thingsboard.server.dao.model.sql.AlarmTypeCompositeKey;
|
||||
import org.thingsboard.server.dao.model.sql.AlarmTypeEntity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface AlarmTypeRepository extends JpaRepository<AlarmTypeEntity, AlarmTypeCompositeKey> {
|
||||
|
||||
Page<AlarmTypeEntity> findByTenantId(UUID tenantId, Pageable pageable);
|
||||
|
||||
}
|
||||
@ -22,7 +22,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmComment;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmCommentInfo;
|
||||
import org.thingsboard.server.common.data.id.AlarmId;
|
||||
@ -93,9 +92,4 @@ public class JpaAlarmCommentDao extends JpaPartitionedAbstractDao<AlarmCommentEn
|
||||
return alarmCommentRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ALARM_COMMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.thingsboard.common.util.JacksonUtil;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.alarm.Alarm;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmApiCallResult;
|
||||
@ -563,9 +562,4 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
|
||||
return EntityType.ALARM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ALARM;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* Copyright © 2016-2024 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.dao.sql.alarm;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.alarm.AlarmType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.dao.DaoUtil;
|
||||
import org.thingsboard.server.dao.TenantEntityDao;
|
||||
import org.thingsboard.server.dao.util.SqlDao;
|
||||
|
||||
@Component
|
||||
@SqlDao
|
||||
public class JpaAlarmTypeDao implements TenantEntityDao<AlarmType> {
|
||||
|
||||
@Autowired
|
||||
private AlarmTypeRepository alarmTypeRepository;
|
||||
|
||||
@Override
|
||||
public PageData<AlarmType> findAllByTenantId(TenantId tenantId, PageLink pageLink) {
|
||||
return DaoUtil.toPageData(alarmTypeRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink, "tenantId", "type")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ALARM_TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,6 @@ package org.thingsboard.server.dao.sql.alarm;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.alarm.EntityAlarm;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -38,9 +37,4 @@ public class JpaEntityAlarmDao implements TenantEntityDao<EntityAlarm> {
|
||||
return DaoUtil.toPageData(entityAlarmRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink, "entityId", "alarmId")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ENTITY_ALARM;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.asset.Asset;
|
||||
import org.thingsboard.server.common.data.asset.AssetInfo;
|
||||
import org.thingsboard.server.common.data.edqs.fields.AssetFields;
|
||||
@ -285,9 +284,4 @@ public class JpaAssetDao extends JpaAbstractDao<AssetEntity, Asset> implements A
|
||||
return EntityType.ASSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ASSET;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.asset.AssetProfile;
|
||||
import org.thingsboard.server.common.data.asset.AssetProfileInfo;
|
||||
import org.thingsboard.server.common.data.edqs.fields.AssetProfileFields;
|
||||
@ -157,9 +156,4 @@ public class JpaAssetProfileDao extends JpaAbstractDao<AssetProfileEntity, Asset
|
||||
return EntityType.ASSET_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ASSET_PROFILE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.Customer;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.CustomerFields;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -123,9 +122,4 @@ public class JpaCustomerDao extends JpaAbstractDao<CustomerEntity, Customer> imp
|
||||
return EntityType.CUSTOMER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.CUSTOMER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.Dashboard;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.DashboardFields;
|
||||
import org.thingsboard.server.common.data.id.DashboardId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -108,9 +107,4 @@ public class JpaDashboardDao extends JpaAbstractDao<DashboardEntity, Dashboard>
|
||||
return EntityType.DASHBOARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.DASHBOARD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,6 @@ import org.thingsboard.server.common.data.DeviceProfileInfo;
|
||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.edqs.fields.DeviceProfileFields;
|
||||
import org.thingsboard.server.common.data.edqs.fields.GenericFields;
|
||||
import org.thingsboard.server.dao.ExportableEntityRepository;
|
||||
import org.thingsboard.server.dao.model.sql.DeviceProfileEntity;
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -76,9 +75,4 @@ public class JpaDeviceCredentialsDao extends JpaAbstractDao<DeviceCredentialsEnt
|
||||
return DaoUtil.toPageData(deviceCredentialsRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.DEVICE_CREDENTIALS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ import org.thingsboard.server.common.data.DeviceInfoFilter;
|
||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.edqs.fields.DeviceFields;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
@ -300,9 +299,4 @@ public class JpaDeviceDao extends JpaAbstractDao<DeviceEntity, Device> implement
|
||||
return EntityType.DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.DEVICE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,7 +25,6 @@ import org.thingsboard.server.common.data.DeviceProfileInfo;
|
||||
import org.thingsboard.server.common.data.DeviceTransportType;
|
||||
import org.thingsboard.server.common.data.EntityInfo;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.StringUtils;
|
||||
import org.thingsboard.server.common.data.edqs.fields.DeviceProfileFields;
|
||||
import org.thingsboard.server.common.data.id.DeviceProfileId;
|
||||
@ -175,9 +174,4 @@ public class JpaDeviceProfileDao extends JpaAbstractDao<DeviceProfileEntity, Dev
|
||||
return EntityType.DEVICE_PROFILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.DEVICE_PROFILE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edge.Edge;
|
||||
import org.thingsboard.server.common.data.edge.EdgeInfo;
|
||||
import org.thingsboard.server.common.data.edqs.fields.EdgeFields;
|
||||
@ -237,9 +236,4 @@ public class JpaEdgeDao extends JpaAbstractDao<EdgeEntity, Edge> implements Edge
|
||||
return EntityType.EDGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.EDGE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.thingsboard.server.common.data.edqs.fields.EntityViewFields;
|
||||
import org.thingsboard.server.common.data.edqs.fields.GenericFields;
|
||||
import org.thingsboard.server.dao.ExportableEntityRepository;
|
||||
import org.thingsboard.server.dao.model.sql.EntityViewEntity;
|
||||
import org.thingsboard.server.dao.model.sql.EntityViewInfoEntity;
|
||||
|
||||
@ -25,7 +25,6 @@ import org.thingsboard.server.common.data.EntitySubtype;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.EntityView;
|
||||
import org.thingsboard.server.common.data.EntityViewInfo;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.EntityViewFields;
|
||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -236,9 +235,4 @@ public class JpaEntityViewDao extends JpaAbstractDao<EntityViewEntity, EntityVie
|
||||
return EntityType.ENTITY_VIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ENTITY_VIEW;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.NotificationRuleId;
|
||||
import org.thingsboard.server.common.data.id.NotificationTargetId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -123,9 +122,4 @@ public class JpaNotificationRuleDao extends JpaAbstractDao<NotificationRuleEntit
|
||||
return EntityType.NOTIFICATION_RULE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.NOTIFICATION_RULE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.NotificationTargetId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.notification.NotificationType;
|
||||
@ -122,9 +121,4 @@ public class JpaNotificationTargetDao extends JpaAbstractDao<NotificationTargetE
|
||||
return EntityType.NOTIFICATION_TARGET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.NOTIFICATION_TARGET;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.NotificationTemplateId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.notification.NotificationType;
|
||||
@ -100,9 +99,4 @@ public class JpaNotificationTemplateDao extends JpaAbstractDao<NotificationTempl
|
||||
return EntityType.NOTIFICATION_TEMPLATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.NOTIFICATION_TEMPLATE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.OtaPackage;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -69,9 +68,4 @@ public class JpaOtaPackageDao extends JpaAbstractDao<OtaPackageEntity, OtaPackag
|
||||
return EntityType.OTA_PACKAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.OTA_PACKAGE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.DataConstants;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
@ -99,9 +98,4 @@ public class JpaQueueDao extends JpaAbstractDao<QueueEntity, Queue> implements Q
|
||||
return EntityType.QUEUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.QUEUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.QueueStatsFields;
|
||||
import org.thingsboard.server.common.data.id.QueueStatsId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -67,11 +66,6 @@ public class JpaQueueStatsDao extends JpaAbstractDao<QueueStatsEntity, QueueStat
|
||||
return DaoUtil.toPageData(queueStatsRepository.findByTenantId(tenantId.getId(), pageLink.getTextSearch(), DaoUtil.toPageable(pageLink)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.QUEUE_STATS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByTenantId(TenantId tenantId) {
|
||||
queueStatsRepository.deleteByTenantId(tenantId.getId());
|
||||
|
||||
@ -19,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.ResourceSubType;
|
||||
import org.thingsboard.server.common.data.ResourceType;
|
||||
import org.thingsboard.server.common.data.TbResource;
|
||||
@ -147,9 +146,4 @@ public class JpaTbResourceDao extends JpaAbstractDao<TbResourceEntity, TbResourc
|
||||
return EntityType.TB_RESOURCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.RESOURCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -86,9 +85,4 @@ public class JpaRpcDao extends JpaAbstractDao<RpcEntity, Rpc> implements RpcDao,
|
||||
return EntityType.RPC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.RPC;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.RuleChainFields;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -152,9 +151,4 @@ public class JpaRuleChainDao extends JpaAbstractDao<RuleChainEntity, RuleChain>
|
||||
return EntityType.RULE_CHAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.RULE_CHAIN;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.RuleNodeId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -118,9 +117,4 @@ public class JpaRuleNodeDao extends JpaAbstractDao<RuleNodeEntity, RuleNode> imp
|
||||
return EntityType.RULE_NODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.RULE_NODE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.thingsboard.server.common.data.AdminSettings;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
@ -78,9 +77,4 @@ public class JpaAdminSettingsDao extends JpaAbstractDao<AdminSettingsEntity, Adm
|
||||
return DaoUtil.toPageData(adminSettingsRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.ADMIN_SETTINGS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ApiUsageState;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.ApiUsageStateFields;
|
||||
import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
@ -93,9 +92,4 @@ public class JpaApiUsageStateDao extends JpaAbstractDao<ApiUsageStateEntity, Api
|
||||
return EntityType.API_USAGE_STATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.API_USAGE_STATE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ package org.thingsboard.server.dao.sql.user;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.id.UserId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -73,9 +72,4 @@ public class JpaUserAuthSettingsDao extends JpaAbstractDao<UserAuthSettingsEntit
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.USER_AUTH_SETTINGS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ package org.thingsboard.server.dao.sql.user;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.id.UserId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -93,9 +92,4 @@ public class JpaUserCredentialsDao extends JpaAbstractDao<UserCredentialsEntity,
|
||||
return DaoUtil.toPageData(userCredentialsRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.USER_CREDENTIALS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.User;
|
||||
import org.thingsboard.server.common.data.edqs.fields.UserFields;
|
||||
import org.thingsboard.server.common.data.id.CustomerId;
|
||||
@ -157,9 +156,4 @@ public class JpaUserDao extends JpaAbstractDao<UserEntity, User> implements User
|
||||
return EntityType.USER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.USER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ package org.thingsboard.server.dao.sql.user;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.id.UserId;
|
||||
import org.thingsboard.server.common.data.page.PageData;
|
||||
@ -74,9 +73,4 @@ public class JpaUserSettingsDao implements UserSettingsDao, TenantEntityDao<User
|
||||
return DaoUtil.toPageData(userSettingsRepository.findByTenantId(tenantId.getId(), DaoUtil.toPageable(pageLink)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.USER_SETTINGS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.WidgetTypeFields;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.id.WidgetTypeId;
|
||||
@ -274,9 +273,4 @@ public class JpaWidgetTypeDao extends JpaAbstractDao<WidgetTypeDetailsEntity, Wi
|
||||
return EntityType.WIDGET_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.WIDGET_TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.data.domain.Limit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.edqs.fields.EntityFields;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.id.WidgetsBundleId;
|
||||
@ -177,9 +176,4 @@ public class JpaWidgetsBundleDao extends JpaAbstractDao<WidgetsBundleEntity, Wid
|
||||
return EntityType.WIDGETS_BUNDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType getType() {
|
||||
return ObjectType.WIDGETS_BUNDLE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -21,31 +21,16 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.thingsboard.server.common.data.EntityType;
|
||||
import org.thingsboard.server.common.data.ObjectType;
|
||||
import org.thingsboard.server.common.data.id.TenantId;
|
||||
import org.thingsboard.server.common.data.page.PageLink;
|
||||
import org.thingsboard.server.dao.Dao;
|
||||
import org.thingsboard.server.dao.TenantEntityDao;
|
||||
import org.thingsboard.server.dao.entity.EntityDaoRegistry;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
import static org.thingsboard.server.common.data.ObjectType.ATTRIBUTE_KV;
|
||||
import static org.thingsboard.server.common.data.ObjectType.AUDIT_LOG;
|
||||
import static org.thingsboard.server.common.data.ObjectType.EVENT;
|
||||
import static org.thingsboard.server.common.data.ObjectType.LATEST_TS_KV;
|
||||
import static org.thingsboard.server.common.data.ObjectType.OAUTH2_CLIENT;
|
||||
import static org.thingsboard.server.common.data.ObjectType.OAUTH2_DOMAIN;
|
||||
import static org.thingsboard.server.common.data.ObjectType.OAUTH2_MOBILE;
|
||||
import static org.thingsboard.server.common.data.ObjectType.RELATION;
|
||||
import static org.thingsboard.server.common.data.ObjectType.TENANT;
|
||||
import static org.thingsboard.server.common.data.ObjectType.TENANT_PROFILE;
|
||||
|
||||
@Slf4j
|
||||
@DaoSqlTest
|
||||
@ -103,20 +88,4 @@ public class EntityDaoRegistryTest extends AbstractServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllTenantEntityDaos_whenFindAllByTenantId_thenOk() {
|
||||
Set<ObjectType> ignored = EnumSet.of(TENANT, TENANT_PROFILE, RELATION, EVENT, ATTRIBUTE_KV, LATEST_TS_KV, AUDIT_LOG,
|
||||
OAUTH2_CLIENT, OAUTH2_DOMAIN, OAUTH2_MOBILE);
|
||||
for (ObjectType type : ObjectType.values()) {
|
||||
if (ignored.contains(type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TenantEntityDao<?> dao = assertDoesNotThrow(() -> entityDaoRegistry.getTenantEntityDao(type));
|
||||
assertDoesNotThrow(() -> {
|
||||
dao.findAllByTenantId(tenantId, new PageLink(100));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
<logger name="org.thingsboard.server" level="INFO"/>
|
||||
<logger name="org.apache.kafka.common.utils.AppInfoParser" level="WARN"/>
|
||||
<logger name="org.apache.kafka.clients" level="WARN"/>
|
||||
<!-- <logger name="org.thingsboard.server.service.queue" level="TRACE" />-->
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
|
||||
@ -69,14 +69,14 @@ import java.util.UUID;
|
||||
@Configuration
|
||||
@ComponentScan({"org.thingsboard.server.edqs.repo", "org.thingsboard.server.edqs.util"})
|
||||
@EntityScan("org.thingsboard.server.edqs")
|
||||
@TestPropertySource(locations = {"classpath:edq-test.properties"})
|
||||
@TestPropertySource(locations = {"classpath:edqs-test.properties"})
|
||||
@TestExecutionListeners({
|
||||
DependencyInjectionTestExecutionListener.class,
|
||||
DirtiesContextTestExecutionListener.class})
|
||||
public abstract class AbstractEDQTest {
|
||||
|
||||
@Autowired
|
||||
protected InMemoryEdqRepository repository;
|
||||
protected DefaultEdqsRepository repository;
|
||||
@Autowired
|
||||
protected EdqsConverter edqsConverter;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user