Mercurial Hosting > luan
annotate src/goodjava/lucene/logging/LoggingIndexWriter.java @ 1575:0160650180bc
better http authentication
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 27 Jan 2021 15:31:26 -0700 |
parents | 52241b69c339 |
children | ea7075b7afe1 |
rev | line source |
---|---|
1461 | 1 package goodjava.lucene.logging; |
2 | |
1465 | 3 import java.io.File; |
4 import java.io.RandomAccessFile; | |
5 import java.io.ByteArrayOutputStream; | |
6 import java.io.DataOutputStream; | |
7 import java.io.DataInputStream; | |
8 import java.io.FileInputStream; | |
1461 | 9 import java.io.IOException; |
10 import java.util.Map; | |
1465 | 11 import java.util.Set; |
12 import java.util.HashSet; | |
13 import java.util.Random; | |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
14 import java.util.concurrent.TimeUnit; |
1465 | 15 import org.apache.lucene.document.Document; |
16 import org.apache.lucene.index.DirectoryReader; | |
17 import org.apache.lucene.index.IndexReader; | |
1539 | 18 import org.apache.lucene.index.IndexWriter; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
19 import org.apache.lucene.index.Term; |
1465 | 20 import org.apache.lucene.search.IndexSearcher; |
1461 | 21 import org.apache.lucene.search.Query; |
1465 | 22 import org.apache.lucene.search.MatchAllDocsQuery; |
23 import org.apache.lucene.search.TopDocs; | |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
24 import org.apache.lucene.search.PrefixQuery; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
25 import org.apache.lucene.search.SortField; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
26 import org.apache.lucene.search.Sort; |
1465 | 27 import org.apache.lucene.store.Directory; |
28 import org.apache.lucene.store.FSDirectory; | |
1473 | 29 import goodjava.io.IoUtils; |
1461 | 30 import goodjava.lucene.api.GoodIndexWriter; |
1465 | 31 import goodjava.lucene.api.LuceneIndexWriter; |
32 import goodjava.lucene.api.GoodCollector; | |
33 import goodjava.lucene.api.LuceneUtils; | |
34 import goodjava.logging.Logger; | |
35 import goodjava.logging.LoggerFactory; | |
1461 | 36 |
37 | |
1488 | 38 public class LoggingIndexWriter implements GoodIndexWriter { |
1465 | 39 private static final Logger logger = LoggerFactory.getLogger(LoggingIndexWriter.class); |
1548 | 40 private static final int version = 2; |
1461 | 41 private static final int OP_DELETE_ALL = 1; |
42 private static final int OP_DELETE_DOCUMENTS = 2; | |
43 private static final int OP_ADD_DOCUMENT = 3; | |
44 private static final int OP_UPDATE_DOCUMENT = 4; | |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
45 private static final int OP_TAG = 5; |
1465 | 46 private static final Random rnd = new Random(); |
1461 | 47 |
1465 | 48 public final LuceneIndexWriter indexWriter; |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
49 public boolean wasCreated; |
1465 | 50 private final File logDir; |
1548 | 51 private final long logTime; |
52 protected final LogFile[] logs = new LogFile[3]; | |
1486 | 53 private LogOutputStream log; |
1465 | 54 private final File index; |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
55 private final SemaphoreLock mergeLock = new SemaphoreLock(); |
1461 | 56 |
1548 | 57 public LoggingIndexWriter(LuceneIndexWriter indexWriter,File logDir,long logTime) |
58 throws IOException | |
59 { | |
1461 | 60 this.indexWriter = indexWriter; |
1465 | 61 this.logDir = logDir; |
1548 | 62 this.logTime = logTime; |
1501 | 63 IoUtils.mkdirs(logDir); |
1465 | 64 if( !logDir.isDirectory() ) |
65 throw new RuntimeException(); | |
66 index = new File(logDir,"index"); | |
67 if( index.exists() ) { | |
68 DataInputStream dis = new DataInputStream(new FileInputStream(index)); | |
69 try { | |
70 if( dis.readInt() == version ) { | |
1548 | 71 for( int i=0; i<logs.length; i++ ) { |
1465 | 72 File file = new File( logDir, dis.readUTF() ); |
1548 | 73 logs[i] = new LogFile(file); |
1465 | 74 } |
75 deleteUnusedFiles(); | |
1486 | 76 setLog(); |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
77 wasCreated = false; |
1465 | 78 return; |
79 } | |
80 } finally { | |
81 dis.close(); | |
82 } | |
83 } | |
1556 | 84 logger.info("building new logs"); |
85 for( int i=0; i<logs.length; i++ ) { | |
86 logs[i] = newLogFile(); | |
87 } | |
88 LogOutputStream log = logs[0].output(); | |
89 logLucene( System.currentTimeMillis(), log, indexWriter ); | |
90 log.close(); | |
91 writeIndex(); | |
92 setLog(); | |
93 logger.info("done building new logs"); | |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
94 wasCreated = true; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
95 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
96 |
1548 | 97 public IndexReader openReader() throws IOException { |
98 return indexWriter.openReader(); | |
99 } | |
100 | |
1539 | 101 public IndexWriter getLuceneIndexWriter() { |
102 return indexWriter.getLuceneIndexWriter(); | |
1528
3bd4d7963456
use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents:
1512
diff
changeset
|
103 } |
3bd4d7963456
use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents:
1512
diff
changeset
|
104 |
1486 | 105 private void setLog() throws IOException { |
106 if( log != null ) | |
107 log.close(); | |
1548 | 108 log = logs[2].output(); |
1486 | 109 } |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
110 /* |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
111 public synchronized boolean isMerging() { |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
112 return mergeLock.isLocked(); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
113 } |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
114 */ |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
115 private void getMergeLock() { |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
116 try { |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
117 if( !mergeLock.tryLock(1,TimeUnit.MINUTES) ) |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
118 throw new RuntimeException("failed to acquire lock"); |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
119 } catch(InterruptedException e) { |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
120 throw new RuntimeException(e); |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
121 } |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
122 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
123 |
1548 | 124 public synchronized void logLucene() |
125 throws IOException | |
126 { | |
127 logLucene( System.currentTimeMillis(), log, indexWriter ); | |
128 } | |
129 | |
130 private static void logLucene(long time,LogOutputStream log,LuceneIndexWriter indexWriter) | |
131 throws IOException | |
132 { | |
133 log.writeLong(time); | |
134 log.writeByte(OP_DELETE_ALL); | |
1465 | 135 IndexReader reader = indexWriter.openReader(); |
136 final IndexSearcher searcher = new IndexSearcher(reader); | |
137 Query query = new MatchAllDocsQuery(); | |
138 searcher.search( query, new GoodCollector(){ | |
139 public void collectDoc(int iDoc) throws IOException { | |
140 Document doc = searcher.doc(iDoc); | |
141 Map<String,Object> storedFields = LuceneUtils.toMap(doc); | |
142 log.writeLong(time); | |
143 log.writeByte(OP_ADD_DOCUMENT); | |
144 log.writeMap(storedFields); | |
145 } | |
146 }); | |
147 reader.close(); | |
148 log.commit(); | |
149 } | |
150 | |
151 private LogFile newLogFile() throws IOException { | |
152 File file; | |
153 do { | |
154 file = new File(logDir,"_"+rnd.nextInt(100)+".log"); | |
155 } while( file.exists() ); | |
1486 | 156 return new LogFile(file); |
1461 | 157 } |
158 | |
1473 | 159 private void deleteUnusedFiles() throws IOException { |
1499 | 160 deleteUnusedFiles(logs,index); |
161 } | |
162 | |
1548 | 163 private static void deleteUnusedFiles(LogFile[] logs,File index) throws IOException { |
1465 | 164 Set<String> used = new HashSet<String>(); |
165 used.add( index.getName() ); | |
166 for( LogFile lf : logs ) { | |
167 used.add( lf.file.getName() ); | |
168 } | |
1499 | 169 for( File f : index.getParentFile().listFiles() ) { |
1465 | 170 if( !used.contains(f.getName()) ) { |
1475 | 171 IoUtils.deleteRecursively(f); |
1465 | 172 } |
173 } | |
1461 | 174 } |
175 | |
1465 | 176 private void writeIndex() throws IOException { |
1499 | 177 writeIndex(logs,index); |
178 } | |
179 | |
1548 | 180 public static void writeIndex(LogFile[] logs,File index) throws IOException { |
181 if( logs.length != 3 ) | |
182 throw new RuntimeException(); | |
1465 | 183 ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
184 DataOutputStream dos = new DataOutputStream(baos); | |
185 dos.writeInt(version); | |
186 for( LogFile lf : logs ) { | |
187 String fileName = lf.file.getName(); | |
188 dos.writeUTF(fileName); | |
189 } | |
190 dos.close(); | |
191 RandomAccessFile raf = new RandomAccessFile( index, "rwd" ); | |
192 raf.write( baos.toByteArray() ); | |
193 raf.close(); | |
1499 | 194 deleteUnusedFiles(logs,index); |
195 //logger.info("writeIndex "+logs.toString()); | |
1461 | 196 } |
197 | |
1465 | 198 private void mergeLogs() throws IOException { |
1548 | 199 logger.info("merge"); |
200 if( !mergeLock.isLocked() ) { | |
201 logger.error("merge without lock"); | |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
202 return; |
1548 | 203 } |
204 LogFile first = logs[0]; | |
205 LogFile second = logs[1]; | |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
206 long lastTime = second.file.lastModified(); |
1465 | 207 File dirFile = new File(logDir,"merge"); |
208 if( dirFile.exists() ) | |
209 throw new RuntimeException(); | |
210 Directory dir = FSDirectory.open(dirFile); | |
1528
3bd4d7963456
use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents:
1512
diff
changeset
|
211 LuceneIndexWriter mergeWriter = new LuceneIndexWriter( dir, indexWriter.goodConfig ); |
1551 | 212 OpDoer opDoer = new BasicOpDoer(mergeWriter); |
1549 | 213 playLog( first.input(), opDoer ); |
214 playLog( second.input(), opDoer ); | |
1465 | 215 mergeWriter.commit(); |
216 LogFile merge = newLogFile(); | |
1548 | 217 LogOutputStream log = merge.output(); |
218 logLucene( lastTime, log, mergeWriter ); | |
219 log.close(); | |
1465 | 220 mergeWriter.close(); |
221 synchronized(this) { | |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
222 //check(); |
1548 | 223 logs[0] = merge; |
224 logs[1] = logs[2]; | |
225 logs[2] = newLogFile(); | |
1465 | 226 writeIndex(); |
1548 | 227 setLog(); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
228 //check(null); |
1465 | 229 } |
1461 | 230 } |
1465 | 231 private final Runnable mergeLogs = new Runnable() { public void run() { |
232 try { | |
233 mergeLogs(); | |
234 } catch(IOException e) { | |
235 throw new RuntimeException(e); | |
236 } finally { | |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
237 mergeLock.unlock(); |
1465 | 238 } |
239 } }; | |
1461 | 240 |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
241 private static class DocIter { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
242 final IndexReader reader; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
243 final TopDocs td; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
244 final int n; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
245 int i = 0; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
246 |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
247 DocIter(IndexReader reader,Query query,Sort sort) throws IOException { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
248 this.reader = reader; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
249 IndexSearcher searcher = new IndexSearcher(reader); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
250 this.td = searcher.search(query,10000000,sort); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
251 this.n = td.scoreDocs.length; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
252 if( td.totalHits != n ) |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
253 throw new RuntimeException(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
254 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
255 |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
256 Document next() throws IOException { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
257 return i < n ? reader.document(td.scoreDocs[i++].doc) : null; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
258 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
259 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
260 |
1487 | 261 private volatile boolean isChecking = false; |
262 | |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
263 public boolean check(SortField sortField) throws IOException { |
1487 | 264 if( isChecking ) |
265 throw new RuntimeException("another check is running"); | |
1508
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
266 isChecking = true; |
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
267 try { |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
268 return doCheck(sortField); |
1508
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
269 } finally { |
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
270 isChecking = false; |
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
271 } |
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
272 } |
86c5e7000ecf
lucene.backup checksum
Franklin Schmidt <fschmidt@gmail.com>
parents:
1504
diff
changeset
|
273 |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
274 protected boolean doCheck(SortField sortField) throws IOException { |
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
275 boolean ok = true; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
276 IndexReader indexReader; |
1548 | 277 LogInputStream[] logReaders; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
278 synchronized(this) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
279 indexReader = indexWriter.openReader(); |
1484
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
280 logReaders = logReaders(logs); |
1465 | 281 } |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
282 try { |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
283 //logger.info("check start"); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
284 indexWriter.check(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
285 File dirFile = new File(logDir,"check"); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
286 IoUtils.deleteRecursively(dirFile); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
287 Directory dir = FSDirectory.open(dirFile); |
1528
3bd4d7963456
use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents:
1512
diff
changeset
|
288 LuceneIndexWriter checkWriter = new LuceneIndexWriter( dir, indexWriter.goodConfig ); |
1551 | 289 playLogs(logReaders,new BasicOpDoer(checkWriter)); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
290 //logger.info("check lucene"); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
291 IndexReader checkReader = checkWriter.openReader(); |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
292 int nCheck = checkReader.numDocs(); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
293 int nOrig = indexReader.numDocs(); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
294 if( nCheck != nOrig ) { |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
295 logger.error("numDocs mismatch: lucene="+nOrig+" logs="+nCheck); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
296 ok = false; |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
297 } |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
298 if( sortField == null ) { |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
299 if( ok && hash(indexReader) != hash(checkReader) ) { |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
300 logger.error("hash mismatch"); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
301 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
302 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
303 } else { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
304 Sort sort = new Sort(sortField); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
305 String sortFieldName = sortField.getField(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
306 Query query = new PrefixQuery(new Term(sortFieldName)); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
307 DocIter origIter = new DocIter(indexReader,query,sort); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
308 DocIter checkIter = new DocIter(checkReader,query,sort); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
309 Map<String,Object> origFields = LuceneUtils.toMap(origIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
310 Map<String,Object> checkFields = LuceneUtils.toMap(checkIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
311 while( origFields!=null && checkFields!=null ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
312 Comparable origFld = (Comparable)origFields.get(sortFieldName); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
313 Comparable checkFld = (Comparable)checkFields.get(sortFieldName); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
314 int cmp = origFld.compareTo(checkFld); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
315 if( cmp==0 ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
316 if( !origFields.equals(checkFields) ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
317 logger.error(sortFieldName+" "+origFld+" not equal"); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
318 logger.error("lucene = "+origFields); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
319 logger.error("logs = "+checkFields); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
320 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
321 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
322 origFields = LuceneUtils.toMap(origIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
323 checkFields = LuceneUtils.toMap(checkIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
324 } else if( cmp < 0 ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
325 logger.error(sortFieldName+" "+origFld+" found in lucene but not logs"); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
326 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
327 origFields = LuceneUtils.toMap(origIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
328 } else { // > |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
329 logger.error(sortFieldName+" "+checkFld+" found in logs but not lucene"); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
330 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
331 checkFields = LuceneUtils.toMap(checkIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
332 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
333 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
334 while( origFields!=null ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
335 Comparable origFld = (Comparable)origFields.get(sortFieldName); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
336 logger.error(sortFieldName+" "+origFld+" found in lucene but not logs"); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
337 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
338 origFields = LuceneUtils.toMap(origIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
339 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
340 while( checkFields!=null ) { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
341 Comparable checkFld = (Comparable)checkFields.get(sortFieldName); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
342 logger.error(sortFieldName+" "+checkFld+" found in logs but not lucene"); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
343 ok = false; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
344 checkFields = LuceneUtils.toMap(checkIter.next()); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
345 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
346 //logger.info("check done"); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
347 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
348 checkReader.close(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
349 checkWriter.close(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
350 IoUtils.deleteRecursively(dirFile); |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
351 //logger.info("check done"); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
352 } finally { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
353 indexReader.close(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
354 } |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
355 return ok; |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
356 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
357 |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
358 private static abstract class HashCollector extends GoodCollector { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
359 int total = 0; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
360 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
361 |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
362 private static int hash(IndexReader reader) throws IOException { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
363 final IndexSearcher searcher = new IndexSearcher(reader); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
364 Query query = new MatchAllDocsQuery(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
365 HashCollector col = new HashCollector() { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
366 public void collectDoc(int iDoc) throws IOException { |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
367 Document doc = searcher.doc(iDoc); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
368 Map<String,Object> storedFields = LuceneUtils.toMap(doc); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
369 total += storedFields.hashCode(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
370 } |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
371 }; |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
372 searcher.search(query,col); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
373 return col.total; |
1461 | 374 } |
375 | |
1465 | 376 public synchronized void close() throws IOException { |
377 indexWriter.close(); | |
378 log.commit(); | |
1486 | 379 log.close(); |
1465 | 380 } |
381 | |
382 public synchronized void commit() throws IOException { | |
383 indexWriter.commit(); | |
384 log.commit(); | |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
385 if( mergeLock.isLocked() ) |
1465 | 386 return; |
1548 | 387 if( logs[1].file.lastModified() < System.currentTimeMillis() - logTime ) { |
1538
634f6765830e
use goodjava/lucene/logging
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
388 getMergeLock(); |
1504 | 389 new Thread(mergeLogs).start(); |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
390 // mergeLogs.run(); |
1465 | 391 } |
1461 | 392 } |
393 | |
1465 | 394 public synchronized void rollback() throws IOException { |
395 indexWriter.rollback(); | |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
396 log.rollback(); |
1465 | 397 } |
398 | |
399 public synchronized void deleteAll() throws IOException { | |
400 indexWriter.deleteAll(); | |
1486 | 401 writeOp(OP_DELETE_ALL); |
1461 | 402 } |
403 | |
1465 | 404 public synchronized void deleteDocuments(Query query) throws IOException { |
405 indexWriter.deleteDocuments(query); | |
1486 | 406 writeOp(OP_DELETE_DOCUMENTS); |
1465 | 407 log.writeQuery(query); |
408 } | |
409 | |
410 public synchronized void addDocument(Map<String,Object> storedFields) throws IOException { | |
411 indexWriter.addDocument(storedFields); | |
1486 | 412 writeOp(OP_ADD_DOCUMENT); |
1465 | 413 log.writeMap(storedFields); |
414 } | |
415 | |
416 public synchronized void updateDocument(String keyFieldName,Map<String,Object> storedFields) throws IOException { | |
417 indexWriter.updateDocument(keyFieldName,storedFields); | |
1486 | 418 writeOp(OP_UPDATE_DOCUMENT); |
1465 | 419 log.writeUTF(keyFieldName); |
420 log.writeMap(storedFields); | |
421 } | |
422 | |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
423 public synchronized void tag(String tag) throws IOException { |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
424 writeOp(OP_TAG); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
425 log.writeUTF(tag); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
426 } |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
427 |
1465 | 428 public synchronized void reindexDocuments(String keyFieldName,Query query) throws IOException { |
1461 | 429 indexWriter.reindexDocuments(keyFieldName,query); |
430 } | |
431 | |
1486 | 432 private void writeOp(int op) throws IOException { |
1465 | 433 log.writeLong(System.currentTimeMillis()); |
434 log.writeByte(op); | |
435 } | |
436 | |
1549 | 437 public synchronized void playLogs(OpDoer opDoer) throws IOException { |
438 if( opDoer == null ) | |
1551 | 439 opDoer = new BasicOpDoer(indexWriter); |
1549 | 440 playLogs( logReaders(logs), opDoer ); |
1465 | 441 } |
442 | |
1548 | 443 private static LogInputStream[] logReaders(LogFile[] logs) throws IOException { |
444 LogInputStream[] logReaders = new LogInputStream[logs.length]; | |
445 for( int i=0; i<logs.length; i++ ) { | |
446 logReaders[i] = logs[i].input(); | |
1484
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
447 } |
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
448 return logReaders; |
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
449 } |
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
450 |
1549 | 451 private static void playLogs(LogInputStream[] logReaders,OpDoer opDoer) |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
452 throws IOException |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
453 { |
1484
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
454 for( LogInputStream reader : logReaders ) { |
1549 | 455 playLog(reader,opDoer); |
1465 | 456 } |
1549 | 457 opDoer.commit(); |
1465 | 458 } |
459 | |
1549 | 460 private static void playLog(LogInputStream in,OpDoer opDoer) |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
461 throws IOException |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
462 { |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
463 while( in.available() > 0 ) { |
1549 | 464 playOp(in,opDoer); |
1465 | 465 } |
1484
1fa6e8ec2d53
lucene.logging cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents:
1476
diff
changeset
|
466 in.close(); |
1465 | 467 } |
468 | |
1549 | 469 private static void playOp(LogInputStream in,OpDoer opDoer) |
1548 | 470 throws IOException |
471 { | |
1549 | 472 long time = in.readLong(); // time |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
473 int op = in.readByte(); |
1461 | 474 switch(op) { |
475 case OP_DELETE_ALL: | |
1549 | 476 opDoer.deleteAll(time); |
1548 | 477 return; |
1461 | 478 case OP_DELETE_DOCUMENTS: |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
479 { |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
480 Query query = in.readQuery(); |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
481 //System.out.println("OP_DELETE_DOCUMENTS "+query); |
1549 | 482 opDoer.deleteDocuments(time,query); |
1548 | 483 return; |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
484 } |
1461 | 485 case OP_ADD_DOCUMENT: |
1465 | 486 { |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
487 Map storedFields = in.readMap(); |
1549 | 488 opDoer.addDocument(time,storedFields); |
1548 | 489 return; |
1465 | 490 } |
1461 | 491 case OP_UPDATE_DOCUMENT: |
1465 | 492 { |
1476
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
493 String keyFieldName = in.readUTF(); |
7d145095cc0b
lucene.logging check
Franklin Schmidt <fschmidt@gmail.com>
parents:
1475
diff
changeset
|
494 Map storedFields = in.readMap(); |
1549 | 495 opDoer.updateDocument(time,keyFieldName,storedFields); |
1548 | 496 return; |
1544
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
497 } |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
498 case OP_TAG: |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
499 { |
35601f15ecc3
add lucene log tag and restore_from_log
Franklin Schmidt <fschmidt@gmail.com>
parents:
1539
diff
changeset
|
500 String tag = in.readUTF(); |
1549 | 501 opDoer.tag(time,tag); |
1548 | 502 return; |
1465 | 503 } |
1461 | 504 default: |
505 throw new RuntimeException("invalid op "+op); | |
506 } | |
507 } | |
508 | |
1465 | 509 private static void dump(LuceneIndexWriter indexWriter) throws IOException { |
510 IndexReader reader = indexWriter.openReader(); | |
511 IndexSearcher searcher = new IndexSearcher(reader); | |
512 Query query = new MatchAllDocsQuery(); | |
513 TopDocs td = searcher.search(query,100); | |
514 System.out.println("totalHits = "+td.totalHits); | |
515 for( int i=0; i<td.scoreDocs.length; i++ ) { | |
516 Document doc = searcher.doc(td.scoreDocs[i].doc); | |
517 System.out.println(LuceneUtils.toMap(doc)); | |
1461 | 518 } |
1465 | 519 System.out.println(); |
520 reader.close(); | |
1461 | 521 } |
1465 | 522 |
1461 | 523 } |