synchronized long getNewDirectoryId ( JournalContext context ) throws UnavailableException { initialize ( context ) ; long containerId = mNextDirectoryId . getContainerId ( ) ; long sequenceNumber = mNextDirectoryId . getSequenceNumber ( ) ; long directoryId = BlockId . createBlockId ( containerId , sequenceNumber ) ; if ( sequenceNumber == BlockId . getMaxSequenceNumber ( ) ) { // No more ids in this container. Get a new container for the next id. containerId = mContainerIdGenerator . getNewContainerId ( ) ; sequenceNumber = 0 ; } else { sequenceNumber ++ ; } applyAndJournal ( context , toEntry ( containerId , sequenceNumber ) ) ; return directoryId ; }
Returns the next directory id and journals the state .