Mercurial Hosting > luan
comparison src/luan/modules/lucene/LuceneIndex.java @ 1672:8dd8c556c449
backup work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 26 May 2022 21:10:02 -0600 |
parents | 582384548a69 |
children | 1b9f9fdb3b41 |
comparison
equal
deleted
inserted
replaced
1671:8066b8882732 | 1672:8dd8c556c449 |
---|---|
79 import goodjava.lucene.api.LuceneIndexWriter; | 79 import goodjava.lucene.api.LuceneIndexWriter; |
80 import goodjava.lucene.api.GoodIndexWriterConfig; | 80 import goodjava.lucene.api.GoodIndexWriterConfig; |
81 import goodjava.lucene.api.LuceneUtils; | 81 import goodjava.lucene.api.LuceneUtils; |
82 import goodjava.lucene.logging.LoggingIndexWriter; | 82 import goodjava.lucene.logging.LoggingIndexWriter; |
83 import goodjava.lucene.logging.OpDoer; | 83 import goodjava.lucene.logging.OpDoer; |
84 import goodjava.lucene.backup.BackupIndexWriter; | |
84 import goodjava.parser.ParseException; | 85 import goodjava.parser.ParseException; |
85 import luan.modules.Utils; | 86 import luan.modules.Utils; |
86 import luan.Luan; | 87 import luan.Luan; |
87 import luan.LuanTable; | 88 import luan.LuanTable; |
88 import luan.LuanFunction; | 89 import luan.LuanFunction; |
144 | 145 |
145 private final PostgresBackup postgresBackup; | 146 private final PostgresBackup postgresBackup; |
146 private boolean wasCreated; | 147 private boolean wasCreated; |
147 private final File logDir; | 148 private final File logDir; |
148 private final long logTime; | 149 private final long logTime; |
150 private final String name; | |
151 private final String domain; | |
152 private final String password; | |
149 | 153 |
150 private LuceneIndex(Luan luan,File indexDir,LuanTable options) | 154 private LuceneIndex(Luan luan,File indexDir,LuanTable options) |
151 throws LuanException, IOException, ClassNotFoundException, SQLException | 155 throws LuanException, IOException, ClassNotFoundException, SQLException |
152 { | 156 { |
153 options = new LuanTable(options); | 157 options = new LuanTable(options); |
157 String[] defaultFields = defaultFieldsTbl==null ? null : (String[])defaultFieldsTbl.asList().toArray(new String[0]); | 161 String[] defaultFields = defaultFieldsTbl==null ? null : (String[])defaultFieldsTbl.asList().toArray(new String[0]); |
158 LuanTable postgresSpec = Utils.removeTable(options,"postgres_spec"); | 162 LuanTable postgresSpec = Utils.removeTable(options,"postgres_spec"); |
159 LuanFunction supplementer = Utils.removeFunction(options,"supplementer"); | 163 LuanFunction supplementer = Utils.removeFunction(options,"supplementer"); |
160 logDir = (File)options.remove("log_dir"); | 164 logDir = (File)options.remove("log_dir"); |
161 logTime = (Long)options.remove("log_time"); | 165 logTime = (Long)options.remove("log_time"); |
166 name = (String)options.remove("name"); | |
162 Utils.checkEmpty(options); | 167 Utils.checkEmpty(options); |
168 | |
169 { | |
170 LuanTable module = (LuanTable)luan.require("luan:http/Http.luan"); | |
171 String domain = (String)module.get(luan,"domain"); | |
172 if( domain == null ) | |
173 domain = "localhost"; | |
174 this.domain = domain; | |
175 } | |
176 { | |
177 LuanTable module = (LuanTable)luan.require("luan:Io.luan"); | |
178 String password = (String)module.get(luan,"password"); | |
179 if( password == null ) | |
180 password = "password"; | |
181 this.password = password; | |
182 } | |
163 | 183 |
164 mfp = defaultFieldParser==null ? new MultiFieldParser() : new MultiFieldParser(defaultFieldParser,defaultFields); | 184 mfp = defaultFieldParser==null ? new MultiFieldParser() : new MultiFieldParser(defaultFieldParser,defaultFields); |
165 mfp.fields.put( "type", STRING_FIELD_PARSER ); | 185 mfp.fields.put( "type", STRING_FIELD_PARSER ); |
166 mfp.fields.put( "id", NumberFieldParser.LONG ); | 186 mfp.fields.put( "id", NumberFieldParser.LONG ); |
167 this.indexDir = indexDir; | 187 this.indexDir = indexDir; |
191 | 211 |
192 public boolean reopen() throws IOException { | 212 public boolean reopen() throws IOException { |
193 fsDir = FSDirectory.open(indexDir); | 213 fsDir = FSDirectory.open(indexDir); |
194 boolean wasCreated = !fsDir.getDirectory().exists(); | 214 boolean wasCreated = !fsDir.getDirectory().exists(); |
195 writer = new LuceneIndexWriter(fsDir,config); | 215 writer = new LuceneIndexWriter(fsDir,config); |
196 if( logDir != null ) | 216 if( logDir != null ) { |
197 writer = new LoggingIndexWriter((LuceneIndexWriter)writer,logDir,logTime); | 217 if( BackupIndexWriter.backupDomains == null ) { |
218 writer = new LoggingIndexWriter((LuceneIndexWriter)writer,logDir,logTime); | |
219 } else { | |
220 String name = this.domain; | |
221 if( this.name != null ) | |
222 name += "~" + this.name; | |
223 writer = new BackupIndexWriter((LuceneIndexWriter)writer,logDir,logTime,name,password); | |
224 //qqq | |
225 } | |
226 } | |
198 reader = DirectoryReader.open(fsDir); | 227 reader = DirectoryReader.open(fsDir); |
199 searcher = new IndexSearcher(reader); | 228 searcher = new IndexSearcher(reader); |
200 initId(); | 229 initId(); |
201 return wasCreated; | 230 return wasCreated; |
202 } | 231 } |