Refactoring & renaming

This commit is contained in:
Volodymyr Babak 2020-06-22 19:00:42 +03:00
parent de11d1ce3d
commit b0e08a263a
2 changed files with 17 additions and 8 deletions

View File

@ -15,11 +15,13 @@
*/ */
package org.thingsboard.server.service.edge.rpc.init; package org.thingsboard.server.service.edge.rpc.init;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.MoreExecutors;
import io.grpc.stub.StreamObserver; import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.Dashboard; import org.thingsboard.server.common.data.Dashboard;
@ -131,10 +133,16 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
futures.add(syncAssets(ctx, edge, pushedEntityIds, outputStream)); futures.add(syncAssets(ctx, edge, pushedEntityIds, outputStream));
futures.add(syncEntityViews(ctx, edge, pushedEntityIds, outputStream)); futures.add(syncEntityViews(ctx, edge, pushedEntityIds, outputStream));
futures.add(syncDashboards(ctx, edge, pushedEntityIds, outputStream)); futures.add(syncDashboards(ctx, edge, pushedEntityIds, outputStream));
ListenableFuture<List<Void>> joinFuture = Futures.allAsList(futures); Futures.addCallback(Futures.allAsList(futures), new FutureCallback<List<Void>>() {
Futures.transform(joinFuture, result -> { @Override
public void onSuccess(@Nullable List<Void> result) {
syncRelations(ctx, edge, pushedEntityIds, outputStream); syncRelations(ctx, edge, pushedEntityIds, outputStream);
return null; }
@Override
public void onFailure(Throwable t) {
log.warn("Exception during sync entities", t);
}
}, MoreExecutors.directExecutor()); }, MoreExecutors.directExecutor());
} }

View File

@ -33,7 +33,7 @@ public class TbCoreConsumerStats {
private final AtomicInteger claimDeviceCounter = new AtomicInteger(0); private final AtomicInteger claimDeviceCounter = new AtomicInteger(0);
private final AtomicInteger deviceStateCounter = new AtomicInteger(0); private final AtomicInteger deviceStateCounter = new AtomicInteger(0);
private final AtomicInteger edgeNotificationCounter = new AtomicInteger(0); private final AtomicInteger edgeNotificationMsgCounter = new AtomicInteger(0);
private final AtomicInteger subscriptionMsgCounter = new AtomicInteger(0); private final AtomicInteger subscriptionMsgCounter = new AtomicInteger(0);
private final AtomicInteger toCoreNotificationsCounter = new AtomicInteger(0); private final AtomicInteger toCoreNotificationsCounter = new AtomicInteger(0);
@ -69,7 +69,7 @@ public class TbCoreConsumerStats {
public void log(TransportProtos.EdgeNotificationMsgProto msg) { public void log(TransportProtos.EdgeNotificationMsgProto msg) {
totalCounter.incrementAndGet(); totalCounter.incrementAndGet();
edgeNotificationCounter.incrementAndGet(); edgeNotificationMsgCounter.incrementAndGet();
} }
public void log(TransportProtos.SubscriptionMgrMsgProto msg) { public void log(TransportProtos.SubscriptionMgrMsgProto msg) {
@ -86,12 +86,13 @@ public class TbCoreConsumerStats {
int total = totalCounter.getAndSet(0); int total = totalCounter.getAndSet(0);
if (total > 0) { if (total > 0) {
log.info("Total [{}] sessionEvents [{}] getAttr [{}] subToAttr [{}] subToRpc [{}] toDevRpc [{}] subInfo [{}] claimDevice [{}]" + log.info("Total [{}] sessionEvents [{}] getAttr [{}] subToAttr [{}] subToRpc [{}] toDevRpc [{}] subInfo [{}] claimDevice [{}]" +
" deviceState [{}] subMgr [{}] coreNfs [{}]", " deviceState [{}] subMgr [{}] coreNfs [{}] edgeNfs [{}]",
total, sessionEventCounter.getAndSet(0), total, sessionEventCounter.getAndSet(0),
getAttributesCounter.getAndSet(0), subscribeToAttributesCounter.getAndSet(0), getAttributesCounter.getAndSet(0), subscribeToAttributesCounter.getAndSet(0),
subscribeToRPCCounter.getAndSet(0), toDeviceRPCCallResponseCounter.getAndSet(0), subscribeToRPCCounter.getAndSet(0), toDeviceRPCCallResponseCounter.getAndSet(0),
subscriptionInfoCounter.getAndSet(0), claimDeviceCounter.getAndSet(0) subscriptionInfoCounter.getAndSet(0), claimDeviceCounter.getAndSet(0)
, deviceStateCounter.getAndSet(0), subscriptionMsgCounter.getAndSet(0), toCoreNotificationsCounter.getAndSet(0)); , deviceStateCounter.getAndSet(0), subscriptionMsgCounter.getAndSet(0), toCoreNotificationsCounter.getAndSet(0),
edgeNotificationMsgCounter.getAndSet(0));
} }
} }