usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/5] git commit: Set shard and replica size at Index creation time and not client creation time.
Date Sat, 01 Nov 2014 20:23:37 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/key-row-sharding 400189e8d -> a3980d00a


Set shard and replica size at Index creation time and not client creation time.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b9a73b70
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b9a73b70
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b9a73b70

Branch: refs/heads/key-row-sharding
Commit: b9a73b705fc94b428f9ee3de1a58a1bed214fe50
Parents: b6a8bc6
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Fri Oct 31 16:04:36 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Fri Oct 31 16:04:36 2014 -0400

----------------------------------------------------------------------
 .../persistence/index/impl/EsEntityIndexImpl.java     | 13 +++++++++++--
 .../usergrid/persistence/index/impl/EsProvider.java   | 14 ++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9a73b70/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 1ff747f..23accdd 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -64,7 +64,7 @@ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import com.google.common.collect.ImmutableMap;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
-import java.util.concurrent.ExecutionException;
+import java.util.HashMap;
 
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
 import static org.apache.usergrid.persistence.index.impl.IndexingUtils.DOC_ID_SEPARATOR_SPLITTER;
@@ -131,7 +131,16 @@ public class EsEntityIndexImpl implements EntityIndex {
             }
 
             AdminClient admin = client.admin();
-            CreateIndexResponse cir = admin.indices().prepareCreate( indexName ).execute().actionGet();
+
+            CreateIndexResponse cir = admin.indices()
+                .prepareCreate( indexName )
+                .setSettings( new HashMap<String, Object>() {{
+                    put("index.number_of_shards", config.getNumberOfShards() );
+                    put("index.number_of_replicas", config.numberOfReplicas() );
+                }} )
+                .execute()
+                .actionGet();
+
             logger.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged()
);
 
             // create the document, this ensures the index is ready

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b9a73b70/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index a353b43..c99c851 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -104,8 +104,11 @@ public class EsProvider {
 
                     .put("gateway.type", "none")
                     .put("index.store.type", "memory")
-                    .put("index.number_of_shards", 1)
-                    .put("index.number_of_replicas", 1)
+
+                    // should be set on index creation and not here
+//                    .put("index.number_of_shards", 1)
+//                    .put("index.number_of_replicas", 1)
+
                     .build();
 
                 log.info("-----------------------------------------------------------------------");
@@ -161,12 +164,15 @@ public class EsProvider {
 
                     .put( "client.transport.ping_timeout", 2000 ) // milliseconds
                     .put( "client.transport.nodes_sampler_interval", 100 )
-                    .put("index.number_of_shards", fig.getNumberOfShards() )
-                    .put("index.number_of_replicas", fig.numberOfReplicas() )
+
                     .put( "network.tcp.blocking", true )
                     .put( "node.client", true )
                     .put( "node.name", nodeName )
 
+                    // should be set on index creation and not here
+//                    .put("index.number_of_shards", fig.getNumberOfShards() )
+//                    .put("index.number_of_replicas", fig.numberOfReplicas() )
+
                     .build();
 
                 log.debug("Creating ElasticSearch client with settings: " +  settings.getAsMap());


Mime
View raw message