1 22 package org.jboss.tm.recovery; 23 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.List ; 27 28 import org.jboss.logging.Logger; 29 30 42 class LogRestarter 43 implements Runnable 44 { 45 48 private static Logger errorLog = Logger.getLogger(LogRestarter.class); 49 50 51 private boolean running = true; 52 53 54 private List logsToRestart = new ArrayList (); 55 56 61 synchronized void add(BatchLog log) 62 { 63 logsToRestart.add(log); 64 notify(); 65 } 66 67 70 synchronized void stop() 71 { 72 running = false; 73 notify(); 74 } 75 76 79 public void run() 80 { 81 BatchLog log; 82 83 while (running) 84 { 85 synchronized (this) 86 { 87 if (logsToRestart.size() > 0) 88 { 89 log = (BatchLog) logsToRestart.remove(0); 90 } 91 else 92 { 93 try 94 { 95 wait(); 96 } 97 catch (InterruptedException e) 98 { 99 if (!running) 100 break; 101 } 102 continue; 103 } 104 } 105 106 try 107 { 108 log.restart(); 109 } 110 catch (IOException e) 111 { 112 errorLog.error("Error cleaning up transaction log " 113 + log.getFilename(), e); 114 } 115 } 116 117 } 118 119 } 120 | Popular Tags |