[
https://issues.apache.org/jira/browse/PIO-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15828990#comment-15828990
]
ASF GitHub Bot commented on PIO-49:
-----------------------------------
Github user dszeto commented on a diff in the pull request:
https://github.com/apache/incubator-predictionio/pull/336#discussion_r96759997
--- Diff:
data/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESAccessKeys.scala
---
@@ -15,44 +15,45 @@
* limitations under the License.
*/
-
package org.apache.predictionio.data.storage.elasticsearch
-import grizzled.slf4j.Logging
-import org.apache.predictionio.data.storage.StorageClientConfig
+import java.io.IOException
+
+import scala.collection.JavaConverters.mapAsJavaMapConverter
+
+import org.apache.http.entity.ContentType
+import org.apache.http.nio.entity.NStringEntity
+import org.apache.http.util.EntityUtils
import org.apache.predictionio.data.storage.AccessKey
import org.apache.predictionio.data.storage.AccessKeys
-import org.elasticsearch.ElasticsearchException
-import org.elasticsearch.client.Client
-import org.elasticsearch.index.query.FilterBuilders._
-import org.json4s.JsonDSL._
+import org.apache.predictionio.data.storage.StorageClientConfig
+import org.elasticsearch.client.RestClient
import org.json4s._
+import org.json4s.JsonDSL._
import org.json4s.native.JsonMethods._
-import org.json4s.native.Serialization.read
import org.json4s.native.Serialization.write
-import scala.util.Random
+import grizzled.slf4j.Logging
+import org.elasticsearch.client.ResponseException
/** Elasticsearch implementation of AccessKeys. */
-class ESAccessKeys(client: Client, config: StorageClientConfig, index:
String)
+class ESAccessKeys(client: ESClient, config: StorageClientConfig, index:
String)
extends AccessKeys with Logging {
implicit val formats = DefaultFormats.lossless
private val estype = "accesskeys"
- val indices = client.admin.indices
- val indexExistResponse = indices.prepareExists(index).get
- if (!indexExistResponse.isExists) {
- indices.prepareCreate(index).get
- }
- val typeExistResponse =
indices.prepareTypesExists(index).setTypes(estype).get
- if (!typeExistResponse.isExists) {
- val json =
+ val restClient = client.open()
--- End diff --
Should we reuse the same client after it's opened? According to
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_initialization.html
the official recommendation is to have the REST client have the same lifecycle
as the application. I realize this pattern is used extensively in this PR, so
please let us know what you think before you go ahead and change your code.
Right now PredictionIO does not provide a cleanup step in the storage layer
when the application shuts down. This is probably a good opportunity to add.
Would highly appreciate if you would like to take a stab at that.
> Add support for Elasticsearch 5.x
> ---------------------------------
>
> Key: PIO-49
> URL: https://issues.apache.org/jira/browse/PIO-49
> Project: PredictionIO
> Issue Type: Improvement
> Reporter: Shinsuke Sugaya
>
> We work on meta/event storage support for Elasticsearch 5.x.
> Although Elasticsearch 2.x does not allow dots in field names,
> Elasticsearch 5.x supports it. So, it's better to upgrade to ES 5.x release.
> Since ES 5.x provides Java Rest API client, we replaced
> Transport communication with HTTP one. Therefore, our fix
> uses HTTP(9200 port) only.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)