keith-turner commented on code in PR #4160:
URL: https://github.com/apache/accumulo/pull/4160#discussion_r1451606133


##########
core/src/main/java/org/apache/accumulo/core/fate/accumulo/FateMutatorImpl.java:
##########
@@ -132,12 +142,29 @@ public FateMutator<T> delete() {
     return this;
   }
 
+  /**

Review Comment:
   The status column is expected to exist for the lifetime of a fate operation. 
 As a start of using conditional mutations we could build something around  
always checking the status column when an update is made.  This will check that 
row is in a minimally acceptable state for making an update.  We could add more 
conditions later.
   
   Could add a method like the following to FateMutatorImpl
   
   ```java
   /**
    * Requires the status column to be set to one of the passed in statuses in 
order for an update to be made.  If no statuses are passed in, then the status 
column must be absent in order for an update to be made.
    */
    public FateMutator<T> requireStatus(TStatus ... statuses) {}
   ```
   
   With a method like the above could do the following when adding repo.
   
   ```java
         FateMutator<T> fateMutator = newMutator(tid).requireStatus(SUBMITTED, 
IN_PROGRESS);
         fateMutator.putRepo(top.map(t -> t + 1).orElse(1), repo).mutate();
   ```
   
   When adding a completely new fate tx could do the following which would 
require the status column to be absent.
   
   ```java
     @Override
     public long create() {
       long tid = RANDOM.get().nextLong() & 0x7fffffffffffffffL;
   
       
newMutator(tid).requireStatus().putStatus(TStatus.NEW).putCreateTime(System.currentTimeMillis()).mutate();
   
       return tid;
     }
   ```
   



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

Reply via email to