Commit 0f26bb48948a601db374a01f966c1d8ba59151a1
Committed by
Andrew Shvayka
1 parent
bc2d0452
fixed cycle api usage state update
Showing
2 changed files
with
13 additions
and
3 deletions
application/src/main/java/org/thingsboard/server/service/apiusage/DefaultTbApiUsageStateService.java
... | ... | @@ -343,7 +343,15 @@ public class DefaultTbApiUsageStateService implements TbApiUsageStateService { |
343 | 343 | long now = System.currentTimeMillis(); |
344 | 344 | myTenantStates.values().forEach(state -> { |
345 | 345 | if ((state.getNextCycleTs() > now) && (state.getNextCycleTs() - now < TimeUnit.HOURS.toMillis(1))) { |
346 | + TenantId tenantId = state.getTenantId(); | |
346 | 347 | state.setCycles(state.getNextCycleTs(), SchedulerUtils.getStartOfNextNextMonth()); |
348 | + ToUsageStatsServiceMsg.Builder msg = ToUsageStatsServiceMsg.newBuilder(); | |
349 | + msg.setTenantIdMSB(tenantId.getId().getMostSignificantBits()); | |
350 | + msg.setTenantIdLSB(tenantId.getId().getLeastSignificantBits()); | |
351 | + for (ApiUsageRecordKey key : ApiUsageRecordKey.values()) { | |
352 | + msg.addValues(UsageStatsKVProto.newBuilder().setKey(key.name()).setValue(0).build()); | |
353 | + } | |
354 | + process(new TbProtoQueueMsg<>(UUID.randomUUID(), msg.build()), TbCallback.EMPTY); | |
347 | 355 | } |
348 | 356 | }); |
349 | 357 | } finally { | ... | ... |
... | ... | @@ -195,9 +195,11 @@ public class HashPartitionService implements PartitionService { |
195 | 195 | if (current.getServiceTypesList().contains(serviceType.name())) { |
196 | 196 | result.add(current.getServiceId()); |
197 | 197 | } |
198 | - for (ServiceInfo serviceInfo : currentOtherServices) { | |
199 | - if (serviceInfo.getServiceTypesList().contains(serviceType.name())) { | |
200 | - result.add(serviceInfo.getServiceId()); | |
198 | + if (currentOtherServices != null) { | |
199 | + for (ServiceInfo serviceInfo : currentOtherServices) { | |
200 | + if (serviceInfo.getServiceTypesList().contains(serviceType.name())) { | |
201 | + result.add(serviceInfo.getServiceId()); | |
202 | + } | |
201 | 203 | } |
202 | 204 | } |
203 | 205 | return result; | ... | ... |