public LastAck getLastAck(Transaction tx, StoredDestination sd, String subscriptionKey) throws IOException { return sd.subscriptionAcks.get(tx, subscriptionKey); }
StoredDestination rc = destinations.get(tx, key); if (rc == null) {
MessageKeys get(Transaction tx, Long key) throws IOException { MessageKeys result = defaultPriorityIndex.get(tx, key); if (result == null) { result = highPriorityIndex.get(tx, key); if (result == null) { result = lowPriorityIndex.get(tx, key); lastGetPriority = LO; } else { lastGetPriority = HI; } } else { lastGetPriority = DEF; } return result; }
protected int recoverRolledBackAcks(StoredDestination sd, Transaction tx, int maxReturned, MessageRecoveryListener listener) throws Exception { int counter = 0; String id; for (Iterator<String> iterator = rolledBackAcks.iterator(); iterator.hasNext(); ) { id = iterator.next(); iterator.remove(); Long sequence = sd.messageIdIndex.get(tx, id); if (sequence != null) { if (sd.orderIndex.alreadyDispatched(sequence)) { listener.recoverMessage(loadMessage(sd.orderIndex.get(tx, sequence).location)); counter++; if (counter >= maxReturned) { break; } } else { LOG.info("rolledback ack message {} with seq {} will be picked up in future batch {}", id, sequence, sd.orderIndex.cursor); } } else { LOG.warn("Failed to locate rolled back ack message {} in {}", id, sd); } } return counter; }
/** * Adds a reference for the journal log file pointed to by the given Location value. * * To prevent log files in the journal that still contain valid data that needs to be * kept in order to allow for recovery the logs must have active references. Each Job * scheduler should ensure that the logs are accurately referenced. * * @param tx * The TX under which the update is to be performed. * @param location * The location value to update the reference count of. * * @throws IOException if an error occurs while updating the journal references table. */ protected void incrementJournalCount(Transaction tx, Location location) throws IOException { int logId = location.getDataFileId(); Integer val = metaData.getJournalRC().get(tx, logId); int refCount = val != null ? val.intValue() + 1 : 1; metaData.getJournalRC().put(tx, logId, refCount); }
/** * Updates the Job removal tracking index with the location of a remove command and the * original JobLocation entry. * * The JobLocation holds the locations in the logs where the add and update commands for * a job stored. The log file containing the remove command can only be discarded after * both the add and latest update log files have also been discarded. * * @param tx * The TX under which the update is to be performed. * @param location * The location value to reference a remove command. * @param removedJob * The original JobLocation instance that holds the add and update locations * * @throws IOException if an error occurs while updating the remove location tracker. */ protected void referenceRemovedLocation(Transaction tx, Location location, JobLocation removedJob) throws IOException { int logId = location.getDataFileId(); List<Integer> removed = this.metaData.getRemoveLocationTracker().get(tx, logId); if (removed == null) { removed = new ArrayList<Integer>(); } removed.add(removedJob.getLocation().getDataFileId()); this.metaData.getRemoveLocationTracker().put(tx, logId, removed); }
destination.subscriptions.get(tx, subscriptionKey); destination.subLocations.put( tx, subscriptionKey, checkpointSubscriptionCommand(kahaSub));
/** * Removes one reference for the Journal log file indicated in the given Location value. * * The references are used to track which log files cannot be GC'd. When the reference count * on a log file reaches zero the file id is removed from the tracker and the log will be * removed on the next check point update. * * @param tx * The TX under which the update is to be performed. * @param location * The location value to update the reference count of. * * @throws IOException if an error occurs while updating the journal references table. */ protected void decrementJournalCount(Transaction tx, Location location) throws IOException { int logId = location.getDataFileId(); Integer refCount = metaData.getJournalRC().get(tx, logId); if (refCount != null) { int refCountValue = refCount; refCountValue--; if (refCountValue <= 0) { metaData.getJournalRC().remove(tx, logId); } else { metaData.getJournalRC().put(tx, logId, refCountValue); } } }
StoredDestination rc = metadata.destinations.get(tx, key); if (rc == null) {
Long sequence = sd.messageIdIndex.get(tx, command.getMessageId());
private void updateIndex(Transaction tx, KahaRemoveMessageCommand command) throws IOException { StoredDestination sd = getStoredDestination(command.getDestination(), tx); if (!command.hasSubscriptionKey()) { // In the queue case we just remove the message from the index.. Long sequenceId = sd.messageIdIndex.remove(tx, command.getMessageId()); if (sequenceId != null) { sd.orderIndex.remove(tx, sequenceId); } } else { // In the topic case we need remove the message once it's been acked // by all the subs Long sequence = sd.messageIdIndex.get(tx, command.getMessageId()); // Make sure it's a valid message id... if (sequence != null) { String subscriptionKey = command.getSubscriptionKey(); Long prev = sd.subscriptionAcks.put(tx, subscriptionKey, sequence); // The following method handles deleting un-referenced messages. removeAckByteSequence(tx, sd, subscriptionKey, prev); // Add it to the new location set. addAckByteSequence(sd, sequence, subscriptionKey); } } }
StoredDestination sd = getStoredDestination(command.getDestination(), tx); Long id = sd.messageIdIndex.get(tx, command.getMessageId()); if (id != null) { MessageKeys previousKeys = sd.orderIndex.put(
public LastAck getLastAck(Transaction tx, StoredDestination sd, String subscriptionKey) throws IOException { return sd.subscriptionAcks.get(tx, subscriptionKey); }
public LastAck getLastAck(Transaction tx, StoredDestination sd, String subscriptionKey) throws IOException { return sd.subscriptionAcks.get(tx, subscriptionKey); }
public LastAck getLastAck(Transaction tx, StoredDestination sd, String subscriptionKey) throws IOException { return sd.subscriptionAcks.get(tx, subscriptionKey); }
MessageKeys get(Transaction tx, Long key) throws IOException { MessageKeys result = defaultPriorityIndex.get(tx, key); if (result == null) { result = highPriorityIndex.get(tx, key); if (result == null) { result = lowPriorityIndex.get(tx, key); lastGetPriority = LO; } else { lastGetPriority = HI; } } else { lastGetPriority = DEF; } return result; }
MessageKeys get(Transaction tx, Long key) throws IOException { MessageKeys result = defaultPriorityIndex.get(tx, key); if (result == null) { result = highPriorityIndex.get(tx, key); if (result == null) { result = lowPriorityIndex.get(tx, key); lastGetPriority = LO; } else { lastGetPriority = HI; } } else { lastGetPriority = DEF; } return result; }
MessageKeys get(Transaction tx, Long key) throws IOException { MessageKeys result = defaultPriorityIndex.get(tx, key); if (result == null) { result = highPriorityIndex.get(tx, key); if (result == null) { result = lowPriorityIndex.get(tx, key); lastGetPriority = LO; } else { lastGetPriority = HI; } } else { lastGetPriority = DEF; } return result; }
/** * Adds a reference for the journal log file pointed to by the given Location value. * * To prevent log files in the journal that still contain valid data that needs to be * kept in order to allow for recovery the logs must have active references. Each Job * scheduler should ensure that the logs are accurately referenced. * * @param tx * The TX under which the update is to be performed. * @param location * The location value to update the reference count of. * * @throws IOException if an error occurs while updating the journal references table. */ protected void incrementJournalCount(Transaction tx, Location location) throws IOException { int logId = location.getDataFileId(); Integer val = metaData.getJournalRC().get(tx, logId); int refCount = val != null ? val.intValue() + 1 : 1; metaData.getJournalRC().put(tx, logId, refCount); }
/** * Updates the Job removal tracking index with the location of a remove command and the * original JobLocation entry. * * The JobLocation holds the locations in the logs where the add and update commands for * a job stored. The log file containing the remove command can only be discarded after * both the add and latest update log files have also been discarded. * * @param tx * The TX under which the update is to be performed. * @param location * The location value to reference a remove command. * @param removedJob * The original JobLocation instance that holds the add and update locations * * @throws IOException if an error occurs while updating the remove location tracker. */ protected void referenceRemovedLocation(Transaction tx, Location location, JobLocation removedJob) throws IOException { int logId = location.getDataFileId(); List<Integer> removed = this.metaData.getRemoveLocationTracker().get(tx, logId); if (removed == null) { removed = new ArrayList<Integer>(); } removed.add(removedJob.getLocation().getDataFileId()); this.metaData.getRemoveLocationTracker().put(tx, logId, removed); }