bdeggleston commented on code in PR #33:
URL: https://github.com/apache/cassandra-accord/pull/33#discussion_r1103366712


##########
accord-core/src/main/java/accord/local/ImmutableState.java:
##########
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package accord.local;
+
+/**
+ * Since metadata instances are immutable, there can be several copies 
floating around in memory, all but one
+ * of which is stale. This can lead to difficult to diagnose bugs, especially 
when an implementation side cache
+ * is involved.
+ * The ImmutableState base class defines the various lifecycle stage and helps 
restrict what the user does with it,
+ * with the goal or throwing an exception as soon as an illegal usage occurs, 
instead of after.
+ *
+ * An up to date instances can have one of 2 statuses, DORMANT or ACTIVE. An 
instance is only ACTIVE in the time
+ * between when the safe store for it's current operation is created, and 
closed, and is otherwise marked DORMANT.
+ * While DORMANT, it cannot be read from or updated. This is to help detect 
leaked instances being read from or
+ * updated when they shouldn't be.
+ *
+ * Once an update has created a superseding instance, the original instance is 
marked SUPERSEDED. It can then be
+ * marked CLEANING_UP, during which time its fields can be read to assist in 
determining what has been updated.
+ * From CLEANING_UP, an instance can be marked INVALIDATED to indicate that 
any access is illegal. An instance
+ * marked SUPERSEDED can also go directly to INVALIDATED, in the case of 
intermediate updates.
+ */
+public abstract class ImmutableState

Review Comment:
   Added LiveCommand, and it's definitely an improvement in readability and 
complexity. I agree that the naming isn’t my favorite, but I don’t have any 
better ideas at the moment. I think I may prefer SafeCommand to LiveCommand 
just for consistency with SafeCommandStore. Maybe CommandReference or 
CommandRef?
   
   Although there isn’t an overarching builder for command updates, I have kept 
CommonAttributes separate which can be converted to mutable command attributes 
and updated via the boilerplate methods for setting things like route, 
partialTxn, etc, and is only converted to mutable if something needs changing. 
This seemed like a reasonable approach given the number of attributes set and 
some of the shared data, or in the case of durability, the frequency of 
updates. If anyone has strong feelings about that though, I can work on 
untangling them into some methods that return values which are passed into the 
command update.



-- 
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