(TransactionLog oldLog, boolean removeOld)
| 735 | and then decrementing its reference and dropping it. |
| 736 | */ |
| 737 | @SuppressWarnings( |
| 738 | "ReferenceEquality") // TransactionLog identity, not equality, is what matters here |
| 739 | protected synchronized void addOldLog(TransactionLog oldLog, boolean removeOld) { |
| 740 | if (oldLog == null) return; |
| 741 | |
| 742 | numOldRecords += oldLog.numRecords(); |
| 743 | |
| 744 | int currRecords = numOldRecords; |
| 745 | |
| 746 | if (oldLog != tlog && tlog != null) { |
| 747 | currRecords += tlog.numRecords(); |
| 748 | } |
| 749 | |
| 750 | while (removeOld && logs.size() > 0) { |
| 751 | TransactionLog log = logs.peekLast(); |
| 752 | int nrec = log.numRecords(); |
| 753 | // remove oldest log if we don't need it to keep at least numRecordsToKeep, or if |
| 754 | // we already have the limit of 10 log files. |
| 755 | if (currRecords - nrec >= numRecordsToKeep |
| 756 | || (maxNumLogsToKeep > 0 && logs.size() >= maxNumLogsToKeep)) { |
| 757 | currRecords -= nrec; |
| 758 | numOldRecords -= nrec; |
| 759 | logs.removeLast().decref(); // dereference so it will be deleted when no longer in use |
| 760 | continue; |
| 761 | } |
| 762 | |
| 763 | break; |
| 764 | } |
| 765 | |
| 766 | // don't incref... we are taking ownership from the caller. |
| 767 | logs.addFirst(oldLog); |
| 768 | } |
| 769 |
no test coverage detected