syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [syncope] branch 2_1_X updated: [SYNCOPE-1440] Adjusting 'from' param
Date Mon, 04 Mar 2019 10:55:30 GMT
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_1_X by this push:
     new d4e8f59  [SYNCOPE-1440] Adjusting 'from' param
d4e8f59 is described below

commit d4e8f5928c3f9c5db3d036be163ba21e282a1ed0
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
AuthorDate: Mon Mar 4 11:19:21 2019 +0100

    [SYNCOPE-1440] Adjusting 'from' param
---
 .../ext/elasticsearch/client/ElasticsearchUtils.java | 20 ++++++++++++++++++++
 .../main/resources/elasticsearchClientContext.xml    |  2 ++
 .../jpa/dao/ElasticsearchAnySearchDAO.java           |  2 +-
 .../provisioning/java/job/ElasticsearchReindex.java  |  7 ++++++-
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
index 14a521c..2f64eb7 100644
--- a/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
+++ b/ext/elasticsearch/client-elasticsearch/src/main/java/org/apache/syncope/ext/elasticsearch/client/ElasticsearchUtils.java
@@ -58,6 +58,10 @@ public class ElasticsearchUtils {
 
     private int retryOnConflict = 5;
 
+    private int numberOfShards = 1;
+
+    private int numberOfReplicas = 1;
+
     public void setIndexMaxResultWindow(final int indexMaxResultWindow) {
         this.indexMaxResultWindow = indexMaxResultWindow;
     }
@@ -74,6 +78,22 @@ public class ElasticsearchUtils {
         return retryOnConflict;
     }
 
+    public int getNumberOfShards() {
+        return numberOfShards;
+    }
+
+    public void setNumberOfShards(final int numberOfShards) {
+        this.numberOfShards = numberOfShards;
+    }
+
+    public int getNumberOfReplicas() {
+        return numberOfReplicas;
+    }
+
+    public void setNumberOfReplicas(final int numberOfReplicas) {
+        this.numberOfReplicas = numberOfReplicas;
+    }
+
     /**
      * Returns the builder specialized with content from the provided any.
      *
diff --git a/ext/elasticsearch/client-elasticsearch/src/main/resources/elasticsearchClientContext.xml
b/ext/elasticsearch/client-elasticsearch/src/main/resources/elasticsearchClientContext.xml
index 996ae12..0cc8dbb 100644
--- a/ext/elasticsearch/client-elasticsearch/src/main/resources/elasticsearchClientContext.xml
+++ b/ext/elasticsearch/client-elasticsearch/src/main/resources/elasticsearchClientContext.xml
@@ -38,6 +38,8 @@ under the License.
   <bean class="org.apache.syncope.ext.elasticsearch.client.ElasticsearchUtils">
     <property name="indexMaxResultWindow" value="10000"/>
     <property name="retryOnConflict" value="5"/>
+    <property name="numberOfShards" value="1"/>
+    <property name="numberOfReplicas" value="1"/>
   </bean>
   <bean class="org.apache.syncope.ext.elasticsearch.client.ElasticsearchIndexManager"/>
   
diff --git a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
index bf8490f..a99ed24 100644
--- a/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
+++ b/ext/elasticsearch/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/ElasticsearchAnySearchDAO.java
@@ -200,7 +200,7 @@ public class ElasticsearchAnySearchDAO extends AbstractAnySearchDAO {
                 adminRealms,
                 cond,
                 kind,
-                (page <= 0 ? 0 : page - 1),
+                (itemsPerPage * (page <= 0 ? 0 : page - 1)),
                 (itemsPerPage < 0 ? elasticsearchUtils.getIndexMaxResultWindow() : itemsPerPage),
                 sortBuilders(kind, orderBy));
 
diff --git a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
index 260e589..eea2a8f 100644
--- a/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
+++ b/ext/elasticsearch/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/ElasticsearchReindex.java
@@ -156,6 +156,10 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate
{
                 endObject().
                 endObject().
                 endObject().
+                startObject("index").
+                field("number_of_shards", elasticsearchUtils.getNumberOfShards()).
+                field("number_of_replicas", elasticsearchUtils.getNumberOfReplicas()).
+                endObject().
                 endObject();
 
         XContentBuilder mapping = XContentFactory.jsonBuilder().
@@ -174,7 +178,8 @@ public class ElasticsearchReindex extends AbstractSchedTaskJobDelegate
{
                 endObject();
 
         CreateIndexResponse response = client.indices().create(
-                new CreateIndexRequest(elasticsearchUtils.getContextDomainName(kind)).settings(settings).
+                new CreateIndexRequest(elasticsearchUtils.getContextDomainName(kind)).
+                        settings(settings).
                         mapping(kind.name(), mapping), RequestOptions.DEFAULT);
         LOG.debug("Successfully created {} for {}: {}",
                 elasticsearchUtils.getContextDomainName(kind), kind.name(), response);


Mime
View raw message