Skip to content
Permalink
Browse files
AMBARI-21400. Upgrade Infra Solr version from 5.5.2 to 6.6.x (oleewere)
  • Loading branch information
oleewere committed Jul 7, 2017
1 parent bd44a8e commit 4cf6cad87357f10463709888170eddeff9f4003e
Showing 7 changed files with 743 additions and 164 deletions.

Large diffs are not rendered by default.

@@ -52,12 +52,14 @@ public class AmbariSolrCloudCLI {
private static final String UNSECURE_ZNODE_COMMAND = "unsecure-znode";
private static final String SECURE_SOLR_ZNODE_COMMAND = "secure-solr-znode";
private static final String SECURITY_JSON_LOCATION = "security-json-location";
private static final String REMOVE_ADMIN_HANDLERS = "remove-admin-handlers";
private static final String CMD_LINE_SYNTAX =
"\n./solrCloudCli.sh --create-collection -z host1:2181,host2:2181/ambari-solr -c collection -cs conf_set"
+ "\n./solrCloudCli.sh --upload-config -z host1:2181,host2:2181/ambari-solr -d /tmp/myconfig_dir -cs config_set"
+ "\n./solrCloudCli.sh --download-config -z host1:2181,host2:2181/ambari-solr -cs config_set -d /tmp/myonfig_dir"
+ "\n./solrCloudCli.sh --check-config -z host1:2181,host2:2181/ambari-solr -cs config_set"
+ "\n./solrCloudCli.sh --create-shard -z host1:2181,host2:2181/ambari-solr -c collection -sn myshard"
+ "\n./solrCloudCli.sh --remove-admin-handlers -z host1:2181,host2:2181/ambari-solr -c collection"
+ "\n./solrCloudCli.sh --create-znode -z host1:2181,host2:2181 -zn /ambari-solr"
+ "\n./solrCloudCli.sh --check-znode -z host1:2181,host2:2181 -zn /ambari-solr"
+ "\n./solrCloudCli.sh --cluster-prop -z host1:2181,host2:2181/ambari-solr -cpn urlScheme -cpn http"
@@ -137,6 +139,11 @@ public static void main(String[] args) {
.desc("Disable security for znode")
.build();

final Option removeAdminHandlerOption = Option.builder("rah")
.longOpt(REMOVE_ADMIN_HANDLERS)
.desc("Remove AdminHandlers request handler from solrconfig.xml")
.build();

final Option shardNameOption = Option.builder("sn")
.longOpt("shard-name")
.desc("Name of the shard for create-shard command")
@@ -328,6 +335,7 @@ public static void main(String[] args) {

options.addOption(helpOption);
options.addOption(retryOption);
options.addOption(removeAdminHandlerOption);
options.addOption(intervalOption);
options.addOption(zkConnectStringOption);
options.addOption(configSetOption);
@@ -414,6 +422,9 @@ public static void main(String[] args) {
} else if (cli.hasOption("uz")) {
command = UNSECURE_ZNODE_COMMAND;
validateRequiredOptions(cli, command, zkConnectStringOption, znodeOption, jaasFileOption);
} else if (cli.hasOption("rah")) {
command = REMOVE_ADMIN_HANDLERS;
validateRequiredOptions(cli, command, zkConnectStringOption, collectionOption);
} else {
List<String> commands = Arrays.asList(CREATE_COLLECTION_COMMAND, CREATE_SHARD_COMMAND, UPLOAD_CONFIG_COMMAND,
DOWNLOAD_CONFIG_COMMAND, CONFIG_CHECK_COMMAND, SET_CLUSTER_PROP, CREATE_ZNODE, SECURE_ZNODE_COMMAND, UNSECURE_ZNODE_COMMAND,
@@ -539,6 +550,9 @@ public static void main(String[] args) {
case SECURE_SOLR_ZNODE_COMMAND:
solrCloudClient = clientBuilder.build();
solrCloudClient.secureSolrZnode();
case REMOVE_ADMIN_HANDLERS:
solrCloudClient = clientBuilder.build();
solrCloudClient.removeAdminHandlerFromCollectionConfig();
break;
default:
throw new AmbariSolrCloudClientException(String.format("Not found command: '%s'", command));
@@ -27,6 +27,7 @@
import org.apache.ambari.infra.solr.commands.GetShardsCommand;
import org.apache.ambari.infra.solr.commands.GetSolrHostsCommand;
import org.apache.ambari.infra.solr.commands.ListCollectionCommand;
import org.apache.ambari.infra.solr.commands.RemoveAdminHandlersCommand;
import org.apache.ambari.infra.solr.commands.SecureSolrZNodeZkCommand;
import org.apache.ambari.infra.solr.commands.SecureZNodeZkCommand;
import org.apache.ambari.infra.solr.commands.SetClusterPropertyZkCommand;
@@ -257,6 +258,13 @@ public Collection<String> getSolrHosts() throws Exception {
return new GetSolrHostsCommand(getRetryTimes(), getInterval()).run(this);
}

/**
* Remove solr.admin.AdminHandlers requestHandler from solrconfi.xml
*/
public boolean removeAdminHandlerFromCollectionConfig() throws Exception {
return new RemoveAdminHandlersCommand(getRetryTimes(), getInterval()).run(this);
}

public String getZkConnectString() {
return zkConnectString;
}
@@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.ambari.infra.solr.commands;

import org.apache.ambari.infra.solr.AmbariSolrCloudClient;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.SolrZooKeeper;
import org.apache.zookeeper.data.Stat;

public class RemoveAdminHandlersCommand extends AbstractZookeeperRetryCommand<Boolean> {

public RemoveAdminHandlersCommand(int maxRetries, int interval) {
super(maxRetries, interval);
}

@Override
protected Boolean executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception {
String solrConfigXmlPath = String.format("/configs/%s/solrconfig.xml", client.getCollection());
if (zkClient.exists(solrConfigXmlPath, true)) {
Stat stat = new Stat();
byte[] solrConfigXmlBytes = zkClient.getData(solrConfigXmlPath, null, stat, true);
String solrConfigStr = new String(solrConfigXmlBytes);
if (solrConfigStr.contains("class=\"solr.admin.AdminHandlers\"")) {
byte[] newSolrConfigXmlBytes = new String(solrConfigXmlBytes).replaceAll("(?s)<requestHandler name=\"/admin/\".*?class=\"solr.admin.AdminHandlers\" />", "").getBytes();
zkClient.setData(solrConfigXmlPath, newSolrConfigXmlBytes, stat.getVersion() + 1, true);
}
}
return true;
}
}
@@ -19,9 +19,9 @@
package org.apache.ambari.infra.solr.commands;

import org.apache.ambari.infra.solr.AmbariSolrCloudClient;
import org.apache.solr.common.cloud.ClusterProperties;
import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.SolrZooKeeper;
import org.apache.solr.common.cloud.ZkStateReader;

public class SetClusterPropertyZkCommand extends AbstractZookeeperRetryCommand<String>{

@@ -33,8 +33,8 @@ public SetClusterPropertyZkCommand(int maxRetries, int interval) {
protected String executeZkCommand(AmbariSolrCloudClient client, SolrZkClient zkClient, SolrZooKeeper solrZooKeeper) throws Exception {
String propertyName = client.getPropName();
String propertyValue = client.getPropValue();
ZkStateReader reader = new ZkStateReader(zkClient);
reader.setClusterProperty(propertyName, propertyValue);
ClusterProperties clusterProperties = new ClusterProperties(zkClient);
clusterProperties.setClusterProperty(propertyName, propertyValue);
return propertyValue;
}
}
@@ -242,6 +242,11 @@ public String getHttpMethod() {
public String getResource() {
return (String) values.get("resource");
}

@Override
public Object getHandler() {
return null;
}
}

}
@@ -31,7 +31,7 @@

<properties>
<jdk.version>1.8</jdk.version>
<solr.version>5.5.2</solr.version>
<solr.version>6.6.0</solr.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<python.ver>python &gt;= 2.6</python.ver>
<deb.python.ver>python (&gt;= 2.6)</deb.python.ver>

0 comments on commit 4cf6cad

Please sign in to comment.