comparison src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1508:86c5e7000ecf

lucene.backup checksum
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 16 May 2020 17:56:02 -0600
parents f443542d8650
children 31b543826ca9
comparison
equal deleted inserted replaced
1507:c8f4867fd083 1508:86c5e7000ecf
228 private volatile boolean isChecking = false; 228 private volatile boolean isChecking = false;
229 229
230 public void check(SortField sortField) throws IOException { 230 public void check(SortField sortField) throws IOException {
231 if( isChecking ) 231 if( isChecking )
232 throw new RuntimeException("another check is running"); 232 throw new RuntimeException("another check is running");
233 isChecking = true;
234 try {
235 doCheck(sortField);
236 } finally {
237 isChecking = false;
238 }
239 }
240
241 protected void doCheck(SortField sortField) throws IOException {
233 IndexReader indexReader; 242 IndexReader indexReader;
234 List<LogInputStream> logReaders; 243 List<LogInputStream> logReaders;
235 synchronized(this) { 244 synchronized(this) {
236 indexReader = indexWriter.openReader(); 245 indexReader = indexWriter.openReader();
237 logReaders = logReaders(logs); 246 logReaders = logReaders(logs);
238 } 247 }
239 isChecking = true;
240 try { 248 try {
241 logger.info("check start"); 249 logger.info("check start");
242 indexWriter.check(); 250 indexWriter.check();
243 File dirFile = new File(logDir,"check"); 251 File dirFile = new File(logDir,"check");
244 IoUtils.deleteRecursively(dirFile); 252 IoUtils.deleteRecursively(dirFile);
300 checkReader.close(); 308 checkReader.close();
301 checkWriter.close(); 309 checkWriter.close();
302 IoUtils.deleteRecursively(dirFile); 310 IoUtils.deleteRecursively(dirFile);
303 logger.info("check done"); 311 logger.info("check done");
304 } finally { 312 } finally {
305 isChecking = false;
306 indexReader.close(); 313 indexReader.close();
307 } 314 }
308 } 315 }
309 316
310 private static abstract class HashCollector extends GoodCollector { 317 private static abstract class HashCollector extends GoodCollector {