1 5 package com.tc.objectserver.persistence.impl; 6 7 import com.tc.objectserver.persistence.api.PersistentSequence; 8 import com.tc.util.Assert; 9 import com.tc.util.UUID; 10 11 public class InMemorySequenceProvider implements PersistentSequence { 12 13 private final String uid = UUID.getUUID().toString(); 14 private long id = 0; 15 16 public synchronized String getUID() { 17 return uid; 18 } 19 20 public synchronized long next() { 21 return id++; 22 } 23 24 public synchronized long nextBatch(int batchSize) { 25 long lid = id; 26 id += batchSize; 27 return lid; 28 } 29 30 public synchronized void setNext(long next) { 31 Assert.assertTrue(id <= next); 32 id = next; 33 } 34 35 } 36 | Popular Tags |