Skip to content

Commit

Permalink
refactor: comments and rearrange variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosentino11 committed Oct 27, 2023
1 parent 4064718 commit 73c591d
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public class CISShadowMonitor implements Consumer<NetworkStateProvider.Connectio
.retryableExceptions(Collections.singletonList(Exception.class))
.build();

// we only need to subscribe to shadow topics once across the lifetime of this monitor
private final AtomicBoolean subscribed = new AtomicBoolean();

// we don't need to unsubscribe, because mqtt client reconnects with clean session on startup.
// instead, we can cancel current operations and block new ones on shutdown.
private final AtomicBoolean stopped = new AtomicBoolean();
Expand All @@ -104,13 +107,13 @@ public class CISShadowMonitor implements Consumer<NetworkStateProvider.Connectio

private final Object getShadowLock = new Object();
private Future<?> getShadowTask;
AtomicReference<CompletableFuture<?>> shadowGetResponseReceived = new AtomicReference<>();
AtomicReference<CompletableFuture<?>> getShadowResponseReceived = new AtomicReference<>();

private String lastVersion;

private final Supplier<Integer> mqttOperationTimeoutMillis;
private MqttClientConnection connection;
private IotShadowClient iotShadowClient;
private String lastVersion;
private final AtomicBoolean subscribed = new AtomicBoolean();
private final NetworkStateProvider networkStateProvider;
private final List<CertificateGenerator> monitoredCertificateGenerators = new CopyOnWriteArrayList<>();
private final ExecutorService executorService;
Expand Down Expand Up @@ -337,7 +340,7 @@ private void fetchCISShadowAsync() {
GET_CIS_SHADOW_RETRY_CONFIG,
() -> {
CompletableFuture<?> shadowGetResponseReceived = new CompletableFuture<>();
this.shadowGetResponseReceived.set(shadowGetResponseReceived);
this.getShadowResponseReceived.set(shadowGetResponseReceived);
publishToGetCISShadowTopic().get();
// await shadow get accepted, rejected
long waitForGetResponseTimeout =
Expand Down Expand Up @@ -407,7 +410,7 @@ private void subscribeToShadowTopics() throws InterruptedException, ExecutionExc
}

private void reportShadowReceived() {
CompletableFuture<?> shadowReceived = this.shadowGetResponseReceived.get();
CompletableFuture<?> shadowReceived = this.getShadowResponseReceived.get();
if (shadowReceived != null) {
shadowReceived.complete(null);
}
Expand Down

0 comments on commit 73c591d

Please sign in to comment.