Simplify setting index.store.type with smb_simple_fs and smb_mmap_fs

This commit changes work done in #60 by using automatic store type discovery which exists in elasticsearch core.

Instead of writing configuration like:

```yaml
index.store.type: org.elasticsearch.index.store.fs.SmbMmapFsIndexStoreModule
index.store.type: org.elasticsearch.index.store.fs.SmbSimpleFsIndexStoreModule
```

We can now use:

```yaml
index.store.type: smb_mmap_fs
index.store.type: smb_simple_fs
```

Note that we move `org.elasticsearch.index.store.fs.SmbMmapFsIndexStoreModule` to  `org.elasticsearch.index.store.smbmmapfs.SmbMmapFsIndexStoreModule` and `org.elasticsearch.index.store.fs.SmbSimpleFsDirectoryService` to `org.elasticsearch.index.store.smbsimplefs.SmbSimpleFsDirectoryService` instead of deprecating the old classes and add new ones.
It means that if users were using a 2.5.2-SNAPSHOT version, they will need to update their settings.

(cherry picked from commit 613ce5a)
(cherry picked from commit 7831521)
This commit is contained in:
David Pilato 2015-02-17 10:33:39 +01:00
parent 24cf553c9a
commit 396cf117c9
10 changed files with 131 additions and 15 deletions

View File

@ -453,24 +453,26 @@ When using a shared file system based on the SMB protocol (like Azure File Servi
The Azure Cloud plugin provides two storage types optimized for SMB: The Azure Cloud plugin provides two storage types optimized for SMB:
- `org.elasticsearch.index.store.fs.SmbMmapFsIndexStoreModule`: a SMB specific implementation of the default [mmap fs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-store.html#mmapfs) - `smb_mmap_fs`: a SMB specific implementation of the default [mmap fs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-store.html#mmapfs)
- `org.elasticsearch.index.store.fs.SmbSimpleFsIndexStoreModule`: a SMB specific implementation of the default [simple fs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-store.html#simplefs) - `smb_simple_fs`: a SMB specific implementation of the default [simple fs](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/index-modules-store.html#simplefs)
To use one of these specific storage types, you need to install the Azure Cloud plugin and restart the node. Then configure Elasticsearch to set To use one of these specific storage types, you need to install the Azure Cloud plugin and restart the node.
the storage type you want. Then configure Elasticsearch to set the storage type you want.
This can be configured for all indices by adding this to the config/elasticsearch.yml file: This can be configured for all indices by adding this to the `elasticsearch.yml` file:
```
index.store.type: org.elasticsearch.index.store.fs.SmbSimpleFsIndexStoreModule ```yaml
index.store.type: smb_simple_fs
``` ```
Note that setting will be applied for newly created indices. Note that setting will be applied for newly created indices.
It can also be set on a per-index basis at index creation time: It can also be set on a per-index basis at index creation time:
```
```sh
curl -XPUT localhost:9200/my_index -d '{ curl -XPUT localhost:9200/my_index -d '{
"settings": { "settings": {
"index.store.type": "org.elasticsearch.index.store.fs.SmbMmapFsIndexStoreModule" "index.store.type": "smb_mmap_fs"
} }
}' }'
``` ```

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; 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;
@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.IndexStore; import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.index.store.fs.FsDirectoryService;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; package org.elasticsearch.index.store.smbmmapfs;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; package org.elasticsearch.index.store.smbmmapfs;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.index.store.IndexStore; import org.elasticsearch.index.store.IndexStore;

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; 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;
@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.IndexStore; import org.elasticsearch.index.store.IndexStore;
import org.elasticsearch.index.store.fs.FsDirectoryService;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; package org.elasticsearch.index.store.smbsimplefs;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.index.store.fs; package org.elasticsearch.index.store.smbsimplefs;
import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.index.store.IndexStore; import org.elasticsearch.index.store.IndexStore;

View File

@ -0,0 +1,42 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.index.store;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.test.ElasticsearchIntegrationTest;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
abstract public class AbstractAzureFsTest extends ElasticsearchIntegrationTest {
@Test
public void testAzureFs() {
// Create an index and index some documents
createIndex("test");
long nbDocs = randomIntBetween(10, 1000);
for (long i = 0; i < nbDocs; i++) {
index("test", "doc", "" + i, "foo", "bar");
}
refresh();
SearchResponse response = client().prepareSearch("test").get();
assertThat(response.getHits().totalHits(), is(nbDocs));
}
}

View File

@ -0,0 +1,36 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.index.store;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
public class SmbMMapFsTest extends AbstractAzureFsTest {
@Override
public Settings indexSettings() {
return ImmutableSettings.builder()
.put(super.indexSettings())
.put("index.store.type", "smb_mmap_fs")
.build();
}
}

View File

@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.index.store;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
public class SmbSimpleFsTest extends AbstractAzureFsTest {
@Override
public Settings indexSettings() {
return ImmutableSettings.builder()
.put(super.indexSettings())
.put("index.store.type", "smb_simple_fs")
.build();
}
}