Search in sources :

Example 1 with SegmentOverflowException

use of org.apache.jackrabbit.oak.segment.SegmentOverflowException in project jackrabbit-oak by apache.

the class LockBasedScheduler method schedule.

@Override
public NodeState schedule(@Nonnull Commit commit, SchedulerOption... schedulingOptions) throws CommitFailedException {
    boolean queued = false;
    try {
        long queuedTime = -1;
        if (commitSemaphore.availablePermits() < 1) {
            queuedTime = System.nanoTime();
            stats.onCommitQueued();
            queued = true;
        }
        commitSemaphore.acquire();
        try {
            if (queued) {
                long dequeuedTime = System.nanoTime();
                stats.dequeuedAfter(dequeuedTime - queuedTime);
                stats.onCommitDequeued();
            }
            long beforeCommitTime = System.nanoTime();
            SegmentNodeState merged = (SegmentNodeState) execute(commit);
            commit.applied(merged);
            long afterCommitTime = System.nanoTime();
            stats.committedAfter(afterCommitTime - beforeCommitTime);
            stats.onCommit();
            return merged;
        } finally {
            commitSemaphore.release();
        }
    } catch (InterruptedException e) {
        currentThread().interrupt();
        throw new CommitFailedException("Segment", 2, "Merge interrupted", e);
    } catch (SegmentOverflowException e) {
        throw new CommitFailedException("Segment", 3, "Merge failed", e);
    }
}
Also used : SegmentOverflowException(org.apache.jackrabbit.oak.segment.SegmentOverflowException) SegmentNodeState(org.apache.jackrabbit.oak.segment.SegmentNodeState) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Aggregations

CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)1 SegmentOverflowException (org.apache.jackrabbit.oak.segment.SegmentOverflowException)1