@Override public synchronized JournalLoadInformation loadSyncOnly(JournalState syncState) throws Exception { assert syncState == JournalState.SYNCING || syncState == JournalState.SYNCING_UP_TO_DATE; return load(DummyLoader.INSTANCE, true, syncState); }
@Override public synchronized JournalLoadInformation loadInternalOnly() throws Exception { return load(DummyLoader.INSTANCE, true, null); }
@Override public synchronized JournalLoadInformation loadSyncOnly(JournalState syncState) throws Exception { assert syncState == JournalState.SYNCING || syncState == JournalState.SYNCING_UP_TO_DATE; return load(DummyLoader.INSTANCE, true, syncState); }
@Override public synchronized JournalLoadInformation loadInternalOnly() throws Exception { return load(DummyLoader.INSTANCE, true, null); }
return load(loadManager, true, null);
return load(loadManager, true, null);
private synchronized JournalLoadInformation load(final LoaderCallback loadManager, final boolean changeData, final JournalState replicationSync) throws Exception { final JournalState state = this.state; if (state == JournalState.STOPPED || state == JournalState.LOADED) { throw new IllegalStateException("Journal " + this + " must be in " + JournalState.STARTED + " state, was " + state); } if (state == replicationSync) { throw new IllegalStateException("Journal cannot be in state " + JournalState.STARTED); } // AtomicReference is used only as a reference, not as an Atomic value final AtomicReference<ByteBuffer> wholeFileBufferRef = new AtomicReference<>(); try { return load(loadManager, changeData, replicationSync, wholeFileBufferRef); } finally { final ByteBuffer wholeFileBuffer = wholeFileBufferRef.get(); if (wholeFileBuffer != null) { fileFactory.releaseDirectBuffer(wholeFileBuffer); wholeFileBufferRef.lazySet(null); } } }
private synchronized JournalLoadInformation load(final LoaderCallback loadManager, final boolean changeData, final JournalState replicationSync) throws Exception { final JournalState state = this.state; if (state == JournalState.STOPPED || state == JournalState.LOADED) { throw new IllegalStateException("Journal " + this + " must be in " + JournalState.STARTED + " state, was " + state); } if (state == replicationSync) { throw new IllegalStateException("Journal cannot be in state " + JournalState.STARTED); } // AtomicReference is used only as a reference, not as an Atomic value final AtomicReference<ByteBuffer> wholeFileBufferRef = new AtomicReference<>(); try { return load(loadManager, changeData, replicationSync, wholeFileBufferRef); } finally { final ByteBuffer wholeFileBuffer = wholeFileBufferRef.get(); if (wholeFileBuffer != null) { fileFactory.releaseDirectBuffer(wholeFileBuffer); wholeFileBufferRef.lazySet(null); } } }
private void checkJournalSize() throws Exception { JournalImpl journal = createJournal(getTestDirfile(), false); ArrayList<RecordInfo> info = new ArrayList<>(); ArrayList<PreparedTransactionInfo> txInfo = new ArrayList<>(); journal.load(info, txInfo, new TransactionFailureCallback() { @Override public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete) { } }); Assert.assertEquals(900, info.size()); }
private void setupJournal(final int journalSize, final int alignment, final int numberOfMinimalFiles) throws Exception { if (factory == null) { factory = new FakeSequentialFileFactory(alignment, true); } if (journalImpl != null) { journalImpl.stop(); } journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000); journalImpl.start(); records.clear(); transactions.clear(); journalImpl.load(records, transactions, null); }
/** * @throws Exception */ private void printJournal() throws Exception { NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getJournalDir()), 100); JournalImpl journal = new JournalImpl(ActiveMQDefaultConfiguration.getDefaultJournalFileSize(), 2, 2, 0, 0, factory, "activemq-data", "amq", 100); ArrayList<RecordInfo> records = new ArrayList<>(); ArrayList<PreparedTransactionInfo> transactions = new ArrayList<>(); journal.start(); journal.load(records, transactions, null); // System.out.println("==============================================="); // System.out.println("Journal records at the end:"); // // for (RecordInfo record : records) // { // System.out.println(record.id + ", update = " + record.isUpdate); // } journal.stop(); } }
private void setupAndLoadJournal(final int journalSize, final int alignment, final int numberOfMinimalFiles) throws Exception { if (factory == null) { factory = new FakeSequentialFileFactory(alignment, true); } if (journalImpl != null) { journalImpl.stop(); } journalImpl = new JournalImpl(journalSize, numberOfMinimalFiles, numberOfMinimalFiles, 0, 0, factory, "tt", "tt", 1000); addActiveMQComponent(journalImpl); journalImpl.start(); records.clear(); transactions.clear(); incompleteTransactions.clear(); journalImpl.load(records, transactions, new TransactionFailureCallback() { @Override public void failedTransaction(final long transactionID, final List<RecordInfo> records, final List<RecordInfo> recordsToDelete) { System.out.println("records.length = " + records.size()); incompleteTransactions.add(transactionID); } }); }
/** * Reads a journal system and returns a Map<Integer,AtomicInteger> of recordTypes and the number of records per type, * independent of being deleted or not * * @param config * @return * @throws Exception */ protected Pair<List<RecordInfo>, List<PreparedTransactionInfo>> loadMessageJournal(Configuration config) throws Exception { JournalImpl messagesJournal = null; try { SequentialFileFactory messagesFF = new NIOSequentialFileFactory(new File(getJournalDir()), null, 1); messagesJournal = new JournalImpl(config.getJournalFileSize(), config.getJournalMinFiles(), config.getJournalPoolFiles(), 0, 0, messagesFF, "activemq-data", "amq", 1); final List<RecordInfo> committedRecords = new LinkedList<>(); final List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>(); messagesJournal.start(); messagesJournal.load(committedRecords, preparedTransactions, null, false); return new Pair<>(committedRecords, preparedTransactions); } finally { try { if (messagesJournal != null) { messagesJournal.stop(); } } catch (Throwable ignored) { } } }
messagesJournal.load(records, preparedTransactions, null);
final List<PreparedTransactionInfo> preparedTransactions = new LinkedList<>(); journal.load(committedRecords, preparedTransactions, null, false);
journal.load(new LoaderCallback() {
private void reload(final String type, final String journalDir, final long numberOfRecords, final int numberOfThreads) throws Exception { JournalImpl journal = ValidateTransactionHealthTest.createJournal(type, journalDir); journal.start(); try { Loader loadTest = new Loader(numberOfRecords); journal.load(loadTest); Assert.assertEquals(numberOfRecords * numberOfThreads, loadTest.numberOfAdds); Assert.assertEquals(0, loadTest.numberOfPreparedTransactions); Assert.assertEquals(0, loadTest.numberOfUpdates); Assert.assertEquals(0, loadTest.numberOfDeletes); if (loadTest.ex != null) { throw loadTest.ex; } } finally { journal.stop(); } }
messagesJournal.load(infos, null, null);
journal.load(new LoaderCallback() {