Search in sources :

Example 6 with ByteSlot

use of org.apache.hadoop.hbase.procedure2.util.ByteSlot in project hbase by apache.

the class WALProcedureStore method start.

@Override
public void start(int numSlots) throws IOException {
    if (!setRunning(true)) {
        return;
    }
    // Init buffer slots
    loading.set(true);
    runningProcCount = numSlots;
    syncMaxSlot = numSlots;
    slots = new ByteSlot[numSlots];
    slotsCache = new LinkedTransferQueue();
    while (slotsCache.size() < numSlots) {
        slotsCache.offer(new ByteSlot());
    }
    // Tunings
    walCountWarnThreshold = conf.getInt(WAL_COUNT_WARN_THRESHOLD_CONF_KEY, DEFAULT_WAL_COUNT_WARN_THRESHOLD);
    maxRetriesBeforeRoll = conf.getInt(MAX_RETRIES_BEFORE_ROLL_CONF_KEY, DEFAULT_MAX_RETRIES_BEFORE_ROLL);
    maxSyncFailureRoll = conf.getInt(MAX_SYNC_FAILURE_ROLL_CONF_KEY, DEFAULT_MAX_SYNC_FAILURE_ROLL);
    waitBeforeRoll = conf.getInt(WAIT_BEFORE_ROLL_CONF_KEY, DEFAULT_WAIT_BEFORE_ROLL);
    rollRetries = conf.getInt(ROLL_RETRIES_CONF_KEY, DEFAULT_ROLL_RETRIES);
    rollThreshold = conf.getLong(ROLL_THRESHOLD_CONF_KEY, DEFAULT_ROLL_THRESHOLD);
    periodicRollMsec = conf.getInt(PERIODIC_ROLL_CONF_KEY, DEFAULT_PERIODIC_ROLL);
    syncWaitMsec = conf.getInt(SYNC_WAIT_MSEC_CONF_KEY, DEFAULT_SYNC_WAIT_MSEC);
    useHsync = conf.getBoolean(USE_HSYNC_CONF_KEY, DEFAULT_USE_HSYNC);
    // WebUI
    syncMetricsBuffer = new CircularFifoBuffer(conf.getInt(STORE_WAL_SYNC_STATS_COUNT, DEFAULT_SYNC_STATS_COUNT));
    // Init sync thread
    syncThread = new Thread("WALProcedureStoreSyncThread") {

        @Override
        public void run() {
            try {
                syncLoop();
            } catch (Throwable e) {
                LOG.error("Got an exception from the sync-loop", e);
                if (!isSyncAborted()) {
                    sendAbortProcessSignal();
                }
            }
        }
    };
    syncThread.start();
}
Also used : CircularFifoBuffer(org.apache.commons.collections.buffer.CircularFifoBuffer) LinkedTransferQueue(java.util.concurrent.LinkedTransferQueue) ByteSlot(org.apache.hadoop.hbase.procedure2.util.ByteSlot)

Example 7 with ByteSlot

use of org.apache.hadoop.hbase.procedure2.util.ByteSlot in project hbase by apache.

the class WALProcedureStore method syncSlots.

protected long syncSlots(final FSDataOutputStream stream, final ByteSlot[] slots, final int offset, final int count) throws IOException {
    long totalSynced = 0;
    for (int i = 0; i < count; ++i) {
        final ByteSlot data = slots[offset + i];
        data.writeTo(stream);
        totalSynced += data.size();
    }
    syncStream(stream);
    sendPostSyncSignal();
    if (LOG.isTraceEnabled()) {
        LOG.trace("Sync slots=" + count + '/' + syncMaxSlot + ", flushed=" + StringUtils.humanSize(totalSynced));
    }
    return totalSynced;
}
Also used : ByteSlot(org.apache.hadoop.hbase.procedure2.util.ByteSlot)

Aggregations

ByteSlot (org.apache.hadoop.hbase.procedure2.util.ByteSlot)7 IOException (java.io.IOException)5 LinkedTransferQueue (java.util.concurrent.LinkedTransferQueue)1 CircularFifoBuffer (org.apache.commons.collections.buffer.CircularFifoBuffer)1