private final void removeFromLog(Uid txid) { if (_synchronousRemoval) { synchronized (_logNames) { Iterator<LogInstance> iter = _logNames.iterator(); LogInstance entry = null; while (iter.hasNext()) { entry = (LogInstance) iter.next(); if (entry.present(txid)) { // entry.removeTxId(txid); break; } } } } }
private final TransactionData getLogName(Uid txid, String tName, long size) throws ObjectStoreException { synchronized (_logNames) { Iterator<LogInstance> iter = _logNames.iterator(); LogInstance entry = null; /* * First check to see if the TxId is in an existing log. Always * return the same log instance for the same txid so we can * keep all data in the same location. This may mean that we have * to extend the size of the log over time to accommodate situations * where the log is modified but not deleted for a while, e.g., during * recovery. */ while (iter.hasNext()) { entry = (LogInstance) iter.next(); if (entry.present(txid)) { if (size == -1) // we are reading only return entry.getTxId(txid); else return entry.addTxId(txid, size); } } /* * If we get here then this TxId isn't in one of the * logs we are maintaining currently. So go back through * the list of logs and find one that is small enough * for us to use. The first one with room will do. */ iter = _logNames.iterator(); while (iter.hasNext()) { entry = (LogInstance) iter.next(); if (!entry.isFrozen()) { if (entry.remaining() > size) { return entry.addTxId(txid, size); } else { /* * TODO * * When can we remove the information about this * log from memory? If we do it too soon then it's possible * that delete entries will not go into the right log. If we * leave it too late then the memory footprint increases. Prune * the entry when we prune the log from disk? */ entry.freeze(); } } } // if we get here, then we need to create a new log entry = new LogInstance(tName, _maxFileSize); _logNames.add(entry); return entry.addTxId(txid, size); } }