Github user marevol commented on a diff in the pull request:

    
https://github.com/apache/incubator-predictionio/pull/336#discussion_r96766370
  
    --- 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 --
    
    > This is probably a good opportunity to add.
    
    +1
    We could not reuse RestClient because it's not closed.
    I think it's better to call "close" process for storage at the end of 
application, and then reuse RestClient.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to