Skip to content

Commit 2e68825

Browse files
committed
[elasticsearch,elasticsearch5] Add Elasticsearch 5.x binding
1 parent 68fbbb0 commit 2e68825

12 files changed

Lines changed: 730 additions & 41 deletions

File tree

bin/bindings.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ aerospike:com.yahoo.ycsb.db.AerospikeClient
3030
asynchbase:com.yahoo.ycsb.db.AsyncHBaseClient
3131
arangodb:com.yahoo.ycsb.db.ArangoDBClient
3232
arangodb3:com.yahoo.ycsb.db.arangodb.ArangoDB3Client
33+
azuredocumentdb:com.yahoo.ycsb.db.azuredocumentdb.AzureDocumentDBClient
3334
azuretablestorage:com.yahoo.ycsb.db.azuretablestorage.AzureClient
3435
basic:com.yahoo.ycsb.BasicDB
3536
cassandra-cql:com.yahoo.ycsb.db.CassandraCQLClient
3637
cassandra2-cql:com.yahoo.ycsb.db.CassandraCQLClient
3738
couchbase:com.yahoo.ycsb.db.CouchbaseClient
3839
couchbase2:com.yahoo.ycsb.db.couchbase2.Couchbase2Client
39-
azuredocumentdb:com.yahoo.ycsb.db.azuredocumentdb.AzureDocumentDBClient
4040
dynamodb:com.yahoo.ycsb.db.DynamoDBClient
4141
elasticsearch:com.yahoo.ycsb.db.ElasticsearchClient
42+
elasticsearch5:com.yahoo.ycsb.db.elasticsearch5.ElasticsearchClient
4243
geode:com.yahoo.ycsb.db.GeodeClient
4344
googlebigtable:com.yahoo.ycsb.db.GoogleBigtableClient
4445
googledatastore:com.yahoo.ycsb.db.GoogleDatastoreClient

distribution/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ LICENSE file.
9494
<artifactId>elasticsearch-binding</artifactId>
9595
<version>${project.version}</version>
9696
</dependency>
97+
<dependency>
98+
<groupId>com.yahoo.ycsb</groupId>
99+
<artifactId>elasticsearch5-binding</artifactId>
100+
<version>${project.version}</version>
101+
</dependency>
97102
<dependency>
98103
<groupId>com.yahoo.ycsb</groupId>
99104
<artifactId>geode-binding</artifactId>

elasticsearch/src/test/java/com/yahoo/ycsb/db/ElasticsearchClientTest.java

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2012 YCSB contributors. All rights reserved.
2+
* Copyright (c) 2012-2017 YCSB contributors. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you
55
* may not use this file except in compliance with the License. You
@@ -30,7 +30,6 @@
3030
import org.junit.Before;
3131
import org.junit.BeforeClass;
3232
import org.junit.ClassRule;
33-
import org.junit.Rule;
3433
import org.junit.Test;
3534
import org.junit.rules.TemporaryFolder;
3635

@@ -44,15 +43,15 @@
4443
public class ElasticsearchClientTest {
4544

4645
@ClassRule public final static TemporaryFolder temp = new TemporaryFolder();
47-
protected final static ElasticsearchClient instance = new ElasticsearchClient();
48-
protected final static HashMap<String, ByteIterator> MOCK_DATA;
49-
protected final static String MOCK_TABLE = "MOCK_TABLE";
50-
protected final static String MOCK_KEY0 = "0";
51-
protected final static String MOCK_KEY1 = "1";
52-
protected final static String MOCK_KEY2 = "2";
46+
private final static ElasticsearchClient instance = new ElasticsearchClient();
47+
private final static HashMap<String, ByteIterator> MOCK_DATA;
48+
private final static String MOCK_TABLE = "MOCK_TABLE";
49+
private final static String MOCK_KEY0 = "0";
50+
private final static String MOCK_KEY1 = "1";
51+
private final static String MOCK_KEY2 = "2";
5352

5453
static {
55-
MOCK_DATA = new HashMap<String, ByteIterator>(10);
54+
MOCK_DATA = new HashMap<>(10);
5655
for (int i = 1; i <= 10; i++) {
5756
MOCK_DATA.put("field" + i, new StringByteIterator("value" + i));
5857
}
@@ -88,7 +87,6 @@ public void tearDown() {
8887
*/
8988
@Test
9089
public void testInsert() {
91-
System.out.println("insert");
9290
Status result = instance.insert(MOCK_TABLE, MOCK_KEY0, MOCK_DATA);
9391
assertEquals(Status.OK, result);
9492
}
@@ -98,7 +96,6 @@ public void testInsert() {
9896
*/
9997
@Test
10098
public void testDelete() {
101-
System.out.println("delete");
10299
Status result = instance.delete(MOCK_TABLE, MOCK_KEY1);
103100
assertEquals(Status.OK, result);
104101
}
@@ -108,9 +105,8 @@ public void testDelete() {
108105
*/
109106
@Test
110107
public void testRead() {
111-
System.out.println("read");
112108
Set<String> fields = MOCK_DATA.keySet();
113-
HashMap<String, ByteIterator> resultParam = new HashMap<String, ByteIterator>(10);
109+
HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
114110
Status result = instance.read(MOCK_TABLE, MOCK_KEY1, fields, resultParam);
115111
assertEquals(Status.OK, result);
116112
}
@@ -120,9 +116,8 @@ public void testRead() {
120116
*/
121117
@Test
122118
public void testUpdate() {
123-
System.out.println("update");
124119
int i;
125-
HashMap<String, ByteIterator> newValues = new HashMap<String, ByteIterator>(10);
120+
HashMap<String, ByteIterator> newValues = new HashMap<>(10);
126121

127122
for (i = 1; i <= 10; i++) {
128123
newValues.put("field" + i, new StringByteIterator("newvalue" + i));
@@ -132,24 +127,22 @@ public void testUpdate() {
132127
assertEquals(Status.OK, result);
133128

134129
//validate that the values changed
135-
HashMap<String, ByteIterator> resultParam = new HashMap<String, ByteIterator>(10);
130+
HashMap<String, ByteIterator> resultParam = new HashMap<>(10);
136131
instance.read(MOCK_TABLE, MOCK_KEY1, MOCK_DATA.keySet(), resultParam);
137132

138133
for (i = 1; i <= 10; i++) {
139134
assertEquals("newvalue" + i, resultParam.get("field" + i).toString());
140135
}
141-
142136
}
143137

144138
/**
145139
* Test of scan method, of class ElasticsearchClient.
146140
*/
147141
@Test
148142
public void testScan() {
149-
System.out.println("scan");
150143
int recordcount = 10;
151144
Set<String> fields = MOCK_DATA.keySet();
152-
Vector<HashMap<String, ByteIterator>> resultParam = new Vector<HashMap<String, ByteIterator>>(10);
145+
Vector<HashMap<String, ByteIterator>> resultParam = new Vector<>(10);
153146
Status result = instance.scan(MOCK_TABLE, MOCK_KEY1, recordcount, fields, resultParam);
154147
assertEquals(Status.OK, result);
155148
}

elasticsearch5/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<!--
2+
Copyright (c) 2017 YCSB contributors. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License"); you
5+
may not use this file except in compliance with the License. You
6+
may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13+
implied. See the License for the specific language governing
14+
permissions and limitations under the License. See accompanying
15+
LICENSE file.
16+
-->
17+
18+
## Quick Start
19+
20+
This section describes how to run YCSB on Elasticsearch 5.x running locally.
21+
22+
### 1. Set Up YCSB
23+
24+
Clone the YCSB git repository and compile:
25+
26+
git clone git://github.com/brianfrankcooper/YCSB.git
27+
cd YCSB
28+
mvn clean package
29+
30+
### 2. Run YCSB
31+
32+
Now you are ready to run! First, load the data:
33+
34+
./bin/ycsb load elasticsearch5 -s -P workloads/workloada -p path.home=<path>
35+
36+
Then, run the workload:
37+
38+
./bin/ycsb run elasticsearch5 -s -P workloads/workloada -p path.home=<path>
39+
40+
Note that the `<path>` specified in each execution should be the same.
41+
42+
The Elasticsearch 5 binding has two modes of operation, embedded mode and remote
43+
mode. In embedded mode, the client creates an embedded instance of
44+
Elasticsearch that uses the specified `<path>` to persist data between
45+
executions.
46+
47+
In remote mode, the client will hit a standalone instance of Elasticsearch. To
48+
use remote mode, add the flags `-p es.remote=true` and specify a hosts list via
49+
`-p es.hosts.list=<hostname1:port1>,...,<hostnamen:portn>`.
50+
51+
./bin/ycsb run elasticsearch5 -s -P workloads/workloada -p es.remote=true \
52+
-p es.hosts.list=<hostname1:port1>,...,<hostnamen:portn>`
53+
54+
Note that `es.hosts.list` defaults to `localhost:9300`. For further
55+
configuration see below:
56+
57+
### Defaults Configuration
58+
The default setting for the Elasticsearch node that is created is as follows:
59+
60+
cluster.name=es.ycsb.cluster
61+
es.index.key=es.ycsb
62+
es.number_of_shards=1
63+
es.number_of_replicas=0
64+
es.remote=false
65+
es.newdb=false
66+
es.hosts.list=localhost:9300 (only applies if es.remote=true)
67+
68+
### Custom Configuration
69+
If you wish to customize the settings used to create the Elasticsearch node
70+
you can created a new property file that contains your desired Elasticsearch
71+
node settings and pass it in via the parameter to 'bin/ycsb' script. Note that
72+
the default properties will be kept if you don't explicitly overwrite them.
73+
74+
Assuming that we have a properties file named "myproperties.data" that contains
75+
custom Elasticsearch node configuration you can execute the following to
76+
pass it into the Elasticsearch client:
77+
78+
79+
./bin/ycsb run elasticsearch5 -P workloads/workloada -P myproperties.data -s
80+
81+
If you wish to change the default index name you can set the following property:
82+
83+
es.index.key=my_index_key
84+
85+
If you wish to run against a remote cluster you can set the following property:
86+
87+
es.remote=true
88+
89+
By default this will use localhost:9300 as a seed node to discover the cluster.
90+
You can also specify
91+
92+
es.hosts.list=(\w+:\d+)+
93+
94+
(a comma-separated list of host/port pairs) to change this.

elasticsearch5/pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2017 YCSB contributors. All rights reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License"); you
6+
may not use this file except in compliance with the License. You
7+
may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14+
implied. See the License for the specific language governing
15+
permissions and limitations under the License. See accompanying
16+
LICENSE file.
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>com.yahoo.ycsb</groupId>
24+
<artifactId>binding-parent</artifactId>
25+
<version>0.13.0-SNAPSHOT</version>
26+
<relativePath>../binding-parent</relativePath>
27+
</parent>
28+
29+
<artifactId>elasticsearch5-binding</artifactId>
30+
<name>Elasticsearch 5.x Binding</name>
31+
<packaging>jar</packaging>
32+
<dependencies>
33+
<dependency>
34+
<!-- jna is supported in ES and will be used when provided
35+
otherwise a fallback is used -->
36+
<groupId>net.java.dev.jna</groupId>
37+
<artifactId>jna</artifactId>
38+
<version>4.1.0</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.yahoo.ycsb</groupId>
42+
<artifactId>core</artifactId>
43+
<version>${project.version}</version>
44+
<scope>provided</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.elasticsearch.client</groupId>
48+
<artifactId>transport</artifactId>
49+
<version>${elasticsearch5-version}</version>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.apache.logging.log4j</groupId>
53+
<artifactId>log4j-api</artifactId>
54+
<version>2.7</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.apache.logging.log4j</groupId>
58+
<artifactId>log4j-core</artifactId>
59+
<version>2.7</version>
60+
</dependency>
61+
<dependency>
62+
<groupId>junit</groupId>
63+
<artifactId>junit</artifactId>
64+
<version>4.12</version>
65+
<scope>test</scope>
66+
</dependency>
67+
</dependencies>
68+
</project>

0 commit comments

Comments
 (0)