LogMetadata addLedger ( long ledgerId ) { Preconditions . checkState ( this . enabled , "Log is not enabled. Cannot perform any modifications on it." ) ; // Copy existing ledgers. List < LedgerMetadata > newLedgers = new ArrayList <> ( this . ledgers . size ( ) + 1 ) ; newLedgers . addAll ( this . ledgers ) ; // Create and add metadata for the new ledger. int sequence = this . ledgers . size ( ) == 0 ? INITIAL_LEDGER_SEQUENCE : this . ledgers . get ( this . ledgers . size ( ) - 1 ) . getSequence ( ) + 1 ; newLedgers . add ( new LedgerMetadata ( ledgerId , sequence ) ) ; return new LogMetadata ( this . epoch + 1 , this . enabled , Collections . unmodifiableList ( newLedgers ) , this . truncationAddress , this . updateVersion . get ( ) ) ; }
Creates a new instance of the LogMetadata class which contains an additional ledger .