Example usage for org.apache.lucene.store MockDirectoryWrapper MockDirectoryWrapper

List of usage examples for org.apache.lucene.store MockDirectoryWrapper MockDirectoryWrapper

Introduction

In this page you can find the example usage for org.apache.lucene.store MockDirectoryWrapper MockDirectoryWrapper.

Prototype

public MockDirectoryWrapper(Random random, Directory delegate) 

Source Link

Usage

From source file:org.elasticsearch.index.store.DistributorInTheWildTest.java

License:Apache License

@Override
protected Directory getDirectory(Directory in) {
    assert in instanceof MockDirectoryWrapper;
    if (!useNonNrtReaders)
        ((MockDirectoryWrapper) in).setAssertNoDeleteOpenFile(true);

    Directory[] directories = new Directory[1 + random().nextInt(5)];
    directories[0] = in;/*from w  w  w  .jav a  2 s . com*/
    for (int i = 1; i < directories.length; i++) {
        final File tempDir = createTempDir(getTestName());
        directories[i] = newMockFSDirectory(tempDir); // some subclasses rely on this being MDW
        if (!useNonNrtReaders)
            ((MockDirectoryWrapper) directories[i]).setAssertNoDeleteOpenFile(true);
    }
    for (Directory dir : directories) {
        ((MockDirectoryWrapper) dir).setCheckIndexOnClose(false);
    }

    try {

        if (random().nextBoolean()) {
            return new MockDirectoryWrapper(random(), new DistributorDirectory(directories));
        } else {
            return new DistributorDirectory(directories);
        }
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.elasticsearch.index.store.mock.MockDirectoryHelper.java

License:Apache License

public Directory wrap(Directory dir) {
    final MockDirectoryWrapper w = new MockDirectoryWrapper(random, dir);
    w.setRandomIOExceptionRate(randomIOExceptionRate);
    w.setRandomIOExceptionRateOnOpen(randomIOExceptionRateOnOpen);
    w.setThrottling(throttle);/*from  ww  w .  j  a v a  2  s  .co  m*/
    w.setCheckIndexOnClose(checkIndexOnClose);
    wrappers.add(w);
    return new FilterDirectory(w) {
        @Override
        public Directory getDelegate() {
            // TODO we should port this FilterDirectory to Lucene
            return w.getDelegate();
        }
    };
}

From source file:org.elasticsearch.test.store.mock.MockDirectoryHelper.java

License:Apache License

public Directory wrap(Directory dir) {
    final MockDirectoryWrapper w = new MockDirectoryWrapper(random, dir);
    w.setRandomIOExceptionRate(randomIOExceptionRate);
    w.setRandomIOExceptionRateOnOpen(randomIOExceptionRateOnOpen);
    w.setThrottling(throttle);/*w  ww  .  j a v  a2 s .c  om*/
    w.setCheckIndexOnClose(checkIndexOnClose);
    w.setPreventDoubleWrite(preventDoubleWrite);
    w.setNoDeleteOpenFile(noDeleteOpenFile);
    wrappers.add(w);
    return new FilterDirectory(w) {
        @Override
        public Directory getDelegate() {
            // TODO we should port this FilterDirectory to Lucene
            return w.getDelegate();
        }
    };
}