Removed redundant lock
This commit is contained in:
parent
00c3e3ebeb
commit
9af40455bb
@ -92,7 +92,6 @@ import java.util.stream.Collectors;
|
|||||||
public final class EdgeGrpcSession implements Closeable {
|
public final class EdgeGrpcSession implements Closeable {
|
||||||
|
|
||||||
private static final ReentrantLock downlinkMsgLock = new ReentrantLock();
|
private static final ReentrantLock downlinkMsgLock = new ReentrantLock();
|
||||||
private static final ReentrantLock downlinkMsgsPackLock = new ReentrantLock();
|
|
||||||
|
|
||||||
private static final String QUEUE_START_TS_ATTR_KEY = "queueStartTs";
|
private static final String QUEUE_START_TS_ATTR_KEY = "queueStartTs";
|
||||||
|
|
||||||
@ -390,15 +389,15 @@ public final class EdgeGrpcSession implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ListenableFuture<Void> sendDownlinkMsgsPack(List<DownlinkMsg> downlinkMsgsPack) {
|
private ListenableFuture<Void> sendDownlinkMsgsPack(List<DownlinkMsg> downlinkMsgsPack) {
|
||||||
|
if (sendDownlinkMsgsFuture != null && !sendDownlinkMsgsFuture.isDone()) {
|
||||||
|
String erroMsg = "[" + this.sessionId + "] Previous send downdlink future was not properly completed, stopping it now";
|
||||||
|
log.error(erroMsg);
|
||||||
|
sendDownlinkMsgsFuture.setException(new RuntimeException(erroMsg));
|
||||||
|
}
|
||||||
sendDownlinkMsgsFuture = SettableFuture.create();
|
sendDownlinkMsgsFuture = SettableFuture.create();
|
||||||
downlinkMsgsPackLock.lock();
|
|
||||||
try {
|
|
||||||
pendingMsgsMap.clear();
|
pendingMsgsMap.clear();
|
||||||
downlinkMsgsPack.forEach(msg -> pendingMsgsMap.put(msg.getDownlinkMsgId(), msg));
|
downlinkMsgsPack.forEach(msg -> pendingMsgsMap.put(msg.getDownlinkMsgId(), msg));
|
||||||
scheduleDownlinkMsgsPackSend(true);
|
scheduleDownlinkMsgsPackSend(true);
|
||||||
} finally {
|
|
||||||
downlinkMsgsPackLock.unlock();
|
|
||||||
}
|
|
||||||
return sendDownlinkMsgsFuture;
|
return sendDownlinkMsgsFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@ import org.thingsboard.server.service.edge.rpc.fetch.TenantWidgetsBundlesEdgeEve
|
|||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
public class EdgeSyncCursor {
|
public class EdgeSyncCursor {
|
||||||
|
|
||||||
@ -59,13 +60,12 @@ public class EdgeSyncCursor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EdgeEventFetcher getNext() {
|
public EdgeEventFetcher getNext() {
|
||||||
if (hasNext()) {
|
if (!hasNext()) {
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
EdgeEventFetcher edgeEventFetcher = fetchers.get(currentIdx);
|
EdgeEventFetcher edgeEventFetcher = fetchers.get(currentIdx);
|
||||||
currentIdx++;
|
currentIdx++;
|
||||||
return edgeEventFetcher;
|
return edgeEventFetcher;
|
||||||
} else {
|
|
||||||
throw new IndexOutOfBoundsException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentIdx() {
|
public int getCurrentIdx() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user