Use system queue with same name instead of Main when missing

This commit is contained in:
ViacheslavKlimov 2023-07-19 16:39:41 +03:00
parent 2fef3858a3
commit bfd8ff934f
2 changed files with 5 additions and 12 deletions

View File

@ -186,7 +186,8 @@ public class HashPartitionService implements PartitionService {
TenantId isolatedOrSystemTenantId = getIsolatedOrSystemTenantId(serviceType, tenantId); TenantId isolatedOrSystemTenantId = getIsolatedOrSystemTenantId(serviceType, tenantId);
QueueKey queueKey = new QueueKey(serviceType, queueName, isolatedOrSystemTenantId); QueueKey queueKey = new QueueKey(serviceType, queueName, isolatedOrSystemTenantId);
if (!partitionSizesMap.containsKey(queueKey)) { 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); return resolve(queueKey, entityId);
} }
@ -207,6 +208,9 @@ public class HashPartitionService implements PartitionService {
.putLong(entityId.getId().getLeastSignificantBits()).hash().asInt(); .putLong(entityId.getId().getLeastSignificantBits()).hash().asInt();
Integer partitionSize = partitionSizesMap.get(queueKey); Integer partitionSize = partitionSizesMap.get(queueKey);
// if (partitionSize == null) {
// throw new IllegalStateException("Can't get partition ")
// }
int partition = Math.abs(hash % partitionSize); int partition = Math.abs(hash % partitionSize);
return buildTopicPartitionInfo(queueKey, partition); return buildTopicPartitionInfo(queueKey, partition);

View File

@ -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 @Test
public void testDeleteTenantProfileWithExistingTenant() { public void testDeleteTenantProfileWithExistingTenant() {
TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile"); TenantProfile tenantProfile = this.createTenantProfile("Tenant Profile");