test_class.file: oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/RevisionTest.java
test_class.identifier: RevisionTest
test_case.body: @Test
      public void uniqueRevision() throws Exception {
          //Revision.setClock(new Clock.Virtual());
          final BlockingQueue<Revision> revisionQueue = Queues.newLinkedBlockingQueue();
          int noOfThreads = 60;
          final int noOfLoops = 1000;
          List<Thread> workers = new ArrayList<Thread>();
          final AtomicBoolean stop = new AtomicBoolean();
          final CountDownLatch startLatch = new CountDownLatch(1);
          final CountDownLatch stopLatch = new CountDownLatch(noOfThreads);
          for (int i = 0; i < noOfThreads; i++) {
              workers.add(new Thread(new Runnable() {
                  @Override
                  public void run() {
                      Uninterruptibles.awaitUninterruptibly(startLatch);
                      for (int j = 0; j < noOfLoops && !stop.get(); j++) {
                          revisionQueue.add(Revision.newRevision(1));
                      }
                      stopLatch.countDown();
                  }
              }));
          }
  
          final List<Revision> duplicates = Lists.newArrayList();
          final Set<Revision> seenRevs = Sets.newHashSet();
          workers.add(new Thread(new Runnable() {
              @Override
              public void run() {
                  startLatch.countDown();
  
                  while (!stop.get()) {
                      List<Revision> revs = Lists.newArrayList();
                      Queues.drainUninterruptibly(revisionQueue, revs, 5, 100, TimeUnit.MILLISECONDS);
                      record(revs);
                  }
  
                  List<Revision> revs = Lists.newArrayList();
                  revisionQueue.drainTo(revs);
                  record(revs);
              }
  
              private void record(List<Revision> revs) {
                  for (Revision rev : revs) {
                      if (!seenRevs.add(rev)) {
                          duplicates.add(rev);
                      }
                  }
  
                  if (!duplicates.isEmpty()) {
                      stop.set(true);
                  }
              }
          }));
  
          for (Thread t : workers) {
              t.start();
          }
  
          stopLatch.await();
          stop.set(true);
  
          for (Thread t : workers) {
              t.join();
          }
          assertTrue(String.format("Duplicate rev seen %s %n Seen %s", duplicates, seenRevs), duplicates.isEmpty());
      }
test_case.class_method_signature: RevisionTest.uniqueRevision()
test_case.full_signature: @Test public void uniqueRevision()
test_case.identifier: uniqueRevision
test_case.invocations: newLinkedBlockingQueue add awaitUninterruptibly get add newRevision countDown newArrayList newHashSet add countDown get newArrayList drainUninterruptibly record newArrayList drainTo record add add isEmpty set start await set join assertTrue format isEmpty
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void uniqueRevision()
focal_class.declarator: REV_STRING_APPROX_SIZE = Revision.newRevision(0).toString().length() + 2
focal_class.modifier: final static
focal_class.original_string: final static int REV_STRING_APPROX_SIZE = Revision.newRevision(0).toString().length() + 2;
focal_class.type: int
focal_class.var_name: REV_STRING_APPROX_SIZE
focal_class.declarator: SHALLOW_MEMORY_USAGE = 32
focal_class.modifier: static final
focal_class.original_string: static final int SHALLOW_MEMORY_USAGE = 32;
focal_class.type: int
focal_class.var_name: SHALLOW_MEMORY_USAGE
focal_class.declarator: lastTimestamp
focal_class.modifier: private static volatile
focal_class.original_string: private static volatile long lastTimestamp;
focal_class.type: long
focal_class.var_name: lastTimestamp
focal_class.declarator: lastRevisionTimestamp
focal_class.modifier: private static volatile
focal_class.original_string: private static volatile long lastRevisionTimestamp;
focal_class.type: long
focal_class.var_name: lastRevisionTimestamp
focal_class.declarator: lastRevisionCount
focal_class.modifier: private static volatile
focal_class.original_string: private static volatile int lastRevisionCount;
focal_class.type: int
focal_class.var_name: lastRevisionCount
focal_class.declarator: timestamp
focal_class.modifier: private final
focal_class.original_string: private final long timestamp;
focal_class.type: long
focal_class.var_name: timestamp
focal_class.declarator: counter
focal_class.modifier: private final
focal_class.original_string: private final int counter;
focal_class.type: int
focal_class.var_name: counter
focal_class.declarator: clusterId
focal_class.modifier: private final
focal_class.original_string: private final int clusterId;
focal_class.type: int
focal_class.var_name: clusterId
focal_class.declarator: branch
focal_class.modifier: private final
focal_class.original_string: private final boolean branch;
focal_class.type: boolean
focal_class.var_name: branch
focal_class.declarator: clock
focal_class.modifier: private static
focal_class.original_string: private static Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.file: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/Revision.java
focal_class.identifier: Revision
focal_class.interfaces: implements CacheValue
focal_class.class_method_signature: Revision.setClock(Clock c)
focal_class.full_signature: static void setClock(Clock c)
focal_class.identifier: setClock
focal_class.modifiers: static
focal_class.parameters: (Clock c)
focal_class.return: void
focal_class.signature: void setClock(Clock c)
focal_class.class_method_signature: Revision.resetClockToDefault()
focal_class.full_signature: static void resetClockToDefault()
focal_class.identifier: resetClockToDefault
focal_class.modifiers: static
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void resetClockToDefault()
focal_class.class_method_signature: Revision.Revision(long timestamp, int counter, int clusterId)
focal_class.full_signature: public  Revision(long timestamp, int counter, int clusterId)
focal_class.identifier: Revision
focal_class.modifiers: public
focal_class.parameters: (long timestamp, int counter, int clusterId)
focal_class.signature:  Revision(long timestamp, int counter, int clusterId)
focal_class.class_method_signature: Revision.Revision(long timestamp, int counter, int clusterId, boolean branch)
focal_class.full_signature: public  Revision(long timestamp, int counter, int clusterId, boolean branch)
focal_class.identifier: Revision
focal_class.modifiers: public
focal_class.parameters: (long timestamp, int counter, int clusterId, boolean branch)
focal_class.signature:  Revision(long timestamp, int counter, int clusterId, boolean branch)
focal_class.class_method_signature: Revision.compareRevisionTime(Revision other)
focal_class.full_signature:  int compareRevisionTime(Revision other)
focal_class.identifier: compareRevisionTime
focal_class.parameters: (Revision other)
focal_class.return: int
focal_class.signature: int compareRevisionTime(Revision other)
focal_class.class_method_signature: Revision.compareRevisionTimeThenClusterId(Revision other)
focal_class.full_signature:  int compareRevisionTimeThenClusterId(Revision other)
focal_class.identifier: compareRevisionTimeThenClusterId
focal_class.parameters: (Revision other)
focal_class.return: int
focal_class.signature: int compareRevisionTimeThenClusterId(Revision other)
focal_class.class_method_signature: Revision.compareTo(Revision other)
focal_class.full_signature:  int compareTo(Revision other)
focal_class.identifier: compareTo
focal_class.parameters: (Revision other)
focal_class.return: int
focal_class.signature: int compareTo(Revision other)
focal_class.class_method_signature: Revision.compareClusterId(Revision other)
focal_class.full_signature:  int compareClusterId(Revision other)
focal_class.identifier: compareClusterId
focal_class.parameters: (Revision other)
focal_class.return: int
focal_class.signature: int compareClusterId(Revision other)
focal_class.class_method_signature: Revision.newRevision(int clusterId)
focal_class.full_signature: static Revision newRevision(int clusterId)
focal_class.identifier: newRevision
focal_class.modifiers: static
focal_class.parameters: (int clusterId)
focal_class.return: Revision
focal_class.signature: Revision newRevision(int clusterId)
focal_class.class_method_signature: Revision.getCurrentTimestamp()
focal_class.full_signature: public static long getCurrentTimestamp()
focal_class.identifier: getCurrentTimestamp
focal_class.modifiers: public static
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getCurrentTimestamp()
focal_class.class_method_signature: Revision.getTimestampDifference(Revision r1, Revision r2)
focal_class.full_signature: public static long getTimestampDifference(Revision r1, Revision r2)
focal_class.identifier: getTimestampDifference
focal_class.modifiers: public static
focal_class.parameters: (Revision r1, Revision r2)
focal_class.return: long
focal_class.signature: long getTimestampDifference(Revision r1, Revision r2)
focal_class.class_method_signature: Revision.fromString(String rev)
focal_class.full_signature: public static Revision fromString(String rev)
focal_class.identifier: fromString
focal_class.modifiers: public static
focal_class.parameters: (String rev)
focal_class.return: Revision
focal_class.signature: Revision fromString(String rev)
focal_class.class_method_signature: Revision.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_class.class_method_signature: Revision.toStringBuilder(StringBuilder sb)
focal_class.full_signature: public StringBuilder toStringBuilder(StringBuilder sb)
focal_class.identifier: toStringBuilder
focal_class.modifiers: public
focal_class.parameters: (StringBuilder sb)
focal_class.return: StringBuilder
focal_class.signature: StringBuilder toStringBuilder(StringBuilder sb)
focal_class.class_method_signature: Revision.toReadableString()
focal_class.full_signature: public String toReadableString()
focal_class.identifier: toReadableString
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toReadableString()
focal_class.class_method_signature: Revision.getTimestamp()
focal_class.full_signature: public long getTimestamp()
focal_class.identifier: getTimestamp
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getTimestamp()
focal_class.class_method_signature: Revision.getCounter()
focal_class.full_signature: public int getCounter()
focal_class.identifier: getCounter
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getCounter()
focal_class.class_method_signature: Revision.isBranch()
focal_class.full_signature: public boolean isBranch()
focal_class.identifier: isBranch
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isBranch()
focal_class.class_method_signature: Revision.asBranchRevision()
focal_class.full_signature: public Revision asBranchRevision()
focal_class.identifier: asBranchRevision
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Revision
focal_class.signature: Revision asBranchRevision()
focal_class.class_method_signature: Revision.asTrunkRevision()
focal_class.full_signature: public Revision asTrunkRevision()
focal_class.identifier: asTrunkRevision
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: Revision
focal_class.signature: Revision asTrunkRevision()
focal_class.class_method_signature: Revision.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: Revision.equals(Object other)
focal_class.full_signature: @Override public boolean equals(Object other)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object other)
focal_class.return: boolean
focal_class.signature: boolean equals(Object other)
focal_class.class_method_signature: Revision.getClusterId()
focal_class.full_signature: public int getClusterId()
focal_class.identifier: getClusterId
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getClusterId()
focal_class.class_method_signature: Revision.getMemory()
focal_class.full_signature: @Override public int getMemory()
focal_class.identifier: getMemory
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getMemory()
focal_class.class_method_signature: Revision.toHexString(StringBuilder sb, long x)
focal_class.full_signature: private static void toHexString(StringBuilder sb, long x)
focal_class.identifier: toHexString
focal_class.modifiers: private static
focal_class.parameters: (StringBuilder sb, long x)
focal_class.return: void
focal_class.signature: void toHexString(StringBuilder sb, long x)
focal_method.body: static Revision newRevision(int clusterId) {
          long timestamp = getCurrentTimestamp();
          int c;
          synchronized (Revision.class) {
              // need to check again, because threads
              // could arrive inside the synchronized block
              // out of order
              if (timestamp < lastRevisionTimestamp) {
                  timestamp = lastRevisionTimestamp;
              }
              if (timestamp == lastRevisionTimestamp) {
                  c = ++lastRevisionCount;
              } else {
                  lastRevisionTimestamp = timestamp;
                  lastRevisionCount = c = 0;
              }
          }
          return new Revision(timestamp, c, clusterId);
      }
focal_method.class_method_signature: Revision.newRevision(int clusterId)
focal_method.full_signature: static Revision newRevision(int clusterId)
focal_method.identifier: newRevision
focal_method.invocations: getCurrentTimestamp
focal_method.modifiers: static
focal_method.parameters: (int clusterId)
focal_method.return: Revision
focal_method.signature: Revision newRevision(int clusterId)