MessageKeys remove(Transaction tx, Long key) throws IOException { MessageKeys result = defaultPriorityIndex.remove(tx, key); if (result == null && highPriorityIndex!=null) { result = highPriorityIndex.remove(tx, key); if (result ==null && lowPriorityIndex!=null) { result = lowPriorityIndex.remove(tx, key); } } return result; }
private void removeJournalRCForMissingFiles(Transaction tx, Set<Integer> missing) throws IOException { List<Integer> matches = new ArrayList<Integer>(); Iterator<Entry<Integer, Integer>> references = metaData.getJournalRC().iterator(tx); while (references.hasNext()) { int dataFileId = references.next().getKey(); if (missing.contains(dataFileId)) { matches.add(dataFileId); } } for (Integer match : matches) { metaData.getJournalRC().remove(tx, match); } }
private void removeAckLocationsForSub(KahaSubscriptionCommand command, Transaction tx, StoredDestination sd, String subscriptionKey) throws IOException { if (!sd.ackPositions.isEmpty(tx)) { SequenceSet sequences = sd.ackPositions.remove(tx, subscriptionKey); if (sequences == null || sequences.isEmpty()) { return; } ArrayList<Long> unreferenced = new ArrayList<>(); for(Long sequenceId : sequences) { if(!isSequenceReferenced(tx, sd, sequenceId)) { unreferenced.add(sequenceId); } } for(Long sequenceId : unreferenced) { // Find all the entries that need to get deleted. ArrayList<Entry<Long, MessageKeys>> deletes = new ArrayList<>(); sd.orderIndex.getDeleteList(tx, deletes, sequenceId); // Do the actual deletes. for (Entry<Long, MessageKeys> entry : deletes) { sd.locationIndex.remove(tx, entry.getValue().location); sd.messageIdIndex.remove(tx, entry.getValue().messageId); sd.orderIndex.remove(tx, entry.getKey()); decrementAndSubSizeToStoreStat(tx, command.getDestination(), entry.getValue().location.getSize()); } } } }
boolean result = false; List<JobLocation> jobs = this.index.remove(tx, executionTime); Iterator<JobLocation> jobsIter = jobs.iterator(); while (jobsIter.hasNext()) {
List<JobLocation> values = this.index.remove(tx, executionTime); if (location != null) { for (JobLocation job : values) {
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); } } }
private void updateIndex(Transaction tx, KahaSubscriptionCommand command) throws IOException { StoredDestination sd = getStoredDestination(command.getDestination(), tx); // If set then we are creating it.. otherwise we are destroying the sub if (command.hasSubscriptionInfo()) { String subscriptionKey = command.getSubscriptionKey(); sd.subscriptions.put(tx, subscriptionKey, command); long ackByteSequence=-1; if (!command.getRetroactive()) { ackByteSequence = sd.nextMessageId-1; } sd.subscriptionAcks.put(tx, subscriptionKey, ackByteSequence); addAckByteSequence(sd, ackByteSequence, subscriptionKey); } else { // delete the sub... String subscriptionKey = command.getSubscriptionKey(); sd.subscriptions.remove(tx, subscriptionKey); Long prev = sd.subscriptionAcks.remove(tx, subscriptionKey); if( prev!=null ) { removeAckByteSequence(tx, sd, subscriptionKey, prev); } } }
/** * 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); } } }
Long sequenceId = sd.messageIdIndex.remove(tx, command.getMessageId()); if (sequenceId != null) { MessageKeys keys = sd.orderIndex.remove(tx, sequenceId); if (keys != null) { sd.locationIndex.remove(tx, keys.location); decrementAndSubSizeToStoreStat(tx, command.getDestination(), keys.location.getSize()); recordAckMessageReferenceLocation(ackLocation, keys.location);
jobLocation.setNextTime(nextExecutionTime); if (this.index.containsKey(tx, nextExecutionTime)) { values = this.index.remove(tx, nextExecutionTime);
sd.locationIndex.remove(tx, previousKeys.location);
private void updateIndex(Transaction tx, KahaRemoveDestinationCommand command) throws IOException { StoredDestination sd = getStoredDestination(command.getDestination(), tx); sd.orderIndex.clear(tx); sd.orderIndex.unload(tx); tx.free(sd.orderIndex.getPageId()); sd.messageIdIndex.clear(tx); sd.messageIdIndex.unload(tx); tx.free(sd.messageIdIndex.getPageId()); if (sd.subscriptions != null) { sd.subscriptions.clear(tx); sd.subscriptions.unload(tx); tx.free(sd.subscriptions.getPageId()); sd.subscriptionAcks.clear(tx); sd.subscriptionAcks.unload(tx); tx.free(sd.subscriptionAcks.getPageId()); } String key = key(command.getDestination()); storedDestinations.remove(key); destinations.remove(tx, key); }
metadata.destinations.remove(tx, key); clearStoreStats(command.getDestination()); storeCache.remove(key(command.getDestination()));
sd.locationIndex.remove(tx, location); id = -1;