Skip to content
Snippets Groups Projects
Commit 8a3fb147 authored by Jason Tedor's avatar Jason Tedor Committed by GitHub
Browse files

Merge pull request #800 from jasontedor/elasticsearch-modes

Various Elasticsearch improvements
parents b62e0d92 48e24cbf
No related branches found
No related tags found
No related merge requests found
......@@ -31,13 +31,28 @@ Clone the YCSB git repository and compile:
Now you are ready to run! First, load the data:
./bin/ycsb load elasticsearch -s -P workloads/workloada
./bin/ycsb load elasticsearch -s -P workloads/workloada -p path.home=<path>
Then, run the workload:
./bin/ycsb run elasticsearch -s -P workloads/workloada
./bin/ycsb run elasticsearch -s -P workloads/workloada -p path.home=<path>
For further configuration see below:
Note that the `<path>` specified in each execution should be the same.
The Elasticsearch binding has two modes of operation, embedded mode and remote
mode. In embedded mode, the client creates an embedded instance of
Elasticsearch that uses the specified `<path>` to persist data between
executions.
In remote mode, the client will hit a standalone instance of Elasticsearch. To
use remote mode, add the flags `-p es.remote=true` and specify a hosts list via
`-p es.hosts.list=<hostname1:port1>,...,<hostnamen:portn>`.
./bin/ycsb run elasticsearch -s -P workloads/workloada -p es.remote=true \
-p es.hosts.list=<hostname1:port1>,...,<hostnamen:portn>`
Note that `es.hosts.list` defaults to `localhost:9300`. For further
configuration see below:
### Defaults Configuration
The default setting for the Elasticsearch node that is created is as follows:
......@@ -48,7 +63,7 @@ The default setting for the Elasticsearch node that is created is as follows:
es.number_of_replicas=0
es.remote=false
es.newdb=false
es.hosts.list=localhost:9200 (only applies if es.remote=true)
es.hosts.list=localhost:9300 (only applies if es.remote=true)
### Custom Configuration
If you wish to customize the settings used to create the Elasticsearch node
......
......@@ -29,7 +29,7 @@ LICENSE file.
<name>Elasticsearch Binding</name>
<packaging>jar</packaging>
<properties>
<elasticsearch-version>2.3.2</elasticsearch-version>
<elasticsearch-version>2.3.4</elasticsearch-version>
</properties>
<dependencies>
<dependency>
......@@ -51,9 +51,9 @@ LICENSE file.
<version>${elasticsearch-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -82,20 +82,29 @@ public class ElasticsearchClient extends DB {
*/
@Override
public void init() throws DBException {
Properties props = getProperties();
final Properties props = getProperties();
// Check if transport client needs to be used (To connect to multiple
// elasticsearch nodes)
remoteMode = Boolean.parseBoolean(props.getProperty("es.remote", "false"));
final String pathHome = props.getProperty("path.home");
// when running in embedded mode, require path.home
if (!remoteMode && (pathHome == null || pathHome.isEmpty())) {
throw new IllegalArgumentException("path.home must be specified when running in embedded mode");
}
this.indexKey = props.getProperty("es.index.key", DEFAULT_INDEX_KEY);
int numberOfShards = parseIntegerProperty(props, "es.number_of_shards", NUMBER_OF_SHARDS);
int numberOfReplicas = parseIntegerProperty(props, "es.number_of_replicas", NUMBER_OF_REPLICAS);
// Check if transport client needs to be used (To connect to multiple
// elasticsearch nodes)
remoteMode = Boolean.parseBoolean(props.getProperty("es.remote", "false"));
Boolean newdb = Boolean.parseBoolean(props.getProperty("es.newdb", "false"));
Builder settings = Settings.settingsBuilder()
.put("cluster.name", DEFAULT_CLUSTER_NAME)
.put("node.local", Boolean.toString(!remoteMode))
.put("path.home", System.getProperty("java.io.tmpdir"));
.put("path.home", pathHome);
// if properties file contains elasticsearch user defined properties
// add it to the settings file (will overwrite the defaults).
......
......@@ -21,25 +21,29 @@
*/
package com.yahoo.ycsb.db;
import static org.testng.AssertJUnit.assertEquals;
import com.yahoo.ycsb.ByteIterator;
import com.yahoo.ycsb.DBException;
import com.yahoo.ycsb.Status;
import com.yahoo.ycsb.StringByteIterator;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.util.HashMap;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import static org.junit.Assert.assertEquals;
public class ElasticsearchClientTest {
@ClassRule public final static TemporaryFolder temp = new TemporaryFolder();
protected final static ElasticsearchClient instance = new ElasticsearchClient();
protected final static HashMap<String, ByteIterator> MOCK_DATA;
protected final static String MOCK_TABLE = "MOCK_TABLE";
......@@ -56,6 +60,9 @@ public class ElasticsearchClientTest {
@BeforeClass
public static void setUpClass() throws DBException {
final Properties props = new Properties();
props.put("path.home", temp.getRoot().toString());
instance.setProperties(props);
instance.init();
}
......@@ -64,13 +71,13 @@ public class ElasticsearchClientTest {
instance.cleanup();
}
@BeforeMethod
@Before
public void setUp() {
instance.insert(MOCK_TABLE, MOCK_KEY1, MOCK_DATA);
instance.insert(MOCK_TABLE, MOCK_KEY2, MOCK_DATA);
}
@AfterMethod
@After
public void tearDown() {
instance.delete(MOCK_TABLE, MOCK_KEY1);
instance.delete(MOCK_TABLE, MOCK_KEY2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment