/** * <br> * Checks for holes on the transaction (a commit written but with an incomplete transaction). * <br> * This method will validate if the transaction (PREPARE/COMMIT) is complete as stated on the * COMMIT-RECORD. * <br> * For details see {@link JournalCompleteRecordTX} about how the transaction-summary is recorded. * * @param journalTransaction * @param orderedFiles * @param numberOfRecords * @return */ private boolean checkTransactionHealth(final JournalFile currentFile, final JournalTransaction journalTransaction, final List<JournalFile> orderedFiles, final int numberOfRecords) { return journalTransaction.getCounter(currentFile) == numberOfRecords; }
/** * <br> * Checks for holes on the transaction (a commit written but with an incomplete transaction). * <br> * This method will validate if the transaction (PREPARE/COMMIT) is complete as stated on the * COMMIT-RECORD. * <br> * For details see {@link JournalCompleteRecordTX} about how the transaction-summary is recorded. * * @param journalTransaction * @param orderedFiles * @param numberOfRecords * @return */ private boolean checkTransactionHealth(final JournalFile currentFile, final JournalTransaction journalTransaction, final List<JournalFile> orderedFiles, final int numberOfRecords) { return journalTransaction.getCounter(currentFile) == numberOfRecords; }
/** * @param currentFile * @param data */ public void fillNumberOfRecords(final JournalFile currentFile, final JournalInternalRecord data) { data.setNumberOfRecords(getCounter(currentFile)); }
/** * @param currentFile * @param data */ public void fillNumberOfRecords(final JournalFile currentFile, final JournalInternalRecord data) { data.setNumberOfRecords(getCounter(currentFile)); }
@Override public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadCommitRecord " + transactionID); } if (pendingTransactions.get(transactionID) != null) { // Sanity check, this should never happen ActiveMQJournalLogger.LOGGER.inconsistencyDuringCompacting(transactionID); } else { JournalTransaction newTransaction = newTransactions.remove(transactionID); if (newTransaction != null) { JournalInternalRecord commitRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.COMMIT, transactionID, null); checkSize(commitRecord.getEncodeSize()); writeEncoder(commitRecord, newTransaction.getCounter(currentFile)); newTransaction.commit(currentFile); } } }
@Override public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadCommitRecord " + transactionID); } if (pendingTransactions.get(transactionID) != null) { // Sanity check, this should never happen ActiveMQJournalLogger.LOGGER.inconsistencyDuringCompacting(transactionID); } else { JournalTransaction newTransaction = newTransactions.remove(transactionID); if (newTransaction != null) { JournalInternalRecord commitRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.COMMIT, transactionID, null); checkSize(commitRecord.getEncodeSize()); writeEncoder(commitRecord, newTransaction.getCounter(currentFile)); newTransaction.commit(currentFile); } } }
@Override public void onReadPrepareRecord(final long transactionID, final byte[] extraData, final int numberOfRecords) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadPrepareRecord " + transactionID); } if (pendingTransactions.get(transactionID) != null) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord prepareRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.PREPARE, transactionID, new ByteArrayEncoding(extraData)); checkSize(prepareRecord.getEncodeSize()); writeEncoder(prepareRecord, newTransaction.getCounter(currentFile)); newTransaction.prepare(currentFile); } }
@Override public void onReadPrepareRecord(final long transactionID, final byte[] extraData, final int numberOfRecords) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadPrepareRecord " + transactionID); } if (pendingTransactions.get(transactionID) != null) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord prepareRecord = new JournalCompleteRecordTX(TX_RECORD_TYPE.PREPARE, transactionID, new ByteArrayEncoding(extraData)); checkSize(prepareRecord.getEncodeSize()); writeEncoder(prepareRecord, newTransaction.getCounter(currentFile)); newTransaction.prepare(currentFile); } }