|
|
@ -221,6 +221,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void onTenantProfileUpdate(TenantProfileId tenantProfileId) { |
|
|
public void onTenantProfileUpdate(TenantProfileId tenantProfileId) { |
|
|
|
|
|
log.info("[{}] On Tenant Profile Update", tenantProfileId); |
|
|
TenantProfile tenantProfile = tenantProfileCache.get(tenantProfileId); |
|
|
TenantProfile tenantProfile = tenantProfileCache.get(tenantProfileId); |
|
|
updateLock.lock(); |
|
|
updateLock.lock(); |
|
|
try { |
|
|
try { |
|
|
@ -236,6 +237,7 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void onTenantUpdate(TenantId tenantId) { |
|
|
public void onTenantUpdate(TenantId tenantId) { |
|
|
|
|
|
log.info("[{}] On Tenant Update", tenantId); |
|
|
TenantProfile tenantProfile = tenantProfileCache.get(tenantId); |
|
|
TenantProfile tenantProfile = tenantProfileCache.get(tenantId); |
|
|
updateLock.lock(); |
|
|
updateLock.lock(); |
|
|
try { |
|
|
try { |
|
|
@ -248,16 +250,17 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void updateTenantState(TenantApiUsageState state, TenantProfile tenantProfile) { |
|
|
private void updateTenantState(TenantApiUsageState state, TenantProfile profile) { |
|
|
|
|
|
log.info("[{}] On Tenant Update.", state.getTenantId()); |
|
|
TenantProfileData oldProfileData = state.getTenantProfileData(); |
|
|
TenantProfileData oldProfileData = state.getTenantProfileData(); |
|
|
state.setTenantProfileId(tenantProfile.getId()); |
|
|
state.setTenantProfileId(profile.getId()); |
|
|
state.setTenantProfileData(tenantProfile.getProfileData()); |
|
|
state.setTenantProfileData(profile.getProfileData()); |
|
|
Map<ApiFeature, ApiUsageStateValue> result = state.checkStateUpdatedDueToThresholds(); |
|
|
Map<ApiFeature, ApiUsageStateValue> result = state.checkStateUpdatedDueToThresholds(); |
|
|
if (!result.isEmpty()) { |
|
|
if (!result.isEmpty()) { |
|
|
persistAndNotify(state, result); |
|
|
persistAndNotify(state, result); |
|
|
} |
|
|
} |
|
|
updateProfileThresholds(state.getTenantId(), state.getApiUsageState().getId(), |
|
|
updateProfileThresholds(state.getTenantId(), state.getApiUsageState().getId(), |
|
|
oldProfileData.getConfiguration(), tenantProfile.getProfileData().getConfiguration()); |
|
|
oldProfileData.getConfiguration(), profile.getProfileData().getConfiguration()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void updateProfileThresholds(TenantId tenantId, ApiUsageStateId id, |
|
|
private void updateProfileThresholds(TenantId tenantId, ApiUsageStateId id, |
|
|
|