Search in sources :

Example 1 with WALClosedException

use of org.apache.hadoop.hbase.regionserver.wal.WALClosedException in project hbase by apache.

the class AbstractWALRoller method run.

@Override
public void run() {
    while (running) {
        long now = EnvironmentEdgeManager.currentTime();
        checkLowReplication(now);
        synchronized (this) {
            if (wals.values().stream().noneMatch(rc -> rc.needsRoll(now))) {
                try {
                    wait(this.threadWakeFrequency);
                } catch (InterruptedException e) {
                    // restore the interrupt state
                    Thread.currentThread().interrupt();
                }
                // several WALs, and also check whether we should quit.
                continue;
            }
        }
        try {
            for (Iterator<Entry<WAL, RollController>> iter = wals.entrySet().iterator(); iter.hasNext(); ) {
                Entry<WAL, RollController> entry = iter.next();
                WAL wal = entry.getKey();
                RollController controller = entry.getValue();
                if (controller.isRollRequested()) {
                    // WAL roll requested, fall through
                    LOG.debug("WAL {} roll requested", wal);
                } else if (controller.needsPeriodicRoll(now)) {
                    // Time for periodic roll, fall through
                    LOG.debug("WAL {} roll period {} ms elapsed", wal, this.rollPeriod);
                } else {
                    continue;
                }
                try {
                    // Force the roll if the logroll.period is elapsed or if a roll was requested.
                    // The returned value is an collection of actual region and family names.
                    Map<byte[], List<byte[]>> regionsToFlush = controller.rollWal(now);
                    if (regionsToFlush != null) {
                        for (Map.Entry<byte[], List<byte[]>> r : regionsToFlush.entrySet()) {
                            scheduleFlush(Bytes.toString(r.getKey()), r.getValue());
                        }
                    }
                } catch (WALClosedException e) {
                    LOG.warn("WAL has been closed. Skipping rolling of writer and just remove it", e);
                    iter.remove();
                }
            }
        } catch (FailedLogCloseException | ConnectException e) {
            abort("Failed log close in log roller", e);
        } catch (IOException ex) {
            // Abort if we get here. We probably won't recover an IOE. HBASE-1132
            abort("IOE in log roller", ex instanceof RemoteException ? ((RemoteException) ex).unwrapRemoteException() : ex);
        } catch (Exception ex) {
            LOG.error("Log rolling failed", ex);
            abort("Log rolling failed", ex);
        }
    }
    LOG.info("LogRoller exiting.");
}
Also used : AbstractFSWAL(org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL) FailedLogCloseException(org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException) WALClosedException(org.apache.hadoop.hbase.regionserver.wal.WALClosedException) IOException(java.io.IOException) IOException(java.io.IOException) RemoteException(org.apache.hadoop.ipc.RemoteException) WALClosedException(org.apache.hadoop.hbase.regionserver.wal.WALClosedException) ConnectException(java.net.ConnectException) FailedLogCloseException(org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException) Entry(java.util.Map.Entry) List(java.util.List) RemoteException(org.apache.hadoop.ipc.RemoteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConnectException(java.net.ConnectException)

Aggregations

IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 AbstractFSWAL (org.apache.hadoop.hbase.regionserver.wal.AbstractFSWAL)1 FailedLogCloseException (org.apache.hadoop.hbase.regionserver.wal.FailedLogCloseException)1 WALClosedException (org.apache.hadoop.hbase.regionserver.wal.WALClosedException)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1