public <T> Response<T> packTransactionStreamResponse( RequestContext context, T response ) { final long toStartFrom = context.lastAppliedTransaction() + 1; final long toEndAt = transactionIdStore.getLastCommittedTransactionId(); TransactionStream transactions = visitor -> { // Check so that it's even worth thinking about extracting any transactions at all if ( toStartFrom > BASE_TX_ID && toStartFrom <= toEndAt ) { extractTransactions( toStartFrom, filterVisitor( visitor, toEndAt ) ); } }; return new TransactionStreamResponse<>( response, storeId.get(), transactions, ResourceReleaser.NO_OP ); }
@Override public Response<Void> fullBackup( StoreWriter writer, boolean forensics ) { String backupIdentifier = getBackupIdentifier(); try ( StoreWriter storeWriter = writer ) { logger.log( "%s: Full backup started...", backupIdentifier ); RequestContext copyStartContext = storeCopyServer.flushStoresAndStreamStoreFiles( FULL_BACKUP_CHECKPOINT_TRIGGER, storeWriter, forensics ); ResponsePacker responsePacker = new StoreCopyResponsePacker( logicalTransactionStore, transactionIdStore, logFileInformation, storeId, copyStartContext.lastAppliedTransaction() + 1, storeCopyServer.monitor() ); long optionalTransactionId = copyStartContext.lastAppliedTransaction(); return responsePacker.packTransactionStreamResponse( anonymous( optionalTransactionId ), null/*no response object*/ ); } finally { logger.log( "%s: Full backup finished.", backupIdentifier ); } }
private void writeContext( RequestContext context, ChannelBuffer targetBuffer ) { targetBuffer.writeLong( context.getEpoch() ); targetBuffer.writeInt( context.machineId() ); targetBuffer.writeInt( context.getEventIdentifier() ); long tx = context.lastAppliedTransaction(); targetBuffer.writeLong( tx ); targetBuffer.writeLong( context.getChecksum() ); }