|
|
@ -343,7 +343,15 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
|
|
long now = System.currentTimeMillis(); |
|
|
long now = System.currentTimeMillis(); |
|
|
myTenantStates.values().forEach(state -> { |
|
|
myTenantStates.values().forEach(state -> { |
|
|
if ((state.getNextCycleTs() > now) && (state.getNextCycleTs() - now < TimeUnit.HOURS.toMillis(1))) { |
|
|
if ((state.getNextCycleTs() > now) && (state.getNextCycleTs() - now < TimeUnit.HOURS.toMillis(1))) { |
|
|
|
|
|
TenantId tenantId = state.getTenantId(); |
|
|
state.setCycles(state.getNextCycleTs(), SchedulerUtils.getStartOfNextNextMonth()); |
|
|
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 { |
|
|
} finally { |
|
|
|