forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
530 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apply plugin: 'elasticsearch.internal-es-plugin' | ||
apply plugin: 'elasticsearch.internal-cluster-test' | ||
esplugin { | ||
name 'kv-indices' | ||
description 'A plugin for the kv indices functionality' | ||
classname 'org.elasticsearch.xpack.kv.KVIndices' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
base { | ||
archivesName = 'x-pack-kv-indices' | ||
} | ||
|
||
dependencies { | ||
compileOnly project(path: xpackModule('core')) | ||
testImplementation(testArtifact(project(xpackModule('core')))) | ||
api 'org.rocksdb:rocksdbjni:9.2.1' | ||
} |
51 changes: 51 additions & 0 deletions
51
.../kv-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/kv/KVIndexIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.index.engine.kv; | ||
|
||
import org.elasticsearch.indices.IndicesService; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.test.ESIntegTestCase; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.xpack.core.LocalStateCompositeXPackPlugin; | ||
import org.elasticsearch.xpack.kv.KVIndices; | ||
import org.elasticsearch.xpack.kv.RocksEngine; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
@ESIntegTestCase.ClusterScope(numDataNodes = 0) | ||
@ESTestCase.WithoutSecurityManager | ||
public class KVIndexIT extends ESIntegTestCase { | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return List.of(KVIndices.class, LocalStateCompositeXPackPlugin.class); | ||
} | ||
|
||
@Override | ||
protected boolean addMockInternalEngine() { | ||
return false; | ||
} | ||
|
||
public void testBasic() throws Exception { | ||
internalCluster().startNodes(1); | ||
var indexName = randomIdentifier(); | ||
createIndex(indexName, indexSettings(1, 0).put(RocksEngine.INDEX_KV.getKey(), true).build()); | ||
indexDoc(indexName, "test", "asd", "asd1"); | ||
indexDoc(indexName, "test2", "asd", "asd1"); | ||
RocksEngine engine = (RocksEngine) internalCluster().getInstance(IndicesService.class) | ||
.indexService(resolveIndex(indexName)) | ||
.getShard(0) | ||
.getEngineOrNull(); | ||
|
||
assertThat(engine.getBytes("test".getBytes()), notNullValue()); | ||
assertThat(engine.getBytes("test2".getBytes()), notNullValue()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
x-pack/plugin/kv-indices/src/main/java/org/elasticsearch/xpack/kv/KVIndices.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.kv; | ||
|
||
import org.elasticsearch.common.settings.Setting; | ||
import org.elasticsearch.index.IndexSettings; | ||
import org.elasticsearch.index.engine.EngineFactory; | ||
import org.elasticsearch.plugins.ActionPlugin; | ||
import org.elasticsearch.plugins.EnginePlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class KVIndices extends Plugin implements ActionPlugin, EnginePlugin { | ||
|
||
@Override | ||
public Optional<EngineFactory> getEngineFactory(IndexSettings indexSettings) { | ||
if (indexSettings.getValue(RocksEngine.INDEX_KV)) { | ||
return Optional.of(RocksEngine::new); | ||
} else { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public List<Setting<?>> getSettings() { | ||
return Arrays.asList(RocksEngine.INDEX_KV); | ||
} | ||
} |
Oops, something went wrong.