Package org.apache.lucene.store

Examples of org.apache.lucene.store.SimpleFSDirectory


    @Override
    public void setUp() throws Exception {
       super.setUp();
       File file = _TestUtil.getTempDir("testIndex");
       // use a simple FSDir here, to be sure to have SimpleFSInputs
       dir = new SimpleFSDirectory(file,null);
    }
View Full Code Here


    });

    boolean foundOldestToKeep = false;

    for (ZoieMultiReader<R> reader : readerList) {
      SimpleFSDirectory dir = (SimpleFSDirectory) reader.directory();
      String path = dir.getDirectory().getName();

      if (foundOldestToKeep) {
        if (listener != null) {
          listener.onIndexReaderCleanUp(reader);
        }
        log.info("trimming: remove " + path);
        log.info(dir.getDirectory() + " -before--"
            + (dir.getDirectory().exists() ? " not deleted " : " deleted"));
        FileUtil.rmDir(dir.getDirectory());
        log.info(dir.getDirectory() + " -after--"
            + (dir.getDirectory().exists() ? " not deleted " : " deleted"));
        continue;
      } else {
        // Always keep this reader (when the oldest one to keep has not
        // been found), no matter the index directory name can be parsed
        // or not.
View Full Code Here

    return box._archiveZoies;
  }

  private DirectoryReader getArchive(ZoieSystem<R, D> zoie) throws CorruptIndexException, IOException {
    String dirName = zoie.getAdminMBean().getIndexDir();
    Directory dir = new SimpleFSDirectory(new File(dirName));
    DirectoryReader reader = null;
    if (DirectoryReader.indexExists(dir)) {
      reader = DirectoryReader.open(dir);
    } else {
      log.info("empty index " + dirName);
View Full Code Here

  private FSDirectory getFSDirectoryFromFile(File f) throws IOException {
    FSDirectory dir = null;
    switch (_mode) {
    case SIMPLE:
      dir = new SimpleFSDirectory(f);
      break;
    case NIO:
      dir = new NIOFSDirectory(f);
      break;
    case MMAP:
View Full Code Here

    }

    FSDirectory dir = null;
    switch (_mode) {
    case SIMPLE:
      dir = new SimpleFSDirectory(_location);
      break;
    case NIO:
      dir = new NIOFSDirectory(_location);
      break;
    case MMAP:
View Full Code Here

  public synchronized RAMSearchIndex<R> newInstance(String version,
      IndexReaderDecorator<R> decorator, SearchIndexManager<R> idxMgr) {
    Directory ramIdxDir;
    try {
      File backingdir = new File("/tmp/ram" + fold);// /Volumes/ramdisk/
      ramIdxDir = new SimpleFSDirectory(backingdir);
      fold++;
      return new RAMSearchIndex<R>(version, decorator, idxMgr, ramIdxDir, backingdir);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      log.error(e);
View Full Code Here

        }
    }

    public static void corruptFile(File file, ESLogger logger) throws IOException {
        File fileToCorrupt = file;
        try (final SimpleFSDirectory dir = new SimpleFSDirectory(fileToCorrupt.getParentFile().toPath())) {
            long checksumBeforeCorruption;
            try (IndexInput input = dir.openInput(fileToCorrupt.getName(), IOContext.DEFAULT)) {
                checksumBeforeCorruption = CodecUtil.retrieveChecksum(input);
            }
            try (RandomAccessFile raf = new RandomAccessFile(fileToCorrupt, "rw")) {
                raf.seek(randomIntBetween(0, (int)Math.min(Integer.MAX_VALUE, raf.length()-1)));
                long filePointer = raf.getFilePointer();
                byte b = raf.readByte();
                raf.seek(filePointer);
                raf.writeByte(~b);
                raf.getFD().sync();
                logger.debug("Corrupting file {} --  flipping at position {} from {} to {} ", fileToCorrupt.getName(), filePointer, Integer.toHexString(b), Integer.toHexString(~b));
            }
        long checksumAfterCorruption;
        long actualChecksumAfterCorruption;
        try (ChecksumIndexInput input = dir.openChecksumInput(fileToCorrupt.getName(), IOContext.DEFAULT)) {
            assertThat(input.getFilePointer(), is(0l));
            input.seek(input.length() - 8); // one long is the checksum... 8 bytes
            checksumAfterCorruption = input.getChecksum();
            actualChecksumAfterCorruption = input.readLong();
        }
        StringBuilder msg = new StringBuilder();
        msg.append("Checksum before: [").append(checksumBeforeCorruption).append("]");
        msg.append(" after: [").append(checksumAfterCorruption).append("]");
        msg.append(" checksum value after corruption: ").append(actualChecksumAfterCorruption).append("]");
        msg.append(" file: ").append(fileToCorrupt.getName()).append(" length: ").append(dir.fileLength(fileToCorrupt.getName()));
        logger.debug(msg.toString());
        assumeTrue("Checksum collision - " + msg.toString(),
                checksumAfterCorruption != checksumBeforeCorruption // collision
                        || actualChecksumAfterCorruption != checksumBeforeCorruption); // checksum corrupted
        }
View Full Code Here

        super(shardId, indexSettings, indexStore);
    }

    @Override
    protected Directory newFSDirectory(File location, LockFactory lockFactory) throws IOException {
        return new SimpleFSDirectory(location.toPath(), lockFactory);
    }
View Full Code Here

    public void setUp() throws Exception {
       super.setUp();
       File file = new File(System.getProperty("tempDir"), "testIndex");
       _TestUtil.rmDir(file);
       // use a simple FSDir here, to be sure to have SimpleFSInputs
       dir = new SimpleFSDirectory(file,null);
    }
View Full Code Here

    @Override
    public void setUp() throws Exception {
       super.setUp();
       File file = _TestUtil.getTempDir("testIndex");
       // use a simple FSDir here, to be sure to have SimpleFSInputs
       dir = new SimpleFSDirectory(file,null);
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.SimpleFSDirectory

Copyright © 2018 www.massapicom. 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.