milleruntime commented on issue #2495:
URL: https://github.com/apache/accumulo/issues/2495#issuecomment-1156831152

   While working on https://github.com/apache/accumulo/pull/2780, I realized we 
need a concrete ID for Fate as well. It would be nice to have if we are going 
to release an API of fate operations. This is what I was thinking:
   <pre>
   /**
    * A strongly typed representation of a Fate Transaction ID. There are two 
representations of a
    * FateTxId. The first is a hexadecimal long. The second is a formatted 
String.
    *
    * @since 2.1.0
    */
   public class FateTxId extends AbstractId<FateTxId> {
       private FateTxId(long hexadecimal) {
           super(FateTxIdUtil.formatTid(hexadecimal));
       }
   
       /**
        * Get a FateTxId object for the provided hexadecimal number. This is 
guaranteed to be non-null.
        *
        * @param hexadecimal
        *          Fate transaction ID as a hexadecimal long
        * @return FateTxId object
        */
       public static FateTxId of(final long hexadecimal) {
           try {
               return cache.get(hexadecimal, () -> new FateTxId(hexadecimal));
           } catch (ExecutionException e) {
               throw new AssertionError(
                       "This should never happen: ID constructor should never 
return null.");
           }
       }
   
       /**
        * Get a FateTxId object for the provided formatted String. This is 
guaranteed to be non-null.
        *
        * @param formattedString
        *          Fate transaction ID as a formatted String
        * @return FateTxId object
        */
       public static FateTxId of(String formattedString) {
           if (!FateTxIdUtil.isFormatedTid(formattedString)) {
               throw new IllegalArgumentException("The string provided (" + 
formattedString +
                       ") is not formatted properly. ");
           }
           return new FateTxId(FateTxIdUtil.fromString(formattedString));
       }
   }
   </pre>


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