private boolean shouldForward(JournalCommand<?> command) { boolean result = false; if (command != null) { if (command instanceof KahaRemoveMessageCommand) { result = true; } else if (command instanceof KahaCommitCommand) { KahaCommitCommand kahaCommitCommand = (KahaCommitCommand) command; if (kahaCommitCommand.hasTransactionInfo() && kahaCommitCommand.getTransactionInfo().hasXaTransactionId()) { result = true; } } } return result; }
@Override public void writePayload(KahaSubscriptionCommand object, DataOutput dataOut) throws IOException { object.writeFramed((OutputStream)dataOut); } }
public KahaSubscriptionCommand readPayload(DataInput dataIn) throws IOException { KahaSubscriptionCommand rc = new KahaSubscriptionCommand(); rc.mergeFramed((InputStream)dataIn); return rc; }
static TransactionId convert(KahaTransactionInfo transactionInfo) { if (transactionInfo.hasLocalTransactionId()) { KahaLocalTransactionId tx = transactionInfo.getLocalTransactionId(); LocalTransactionId rc = new LocalTransactionId(); rc.setConnectionId(new ConnectionId(tx.getConnectionId())); rc.setValue(tx.getTransactionId()); return rc; } else { KahaXATransactionId tx = transactionInfo.getXaTransactionId(); XATransactionId rc = new XATransactionId(); rc.setBranchQualifier(tx.getBranchQualifier().toByteArray()); rc.setGlobalTransactionId(tx.getGlobalTransactionId().toByteArray()); rc.setFormatId(tx.getFormatId()); return rc; } } }
private void doReschedule(final String jobId, long executionTime, long nextExecutionTime, int rescheduledCount) throws IOException { KahaRescheduleJobCommand update = new KahaRescheduleJobCommand(); update.setScheduler(name); update.setJobId(jobId); update.setExecutionTime(executionTime); update.setNextExecutionTime(nextExecutionTime); update.setRescheduledCount(rescheduledCount); this.store.store(update); }
static KahaTransactionInfo convertToLocal(TransactionId tx) { KahaTransactionInfo rc = new KahaTransactionInfo(); LocalTransactionId t = (LocalTransactionId) tx; KahaLocalTransactionId kahaTxId = new KahaLocalTransactionId(); kahaTxId.setConnectionId(t.getConnectionId().getValue()); kahaTxId.setTransactionId(t.getValue()); rc.setLocalTransactionId(kahaTxId); return rc; }
KahaLocation convert(Location location) { KahaLocation rc = new KahaLocation(); rc.setLogId(location.getDataFileId()); rc.setOffset(location.getOffset()); return rc; }
private void doRemoveRange(long start, long end) throws IOException { KahaRemoveScheduledJobsCommand destroy = new KahaRemoveScheduledJobsCommand(); destroy.setScheduler(name); destroy.setStartTime(start); destroy.setEndTime(end); this.store.store(destroy); }
private void doRemove(long executionTime, final String jobId) throws IOException { KahaRemoveScheduledJobCommand remove = new KahaRemoveScheduledJobCommand(); remove.setScheduler(name); remove.setJobId(jobId); remove.setNextExecutionTime(executionTime); this.store.store(remove); }
@Override public void deleteSubscription(String clientId, String subscriptionName) throws IOException { KahaSubscriptionCommand command = new KahaSubscriptionCommand(); command.setDestination(dest); command.setSubscriptionKey(subscriptionKey(clientId, subscriptionName)); process(command); }
@Override public void removeAllMessages(ConnectionContext context) throws IOException { KahaRemoveDestinationCommand command = new KahaRemoveDestinationCommand(); command.setDestination(dest); store(command, true, null, null); }
/** * Determine whether this Destination matches the DestinationType * * @param destination * @param type * @return */ protected boolean matchType(Destination destination, KahaDestination.DestinationType type) { if (destination instanceof Topic && type.equals(KahaDestination.DestinationType.TOPIC)) { return true; } else if (destination instanceof Queue && type.equals(KahaDestination.DestinationType.QUEUE)) { return true; } return false; }
public ByteSequence toByteSequence(JournalCommand<?> data) throws IOException { int size = data.serializedSizeFramed(); DataByteArrayOutputStream os = new DataByteArrayOutputStream(size + 1); os.writeByte(data.type().getNumber()); data.writeFramed(os); return os.toByteSequence(); }
KahaLocation convert(Location location) { KahaLocation rc = new KahaLocation(); rc.setLogId(location.getDataFileId()); rc.setOffset(location.getOffset()); return rc; }
@Override public KahaSubscriptionCommand readPayload(DataInput dataIn) throws IOException { KahaSubscriptionCommand rc = new KahaSubscriptionCommand(); rc.mergeFramed((InputStream)dataIn); return rc; }
@Override public void removeAllMessages(ConnectionContext context) throws IOException { KahaRemoveDestinationCommand command = new KahaRemoveDestinationCommand(); command.setDestination(dest); process(command); }
public void writePayload(KahaSubscriptionCommand object, DataOutput dataOut) throws IOException { object.writeFramed((OutputStream)dataOut); } }