Skip to content

[elasticsearch,elasticsearch5] Add Elasticsearch 5.x binding#925

Merged
jasontedor merged 27 commits into
brianfrankcooper:masterfrom
risdenk:initial-es5
Aug 10, 2017
Merged

[elasticsearch,elasticsearch5] Add Elasticsearch 5.x binding#925
jasontedor merged 27 commits into
brianfrankcooper:masterfrom
risdenk:initial-es5

Conversation

@risdenk

@risdenk risdenk commented Feb 7, 2017

Copy link
Copy Markdown
Collaborator

Fixes #893

Elasticsearch 5.x Highlights:

  • Option for Elasticsearch 5.x Transport or REST client
  • scan is changed to not implemented (due to not being about to range query over _id or _uid)
  • skip tests on JDK 7

Other changes:

  • Cleaned up Elasticsearch 2.x test for Java 7+
  • Exposed elasticsearch version in top level pom.xml
  • Reordered properties in top level pom.xml alphabetically

@risdenk risdenk added this to the 0.13.0 milestone Feb 7, 2017
@risdenk
risdenk requested a review from jasontedor February 7, 2017 02:41
@risdenk

risdenk commented Feb 7, 2017

Copy link
Copy Markdown
Collaborator Author

@jasontedor I know that ES is moving towards the Java REST client but this was the closest to what the existing Elasticsearch binding was doing. If its not the right approach no worries.

@jasontedor

Copy link
Copy Markdown
Collaborator

Thanks a lot for doing thing @risdenk.

Yeah, I was going to use the low-level REST client when I made time to address #893.

Also, my plan was to support scan by indexing another field, and it'd probably be better to let auto-IDs be employed here.

Do you want to make those changes or would you like me to? (To be clear, I'm happy either way.)

@risdenk

risdenk commented Feb 7, 2017

Copy link
Copy Markdown
Collaborator Author

Your ideas sounds good to me. I might take a crack at it tonight. If I don't get to it feel free to work on it.

@risdenk

risdenk commented Feb 8, 2017

Copy link
Copy Markdown
Collaborator Author

@jasontedor This is still a work in progress but pushed my changes just in case its helpful.

I started working on the REST client here: ElasticsearchRestClient.java

Its not integrated yet with the tests or as far as the binding goes. Just a start to see how it would lay out. I'm hoping we can opt for either Transport or REST client to allow benchmarking both.

@MichaelTong

MichaelTong commented Jun 22, 2017

Copy link
Copy Markdown

Hi @risdenk , I checked out your branch and trying to build the elasticsearch5 client. After I put a "elasticsearch5" entry in bin/ycsb and started to run it, it threw exception saying IllegalArgumentException.

Exception in thread "Thread-3" java.lang.IllegalArgumentException: unknown setting [access] please check that any required plugins are installed, or check the bre
aking changes documentation for removed settings
        at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:276)
        at org.elasticsearch.common.settings.AbstractScopedSettings.validate(AbstractScopedSettings.java:244)
        at org.elasticsearch.common.settings.SettingsModule.<init>(SettingsModule.java:138)
        at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:138)
        at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:258)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:125)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:111)
        at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:101)
        at com.yahoo.ycsb.db.elasticsearch5.ElasticsearchClient.init(ElasticsearchClient.java:113)
        at com.yahoo.ycsb.DBWrapper.init(DBWrapper.java:85)
        at com.yahoo.ycsb.ClientThread.run(Client.java:415)
        at java.lang.Thread.run(Thread.java:748)
        Suppressed: java.lang.IllegalArgumentException: unknown setting [db] please check that any required plugins are installed, or check the breaking changes d
ocumentation for removed settings
                ... 12 more
        Suppressed: java.lang.IllegalArgumentException: unknown setting [dotransactions] please check that any required plugins are installed, or check the breaki
ng changes documentation for removed settings
                ... 12 more
        Suppressed: java.lang.IllegalArgumentException: unknown setting [es.hosts.list] please check that any required plugins are installed, or check the breakin
g changes documentation for removed settings
                ... 12 more
        Suppressed: java.lang.IllegalArgumentException: unknown setting [es.remote] please check that any required plugins are installed, or check the breaking ch
anges documentation for removed settings
                ... 12 more
        Suppressed: java.lang.IllegalArgumentException: unknown setting [fieldcount] please check that any required plugins are installed, or check the breaking c
hanges documentation for removed settings
                ... 12 more
        Suppressed: java.lang.IllegalArgumentException: unknown setting [fieldlength] please check that any required plugins are installed, or check the breaking
changes documentation for removed settings
                ... 12 more

It seems that it also put workload file into setting

@levaphenyl

Copy link
Copy Markdown

Hello,

Same problem than @MichaelTong here. Apparently, when choosing es.remote=true, all parameters passed in the command line or in the workload file are dumped in the variable setting, including db, threadcount etc.

The second bug is that the client throws a NullPointerException if path.home is not given even if es.remote=true.

I just added a pull request to fix this.

Hope this helps :).

@jasontedor jasontedor mentioned this pull request Aug 5, 2017
@manolama

manolama commented Aug 5, 2017

Copy link
Copy Markdown
Collaborator

@risdenk Should we still target this for 0.13? Thanks!

@jasontedor

Copy link
Copy Markdown
Collaborator

@manolama See my comment on #981.

* master:
  [core] Fixing squid:S1319 -  Declarations should use Java collection interfaces such as "List" rather than specific implementation classes such as "LinkedList". (manolama - updated bindings added since the PR)
  [core] Use longs instead of ints to support larger key spaces. Changed int to long in Measurements code to support large scale workloads. (manolama - fixed checkstyle errors)
  [core] Export totalHistogram for HdrHistogram measurement
  [core] Add an operation enum to the Workload class. This can eventually be used to replace the strings.
  [core] Add a Fisher-Yates array shuffle to the Utils class.
  [core] Fix an issue where the threadid and threadCount were not passed to the workload client threads. Had to use setters to get around the checkstyle complaint of having too many parameters.
  Upgrading googlebigtable to the latest version. The API used by googlebigtable has had quite a bit of churn.  This is the minimal set of changes required for the upgrade.
  [geode] Update to apache-geode 1.2.0 release
  [core] Update to use newer version of Google Cloud Spanner client and associated required change
  [core] Add a reset() method to the ByteIterator abstract and implementations for each of the children. This lets us re-use byte iterators if we need to access the values again (when applicable).
  [hbase12] Add HBase 1.2+ specific client that relies on the shaded client artifact provided by those versions. (brianfrankcooper#970)
  [distro] Refresh Apache licence text (brianfrankcooper#969)
  [memcached] support binary protocol (brianfrankcooper#965)
  [accumulo] A general "refresh" to the Accumulo binding (brianfrankcooper#947)
  [cloudspanner] Add binding for Google's Cloud Spanner. (brianfrankcooper#939)
  [aerospike] Change the write policy to REPLACE_ONLY (brianfrankcooper#937)
This commit bumps the Elasticsearch dependency version of the
Elasticsearch 5 binding to version 5.5.1.
If path.home is not set we should not add it to the settings object used
to construct the transport client otherwise we will hit a null pointer
exception due to the null value being dereferenced in the internals of
Elasticsearch.
Since Elasticsearch 5, Elasticsearch is now strict about settings. This
means that if you pass it a setting that it does not recognize,
Elasticsearch will throw an exception whereas previously it was lenient
in such situations. This commit removes passing all properties as
settings to Elasticsearch in favor of a special prefix es.setting for
which properties prefixed with this will be passed as settings to
Elasticsearch.
Upstream Elasticsearch does not support embedded nodes as of
Elasticsearch 5. This commit removes the usage of embedded nodes within
YCSB.
This commit refactors the indexing of documents in the Elasticsearch 5
binding to use auto-generated IDs, instead indexing the key field as a
dedicated field rather than using it as the ID. This enables us to
implement scan functionality which we add in this commit as well.
We can remove the path.home setting for the Elasticsearch 5 binding for
the transport client so this commit does that.
This commit fixes a bug in the Elasticsearch 5 transport client
binding. Namely, the update method was not indexing using the ID of the
read document, but instead the provided key. As auto-generated IDs are
used, this is a mistake as this is not the ID of the document. This
commit fixes this issue.

Additionally, the type is passed to the search method and used in
searches. While this is not a correctness issue per se, we fix it for
clarity.
This commit is an initial cut at a complete implementation using the
low-level Elasticsearch REST client.
This commit is a straightforward code cleanup of the Elasticsearch 5
transport client and REST client implementations.
This commit fixes issues with the Elasticsearch 5 transport client and
REST client bindings so that all tests pass.
This commit updates the Elasticsearch 5 binding docs to include
references for starting Elasticsearch 5, how to configure the transport
client, and how to use the low-level REST client binding.
@jasontedor

Copy link
Copy Markdown
Collaborator

@risdenk I think that this a ready now as tests are passing now for both the transport client and REST client bindings. I'm not sure who should review this, can you?

@jasontedor
jasontedor removed their request for review August 9, 2017 05:27
This commit sets the Elasticsearch 5 binding to only use the
elasticsearch-maven-plugin if tests are running on JDK 8.
@levaphenyl

levaphenyl commented Aug 9, 2017

Copy link
Copy Markdown

@jasontedor The current implementation for the ES5 binding does not support scan operations. In ES5, RangeQueries are not allowed on the field _id anymore. I proposed a implementation using matchQuery in my previous pull request in risdenk/YCSB but I'm not sure since I am neither a Java developer, nor a ES expert.

@jasontedor

Copy link
Copy Markdown
Collaborator

@levaphenyl I updated this pull request to add support for scan by indexing another field that we can do range queries on. I made almost no effort to optimize this, only to get something working first that can be iterated on later after integration (first make it right, then make it fast). 😄

@levaphenyl

Copy link
Copy Markdown

@jasontedor Sorry, I didn't read your commits well enough. This looks nice and adding the support for auto-ID is a great idea! Thank you 😄.

@jasontedor

Copy link
Copy Markdown
Collaborator

@levaphenyl You're welcome, thanks for your interest!

This commit adds some basic formatting to the transport client logs for
the transport client used in the Elasticsearch 5 binding.
@risdenk

risdenk commented Aug 10, 2017

Copy link
Copy Markdown
Collaborator Author

@jasontedor - I'll take a look

@risdenk risdenk left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasontedor Changes look good. I didn't get a chance to run it yet probably tomorrow.

Most of the comments are around stderr vs stdout. Stdout is typically reserved for metric output only and everything else to stderr. The other thought is using log4j instead of System...println/err.printStackTrace() for some of the messages.

}
}
final String clusterName = settings.get("cluster.name");
System.out.println("Elasticsearch cluster name = " + clusterName);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should go to System.err if we need it. Metrics should go to standard out.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped it: e30441c

.put("client.transport.nodes_sampler_interval", "30s");
// Default it to localhost:9300
final String[] nodeList = props.getProperty("es.hosts.list", DEFAULT_REMOTE_HOST).split(",");
System.out.println("Elasticsearch Remote Hosts = " + props.getProperty("es.hosts.list", DEFAULT_REMOTE_HOST));

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should go to System.err if we need it. Metrics should go to standard out.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dropped it: e30441c

Comment thread elasticsearch5/README.md Outdated
es.index.key=es.ycsb
es.number_of_shards=1
es.number_of_replicas=0
es.newdb=false

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does newdb make sense here? New index?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed d791ae6.


return Status.OK;
} catch (final Exception e) {
e.printStackTrace();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should go to stderr. Not sure it does by default.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, Exception#printStackTrace goes to stderr by default.


return Status.OK;
} catch (final Exception e) {
e.printStackTrace();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should go to stderr

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception#printStackTrace goes to stderr by default.

}
return Status.OK;
} catch (final Exception e) {
e.printStackTrace();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stderr

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception#printStackTrace goes to stderr by default.

@@ -0,0 +1,7 @@
appender.console.type = Console

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is getting logged by this but if it is during the YCSB testing should go to stderr instead of stdout.

@jasontedor jasontedor Aug 10, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for any internal logging produced by the transport client (for example, if there are issues connecting to the Elasticsearch cluster, a user can set es.setting.logger.org.elasticsearch to debug and see the debugging logging by the transport client to help debug such an issue. I pushed a65dcb7 so that these logs go to stderr.

Comment thread hypertable/pom.xml Outdated
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${thrift.version}</version>
<version>0.8.0</version>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change variable here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...not sure where that came from, was not intentional and will revert.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 6ae7050.

Comment thread jdbc/pom.xml Outdated
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-jdbc</artifactId>
<version>${openjpa.jdbc.version}</version>
<version>2.1.1</version>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change variable here?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm...not sure where that came from, was not intentional and will revert.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 6ae7050.

Comment thread pom.xml Outdated
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<thrift.version>0.8.0</thrift.version>
<hypertable.version>0.9.5.6</hypertable.version>
<elasticsearch-version>2.4.4</elasticsearch-version>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elasticsearch-version not used anywhere?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 2250903.

This commit reverts some unrelated changes to POMs for other bindings,
perhaps made inadvertently while merging master into a development
branch.
This commit sets the log of the internal transport client used in the
Elasitcsearch 5 binding to use standard error instead of standard out.
This commit removes some unnecessary logging statements for the
elasticsearch5 and elasticsearch5-rest bindings.
This commit changes the name of a property, es.newdb, to es.new_index as
this is more consistent with the terminology used in Elasticsearch.
This commit wraps the usage of a content builder in a try-with-resources
block to ensure that it is correctly closed.
This commit removes an unrelated POM change for the original
(Elasticsearch 2) binding.
The comments were incorrectly referring to ElasticsearchClient but they
should be referring to ElasticsearchRestClient instead.
@jasontedor

Copy link
Copy Markdown
Collaborator

Thanks @risdenk, I've responded to your feedback.

@risdenk

risdenk commented Aug 10, 2017

Copy link
Copy Markdown
Collaborator Author

@jasontedor I see your referenced commits but they aren't on this PR like the other commits? Where did they end up? Its weird that I can't seem to find them but the links you posted work.

@jasontedor

Copy link
Copy Markdown
Collaborator

I'm not sure, I agree they are not visible on the PR. I also noticed that I did not receive email notifications for the pushes.

@jasontedor

Copy link
Copy Markdown
Collaborator

@risdenk I think they are visible now.

@risdenk risdenk left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Tests run as well. Few minor comments from opening in an IDE.

  • ElasticsearchClientIT and ElasticsearchRestClientIT are basically identical
    • Could be useful to make one test?
  • ElasticsearchClient and ElasticsearchRestClient have duplicated methods
    • Might be worth it to consolidate?
  • Since org.apache.http is already included could use HttpStatus.SC_CREATED for 201 and others (404, 200, etc).

No other major things from me so could be merged.

return performRequest(restClient, method, endpoint, params, null);
}

private static Header[] emptyHeaders = new Header[0];

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be final?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 38d45b0.

This commit removes duplicate test code from the elasticsearch5 and
elasticsearch5-rest test classes.
This commit marks a field intended to be treated as a constant as final.
This commit replaces some magic numbers (HTTP status codes) with
already-existing constants for this purpose.
This commit removes an extraneous newline from
ElasticsearchRestClient.java.
@jasontedor
jasontedor merged commit 385a389 into brianfrankcooper:master Aug 10, 2017
@jasontedor

Copy link
Copy Markdown
Collaborator

Thanks @risdenk! Regarding your last few suggestions I addressed them all except for consolidating code between ElasticsearchClient and ElasticsearchRestClient, I prefer keeping the refresh logic separate.

@levaphenyl

levaphenyl commented Aug 28, 2017

Copy link
Copy Markdown

Just tested the implementation on my cluster and I get a NoNodeAvailableException for 6 of 48 threads with the elasticsearch5 binding. This problem doesn't appear with the elasticsearch5-rest binding.

@busbey busbey mentioned this pull request May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants