ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject ambari git commit: AMBARI-16701. Do not use implicit routing by default in solr-client (oleewere)
Date Tue, 24 May 2016 08:55:32 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 7d4b6fd2b -> b0b6cb418


AMBARI-16701. Do not use implicit routing by default in solr-client (oleewere)


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

Branch: refs/heads/trunk
Commit: b0b6cb4180900821830eb21e56f38cd185af499b
Parents: 7d4b6fd
Author: oleewere <oleewere@gmail.com>
Authored: Tue May 24 10:50:41 2016 +0200
Committer: oleewere <oleewere@gmail.com>
Committed: Tue May 24 10:55:12 2016 +0200

----------------------------------------------------------------------
 .../libraries/functions/solr_cloud_util.py           | 15 ++++++++++++---
 .../ambari/logsearch/solr/AmbariSolrCloudCLI.java    |  4 ++--
 .../solr/commands/CreateCollectionCommand.java       |  6 ++++--
 3 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b0b6cb41/ambari-common/src/main/python/resource_management/libraries/functions/solr_cloud_util.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/solr_cloud_util.py
b/ambari-common/src/main/python/resource_management/libraries/functions/solr_cloud_util.py
index d661288..aba3025 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/solr_cloud_util.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/solr_cloud_util.py
@@ -49,18 +49,27 @@ def upload_configuration_to_zk(zookeeper_quorum, solr_znode, config_set,
config_
   )
 
 def create_collection(zookeeper_quorum, solr_znode, collection, config_set, java64_home,
user, group,
-                      shards = 1, replication_factor = 1, max_shards = 1, retry = 5, interval
= 10):
+                      shards = 1, replication_factor = 1, max_shards = 1, retry = 5, interval
= 10,
+                      router_name = None, router_field = None):
   """
   Create Solr collection based on a configuration set in zookeeper.
   If this method called again the with higher shard number (or max_shard number), then it
will indicate
   the cli tool to add new shards to the Solr collection. This can be useful after added a
new Solr Cloud
   instance to the cluster.
+
+  If you would like to add shards later to a collection, then use implicit routing, e.g.:
+  router_name = "implicit", router_field = "_router_field_"
   """
   solr_cli_prefix = __create_solr_cloud_cli_prefix(zookeeper_quorum, solr_znode, java64_home)
 
   if max_shards == 1: # if max shards is not specified use this strategy
     max_shards = replication_factor * shards
 
-  Execute(format('{solr_cli_prefix} --create-collection -c {collection} -cs {config_set}
-s {shards} -r {replication_factor} '\
-    '-m {max_shards} -rt {retry} -i {interval}'), user=user, group=group
+  create_collection_cmd = format('{solr_cli_prefix} --create-collection -c {collection} -cs
{config_set} -s {shards} -r {replication_factor} '\
+    '-m {max_shards} -rt {retry} -i {interval}')
+
+  if router_name is not None and router_field is not None:
+    create_collection_cmd += format(' -rn {router_name} -rf {router_field}')
+
+  Execute(create_collection_cmd, user=user, group=group
   )

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0b6cb41/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudCLI.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudCLI.java
b/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudCLI.java
index 21e7fee..a2da737 100644
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudCLI.java
+++ b/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/AmbariSolrCloudCLI.java
@@ -241,8 +241,8 @@ public class AmbariSolrCloudCLI {
       int retry = cli.hasOption("rt") ? Integer.parseInt(cli.getOptionValue("rt")) : 5;
       int interval = cli.hasOption('i') ? Integer.parseInt(cli.getOptionValue('i')) : 10;
       int maxShards = cli.hasOption('m') ? Integer.parseInt(cli.getOptionValue('m')) : shards
* replication;
-      String routerName = cli.hasOption("rn") ? cli.getOptionValue("rn") : "implicit";
-      String routerField = cli.hasOption("rf") ? cli.getOptionValue("rf") : "_router_field_";
+      String routerName = cli.hasOption("rn") ? cli.getOptionValue("rn") : null;
+      String routerField = cli.hasOption("rf") ? cli.getOptionValue("rf") : null;
       String shardName = cli.hasOption("sn") ? cli.getOptionValue("sn") : null;
       boolean isSplitting = !cli.hasOption("ns");
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0b6cb41/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/commands/CreateCollectionCommand.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/commands/CreateCollectionCommand.java
b/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/commands/CreateCollectionCommand.java
index c888269..f981cbb 100644
--- a/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/commands/CreateCollectionCommand.java
+++ b/ambari-logsearch/ambari-logsearch-solr-client/src/main/java/org/apache/ambari/logsearch/solr/commands/CreateCollectionCommand.java
@@ -45,11 +45,13 @@ public class CreateCollectionCommand extends AbstractSolrRetryCommand<Collection
     request.setNumShards(client.getShards());
     request.setReplicationFactor(client.getReplication());
     request.setMaxShardsPerNode(client.getMaxShardsPerNode());
-    if (client.isSplitting()) {
-      request.setShards(ShardUtils.generateShardListStr(client.getMaxShardsPerNode()));
+    if (client.getRouterField() != null && client.getRouterName()!= null) {
       request.setRouterName(client.getRouterName());
       request.setRouterField(client.getRouterField());
     }
+    if (client.isSplitting()) {
+      request.setShards(ShardUtils.generateShardListStr(client.getMaxShardsPerNode()));
+    }
     return request;
   }
 


Mime
View raw message