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
}
}
}
}
}));
}
Aggregations