@SuppressWarnings("unused") private TransactionId key(KahaTransactionInfo transactionInfo) { return TransactionIdConversion.convert(transactionInfo); }
break; case COMMIT: store(new KahaCommitCommand().setTransactionInfo(TransactionIdConversion.convert(txId)), false, null, null); LOG.warn("Recovered and Committing prepared XA TX: [{}]", txId); break; case ROLLBACK: store(new KahaRollbackCommand().setTransactionInfo(TransactionIdConversion.convert(txId)), false, null, null); LOG.warn("Recovered and Rolling Back prepared XA TX: [{}]", txId); break;
@SuppressWarnings("rawtypes") private List<Operation> getInflightTx(KahaTransactionInfo info) { TransactionId key = TransactionIdConversion.convert(info); List<Operation> tx; synchronized (inflightTransactions) { tx = inflightTransactions.get(key); if (tx == null) { tx = Collections.synchronizedList(new ArrayList<Operation>()); inflightTransactions.put(key, tx); } } return tx; }
private KahaTransactionInfo getTransactionInfo(TransactionId txid) { return TransactionIdConversion.convert(theStore.getTransactionIdTransformer().transform(txid)); } }
@SuppressWarnings("rawtypes") protected void process(KahaPrepareCommand command, Location location) { TransactionId key = TransactionIdConversion.convert(command.getTransactionInfo()); List<Operation> tx = null; synchronized (inflightTransactions) { tx = inflightTransactions.remove(key); if (tx != null) { preparedTransactions.put(key, tx); } } if (tx != null && !tx.isEmpty()) { indexLock.writeLock().lock(); try { for (Operation op : tx) { recordAckMessageReferenceLocation(location, op.getLocation()); } } finally { indexLock.writeLock().unlock(); } } }
@SuppressWarnings("rawtypes") protected void process(KahaRollbackCommand command, Location location) throws IOException { TransactionId key = TransactionIdConversion.convert(command.getTransactionInfo()); List<Operation> updates = null; synchronized (inflightTransactions) { updates = inflightTransactions.remove(key); if (updates == null) { updates = preparedTransactions.remove(key); } } if (key.isXATransaction() && updates != null && !updates.isEmpty()) { indexLock.writeLock().lock(); try { for (Operation op : updates) { recordAckMessageReferenceLocation(location, op.getLocation()); } } finally { indexLock.writeLock().unlock(); } } }
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); } }
@SuppressWarnings("rawtypes") protected void process(KahaCommitCommand command, final Location location, final IndexAware before) throws IOException { TransactionId key = TransactionIdConversion.convert(command.getTransactionInfo()); List<Operation> inflightTx; synchronized (inflightTransactions) {
public void persistCompletion(TransactionId txid) throws IOException { store(new KahaCommitCommand().setTransactionInfo(TransactionIdConversion.convert(multiKahaDBPersistenceAdapter.transactionIdTransformer.transform(txid)))); }
public void persistOutcome(Tx tx, TransactionId txid) throws IOException { tx.trackPrepareLocation(store(new KahaPrepareCommand().setTransactionInfo(TransactionIdConversion.convert(multiKahaDBPersistenceAdapter.transactionIdTransformer.transform(txid))))); }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
protected void doAcknowledge(ConnectionContext context, String subscriptionKey, MessageId messageId, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey); command.setMessageId(messageId.toProducerKey()); command.setTransactionInfo(ack != null ? TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId())) : null); if (ack != null && ack.isUnmatchedAck()) { command.setAck(UNMATCHED); } else { org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); } store(command, false, null, null); }
@Override public void addMessage(final ConnectionContext context, final Message message) throws IOException { final KahaAddMessageCommand command = new KahaAddMessageCommand(); command.setDestination(dest); command.setMessageId(message.getMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(message.getTransactionId()))); command.setPriority(message.getPriority()); command.setPrioritySupported(isPrioritizedMessages()); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(message); command.setMessage(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && message.isResponseRequired(), new IndexAware() { // sync add? (for async, future present from getFutureOrSequenceLong) Object possibleFuture = message.getMessageId().getFutureOrSequenceLong(); @Override public void sequenceAssignedWithIndexLocked(final long sequence) { message.getMessageId().setFutureOrSequenceLong(sequence); if (indexListener != null) { if (possibleFuture == null) { trackPendingAdd(dest, sequence); indexListener.onAdd(new IndexListener.MessageContext(context, message, new Runnable() { @Override public void run() { trackPendingAddComplete(dest, sequence); } })); } } } }, null); }
@SuppressWarnings("unused") private TransactionId key(KahaTransactionInfo transactionInfo) { return TransactionIdConversion.convert(transactionInfo); }
@SuppressWarnings("unused") private TransactionId key(KahaTransactionInfo transactionInfo) { return TransactionIdConversion.convert(transactionInfo); }
@SuppressWarnings("rawtypes") private List<Operation> getInflightTx(KahaTransactionInfo info) { TransactionId key = TransactionIdConversion.convert(info); List<Operation> tx; synchronized (inflightTransactions) { tx = inflightTransactions.get(key); if (tx == null) { tx = Collections.synchronizedList(new ArrayList<Operation>()); inflightTransactions.put(key, tx); } } return tx; }
private KahaTransactionInfo getTransactionInfo(TransactionId txid) { return TransactionIdConversion.convert(theStore.getTransactionIdTransformer().transform(txid)); } }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }
@Override public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException { KahaRemoveMessageCommand command = new KahaRemoveMessageCommand(); command.setDestination(dest); command.setMessageId(ack.getLastMessageId().toProducerKey()); command.setTransactionInfo(TransactionIdConversion.convert(transactionIdTransformer.transform(ack.getTransactionId()))); org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(ack); command.setAck(new Buffer(packet.getData(), packet.getOffset(), packet.getLength())); store(command, isEnableJournalDiskSyncs() && ack.isResponseRequired(), null, null); }