Beispiel #1
0
 /**
  * Release a reference to the log corresponding to provided path. The log is closed if this is the
  * last reference.
  */
 private static synchronized void releaseLog(final File logPath) {
   Log<?, ?> log = logsCache.get(logPath);
   if (log == null) {
     // this should never happen
     logger.error(ERR_CHANGELOG_UNREFERENCED_LOG_WHILE_RELEASING.get(logPath.getPath()));
     return;
   }
   if (log.referenceCount > 1) {
     log.referenceCount--;
   } else {
     log.doClose();
     logsCache.remove(logPath);
   }
 }
Beispiel #2
0
 @Override
 public void close() {
   log.sharedLock.lock();
   try {
     delegate.close();
     log.unregisterCursor(this);
   } finally {
     log.sharedLock.unlock();
   }
 }
Beispiel #3
0
 @Override
 public boolean positionTo(
     final K key,
     final KeyMatchingStrategy matchStrategy,
     final PositionStrategy positionStrategy)
     throws ChangelogException {
   final LogFile<K, V> logFile = log.findLogFileFor(key);
   if (logFile != currentLogFile) {
     switchToLogFile(logFile);
   }
   return (key == null) ? true : currentCursor.positionTo(key, matchStrategy, positionStrategy);
 }
Beispiel #4
0
 @Override
 public boolean next() throws ChangelogException {
   final boolean hasNext = currentCursor.next();
   if (hasNext) {
     return true;
   }
   final LogFile<K, V> logFile = log.getNextLogFile(currentLogFile);
   if (logFile != null) {
     switchToLogFile(logFile);
     return currentCursor.next();
   }
   return false;
 }
Beispiel #5
0
 @Override
 public boolean next() throws ChangelogException {
   log.sharedLock.lock();
   try {
     if (mustAbort) {
       delegate.close();
       delegate = new AbortedLogCursor<>(log.getPath());
       mustAbort = false;
     }
     return delegate.next();
   } finally {
     log.sharedLock.unlock();
   }
 }