added connected flag to imitator to avoid error in the test logs
This commit is contained in:
parent
fb6e152f7e
commit
ddfa1c156c
@ -79,6 +79,8 @@ public class EdgeImitator {
|
|||||||
@Getter
|
@Getter
|
||||||
private List<AbstractMessage> downlinkMsgs;
|
private List<AbstractMessage> downlinkMsgs;
|
||||||
|
|
||||||
|
private boolean connected = false;
|
||||||
|
|
||||||
public EdgeImitator(String host, int port, String routingKey, String routingSecret) throws NoSuchFieldException, IllegalAccessException {
|
public EdgeImitator(String host, int port, String routingKey, String routingSecret) throws NoSuchFieldException, IllegalAccessException {
|
||||||
edgeRpcClient = new EdgeGrpcClient();
|
edgeRpcClient = new EdgeGrpcClient();
|
||||||
messagesLatch = new CountDownLatch(0);
|
messagesLatch = new CountDownLatch(0);
|
||||||
@ -100,6 +102,7 @@ public class EdgeImitator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
connected = true;
|
||||||
edgeRpcClient.connect(routingKey, routingSecret,
|
edgeRpcClient.connect(routingKey, routingSecret,
|
||||||
this::onUplinkResponse,
|
this::onUplinkResponse,
|
||||||
this::onEdgeUpdate,
|
this::onEdgeUpdate,
|
||||||
@ -110,6 +113,7 @@ public class EdgeImitator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() throws InterruptedException {
|
public void disconnect() throws InterruptedException {
|
||||||
|
connected = false;
|
||||||
edgeRpcClient.disconnect(false);
|
edgeRpcClient.disconnect(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +135,18 @@ public class EdgeImitator {
|
|||||||
Futures.addCallback(future, new FutureCallback<>() {
|
Futures.addCallback(future, new FutureCallback<>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(@Nullable List<Void> result) {
|
public void onSuccess(@Nullable List<Void> result) {
|
||||||
DownlinkResponseMsg downlinkResponseMsg = DownlinkResponseMsg.newBuilder().setSuccess(true).build();
|
if (connected) {
|
||||||
edgeRpcClient.sendDownlinkResponseMsg(downlinkResponseMsg);
|
DownlinkResponseMsg downlinkResponseMsg = DownlinkResponseMsg.newBuilder().setSuccess(true).build();
|
||||||
|
edgeRpcClient.sendDownlinkResponseMsg(downlinkResponseMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
DownlinkResponseMsg downlinkResponseMsg = DownlinkResponseMsg.newBuilder().setSuccess(false).setErrorMsg(t.getMessage()).build();
|
if (connected) {
|
||||||
edgeRpcClient.sendDownlinkResponseMsg(downlinkResponseMsg);
|
DownlinkResponseMsg downlinkResponseMsg = DownlinkResponseMsg.newBuilder().setSuccess(false).setErrorMsg(t.getMessage()).build();
|
||||||
|
edgeRpcClient.sendDownlinkResponseMsg(downlinkResponseMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, MoreExecutors.directExecutor());
|
}, MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user