MessageKeys put(Transaction tx, int priority, Long key, MessageKeys value) throws IOException { if (priority == javax.jms.Message.DEFAULT_PRIORITY) { return defaultPriorityIndex.put(tx, key, value); } else if (priority > javax.jms.Message.DEFAULT_PRIORITY) { return highPriorityIndex.put(tx, key, value); } else { return lowPriorityIndex.put(tx, key, value); } }
private void upadateIndex(Transaction tx, KahaAddMessageCommand command, ByteSequence data) throws IOException { StoredDestination sd = getStoredDestination(command.getDestination(), tx); // Skip adding the message to the index if this is a topic and there are // no subscriptions. if (sd.subscriptions != null && sd.ackPositions.isEmpty()) { return; } // Add the message. long id = sd.nextMessageId++; Long previous = sd.messageIdIndex.put(tx, command.getMessageId(), id); if( previous == null ) { sd.orderIndex.put(tx, id, new MessageRecord(command.getMessageId(), data)); } else { // restore the previous value.. Looks like this was a redo of a previously // added message. We don't want to assing it a new id as the other indexes would // be wrong.. sd.messageIdIndex.put(tx, command.getMessageId(), previous); } }
/** * 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); }
this.index.put(tx, executionTime, jobs);
/** * 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); }
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); } } }
this.index.put(tx, executionTime, values);
/** * 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 previous = sd.locationIndex.put(tx, location, id); if (previous == null) { previous = sd.messageIdIndex.put(tx, command.getMessageId(), id); if (previous == null) { incrementAndAddSizeToStoreStat(tx, command.getDestination(), location.getSize()); sd.messageIdIndex.put(tx, command.getMessageId(), previous); sd.locationIndex.remove(tx, location); id = -1; sd.locationIndex.put(tx, location, previous);
rc.subscriptionAcks = new BTreeIndex<String, Long>(pageFile, tx.allocate()); destinations.put(tx, key, rc);
sd.subscriptions.put(tx, subscriptionKey, command); sd.subLocations.put(tx, subscriptionKey, location); long ackLocation=NOT_ACKED; addAckLocationForRetroactiveSub(tx, sd, subscriptionKey); sd.subscriptionAcks.put(tx, subscriptionKey, new LastAck(ackLocation)); sd.subscriptionCache.add(subscriptionKey); } else {
sd.orderIndex.get(tx, sequence); byte priority = sd.orderIndex.lastGetPriority(); sd.subscriptionAcks.put(tx, subscriptionKey, new LastAck(sequence, priority));
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); } } }
new MessageKeys(command.getMessageId(), location) ); sd.locationIndex.put(tx, location, id); incrementAndAddSizeToStoreStat(tx, command.getDestination(), location.getSize());
MessageKeys put(Transaction tx, int priority, Long key, MessageKeys value) throws IOException { if (priority == javax.jms.Message.DEFAULT_PRIORITY) { return defaultPriorityIndex.put(tx, key, value); } else if (priority > javax.jms.Message.DEFAULT_PRIORITY) { return highPriorityIndex.put(tx, key, value); } else { return lowPriorityIndex.put(tx, key, value); } }
MessageKeys put(Transaction tx, int priority, Long key, MessageKeys value) throws IOException { if (priority == javax.jms.Message.DEFAULT_PRIORITY) { return defaultPriorityIndex.put(tx, key, value); } else if (priority > javax.jms.Message.DEFAULT_PRIORITY) { return highPriorityIndex.put(tx, key, value); } else { return lowPriorityIndex.put(tx, key, value); } }
MessageKeys put(Transaction tx, int priority, Long key, MessageKeys value) throws IOException { if (priority == javax.jms.Message.DEFAULT_PRIORITY) { return defaultPriorityIndex.put(tx, key, value); } else if (priority > javax.jms.Message.DEFAULT_PRIORITY) { return highPriorityIndex.put(tx, key, value); } else { return lowPriorityIndex.put(tx, key, value); } }