@Override public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, MessageId messageId, MessageAck ack) throws IOException { MultiKahaDBTransactionStore.this.acknowledge(transactionStore, context, (TopicMessageStore) getDelegate(), clientId, subscriptionName, messageId, ack); } };
@Override public void addMessage(ConnectionContext context, final Message send, boolean canOptimizeHint) throws IOException { MultiKahaDBTransactionStore.this.addMessage(transactionStore, context, getDelegate(), send); }
@Override public ListenableFuture<Object> asyncAddQueueMessage(ConnectionContext context, Message message, boolean canOptimizeHint) throws IOException { return MultiKahaDBTransactionStore.this.asyncAddQueueMessage(transactionStore, context, getDelegate(), message); }
private void recoverPendingLocalTransactions() throws IOException { Location location = journal.getNextLocation(null); while (location != null) { process(load(location)); location = journal.getNextLocation(location); } recoveredPendingCommit.addAll(inflightTransactions.keySet()); LOG.info("pending local transactions: " + recoveredPendingCommit); }
public void process(JournalCommand<?> command) throws IOException { switch (command.type()) { case KAHA_PREPARE_COMMAND: KahaPrepareCommand prepareCommand = (KahaPrepareCommand) command; getTx(TransactionIdConversion.convert(prepareCommand.getTransactionInfo())); break; case KAHA_COMMIT_COMMAND: KahaCommitCommand commitCommand = (KahaCommitCommand) command; removeTx(TransactionIdConversion.convert(commitCommand.getTransactionInfo())); break; case KAHA_TRACE_COMMAND: break; default: throw new IOException("Unexpected command in transaction journal: " + command); } }
@Override public void start() throws Exception { if (started.compareAndSet(false, true)) { journal = new Journal() { @Override public void cleanup() { super.cleanup(); txStoreCleanup(); } }; journal.setDirectory(getDirectory()); journal.setMaxFileLength(journalMaxFileLength); journal.setWriteBatchSize(journalWriteBatchSize); IOHelper.mkdirs(journal.getDirectory()); journal.start(); recoverPendingLocalTransactions(); store(new KahaTraceCommand().setMessage("LOADED " + new Date())); } }
Tx tx = getTx(txid); if (wasPrepared) { for (Map.Entry<TransactionStore, TransactionId> storeTx : tx.getStoresMap().entrySet()) { store.prepare(txid); persistOutcome(tx, txid); for (TransactionStore store : tx.getStores()) { store.commit(txid, true, null, null); persistCompletion(txid); removeTx(txid); if (postCommit != null) { postCommit.run();
@Override public void prepare(TransactionId txid) throws IOException { Tx tx = getTx(txid); for (TransactionStore store : tx.getStores()) { store.prepare(txid); } }
@Override public ListenableFuture<Object> asyncAddTopicMessage(ConnectionContext context, Message message) throws IOException { return MultiKahaDBTransactionStore.this.asyncAddTopicMessage(transactionStore, context, getDelegate(), message); }
public int getJournalWriteBatchSize() { return transactionStore.getJournalMaxWriteBatchSize(); }
public int getJournalMaxFileLength() { return transactionStore.getJournalMaxFileLength(); }
public void deleteAllMessages() { IOHelper.deleteChildren(getDirectory()); }
@Override public void deleteAllMessages() throws IOException { for (PersistenceAdapter persistenceAdapter : adapters) { persistenceAdapter.deleteAllMessages(); } transactionStore.deleteAllMessages(); IOHelper.deleteChildren(getDirectory()); for (Object o : destinationMap.get(new AnyDestination(new ActiveMQDestination[]{new ActiveMQQueue(">"), new ActiveMQTopic(">")}))) { if (o instanceof FilteredKahaDBPersistenceAdapter) { FilteredKahaDBPersistenceAdapter filteredKahaDBPersistenceAdapter = (FilteredKahaDBPersistenceAdapter) o; if (filteredKahaDBPersistenceAdapter.getPersistenceAdapter().getDirectory() != DEFAULT_DIRECTORY) { IOHelper.deleteChildren(filteredKahaDBPersistenceAdapter.getPersistenceAdapter().getDirectory()); } if (filteredKahaDBPersistenceAdapter.getPersistenceAdapter() instanceof KahaDBPersistenceAdapter) { KahaDBPersistenceAdapter kahaDBPersistenceAdapter = (KahaDBPersistenceAdapter) filteredKahaDBPersistenceAdapter.getPersistenceAdapter(); if (kahaDBPersistenceAdapter.getIndexDirectory() != null) { IOHelper.deleteChildren(kahaDBPersistenceAdapter.getIndexDirectory()); } } } } }
Tx tx = getTx(txid); if (wasPrepared) { for (TransactionStore store : tx.getStores()) { store.prepare(txid); persistOutcome(tx, txid); for (TransactionStore store : tx.getStores()) { store.commit(txid, true, null, null); persistCompletion(txid); removeTx(txid); if (postCommit != null) { postCommit.run();
@Override public void start() throws Exception { if (started.compareAndSet(false, true)) { journal = new Journal() { @Override public void cleanup() { super.cleanup(); txStoreCleanup(); } }; journal.setDirectory(getDirectory()); journal.setMaxFileLength(journalMaxFileLength); journal.setWriteBatchSize(journalWriteBatchSize); IOHelper.mkdirs(journal.getDirectory()); journal.start(); recoverPendingLocalTransactions(); store(new KahaTraceCommand().setMessage("LOADED " + new Date())); } }
@Override public void recover(XATransactionId xid, Message[] addedMessages, MessageAck[] acks) { try { getTx(xid).trackStore(adapter.createTransactionStore(), xid); } catch (IOException e) { LOG.error("Failed to access transaction store: " + adapter + " for prepared xa tid: " + xid, e); } listener.recover(xid, addedMessages, acks); } });
private void recoverPendingLocalTransactions() throws IOException { Location location = journal.getNextLocation(null); while (location != null) { process(load(location)); location = journal.getNextLocation(location); } recoveredPendingCommit.addAll(inflightTransactions.keySet()); LOG.info("pending local transactions: " + recoveredPendingCommit); }
public void process(JournalCommand<?> command) throws IOException { switch (command.type()) { case KAHA_PREPARE_COMMAND: KahaPrepareCommand prepareCommand = (KahaPrepareCommand) command; getTx(TransactionIdConversion.convert(prepareCommand.getTransactionInfo())); break; case KAHA_COMMIT_COMMAND: KahaCommitCommand commitCommand = (KahaCommitCommand) command; removeTx(TransactionIdConversion.convert(commitCommand.getTransactionInfo())); break; case KAHA_TRACE_COMMAND: break; default: throw new IOException("Unexpected command in transaction journal: " + command); } }
@Override public ListenableFuture<Object> asyncAddTopicMessage(ConnectionContext context, Message message, boolean canOptimizeHint) throws IOException { return MultiKahaDBTransactionStore.this.asyncAddTopicMessage(transactionStore, context, getDelegate(), message); }
public int getJournalWriteBatchSize() { return transactionStore.getJournalMaxWriteBatchSize(); }