Browse Source

Use system queue with same name instead of Main when missing

pull/8988/head
ViacheslavKlimov 3 years ago
parent
commit
bfd8ff934f
  1. 6
      common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java
  2. 11
      dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantProfileServiceTest.java

6
common/queue/src/main/java/org/thingsboard/server/queue/discovery/HashPartitionService.java

@ -186,7 +186,8 @@ public class HashPartitionService implements PartitionService {
TenantId isolatedOrSystemTenantId = getIsolatedOrSystemTenantId(serviceType, tenantId);
QueueKey queueKey = new QueueKey(serviceType, queueName, isolatedOrSystemTenantId);
if (!partitionSizesMap.containsKey(queueKey)) {
queueKey = new QueueKey(serviceType, isolatedOrSystemTenantId);
// TODO: fallback to Main in case no system queue
queueKey = new QueueKey(serviceType, queueName, TenantId.SYS_TENANT_ID);
}
return resolve(queueKey, entityId);
}
@ -207,6 +208,9 @@ public class HashPartitionService implements PartitionService {
.putLong(entityId.getId().getLeastSignificantBits()).hash().asInt();
Integer partitionSize = partitionSizesMap.get(queueKey);
// if (partitionSize == null) {
// throw new IllegalStateException("Can't get partition ")
// }
int partition = Math.abs(hash % partitionSize);
return buildTopicPartitionInfo(queueKey, partition);

11
dao/src/test/java/org/thingsboard/server/dao/service/BaseTenantProfileServiceTest.java

@ -187,17 +187,6 @@ public abstract class BaseTenantProfileServiceTest extends AbstractServiceTest {
});
}
@Test
public void testSaveSameTenantProfileWithDifferentIsolatedTbRuleEngine() {
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");
TenantProfile savedTenantProfile = tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, tenantProfile);
savedTenantProfile.setIsolatedTbRuleEngine(true);
addMainQueueConfig(savedTenantProfile);
Assertions.assertThrows(DataValidationException.class, () -> {
tenantProfileService.saveTenantProfile(TenantId.SYS_TENANT_ID, savedTenantProfile);
});
}
@Test
public void testDeleteTenantProfileWithExistingTenant() {
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");

Loading…
Cancel
Save