Search in sources :

Example 1 with ServerResources

use of org.apache.accumulo.tserver.log.DfsLogger.ServerResources in project accumulo by apache.

the class TabletServerLogger method startLogMaker.

private synchronized void startLogMaker() {
    if (nextLogMaker != null) {
        return;
    }
    nextLogMaker = new SimpleThreadPool(1, "WALog creator");
    nextLogMaker.submit(new LoggingRunnable(log, new Runnable() {

        @Override
        public void run() {
            final ServerResources conf = tserver.getServerConfig();
            final VolumeManager fs = conf.getFileSystem();
            while (!nextLogMaker.isShutdown()) {
                DfsLogger alog = null;
                try {
                    log.debug("Creating next WAL");
                    alog = new DfsLogger(conf, syncCounter, flushCounter);
                    alog.open(tserver.getClientAddressString());
                    String fileName = alog.getFileName();
                    log.debug("Created next WAL " + fileName);
                    tserver.addNewLogMarker(alog);
                    while (!nextLog.offer(alog, 12, TimeUnit.HOURS)) {
                        log.info("Our WAL was not used for 12 hours: {}", fileName);
                    }
                } catch (Exception t) {
                    log.error("Failed to open WAL", t);
                    if (null != alog) {
                        // object before trying to create a new one.
                        try {
                            alog.close();
                        } catch (Exception e) {
                            log.error("Failed to close WAL after it failed to open", e);
                        }
                        // Try to avoid leaving a bunch of empty WALs lying around
                        try {
                            Path path = alog.getPath();
                            if (fs.exists(path)) {
                                fs.delete(path);
                            }
                        } catch (Exception e) {
                            log.warn("Failed to delete a WAL that failed to open", e);
                        }
                    }
                    try {
                        nextLog.offer(t, 12, TimeUnit.HOURS);
                    } catch (InterruptedException ex) {
                    // ignore
                    }
                }
            }
        }
    }));
}
Also used : Path(org.apache.hadoop.fs.Path) LoggingRunnable(org.apache.accumulo.fate.util.LoggingRunnable) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) LoggingRunnable(org.apache.accumulo.fate.util.LoggingRunnable) SimpleThreadPool(org.apache.accumulo.core.util.SimpleThreadPool) ServerResources(org.apache.accumulo.tserver.log.DfsLogger.ServerResources) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SimpleThreadPool (org.apache.accumulo.core.util.SimpleThreadPool)1 LoggingRunnable (org.apache.accumulo.fate.util.LoggingRunnable)1 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)1 ServerResources (org.apache.accumulo.tserver.log.DfsLogger.ServerResources)1 Path (org.apache.hadoop.fs.Path)1