public boolean containsKey(long key) { return get(key) != null; }
public boolean containsKey(long key) { return get(key) != null; }
public boolean containsKey(long key) { return get(key) != null; }
public boolean containsKey(long key) { return get(key) != null; }
public boolean containsKey(long key) { return get(key) != null; }
@Override public void onReadDeleteRecord(final long recordID) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadDeleteRecord " + recordID); } if (newRecords.get(recordID) != null) { // Sanity check, it should never happen ActiveMQJournalLogger.LOGGER.inconsistencyDuringCompactingDelete(recordID); } }
@Override public void onReadDeleteRecord(final long recordID) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadDeleteRecord " + recordID); } if (newRecords.get(recordID) != null) { // Sanity check, it should never happen ActiveMQJournalLogger.LOGGER.inconsistencyDuringCompactingDelete(recordID); } }
@Override void execute() throws Exception { JournalRecord updateRecord = journal.getRecords().get(id); if (updateRecord == null) { ActiveMQJournalLogger.LOGGER.noRecordDuringCompactReplay(id); } else { updateRecord.addUpdateFile(usedFile, size); } }
@Override void execute() throws Exception { JournalRecord updateRecord = journal.getRecords().get(id); if (updateRecord == null) { ActiveMQJournalLogger.LOGGER.noRecordDuringCompactReplay(id); } else { updateRecord.addUpdateFile(usedFile, size); } }
@Override public void onReadUpdateRecord(final RecordInfo info) throws Exception { checkID(info.id); hasData.lazySet(true); loadManager.updateRecord(info); JournalRecord posFiles = records.get(info.id); if (posFiles != null) { // It's legal for this to be null. The file(s) with the may // have been deleted // just leaving some updates in this file posFiles.addUpdateFile(file, info.data.length + JournalImpl.SIZE_ADD_RECORD + 1); // +1 = compact // count } }
@Override void execute() throws Exception { JournalTransaction newTransaction = newTransactions.get(liveTransaction.getId()); if (newTransaction != null) { liveTransaction.merge(newTransaction); liveTransaction.commit(commitFile); } newTransactions.remove(liveTransaction.getId()); }
@Override public void onReadDeleteRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadDeleteRecordTX " + transactionID + " info " + info); } if (pendingTransactions.get(transactionID) != null) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord record = new JournalDeleteRecordTX(transactionID, info.id, new ByteArrayEncoding(info.data)); checkSize(record.getEncodeSize()); writeEncoder(record); newTransaction.addNegative(currentFile, info.id); } // else.. nothing to be done }
@Override public void onReadDeleteRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { logger.trace("onReadDeleteRecordTX " + transactionID + " info " + info); } if (pendingTransactions.get(transactionID) != null) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord record = new JournalDeleteRecordTX(transactionID, info.id, new ByteArrayEncoding(info.data)); checkSize(record.getEncodeSize()); writeEncoder(record); newTransaction.addNegative(currentFile, info.id); } // else.. nothing to be done }
@Override void execute() throws Exception { JournalTransaction newTransaction = newTransactions.get(liveTransaction.getId()); if (newTransaction != null) { liveTransaction.merge(newTransaction); liveTransaction.commit(commitFile); } newTransactions.remove(liveTransaction.getId()); }
@Override void execute() throws Exception { JournalTransaction newTransaction = newTransactions.get(liveTransaction.getId()); if (newTransaction != null) { liveTransaction.merge(newTransaction); liveTransaction.rollback(rollbackFile); } newTransactions.remove(liveTransaction.getId()); }
@Override void execute() throws Exception { JournalTransaction newTransaction = newTransactions.get(liveTransaction.getId()); if (newTransaction != null) { liveTransaction.merge(newTransaction); liveTransaction.rollback(rollbackFile); } newTransactions.remove(liveTransaction.getId()); }
@Test public void testComputeIfAbsent() { ConcurrentLongHashMap<Integer> map = new ConcurrentLongHashMap<>(16, 1); AtomicInteger counter = new AtomicInteger(); LongFunction<Integer> provider = key -> counter.getAndIncrement(); assertEquals(map.computeIfAbsent(0, provider).intValue(), 0); assertEquals(map.get(0).intValue(), 0); assertEquals(map.computeIfAbsent(1, provider).intValue(), 1); assertEquals(map.get(1).intValue(), 1); assertEquals(map.computeIfAbsent(1, provider).intValue(), 1); assertEquals(map.get(1).intValue(), 1); assertEquals(map.computeIfAbsent(2, provider).intValue(), 2); assertEquals(map.get(2).intValue(), 2); }
@Override public void onReadAddRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { logger.trace("Read Add Recprd TX " + transactionID + " info " + info); } if (pendingTransactions.get(transactionID) != null || containsRecord(info.id)) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord record = new JournalAddRecordTX(true, transactionID, info.id, info.getUserRecordType(), EncoderPersister.getInstance(),new ByteArrayEncoding(info.data)); record.setCompactCount((short) (info.compactCount + 1)); checkSize(record.getEncodeSize(), info.compactCount); newTransaction.addPositive(currentFile, info.id, record.getEncodeSize()); writeEncoder(record); } }
@Override public void onReadAddRecordTX(final long transactionID, final RecordInfo info) throws Exception { if (logger.isTraceEnabled()) { logger.trace("Read Add Recprd TX " + transactionID + " info " + info); } if (pendingTransactions.get(transactionID) != null || containsRecord(info.id)) { JournalTransaction newTransaction = getNewJournalTransaction(transactionID); JournalInternalRecord record = new JournalAddRecordTX(true, transactionID, info.id, info.getUserRecordType(), EncoderPersister.getInstance(),new ByteArrayEncoding(info.data)); record.setCompactCount((short) (info.compactCount + 1)); checkSize(record.getEncodeSize(), info.compactCount); newTransaction.addPositive(currentFile, info.id, record.getEncodeSize()); writeEncoder(record); } }