Search in sources :

Example 1 with HashedWheelTimer

use of org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer in project hbase by apache.

the class RegionReplicationFlushRequester method requestFlush.

/**
 * Request a flush for the given region.
 * <p/>
 * The sequence id of the edit which we fail to replicate. A flush must happen after this sequence
 * id to recover the failure.
 */
synchronized void requestFlush(long sequenceId) {
    // if there is already a flush task, just reuse it.
    if (pendingFlushRequest != null) {
        pendingFlushRequestSequenceId = Math.max(sequenceId, pendingFlushRequestSequenceId);
        return;
    }
    // check last flush time
    long elapsedSecs = TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - lastRequestNanos);
    if (elapsedSecs >= minIntervalSecs) {
        request();
        return;
    }
    // schedule a timer task
    HashedWheelTimer timer = getTimer();
    pendingFlushRequestSequenceId = sequenceId;
    pendingFlushRequest = timer.newTimeout(this::flush, minIntervalSecs - elapsedSecs, TimeUnit.SECONDS);
}
Also used : HashedWheelTimer(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer)

Example 2 with HashedWheelTimer

use of org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer in project hbase by apache.

the class RegionReplicationFlushRequester method getTimer.

private static HashedWheelTimer getTimer() {
    HashedWheelTimer timer = TIMER;
    if (timer != null) {
        return timer;
    }
    synchronized (RegionReplicationFlushRequester.class) {
        timer = TIMER;
        if (timer != null) {
            return timer;
        }
        timer = new HashedWheelTimer(new ThreadFactoryBuilder().setNameFormat("RegionReplicationFlushRequester-Timer-pool-%d").setDaemon(true).setUncaughtExceptionHandler(Threads.LOGGING_EXCEPTION_HANDLER).build(), 500, TimeUnit.MILLISECONDS);
        TIMER = timer;
    }
    return timer;
}
Also used : ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) HashedWheelTimer(org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer)

Aggregations

HashedWheelTimer (org.apache.hbase.thirdparty.io.netty.util.HashedWheelTimer)2 ThreadFactoryBuilder (org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder)1