Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YCSB
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Adnan Ahmad
YCSB
Commits
f5f19d86
Unverified
Commit
f5f19d86
authored
8 years ago
by
Jason Tedor
Browse files
Options
Downloads
Patches
Plain Diff
[elasticsearch] Settings for shards and replicas
parent
76647788
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
elasticsearch/src/main/java/com/yahoo/ycsb/db/ElasticsearchClient.java
+15
-2
15 additions, 2 deletions
.../src/main/java/com/yahoo/ycsb/db/ElasticsearchClient.java
with
15 additions
and
2 deletions
elasticsearch/src/main/java/com/yahoo/ycsb/db/ElasticsearchClient.java
+
15
−
2
View file @
f5f19d86
...
...
@@ -60,6 +60,8 @@ import java.util.Vector;
* <ul>
* <li>cluster.name = es.ycsb.cluster
* <li>es.index.key = es.ycsb
* <li>elasticsearch.number_of_shards = 1
* <li>elasticsearch.number_of_replicas = 0
* </ul>
*/
public
class
ElasticsearchClient
extends
DB
{
...
...
@@ -67,6 +69,8 @@ public class ElasticsearchClient extends DB {
private
static
final
String
DEFAULT_CLUSTER_NAME
=
"es.ycsb.cluster"
;
private
static
final
String
DEFAULT_INDEX_KEY
=
"es.ycsb"
;
private
static
final
String
DEFAULT_REMOTE_HOST
=
"localhost:9300"
;
private
static
final
int
NUMBER_OF_SHARDS
=
1
;
private
static
final
int
NUMBER_OF_REPLICAS
=
0
;
private
Node
node
;
private
Client
client
;
private
String
indexKey
;
...
...
@@ -82,6 +86,10 @@ public class ElasticsearchClient extends DB {
this
.
indexKey
=
props
.
getProperty
(
"es.index.key"
,
DEFAULT_INDEX_KEY
);
String
clusterName
=
props
.
getProperty
(
"cluster.name"
,
DEFAULT_CLUSTER_NAME
);
int
numberOfShards
=
parseIntegerProperty
(
props
,
"elasticsearch.number_of_shards"
,
NUMBER_OF_SHARDS
);
int
numberOfReplicas
=
parseIntegerProperty
(
props
,
"elasticsearch.number_of_replicas"
,
NUMBER_OF_REPLICAS
);
// Check if transport client needs to be used (To connect to multiple
// elasticsearch nodes)
remoteMode
=
Boolean
...
...
@@ -146,14 +154,19 @@ public class ElasticsearchClient extends DB {
new
CreateIndexRequest
(
indexKey
)
.
settings
(
Settings
.
builder
()
.
put
(
"index.number_of_shards"
,
1
)
.
put
(
"index.number_of_replicas"
,
0
)
.
put
(
"index.number_of_shards"
,
numberOfShards
)
.
put
(
"index.number_of_replicas"
,
numberOfReplicas
)
.
put
(
"index.mapping._id.indexed"
,
true
)
)).
actionGet
();
client
.
admin
().
cluster
().
health
(
new
ClusterHealthRequest
().
waitForGreenStatus
()).
actionGet
();
}
}
private
int
parseIntegerProperty
(
Properties
properties
,
String
key
,
int
defaultValue
)
{
String
value
=
properties
.
getProperty
(
key
);
return
value
==
null
?
defaultValue
:
Integer
.
parseInt
(
value
);
}
@Override
public
void
cleanup
()
throws
DBException
{
if
(!
remoteMode
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment