comparison src/luan/modules/lucene/LuceneIndex.java @ 1556:52241b69c339

lucene logging
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 11 Oct 2020 17:28:16 -0600
parents 26c51acf00f3
children b89212fd04b5
comparison
equal deleted inserted replaced
1555:1b397a949791 1556:52241b69c339
419 snapshotDeletionPolicy.release(ic); 419 snapshotDeletionPolicy.release(ic);
420 } 420 }
421 } 421 }
422 422
423 public void tag(String tag) throws IOException { 423 public void tag(String tag) throws IOException {
424 writer.tag(tag); 424 boolean commit = !writeLock.isHeldByCurrentThread();
425 writeLock.lock();
426 try {
427 writer.tag(tag);
428 if(commit) writer.commit();
429 } finally {
430 writeLock.unlock();
431 }
425 } 432 }
426 433
427 434
428 435
429 public String to_string() { 436 public String to_string() {
768 throws LuanException, IOException 775 throws LuanException, IOException
769 { 776 {
770 writer.addDocument(toLucene(doc)); 777 writer.addDocument(toLucene(doc));
771 } 778 }
772 779
780 public void relog()
781 throws IOException, LuanException
782 {
783 logger.info("start relog");
784 writeLock.lock();
785 try {
786 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer;
787 loggingWriter.logLucene();
788 } finally {
789 writeLock.unlock();
790 }
791 logger.info("end relog");
792 }
793
773 public void restore_from_log(LuanFunction handler) 794 public void restore_from_log(LuanFunction handler)
774 throws IOException, LuanException, SQLException, ParseException 795 throws IOException, LuanException, SQLException, ParseException
775 { 796 {
776 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer; 797 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer;
777 if( wasCreated && !loggingWriter.wasCreated ) { 798 if( wasCreated && !loggingWriter.wasCreated ) {
789 OpDoer opDoer = handler==null ? null : new LuanOpDoer(writer,handler); 810 OpDoer opDoer = handler==null ? null : new LuanOpDoer(writer,handler);
790 writeLock.lock(); 811 writeLock.lock();
791 boolean ok = false; 812 boolean ok = false;
792 try { 813 try {
793 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer; 814 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer;
794 IndexWriter iw = writer.getLuceneIndexWriter();
795 iw.deleteAll();
796 loggingWriter.playLogs(opDoer); 815 loggingWriter.playLogs(opDoer);
797 ok = true; 816 ok = true;
798 wrote(); 817 wrote();
799 ensure_open(); // refresh searcher 818 ensure_open(); // refresh searcher
800 initId(); 819 initId();
827 if( hasPostgres ) { 846 if( hasPostgres ) {
828 logger.info("postgres check"); 847 logger.info("postgres check");
829 checkPostgres(luan); 848 checkPostgres(luan);
830 } 849 }
831 logger.info("end check"); 850 logger.info("end check");
832 }
833
834 public void rebuild_log() throws IOException {
835 logger.info("start rebuild_log");
836 LoggingIndexWriter loggingWriter = (LoggingIndexWriter)writer;
837 loggingWriter.newLogs();
838 logger.info("end rebuild_log");
839 } 851 }
840 852
841 private void checkPostgres(Luan luan) 853 private void checkPostgres(Luan luan)
842 throws IOException, SQLException, LuanException, ParseException 854 throws IOException, SQLException, LuanException, ParseException
843 { 855 {