Improve clock sequence range configuration
[lgpl/argeo-commons.git] / org.argeo.api.uuid / src / org / argeo / api / uuid / ConcurrentUuidFactory.java
index 6debd83b803426453c9e56b1594b6793bcaf6dcb..264e047063ac0872af99f1fc8b0adeba0530aaa3 100644 (file)
@@ -16,20 +16,20 @@ import java.util.UUID;
  * 
  * @see https://datatracker.ietf.org/doc/html/rfc4122
  */
-public class ConcurrentUuidFactory extends AbstractAsyncUuidFactory {
+public class ConcurrentUuidFactory extends AbstractAsyncUuidFactory implements TypedUuidFactory {
        private final static Logger logger = System.getLogger(ConcurrentUuidFactory.class.getName());
 
-       public ConcurrentUuidFactory(byte[] nodeId) {
-               this(nodeId, 0);
+       public ConcurrentUuidFactory(long initialClockRange, byte[] nodeId) {
+               this(initialClockRange, nodeId, 0);
        }
 
-       public ConcurrentUuidFactory(byte[] nodeId, int offset) {
+       public ConcurrentUuidFactory(long initialClockRange, byte[] nodeId, int offset) {
                Objects.requireNonNull(nodeId);
                if (offset + 6 > nodeId.length)
                        throw new IllegalArgumentException("Offset too big: " + offset);
                byte[] defaultNodeId = toNodeIdBytes(nodeId, offset);
                long nodeIdBase = NodeIdSupplier.toNodeIdBase(defaultNodeId);
-               setNodeIdSupplier(() -> nodeIdBase);
+               setNodeIdSupplier(() -> nodeIdBase, initialClockRange);
        }
 
        /**
@@ -60,7 +60,7 @@ public class ConcurrentUuidFactory extends AbstractAsyncUuidFactory {
        }
 
        @Override
-       protected SecureRandom newSecureRandom() {
+       protected SecureRandom createSecureRandom() {
                SecureRandom secureRandom;
                try {
                        secureRandom = SecureRandom.getInstance("DRBG",