dcapwell commented on code in PR #38:
URL: https://github.com/apache/cassandra-accord/pull/38#discussion_r1177068279


##########
accord-core/src/main/java/accord/local/CommandStores.java:
##########
@@ -65,19 +67,23 @@ CommandStores<?> create(NodeTimeService time,
         private final DataStore store;
         private final ProgressLog.Factory progressLogFactory;
         private final CommandStore.Factory shardFactory;
+        private final RandomSource random;
 
-        Supplier(NodeTimeService time, Agent agent, DataStore store, 
ProgressLog.Factory progressLogFactory, CommandStore.Factory shardFactory)
+        Supplier(NodeTimeService time, Agent agent, DataStore store, 
RandomSource random, ProgressLog.Factory progressLogFactory, 
CommandStore.Factory shardFactory)
         {
             this.time = time;
             this.agent = agent;
             this.store = store;
+            this.random = random;
             this.progressLogFactory = progressLogFactory;
             this.shardFactory = shardFactory;
         }
 
         CommandStore create(int id, RangesForEpochHolder rangesForEpoch)
         {
-            return shardFactory.create(id, time, agent, store, 
progressLogFactory, rangesForEpoch);
+            CommandStore store = shardFactory.create(id, time, agent, 
this.store, progressLogFactory, rangesForEpoch);
+            store.execute(() -> CommandStore.register(store));

Review Comment:
   Ok I hope I have a solution that works here...
   
   I added a new `register` method to `CommandStore` which `CommandStores` 
calls on init.  `CommandStore.register` defaults to this same logic and sync 
store overrides as a noop...
   
   Why did I go this route?  I need to run in the `Executor` once and have 
access to `this`, but if I do that in the constructor I could access a 
non-finalized `CommandStore`, so felt its best to do this logic outside of the 
constructor... which means I need something to trigger...
   
   This makes it so `CommandStores` doesn't know "how" we register, it only 
knows that we "need" to register...  since `CommandStores` no longer knows the 
"how" then it doesn't know this implementation detail....



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to