Mercurial Hosting > luan
comparison src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1487:044a360c2300
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 01 May 2020 16:17:20 -0600 |
parents | 2469aa31f31b |
children | af55cfad6e12 |
comparison
equal
deleted
inserted
replaced
1486:2469aa31f31b | 1487:044a360c2300 |
---|---|
215 Document next() throws IOException { | 215 Document next() throws IOException { |
216 return i < n ? reader.document(td.scoreDocs[i++].doc) : null; | 216 return i < n ? reader.document(td.scoreDocs[i++].doc) : null; |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 private volatile boolean isChecking = false; | |
221 | |
220 public void check(SortField sortField) throws IOException { | 222 public void check(SortField sortField) throws IOException { |
223 if( isChecking ) | |
224 throw new RuntimeException("another check is running"); | |
221 IndexReader indexReader; | 225 IndexReader indexReader; |
222 List<LogInputStream> logReaders; | 226 List<LogInputStream> logReaders; |
223 synchronized(this) { | 227 synchronized(this) { |
224 if( isMerging ) { | |
225 logger.warn("is merging, check aborted"); | |
226 return; | |
227 } | |
228 isMerging = true; | |
229 indexReader = indexWriter.openReader(); | 228 indexReader = indexWriter.openReader(); |
230 logReaders = logReaders(logs); | 229 logReaders = logReaders(logs); |
231 } | 230 } |
231 isChecking = true; | |
232 try { | 232 try { |
233 logger.info("check start"); | 233 logger.info("check start"); |
234 indexWriter.check(); | 234 indexWriter.check(); |
235 File dirFile = new File(logDir,"check"); | 235 File dirFile = new File(logDir,"check"); |
236 IoUtils.deleteRecursively(dirFile); | 236 IoUtils.deleteRecursively(dirFile); |
292 checkReader.close(); | 292 checkReader.close(); |
293 checkWriter.close(); | 293 checkWriter.close(); |
294 IoUtils.deleteRecursively(dirFile); | 294 IoUtils.deleteRecursively(dirFile); |
295 logger.info("check done"); | 295 logger.info("check done"); |
296 } finally { | 296 } finally { |
297 isChecking = false; | |
297 indexReader.close(); | 298 indexReader.close(); |
298 isNotMerging(); | |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 private static abstract class HashCollector extends GoodCollector { | 302 private static abstract class HashCollector extends GoodCollector { |
303 int total = 0; | 303 int total = 0; |