Browse Source

replace remained tenantDao usages to tenantService

pull/5873/head
desoliture 5 years ago
parent
commit
a39b56c93c
  1. 6
      application/src/main/java/org/thingsboard/server/service/ttl/AlarmsCleanUpService.java
  2. 6
      application/src/main/java/org/thingsboard/server/service/ttl/rpc/RpcCleanUpService.java
  3. 2
      common/dao-api/src/main/java/org/thingsboard/server/dao/tenant/TenantService.java
  4. 7
      dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java

6
application/src/main/java/org/thingsboard/server/service/ttl/AlarmsCleanUpService.java

@ -32,7 +32,7 @@ import org.thingsboard.server.dao.alarm.AlarmDao;
import org.thingsboard.server.dao.alarm.AlarmService;
import org.thingsboard.server.dao.relation.RelationService;
import org.thingsboard.server.dao.tenant.TbTenantProfileCache;
import org.thingsboard.server.dao.tenant.TenantDao;
import org.thingsboard.server.dao.tenant.TenantService;
import org.thingsboard.server.queue.discovery.PartitionService;
import org.thingsboard.server.queue.util.TbCoreComponent;
import org.thingsboard.server.service.action.EntityActionService;
@ -50,7 +50,7 @@ public class AlarmsCleanUpService {
@Value("${sql.ttl.alarms.removal_batch_size}")
private Integer removalBatchSize;
private final TenantDao tenantDao;
private final TenantService tenantService;
private final AlarmDao alarmDao;
private final AlarmService alarmService;
private final RelationService relationService;
@ -64,7 +64,7 @@ public class AlarmsCleanUpService {
PageLink removalBatchRequest = new PageLink(removalBatchSize, 0 );
PageData<TenantId> tenantsIds;
do {
tenantsIds = tenantDao.findTenantsIds(tenantsBatchRequest);
tenantsIds = tenantService.findTenantsIds(tenantsBatchRequest);
for (TenantId tenantId : tenantsIds.getData()) {
if (!partitionService.resolve(ServiceType.TB_CORE, tenantId, tenantId).isMyPartition()) {
continue;

6
application/src/main/java/org/thingsboard/server/service/ttl/rpc/RpcCleanUpService.java

@ -27,7 +27,7 @@ import org.thingsboard.server.common.data.tenant.profile.DefaultTenantProfileCon
import org.thingsboard.server.common.msg.queue.ServiceType;
import org.thingsboard.server.dao.rpc.RpcDao;
import org.thingsboard.server.dao.tenant.TbTenantProfileCache;
import org.thingsboard.server.dao.tenant.TenantDao;
import org.thingsboard.server.dao.tenant.TenantService;
import org.thingsboard.server.queue.discovery.PartitionService;
import org.thingsboard.server.queue.util.TbCoreComponent;
@ -43,7 +43,7 @@ public class RpcCleanUpService {
@Value("${sql.ttl.rpc.enabled}")
private boolean ttlTaskExecutionEnabled;
private final TenantDao tenantDao;
private final TenantService tenantService;
private final PartitionService partitionService;
private final TbTenantProfileCache tenantProfileCache;
private final RpcDao rpcDao;
@ -54,7 +54,7 @@ public class RpcCleanUpService {
PageLink tenantsBatchRequest = new PageLink(10_000, 0);
PageData<TenantId> tenantsIds;
do {
tenantsIds = tenantDao.findTenantsIds(tenantsBatchRequest);
tenantsIds = tenantService.findTenantsIds(tenantsBatchRequest);
for (TenantId tenantId : tenantsIds.getData()) {
if (!partitionService.resolve(ServiceType.TB_CORE, tenantId, tenantId).isMyPartition()) {
continue;

2
common/dao-api/src/main/java/org/thingsboard/server/dao/tenant/TenantService.java

@ -39,4 +39,6 @@ public interface TenantService {
PageData<TenantInfo> findTenantInfos(PageLink pageLink);
void deleteTenants();
PageData<TenantId> findTenantsIds(PageLink pageLink);
}

7
dao/src/main/java/org/thingsboard/server/dao/tenant/TenantServiceImpl.java

@ -191,6 +191,13 @@ public class TenantServiceImpl extends AbstractEntityService implements TenantSe
tenantsRemover.removeEntities(new TenantId(EntityId.NULL_UUID), DEFAULT_TENANT_REGION);
}
@Override
public PageData<TenantId> findTenantsIds(PageLink pageLink) {
log.trace("Executing deleteTenants");
Validator.validatePageLink(pageLink);
return tenantDao.findTenantsIds(pageLink);
}
private DataValidator<Tenant> tenantValidator =
new DataValidator<Tenant>() {
@Override

Loading…
Cancel
Save