Example #1
0
  @Override
  public void init(MemeDB memeDB) {
    super.init(memeDB);

    String path = memeDB.getProperty(STATE_PATH);
    if (path == null) {
      throw new RuntimeException(
          "You must include a " + STATE_PATH + " element in memedb.properties");
    }
    this.stateDir = new File(path);
    if (!stateDir.exists()) {
      log.info("Creating lucene directory " + path);
      stateDir.mkdirs();
    } else if (!stateDir.isDirectory()) {
      log.error("Path: {} not valid!", path);
      throw new RuntimeException("Path: " + path + " not valid!");
    }
    for (String db : memeDB.getBackend().getDatabaseNames()) {
      log.debug("Opening fulltext results for: {}", db);
      try {
        openWriterForDatabase(db);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }
Example #2
0
 public void onDatabaseCreated(String db, long seq) {
   this.abort(db);
   File path = indexPath(db);
   onDatabaseDeleted(db, -1);
   if (!path.exists()) {
     log.info("Creating lucene directory {} for db {}", path.getPath(), db);
     path.mkdirs();
   }
   try {
     Directory directory = FSDirectory.getDirectory(path.getPath());
     writers.put(db, new IndexWriter(directory, true, new StandardAnalyzer(), true));
   } catch (CorruptIndexException e) {
   } catch (LockObtainFailedException e) {
   } catch (IOException e) {
   }
 }