| | |
| | | private final AtomicLong lastGeneratedChangeNumber; |
| | | private DbMonitorProvider dbMonitor = new DbMonitorProvider(); |
| | | private final AtomicBoolean shutdown = new AtomicBoolean(false); |
| | | private volatile boolean trimDone = false; |
| | | /** |
| | | * A dedicated thread loops trim(). |
| | | * <p> |
| | |
| | | notifyAll(); |
| | | } |
| | | |
| | | synchronized (this) |
| | | { /* Can we just do a thread.join() ? */ |
| | | while (!trimDone) |
| | | if (trimmingThread != null) |
| | | { |
| | | try |
| | | { |
| | | try |
| | | { |
| | | wait(); |
| | | } catch (InterruptedException e) |
| | | { /* do nothing */ } |
| | | trimmingThread.join(); |
| | | } |
| | | catch (InterruptedException ignored) |
| | | { |
| | | // Nothing can be done about it, just proceed |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | synchronized (this) |
| | | { |
| | | try |
| | | if (!shutdown.get()) |
| | | { |
| | | wait(1000); |
| | | } catch (InterruptedException e) |
| | | { |
| | | Thread.currentThread().interrupt(); |
| | | try |
| | | { |
| | | wait(1000); |
| | | } |
| | | catch (InterruptedException e) |
| | | { |
| | | Thread.currentThread().interrupt(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | break; |
| | | } |
| | | try { |
| | | trim(shutdown); |
| | | |
| | | synchronized (this) |
| | | { |
| | | try |
| | | { |
| | | wait(1000); |
| | | } catch (InterruptedException e) |
| | | { |
| | | Thread.currentThread().interrupt(); |
| | | } |
| | | } |
| | | } catch (Exception end) |
| | | { |
| | | logError(ERR_EXCEPTION_CHANGELOG_TRIM_FLUSH |
| | | .get(stackTraceToSingleLineString(end))); |
| | | if (replicationServer != null) |
| | | { |
| | | replicationServer.shutdown(); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | synchronized (this) |
| | | { |
| | | trimDone = true; |
| | | notifyAll(); |
| | | } |
| | | } |
| | | |