Browse Source

Improvements

pull/3703/head
Andrii Shvaika 6 years ago
parent
commit
f157d07c1f
  1. 11
      application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
  2. 1
      application/src/main/java/org/thingsboard/server/service/queue/DefaultTbClusterService.java
  3. 1
      application/src/main/resources/thingsboard.yml

11
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java

@ -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,

1
application/src/main/java/org/thingsboard/server/service/queue/DefaultTbClusterService.java

@ -274,6 +274,7 @@ public class DefaultTbClusterService implements TbClusterService {
TbQueueProducer<TbProtoQueueMsg<ToRuleEngineNotificationMsg>> toRuleEngineProducer = producerProvider.getRuleEngineNotificationsMsgProducer(); TbQueueProducer<TbProtoQueueMsg<ToRuleEngineNotificationMsg>> toRuleEngineProducer = producerProvider.getRuleEngineNotificationsMsgProducer();
Set<String> tbRuleEngineServices = new HashSet<>(partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE)); Set<String> tbRuleEngineServices = new HashSet<>(partitionService.getAllServiceIds(ServiceType.TB_RULE_ENGINE));
if (msg.getEntityId().getEntityType().equals(EntityType.TENANT) if (msg.getEntityId().getEntityType().equals(EntityType.TENANT)
|| msg.getEntityId().getEntityType().equals(EntityType.TENANT_PROFILE)
|| msg.getEntityId().getEntityType().equals(EntityType.DEVICE_PROFILE) || msg.getEntityId().getEntityType().equals(EntityType.DEVICE_PROFILE)
|| msg.getEntityId().getEntityType().equals(EntityType.API_USAGE_STATE)) { || msg.getEntityId().getEntityType().equals(EntityType.API_USAGE_STATE)) {
TbQueueProducer<TbProtoQueueMsg<ToCoreNotificationMsg>> toCoreNfProducer = producerProvider.getTbCoreNotificationsMsgProducer(); TbQueueProducer<TbProtoQueueMsg<ToCoreNotificationMsg>> toCoreNfProducer = producerProvider.getTbCoreNotificationsMsgProducer();

1
application/src/main/resources/thingsboard.yml

@ -766,7 +766,6 @@ metrics:
# Metrics percentiles returned by actuator for timer metrics. List of double values (divided by ,). # Metrics percentiles returned by actuator for timer metrics. List of double values (divided by ,).
percentiles: "${METRICS_TIMER_PERCENTILES:0.5}" percentiles: "${METRICS_TIMER_PERCENTILES:0.5}"
management: management:
endpoints: endpoints:
web: web:

Loading…
Cancel
Save