Examples of IndexCommit


Examples of org.apache.lucene.index.IndexCommit

    //-------------------------------< internal >-------------------------------

    private void checkCommits(List commits) throws IOException {
        long currentTime = System.currentTimeMillis();
        for (int i = 0; i < commits.size() - 1; i++) {
            IndexCommit ic = (IndexCommit) commits.get(i);
            long lastModified = index.getDirectory().fileModified(ic.getSegmentsFileName());
            if (currentTime - lastModified > maxAge) {
                ic.delete();
            } else {
                // following commits are younger, no need to check
                break;
            }
        }
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

 
  @Override
  public InputStream open(String source, String fileName) throws IOException {
    assert source.equals(INDEX_SOURCE) || source.equals(TAXONOMY_SOURCE) : "invalid source; expected=(" + INDEX_SOURCE
    + " or " + TAXONOMY_SOURCE + ") got=" + source;
    IndexCommit ic = source.equals(INDEX_SOURCE) ? indexCommit : taxoCommit;
    return new IndexInputInputStream(ic.getDirectory().openInput(fileName, IOContext.READONCE));
  }
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

      return;
    }
    // This command does not give the current index version of the master
    // It gives the current 'replicateable' index version
   if (command.equals(CMD_INDEX_VERSION)) {
      IndexCommit commitPoint = indexCommitPoint;  // make a copy so it won't change
      if (commitPoint != null && replicationEnabled.get()) {
        //
        // There is a race condition here.  The commit point may be changed / deleted by the time
        // we get around to reserving it.  This is a very small window though, and should not result
        // in a catastrophic failure, but will result in the client getting an empty file list for
        // the CMD_GET_FILE_LIST command.
        //
        core.getDeletionPolicy().setReserveDuration(commitPoint.getVersion(), reserveCommitDuration);
        rsp.add(CMD_INDEX_VERSION, commitPoint.getVersion());
        rsp.add(GENERATION, commitPoint.getGeneration());
      } else {
        // This happens when replication is not configured to happen after startup and no commit/optimize
        // has happened yet.
        rsp.add(CMD_INDEX_VERSION, 0L);
        rsp.add(GENERATION, 0L);
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

  }

  private void doSnapShoot(SolrParams params, SolrQueryResponse rsp, SolrQueryRequest req) {
    try {
      IndexDeletionPolicyWrapper delPolicy = core.getDeletionPolicy();
      IndexCommit indexCommit = delPolicy.getLatestCommit();
      // race?
      delPolicy.setReserveDuration(indexCommit.getVersion(), reserveCommitDuration);
      if(indexCommit == null) {
        indexCommit = req.getSearcher().getReader().getIndexCommit();
      }
      if (indexCommit != null)  {
        new SnapShooter(core, params.get("location")).createSnapAsync(indexCommit, this);
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

    if (v == null) {
      rsp.add("status", "no indexversion specified");
      return;
    }
    long version = Long.parseLong(v);
    IndexCommit commit = core.getDeletionPolicy().getCommitPoint(version);
    if (commit == null) {
      rsp.add("status", "invalid indexversion");
      return;
    }
    // reserve the indexcommit for sometime
    core.getDeletionPolicy().setReserveDuration(version, reserveCommitDuration);
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
    try {
      //get all the files in the commit
      //use a set to workaround possible Lucene bug which returns same file name multiple times
      Collection<String> files = new HashSet<String>(commit.getFileNames());
      for (String fileName : files) {
        if(fileName.endsWith(".lock")) continue;
        File file = new File(core.getIndexDir(), fileName);
        Map<String, Object> fileMeta = getFileInfo(file);
        result.add(fileMeta);
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

    details.add("isSlave", String.valueOf(isSlave));
    long[] versionAndGeneration = getIndexVersion();
    details.add("indexVersion", versionAndGeneration[0]);
    details.add(GENERATION, versionAndGeneration[1]);

    IndexCommit commit = indexCommitPoint;  // make a copy so it won't change

    if (isMaster) {
      if (includeConfFiles != null) master.add(CONF_FILES, includeConfFiles);
      master.add(REPLICATE_AFTER, getReplicateAfterStrings());
      master.add("replicationEnabled", String.valueOf(replicationEnabled.get()));
    }

    if (isMaster && commit != null) {
      master.add("replicatableIndexVersion", commit.getVersion());
      master.add("replicatableGeneration", commit.getGeneration());
    }

    SnapPuller snapPuller = tempSnapPuller;
    if (showSlaveDetails && snapPuller != null) {
      Properties props = loadReplicationProperties();
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

    return props;
  }


  void refreshCommitpoint() {
    IndexCommit commitPoint = core.getDeletionPolicy().getLatestCommit();
    if(replicateOnCommit || (replicateOnOptimize && commitPoint.isOptimized())) {
      indexCommitPoint = commitPoint;
    }
  }
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

      /**
       * This refreshes the latest replicateable index commit and optionally can create Snapshots as well
       */
      public void postCommit() {
        if (getCommit) {
          IndexCommit oldCommitPoint = indexCommitPoint;
          indexCommitPoint = core.getDeletionPolicy().getLatestCommit();
          if(indexCommitPoint != null){
            core.getDeletionPolicy().saveCommitPoint(indexCommitPoint.getVersion());
          }
          if(oldCommitPoint != null){
            core.getDeletionPolicy().releaseCommitPoint(oldCommitPoint.getVersion());
          }
        }
        if (snapshoot) {
          try {
            SnapShooter snapShooter = new SnapShooter(core, null);
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

        Thread commitThread =  new Thread(new Runnable() {
            @Override
            public void run() {
              try {
                iw.commit();
                IndexCommit ic = sdp.snapshot();
                for (String name : ic.getFileNames()) {
                  //distribute, and backup
                  //System.out.println(names);
                  assertTrue(slowFileExists(dir, name));
                }
              } catch (Exception e) {
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

    writer.setMaxBufferedDocs(2);
    Document doc = new Document();
    doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
    for(int i=0;i<7;i++)
      writer.addDocument(doc);
    IndexCommit cp = (IndexCommit) dp.snapshot();
    copyFiles(dir, cp);
    writer.close();
    copyFiles(dir, cp);
   
    writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.