fixed cycle api usage state update

This commit is contained in:
YevhenBondarenko 2020-12-02 10:53:57 +02:00 committed by Andrew Shvayka
parent bc2d045257
commit 0f26bb4894
2 changed files with 13 additions and 3 deletions

View File

@ -343,7 +343,15 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService {
long now = System.currentTimeMillis();
myTenantStates.values().forEach(state -> {
if ((state.getNextCycleTs() > now) && (state.getNextCycleTs() - now < TimeUnit.HOURS.toMillis(1))) {
TenantId tenantId = state.getTenantId();
state.setCycles(state.getNextCycleTs(), SchedulerUtils.getStartOfNextNextMonth());
ToUsageStatsServiceMsg.Builder msg = ToUsageStatsServiceMsg.newBuilder();
msg.setTenantIdMSB(tenantId.getId().getMostSignificantBits());
msg.setTenantIdLSB(tenantId.getId().getLeastSignificantBits());
for (ApiUsageRecordKey key : ApiUsageRecordKey.values()) {
msg.addValues(UsageStatsKVProto.newBuilder().setKey(key.name()).setValue(0).build());
}
process(new TbProtoQueueMsg<>(UUID.randomUUID(), msg.build()), TbCallback.EMPTY);
}
});
} finally {

View File

@ -195,9 +195,11 @@ public class HashPartitionService implements PartitionService {
if (current.getServiceTypesList().contains(serviceType.name())) {
result.add(current.getServiceId());
}
for (ServiceInfo serviceInfo : currentOtherServices) {
if (serviceInfo.getServiceTypesList().contains(serviceType.name())) {
result.add(serviceInfo.getServiceId());
if (currentOtherServices != null) {
for (ServiceInfo serviceInfo : currentOtherServices) {
if (serviceInfo.getServiceTypesList().contains(serviceType.name())) {
result.add(serviceInfo.getServiceId());
}
}
}
return result;