Rewrite for clarity

This commit is contained in:
Andrii Shvaika 2024-02-16 15:57:50 +02:00
parent 724e95975a
commit 45443d98fc

View File

@ -225,33 +225,33 @@ public class HashPartitionService implements PartitionService {
boolean isManaged;
Set<UUID> assignedTenantProfiles = serviceInfoProvider.getAssignedTenantProfiles();
if (assignedTenantProfiles.isEmpty()) { // if this is regular rule engine
if (tenantId.isSysTenantId()) {
isManaged = true;
boolean isRegular = assignedTenantProfiles.isEmpty();
if (tenantId.isSysTenantId()) {
// All system queues are always processed on regular rule engines.
return isRegular;
}
TenantRoutingInfo routingInfo = getRoutingInfo(tenantId);
if (isRegular) {
if (routingInfo.isIsolated()) {
isManaged = hasDedicatedService(routingInfo.getProfileId());
} else {
TenantRoutingInfo routingInfo = getRoutingInfo(tenantId);
if (routingInfo.isIsolated()) {
isManaged = CollectionsUtil.isEmpty(responsibleServices.get(routingInfo.getProfileId()));
} else {
isManaged = true;
}
isManaged = true;
}
} else {
if (tenantId.isSysTenantId()) {
isManaged = false;
if (routingInfo.isIsolated()) {
isManaged = assignedTenantProfiles.contains(routingInfo.getProfileId().getId());
} else {
TenantRoutingInfo routingInfo = getRoutingInfo(tenantId);
if (routingInfo.isIsolated()) {
isManaged = assignedTenantProfiles.contains(routingInfo.getProfileId().getId());
} else {
isManaged = false;
}
isManaged = false;
}
}
log.trace("[{}] Tenant {} managed by this service", tenantId, isManaged ? "is" : "is not");
return isManaged;
}
private boolean hasDedicatedService(TenantProfileId profileId) {
return CollectionsUtil.isEmpty(responsibleServices.get(profileId));
}
@Override
public TopicPartitionInfo resolve(ServiceType serviceType, String queueName, TenantId tenantId, EntityId entityId) {
TenantId isolatedOrSystemTenantId = getIsolatedOrSystemTenantId(serviceType, tenantId);