| | |
| | | public DBCursor<UpdateMsg> generateCursorFrom(CSN startAfterCSN) |
| | | throws ChangelogException |
| | | { |
| | | if (startAfterCSN == null) |
| | | { |
| | | // flush any potential changes before opening the cursor |
| | | flush(); |
| | | } |
| | | return new JEReplicaDBCursor(db, startAfterCSN, this); |
| | | } |
| | | |
| | |
| | | trimDate = lastBeforeTrimDate; |
| | | } |
| | | |
| | | final int queueLowMarkBytes = queueMaxBytes / 5; |
| | | for (int i = 0; i < 100; i++) |
| | | { |
| | | /* |
| | |
| | | * lowmark). Once the flush backlog increases, stop trimming and start |
| | | * flushing more eagerly. |
| | | */ |
| | | if (i > 20 && msgQueue.size() < queueLowMarkBytes) |
| | | if (i > 20 && isQueueAboveLowMark()) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | synchronized (flushLock) |
| | | { |
| | | /* |
| | | * the trim is done by group in order to save some CPU, IO bandwidth and |
| | | * DB caches: start the transaction then do a bunch of remove then |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | private boolean isQueueAboveLowMark() |
| | | { |
| | | final int lowMarkBytes = queueMaxBytes / 5; |
| | | final int bytesUsed = queueMaxBytes - queueSizeBytes.availablePermits(); |
| | | return bytesUsed > lowMarkBytes; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public void clear() throws ChangelogException |
| | | { |
| | | synchronized(flushLock) |
| | | { |
| | | collectAllPermits(); |
| | | msgQueue.clear(); |
| | | msgQueue.clear(); // this call should not do anything at all |
| | | db.clear(); |
| | | csnLimits = new CSNLimits(null, null); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Getter for the serverID of the server for which this database is managed. |