Examples of IndexCommit


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();
          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

    // this will happen rarely, so just synchronize everything
    // for safety and to avoid race conditions

    synchronized (this) {
      long maxCommitAgeTimeStamp = -1L;
      IndexCommit newest = commits.get(commits.size() - 1);
      log.info("newest commit = " + newest.getVersion());

      int optimizedKept = newest.isOptimized() ? 1 : 0;
      int totalKept = 1;

      // work our way from newest to oldest, skipping the first since we always want to keep it.
      for (int i=commits.size()-2; i>=0; i--) {
        IndexCommit commit = commits.get(i);

        // delete anything too old, regardless of other policies
        try {
          if (maxCommitAge != null) {
            if (maxCommitAgeTimeStamp==-1) {
              DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
              maxCommitAgeTimeStamp = dmp.parseMath(maxCommitAge).getTime();
            }
            if (commit.getTimestamp() < maxCommitAgeTimeStamp) {
              commit.delete();
              continue;
            }
          }
        } catch (Exception e) {
          log.warn("Exception while checking commit point's age for deletion", e);
        }

        if (optimizedKept < maxOptimizedCommitsToKeep && commit.isOptimized()) {
          totalKept++;
          optimizedKept++;
          continue;
        }

        if (totalKept < maxCommitsToKeep) {
          totalKept++;
          continue;
        }
                                                 
        commit.delete();
      }

    } // end synchronized
  }
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

      long latestGeneration = (Long) response.get(GENERATION);
      if (latestVersion == 0L) {
        //there is nothing to be replicated
        return false;
      }
      IndexCommit commit;
      RefCounted<SolrIndexSearcher> searcherRefCounted = null;
      try {
        searcherRefCounted = core.getNewestSearcher(false);
        commit = searcherRefCounted.get().getReader().getIndexCommit();
      } finally {
        if (searcherRefCounted != null)
          searcherRefCounted.decref();
      }
      if (commit.getVersion() == latestVersion && commit.getGeneration() == latestGeneration) {
        //master and slave are alsready in sync just return
        LOG.info("Slave in sync with master.");
        return false;
      }
      LOG.info("Master's version: " + latestVersion + ", generation: " + latestGeneration);
      LOG.info("Slave's version: " + commit.getVersion() + ", generation: " + commit.getGeneration());
      LOG.info("Starting replication process");
      // get the list of files first
      fetchFileList(latestVersion);
      // this can happen if the commit point is deleted before we fetch the file list.
      if(filesToDownload.isEmpty()) return false;
      LOG.info("Number of files in latest index in master: " + filesToDownload.size());

      // Create the sync service
      fsyncService = Executors.newSingleThreadExecutor();
      // use a synchronized list because the list is read by other threads (to show details)
      filesDownloaded = Collections.synchronizedList(new ArrayList<Map<String, Object>>());
      // if the generateion of master is older than that of the slave , it means they are not compatible to be copied
      // then a new index direcory to be created and all the files need to be copied
      boolean isFullCopyNeeded = commit.getGeneration() >= latestGeneration;
      File tmpIndexDir = createTempindexDir(core);
      if (isIndexStale())
        isFullCopyNeeded = true;
      successfulInstall = false;
      boolean deleteTmpIdxDir = true;
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

    public void onCommit(List commits) throws IOException {
        checkCommits(commits);

        // report back current generation
        IndexCommit current = (IndexCommit) commits.get(commits.size() - 1);
        String name = current.getSegmentsFileName();
        if (name.equals(SEGMENTS)) {
            index.setCurrentGeneration(0);
        } else {
            index.setCurrentGeneration(
                    Long.parseLong(name.substring(SEGMENTS.length() + 1),
View Full Code Here

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

        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

    public void onCommit(List<? extends IndexCommit> commits) throws IOException {
        checkCommits(commits);

        // report back current generation
        IndexCommit current = commits.get(commits.size() - 1);
        String name = current.getSegmentsFileName();
        if (name.equals(SEGMENTS)) {
            index.setCurrentGeneration(0);
        } else {
            index.setCurrentGeneration(
                    Long.parseLong(name.substring(SEGMENTS.length() + 1),
View Full Code Here

Examples of org.apache.lucene.index.IndexCommit

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

    private void checkCommits(List<? extends IndexCommit> commits) throws IOException {
        long currentTime = System.currentTimeMillis();
        for (int i = 0; i < commits.size() - 1; i++) {
            IndexCommit ic = 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

    public void onCommit(List commits) throws IOException {
        checkCommits(commits);

        // report back current generation
        IndexCommit current = (IndexCommit) commits.get(commits.size() - 1);
        String name = current.getSegmentsFileName();
        if (name.equals(SEGMENTS)) {
            index.setCurrentGeneration(0);
        } else {
            index.setCurrentGeneration(
                    Long.parseLong(name.substring(SEGMENTS.length() + 1),
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.