Merge remote-tracking branch 'dakrone/fix-smb-plugin-master'

This commit is contained in:
Lee Hinman 2016-02-03 07:50:14 -07:00
commit 3c7f578010
7 changed files with 50 additions and 12 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View 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.MMapDirectory;
import org.elasticsearch.index.store.SmbDirectoryWrapper;
public class SmbMMapDirectoryTests extends ESBaseDirectoryTestCase { public class SmbMMapDirectoryTests extends ESBaseDirectoryTestCase {

View 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 {

View File

@ -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 }}