cleaning up some TODOs

Change-Id: Ib2380e9533ba30c6f9fdf79aed1879dbbe3589a7
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
index fc010ae..4180827 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
@@ -194,8 +194,8 @@
                                 || (linkEvent.type() == LINK_UPDATED &&
                                         linkEvent.subject().isDurable())) {
                             final LinkKey linkKey = linkKey(linkEvent.subject());
-                            Set<IntentId> intentIds = intentsByLink.get(linkKey);
                             synchronized (intentsByLink) {
+                                Set<IntentId> intentIds = intentsByLink.get(linkKey);
                                 log.debug("recompile triggered by LinkDown {} {}", linkKey, intentIds);
                                 toBeRecompiled.addAll(intentIds);
                             }
@@ -206,7 +206,6 @@
                                 linkEvent.subject().isDurable()));
                     }
                 }
-
                 delegate.triggerCompile(toBeRecompiled, !recompileOnly);
             }
         }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/HazelcastLeadershipService.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/HazelcastLeadershipService.java
index b130c13..a76eb14 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/HazelcastLeadershipService.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/impl/HazelcastLeadershipService.java
@@ -175,7 +175,7 @@
         for (Topic topic : topics.values()) {
             Leadership leadership = new Leadership(topic.topicName(),
                                                    topic.leader(),
-                                                   0L); // TODO: epoch not used
+                                                   0L);
             result.put(topic.topicName(), leadership);
         }
         return result;
diff --git a/core/store/dist/src/main/java/org/onosproject/store/core/impl/DistributedIdBlockStore.java b/core/store/dist/src/main/java/org/onosproject/store/core/impl/DistributedIdBlockStore.java
index d383118..47623f0 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/core/impl/DistributedIdBlockStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/core/impl/DistributedIdBlockStore.java
@@ -51,7 +51,6 @@
 
     @Override
     public IdBlock getIdBlock(String topic) {
-        //TODO need to persist this value across cluster failures
         Long blockBase = theInstance.getAtomicLong(topic).getAndAdd(DEFAULT_BLOCK_SIZE);
         return new IdBlock(blockBase, DEFAULT_BLOCK_SIZE);
     }
diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
index 4fc6beb..a3de72b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java
@@ -130,7 +130,6 @@
 
     private final AtomicInteger localBatchIdGen = new AtomicInteger();
 
-    // TODO: make this configurable
     private int pendingFutureTimeoutMinutes = 5;
 
     private Cache<Integer, SettableFuture<CompletedBatchOperation>> pendingFutures =
@@ -149,7 +148,6 @@
     private final ExecutorService backupExecutors =
             Executors.newSingleThreadExecutor(namedThreads("async-backups"));
 
-    // TODO make this configurable
     private boolean syncBackup = false;
 
     protected static final StoreSerializer SERIALIZER = new KryoSerializer() {
@@ -163,7 +161,6 @@
         }
     };
 
-    // TODO: make this configurable
     private static final long FLOW_RULE_STORE_TIMEOUT_MILLIS = 5000;
 
     private ReplicaInfoEventListener replicaInfoEventListener;
@@ -247,7 +244,7 @@
     }
 
 
-    // TODO: This is not a efficient operation on a distributed sharded
+    // This is not a efficient operation on a distributed sharded
     // flow store. We need to revisit the need for this operation or at least
     // make it device specific.
     @Override
@@ -267,7 +264,6 @@
 
         if (!replicaInfo.master().isPresent()) {
             log.warn("Failed to getFlowEntry: No master for {}", rule.deviceId());
-            // TODO: should we try returning from backup?
             return null;
         }
 
@@ -287,9 +283,9 @@
             Future<byte[]> responseFuture = clusterCommunicator.sendAndReceive(message, replicaInfo.master().get());
             return SERIALIZER.decode(responseFuture.get(FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
         } catch (IOException | TimeoutException | ExecutionException | InterruptedException e) {
-            // FIXME: throw a FlowStoreException
-            throw new RuntimeException(e);
+            log.warn("Unable to fetch flow store contents from {}", replicaInfo.master().get());
         }
+        return null;
     }
 
     private StoredFlowEntry getFlowEntryInternal(FlowRule rule) {
@@ -313,7 +309,6 @@
 
         if (!replicaInfo.master().isPresent()) {
             log.warn("Failed to getFlowEntries: No master for {}", deviceId);
-            // TODO: should we try returning from backup?
             return Collections.emptyList();
         }
 
@@ -333,9 +328,9 @@
             Future<byte[]> responseFuture = clusterCommunicator.sendAndReceive(message, replicaInfo.master().get());
             return SERIALIZER.decode(responseFuture.get(FLOW_RULE_STORE_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS));
         } catch (IOException | TimeoutException | ExecutionException | InterruptedException e) {
-            // FIXME: throw a FlowStoreException
-            throw new RuntimeException(e);
+            log.warn("Unable to fetch flow store contents from {}", replicaInfo.master().get());
         }
+        return null;
     }
 
     private Set<FlowEntry> getFlowEntriesInternal(DeviceId deviceId) {
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentBatchQueue.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentBatchQueue.java
index 3f52cd1..085e9b7 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentBatchQueue.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentBatchQueue.java
@@ -88,7 +88,7 @@
     private IntentBatchDelegate delegate;
     private InternalLeaderListener leaderListener = new InternalLeaderListener();
     private final Map<ApplicationId, SQueue<IntentOperations>> batchQueues
-            = Maps.newHashMap(); // FIXME make distributed?
+            = Maps.newHashMap();
     private final Set<ApplicationId> myTopics = Sets.newHashSet();
     private final Map<ApplicationId, IntentOperations> outstandingOps
             = Maps.newHashMap();
@@ -158,7 +158,7 @@
     public void addIntentOperations(IntentOperations ops) {
         checkNotNull(ops, "Intent operations cannot be null.");
         ApplicationId appId = ops.appId();
-        getQueue(appId).add(ops); // TODO consider using put here
+        getQueue(appId).add(ops);
         dispatchNextOperation(appId);
     }
 
@@ -175,7 +175,6 @@
                 log.warn("Operation {} not found", ops);
             }
             SQueue<IntentOperations> queue = batchQueues.get(appId);
-            // TODO consider alternatives to remove
             checkState(queue.remove().equals(ops),
                        "Operations are wrong.");
             outstandingOps.remove(appId);
@@ -214,7 +213,6 @@
      */
     private void leaderChanged(String topic, boolean leader) {
         ApplicationId appId = getAppId(topic);
-        //TODO we are using the event caller's thread, should we use our own?
         synchronized (this) {
             if (leader) {
                 myTopics.add(appId);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
index c353b9f..39255c8 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/HazelcastIntentStore.java
@@ -99,7 +99,6 @@
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected MetricsService metricsService;
 
-    // TODO make this configurable
     private boolean onlyLogTransitionError = true;
 
     private Timer createIntentTimer;
@@ -142,7 +141,7 @@
         getIntentTimer = createResponseTimer("getIntent");
         getIntentStateTimer = createResponseTimer("getIntentState");
 
-        // FIXME: We need a way to add serializer for intents which has been plugged-in.
+        // We need a way to add serializer for intents which has been plugged-in.
         // As a short term workaround, relax Kryo config to
         // registrationRequired=false
         super.activate();
@@ -164,7 +163,6 @@
         MapConfig intentsCfg = config.getMapConfig(INTENTS_MAP_NAME);
         intentsCfg.setAsyncBackupCount(MapConfig.MAX_BACKUP_COUNT - intentsCfg.getBackupCount());
 
-        // TODO: enable near cache, allow read from backup for this IMap
         IMap<byte[], byte[]> rawIntents = super.theInstance.getMap(INTENTS_MAP_NAME);
         intents = new SMap<>(rawIntents , super.serializer);
         intentsListenerId = intents.addEntryListener(new RemoteIntentsListener(), true);
@@ -556,7 +554,6 @@
                     }
 
                     log.trace("{} - {} -> {}", intentId, prevIntentState, newState);
-                    // TODO sanity check and log?
                 } catch (InterruptedException e) {
                     log.error("Batch write was interrupted while processing {}", op,  e);
                     failed.add(op);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
index b0ba219..5e124d0 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/link/impl/GossipLinkStore.java
@@ -164,7 +164,6 @@
         backgroundExecutors =
                 newSingleThreadScheduledExecutor(minPriority(namedThreads("link-bg-%d")));
 
-        // TODO: Make these configurable
         long initialDelaySec = 5;
         long periodSec = 5;
         // start anti-entropy thread
diff --git a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
index f0e89b6..78bc186 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/topology/impl/DistributedTopologyStore.java
@@ -48,8 +48,10 @@
 /**
  * Manages inventory of topology snapshots using trivial in-memory
  * structures implementation.
+ *
+ * Note: This component is not distributed per-se. It runs on every
+ * instance and feeds off of other distributed stores.
  */
-//FIXME: I LIE I AM NOT DISTRIBUTED
 @Component(immediate = true)
 @Service
 public class DistributedTopologyStore
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4AddressSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4AddressSerializer.java
index 0d545d4..2370ad9 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4AddressSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4AddressSerializer.java
@@ -37,7 +37,6 @@
     @Override
     public void write(Kryo kryo, Output output, Ip4Address object) {
         byte[] octs = object.toOctets();
-        // TODO: Writing (and reading) the number of octets is redundant:
         // It is always Ip4Address.BYTE_LENGTH
         output.writeInt(octs.length);
         output.writeBytes(octs);
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4PrefixSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4PrefixSerializer.java
index 695e1f7..fd42126 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4PrefixSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip4PrefixSerializer.java
@@ -39,7 +39,6 @@
     public void write(Kryo kryo, Output output,
             Ip4Prefix object) {
         byte[] octs = object.address().toOctets();
-        // TODO: Writing (and reading) the number of octets is redundant:
         // It is always Ip6Address.BYTE_LENGTH
         output.writeInt(octs.length);
         output.writeBytes(octs);
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6AddressSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6AddressSerializer.java
index 5e0e3f2..f8101f9 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6AddressSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6AddressSerializer.java
@@ -37,7 +37,6 @@
     @Override
     public void write(Kryo kryo, Output output, Ip6Address object) {
         byte[] octs = object.toOctets();
-        // TODO: Writing (and reading) the number of octets is redundant:
         // It is always Ip6Address.BYTE_LENGTH
         output.writeInt(octs.length);
         output.writeBytes(octs);
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6PrefixSerializer.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6PrefixSerializer.java
index 282683b..91ba5a2 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6PrefixSerializer.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/Ip6PrefixSerializer.java
@@ -39,7 +39,6 @@
     public void write(Kryo kryo, Output output,
             Ip6Prefix object) {
         byte[] octs = object.address().toOctets();
-        // TODO: Writing (and reading) the number of octets is redundant:
         // It is always Ip6Address.BYTE_LENGTH
         output.writeInt(octs.length);
         output.writeBytes(octs);