public Stamp allocateTimestamp ( ) { synchronized ( this ) { Preconditions . checkState ( ! closed , "tracker closed " ) ; if ( node == null ) { Preconditions . checkState ( allocationsInProgress == 0 , "expected allocationsInProgress == 0 when node == null" ) ; Preconditions . checkState ( ! updatingZk , "unexpected concurrent ZK update" ) ; createZkNode ( getTimestamp ( ) . getTxTimestamp ( ) ) ; } allocationsInProgress ++ ; } try { Stamp ts = getTimestamp ( ) ; synchronized ( this ) { timestamps . add ( ts . getTxTimestamp ( ) ) ; } return ts ; } catch ( RuntimeException re ) { synchronized ( this ) { allocationsInProgress -- ; } throw re ; } }
Allocate a timestamp