Source:
<code>public void run() { while (!server.isStopped()) { long now = System.currentTimeMillis(); checkLowReplication(now); if (!rollLog.get()) { <START> boolean periodic = false; for (RollController controller : wals.values()) { if (controller.needsPeriodicRoll(now)) { periodic = true; break; } } <END> if (!periodic) { synchronized (rollLog) { try { if (!rollLog.get()) { rollLog.wait(this.threadWakeFrequency); } } catch (InterruptedException e) { } } continue; } } rollLock.lock(); try { for (Entry<WAL, RollController> entry : wals.entrySet()) { final WAL wal = entry.getKey(); RollController controller = entry.getValue(); if (controller.isRollRequested()) { LOG.debug("WAL " + wal + " roll requested"); } else if (controller.needsPeriodicRoll(now)) { LOG.debug("WAL " + wal + " roll period " + this.rollPeriod + "ms elapsed"); } else { continue; } final byte [][] regionsToFlush = controller.rollWal(now); if (regionsToFlush != null) { for (byte r: regionsToFlush) scheduleFlush(r); } } } catch (FailedLogCloseException e) { server.abort("Failed log close in log roller", e); } catch (java.net.ConnectException e) { server.abort("Failed log close in log roller", e); } catch (IOException ex) { LOG.fatal("Aborting", ex); server.abort("IOE in log roller", RemoteExceptionHandler.checkIOException(ex)); } catch (Exception ex) { final String msg = "Failed rolling WAL; aborting to recover edits!"; LOG.error(msg, ex); server.abort(msg, ex); } finally { try { rollLog.set(false); } finally { rollLock.unlock(); } } } LOG.info("LogRoller exiting."); }</code><technical_language>This logic is branch-2 patches. is here? why</technical_language>

Target:
public void run() { while (!server.isStopped()) { long now = EnvironmentEdgeManager.currentTime(); checkLowReplication(now); if (!rollLog.get()) { boolean periodic = false; for (RollController controller : wals.values()) { if (controller.needsPeriodicRoll(now)) { periodic = true; break; } } if (!periodic) { synchronized (rollLog) { try { if (!rollLog.get()) { rollLog.wait(this.threadWakeFrequency); } } catch (InterruptedException e) { } } continue; } } rollLock.lock(); try { for (Entry<WAL, RollController> entry : wals.entrySet()) { final WAL wal = entry.getKey(); RollController controller = entry.getValue(); if (controller.isRollRequested()) { LOG.debug("WAL " + wal + " roll requested"); } else if (controller.needsPeriodicRoll(now)) { LOG.debug("WAL " + wal + " roll period " + this.rollPeriod + "ms elapsed"); } else { continue; } final byte [][] regionsToFlush = controller.rollWal(now); if (regionsToFlush != null) { for (byte r: regionsToFlush) scheduleFlush(r); } } } catch (FailedLogCloseException e) { server.abort("Failed log close in log roller", e); } catch (java.net.ConnectException e) { server.abort("Failed log close in log roller", e); } catch (IOException ex) { LOG.fatal("Aborting", ex); server.abort("IOE in log roller", RemoteExceptionHandler.checkIOException(ex)); } catch (Exception ex) { final String msg = "Failed rolling WAL; aborting to recover edits!"; LOG.error(msg, ex); server.abort(msg, ex); } finally { try { rollLog.set(false); } finally { rollLock.unlock(); } } } LOG.info("LogRoller exiting."); }