Repository: incubator-predictionio Updated Branches: refs/heads/develop 7289174fc -> b0840185f
Add EVENTDATA_REFRESH for Elasticsearch Closes #370 Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/commit/b0840185 Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/tree/b0840185 Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/diff/b0840185 Branch: refs/heads/develop Commit: b0840185f8126acc809d45230208e5bcfb345b07 Parents: 7289174 Author: Shinsuke Sugaya <[email protected]> Authored: Fri Apr 21 12:13:15 2017 -0700 Committer: Donald Szeto <[email protected]> Committed: Fri Apr 21 12:13:15 2017 -0700 ---------------------------------------------------------------------- .../predictionio/data/storage/elasticsearch/ESLEvents.scala | 6 +++--- .../predictionio/data/storage/elasticsearch/ESPEvents.scala | 2 +- .../predictionio/data/storage/elasticsearch/ESUtils.scala | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/b0840185/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESLEvents.scala ---------------------------------------------------------------------- diff --git a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESLEvents.scala b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESLEvents.scala index b57ed03..f379bb8 100644 --- a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESLEvents.scala +++ b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESLEvents.scala @@ -97,7 +97,7 @@ class ESLEvents(val client: ESClient, config: StorageClientConfig, val index: St restClient.performRequest( "POST", s"/$index/$estype/_delete_by_query", - Map("refresh" -> "true").asJava, + Map("refresh" -> ESUtils.getEventDataRefresh(config)).asJava, entity).getStatusLine.getStatusCode match { case 200 => true case _ => @@ -146,7 +146,7 @@ class ESLEvents(val client: ESClient, config: StorageClientConfig, val index: St val response = restClient.performRequest( "POST", s"/$index/$estype/$id", - Map("refresh" -> "true").asJava, + Map("refresh" -> ESUtils.getEventDataRefresh(config)).asJava, entity) val jsonResponse = parse(EntityUtils.toString(response.getEntity)) val result = (jsonResponse \ "result").extract[String] @@ -242,7 +242,7 @@ class ESLEvents(val client: ESClient, config: StorageClientConfig, val index: St val response = restClient.performRequest( "POST", s"/$index/$estype/_delete_by_query", - Map("refresh" -> "true").asJava) + Map("refresh" -> ESUtils.getEventDataRefresh(config)).asJava) val jsonResponse = parse(EntityUtils.toString(response.getEntity)) val result = (jsonResponse \ "result").extract[String] result match { http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/b0840185/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESPEvents.scala ---------------------------------------------------------------------- diff --git a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESPEvents.scala b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESPEvents.scala index 390e78c..b9ad8bb 100644 --- a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESPEvents.scala +++ b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESPEvents.scala @@ -120,7 +120,7 @@ class ESPEvents(client: ESClient, config: StorageClientConfig, index: String) val response = restClient.performRequest( "POST", s"/$index/$estype/_delete_by_query", - Map("refresh" -> "true").asJava) + Map("refresh" -> ESUtils.getEventDataRefresh(config)).asJava) val jsonResponse = parse(EntityUtils.toString(response.getEntity)) val result = (jsonResponse \ "result").extract[String] result match { http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/b0840185/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESUtils.scala ---------------------------------------------------------------------- diff --git a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESUtils.scala b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESUtils.scala index 4711e80..34c76eb 100644 --- a/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESUtils.scala +++ b/storage/elasticsearch/src/main/scala/org/apache/predictionio/data/storage/elasticsearch/ESUtils.scala @@ -277,4 +277,8 @@ object ESUtils { def getNumberOfReplicas(config: StorageClientConfig, index: String): Option[Int] = { config.properties.get(s"${index}_NUM_OF_REPLICAS").map(_.toInt) } + + def getEventDataRefresh(config: StorageClientConfig): String = { + config.properties.getOrElse("EVENTDATA_REFRESH", "true") + } }
