Merge remote-tracking branch 'dakrone/fix-smb-plugin-master'
This commit is contained in:
commit
3c7f578010
|
@ -17,13 +17,18 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.lucene.store;
|
package org.elasticsearch.index.store;
|
||||||
|
|
||||||
import java.io.FilterOutputStream;
|
import java.io.FilterOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import org.apache.lucene.store.FSDirectory;
|
||||||
|
import org.apache.lucene.store.FilterDirectory;
|
||||||
|
import org.apache.lucene.store.IOContext;
|
||||||
|
import org.apache.lucene.store.IndexOutput;
|
||||||
|
import org.apache.lucene.store.OutputStreamIndexOutput;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to wrap an existing {@link org.apache.lucene.store.FSDirectory} so that
|
* This class is used to wrap an existing {@link org.apache.lucene.store.FSDirectory} so that
|
||||||
|
@ -43,14 +48,10 @@ public final class SmbDirectoryWrapper extends FilterDirectory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexOutput createOutput(String name, IOContext context) throws IOException {
|
public IndexOutput createOutput(String name, IOContext context) throws IOException {
|
||||||
fsDirectory.ensureOpen();
|
this.ensureOpen();
|
||||||
fsDirectory.ensureCanWrite(name);
|
|
||||||
return new SmbFSIndexOutput(name);
|
return new SmbFSIndexOutput(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copied from final inner class {@link org.apache.lucene.store.FSDirectory.FSIndexOutput}
|
|
||||||
*/
|
|
||||||
final class SmbFSIndexOutput extends OutputStreamIndexOutput {
|
final class SmbFSIndexOutput extends OutputStreamIndexOutput {
|
||||||
/**
|
/**
|
||||||
* The maximum chunk size is 8192 bytes, because {@link java.io.FileOutputStream} mallocs
|
* The maximum chunk size is 8192 bytes, because {@link java.io.FileOutputStream} mallocs
|
|
@ -22,11 +22,11 @@ package org.elasticsearch.index.store.smbmmapfs;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.LockFactory;
|
import org.apache.lucene.store.LockFactory;
|
||||||
import org.apache.lucene.store.MMapDirectory;
|
import org.apache.lucene.store.MMapDirectory;
|
||||||
import org.apache.lucene.store.SmbDirectoryWrapper;
|
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.shard.ShardPath;
|
import org.elasticsearch.index.shard.ShardPath;
|
||||||
import org.elasticsearch.index.store.FsDirectoryService;
|
import org.elasticsearch.index.store.FsDirectoryService;
|
||||||
import org.elasticsearch.index.store.IndexStore;
|
import org.elasticsearch.index.store.IndexStore;
|
||||||
|
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
|
@ -22,11 +22,11 @@ package org.elasticsearch.index.store.smbsimplefs;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.LockFactory;
|
import org.apache.lucene.store.LockFactory;
|
||||||
import org.apache.lucene.store.SimpleFSDirectory;
|
import org.apache.lucene.store.SimpleFSDirectory;
|
||||||
import org.apache.lucene.store.SmbDirectoryWrapper;
|
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.index.shard.ShardPath;
|
import org.elasticsearch.index.shard.ShardPath;
|
||||||
import org.elasticsearch.index.store.FsDirectoryService;
|
import org.elasticsearch.index.store.FsDirectoryService;
|
||||||
import org.elasticsearch.index.store.IndexStore;
|
import org.elasticsearch.index.store.IndexStore;
|
||||||
|
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.apache.lucene.store;
|
package org.elastiscearch.index.store;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
* Licensed to Elasticsearch under one or more contributor
|
||||||
|
@ -21,6 +21,7 @@ package org.apache.lucene.store;
|
||||||
|
|
||||||
import com.carrotsearch.randomizedtesting.annotations.Listeners;
|
import com.carrotsearch.randomizedtesting.annotations.Listeners;
|
||||||
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
|
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
|
||||||
|
import org.apache.lucene.store.BaseDirectoryTestCase;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TimeUnits;
|
import org.apache.lucene.util.TimeUnits;
|
||||||
import org.elasticsearch.bootstrap.BootstrapForTesting;
|
import org.elasticsearch.bootstrap.BootstrapForTesting;
|
|
@ -17,10 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.lucene.store;
|
package org.elastiscearch.index.store;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.MMapDirectory;
|
||||||
|
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||||
|
|
||||||
public class SmbMMapDirectoryTests extends ESBaseDirectoryTestCase {
|
public class SmbMMapDirectoryTests extends ESBaseDirectoryTestCase {
|
||||||
|
|
||||||
|
@ -28,4 +31,4 @@ public class SmbMMapDirectoryTests extends ESBaseDirectoryTestCase {
|
||||||
protected Directory getDirectory(Path file) throws IOException {
|
protected Directory getDirectory(Path file) throws IOException {
|
||||||
return new SmbDirectoryWrapper(new MMapDirectory(file));
|
return new SmbDirectoryWrapper(new MMapDirectory(file));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -17,10 +17,13 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.lucene.store;
|
package org.elastiscearch.index.store;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.SimpleFSDirectory;
|
||||||
|
import org.elasticsearch.index.store.SmbDirectoryWrapper;
|
||||||
|
|
||||||
public class SmbSimpleFSDirectoryTests extends ESBaseDirectoryTestCase {
|
public class SmbSimpleFSDirectoryTests extends ESBaseDirectoryTestCase {
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
"Test the smb_mmap_fs directory wrapper":
|
||||||
|
- do:
|
||||||
|
indices.create:
|
||||||
|
index: smb-test
|
||||||
|
body:
|
||||||
|
index:
|
||||||
|
store.type: smb_mmap_fs
|
||||||
|
|
||||||
|
- do:
|
||||||
|
cluster.health:
|
||||||
|
wait_for_status: yellow
|
||||||
|
|
||||||
|
- do:
|
||||||
|
index:
|
||||||
|
index: smb-test
|
||||||
|
type: doc
|
||||||
|
id: 1
|
||||||
|
body: { foo: bar }
|
||||||
|
|
||||||
|
- do:
|
||||||
|
get:
|
||||||
|
index: smb-test
|
||||||
|
type: doc
|
||||||
|
id: 1
|
||||||
|
|
||||||
|
- match: { _index: smb-test }
|
||||||
|
- match: { _type: doc }
|
||||||
|
- match: { _id: "1"}
|
||||||
|
- match: { _version: 1}
|
||||||
|
- match: { _source: { foo: bar }}
|
Loading…
Reference in New Issue