You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2016/12/06 23:13:15 UTC
[20/50] [abbrv] lucene-solr:apiv2: SOLR-9784: deprecated uploadconfig
SOLR-9784: deprecated uploadconfig
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/2ec97165
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/2ec97165
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/2ec97165
Branch: refs/heads/apiv2
Commit: 2ec97165204a9e4b55419816fc10eaaab6c9095f
Parents: 346e766
Author: Noble Paul <no...@apache.org>
Authored: Sat Nov 26 12:39:50 2016 +0530
Committer: Noble Paul <no...@apache.org>
Committed: Sat Nov 26 12:53:32 2016 +0530
----------------------------------------------------------------------
.../apache/solr/client/solrj/impl/CloudSolrClient.java | 6 ++++++
.../solrj/impl/ZkClientClusterStateProvider.java | 13 ++++++++++++-
.../solrj/impl/TestCloudSolrClientConnections.java | 4 ++--
.../java/org/apache/solr/cloud/SolrCloudTestCase.java | 3 ++-
4 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ec97165/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index 6e4a256..9c59d4f 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -649,6 +649,7 @@ public class CloudSolrClient extends SolrClient {
* @param configName the name of the config
* @throws IOException if an IO error occurs
*/
+ @Deprecated
public void uploadConfig(Path configPath, String configName) throws IOException {
stateProvider.connect();
assertZKStateProvider().uploadConfig(configPath, configName);
@@ -668,6 +669,7 @@ public class CloudSolrClient extends SolrClient {
* @param downloadPath the path to write config files to
* @throws IOException if an I/O exception occurs
*/
+ @Deprecated
public void downloadConfig(String configName, Path downloadPath) throws IOException {
assertZKStateProvider().downloadConfig(configName, downloadPath);
}
@@ -1532,6 +1534,10 @@ public class CloudSolrClient extends SolrClient {
this.lbClient.setConnectionTimeout(timeout);
}
+ public ClusterStateProvider getClusterStateProvider(){
+ return stateProvider;
+ }
+
private static boolean hasInfoToFindLeaders(UpdateRequest updateRequest, String idField) {
final Map<SolrInputDocument,Map<String,Object>> documents = updateRequest.getDocumentsMap();
final Map<String,Map<String,Object>> deleteById = updateRequest.getDeleteByIdMap();
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ec97165/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
index 5541186..8ed1b5c 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
@@ -34,7 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-class ZkClientClusterStateProvider implements CloudSolrClient.ClusterStateProvider {
+public class ZkClientClusterStateProvider implements CloudSolrClient.ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@@ -95,6 +95,17 @@ class ZkClientClusterStateProvider implements CloudSolrClient.ClusterStateProvid
zkStateReader.getConfigManager().downloadConfigDir(configName, downloadPath);
}
+ /**
+ * Upload a set of config files to Zookeeper and give it a name
+ *
+ * NOTE: You should only allow trusted users to upload configs. If you
+ * are allowing client access to zookeeper, you should protect the
+ * /configs node against unauthorised write access.
+ *
+ * @param configPath {@link java.nio.file.Path} to the config files
+ * @param configName the name of the config
+ * @throws IOException if an IO error occurs
+ */
public void uploadConfig(Path configPath, String configName) throws IOException {
connect();
zkStateReader.getConfigManager().uploadConfigDir(configPath, configName);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ec97165/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java
index f3abc26..4fa6d9a 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/TestCloudSolrClientConnections.java
@@ -68,7 +68,7 @@ public class TestCloudSolrClientConnections extends SolrTestCaseJ4 {
try {
CloudSolrClient client = cluster.getSolrClient();
try {
- client.uploadConfig(configPath, "testconfig");
+ ((ZkClientClusterStateProvider)client.getClusterStateProvider()).uploadConfig(configPath, "testconfig");
fail("Requests to a non-running cluster should throw a SolrException");
} catch (SolrException e) {
assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().contains("cluster not found/not ready"));
@@ -77,7 +77,7 @@ public class TestCloudSolrClientConnections extends SolrTestCaseJ4 {
cluster.startJettySolrRunner();
client.connect(20, TimeUnit.SECONDS);
- client.uploadConfig(configPath, "testconfig");
+ ((ZkClientClusterStateProvider)client.getClusterStateProvider()).uploadConfig(configPath, "testconfig");
ZkConfigManager configManager = new ZkConfigManager(client.getZkStateReader().getZkClient());
assertTrue("List of uploaded configs does not contain 'testconfig'", configManager.listConfigs().contains("testconfig"));
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2ec97165/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
----------------------------------------------------------------------
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
index 77a527e..9cc4a22 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/SolrCloudTestCase.java
@@ -36,6 +36,7 @@ import org.apache.solr.client.solrj.embedded.JettyConfig;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
+import org.apache.solr.client.solrj.impl.ZkClientClusterStateProvider;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
import org.apache.solr.client.solrj.request.CoreStatus;
import org.apache.solr.common.cloud.ClusterProperties;
@@ -159,7 +160,7 @@ public class SolrCloudTestCase extends SolrTestCaseJ4 {
cluster = new MiniSolrCloudCluster(nodeCount, baseDir, solrxml, jettyConfig);
CloudSolrClient client = cluster.getSolrClient();
for (Config config : configs) {
- client.uploadConfig(config.path, config.name);
+ ((ZkClientClusterStateProvider)client.getClusterStateProvider()).uploadConfig(config.path, config.name);
}
if (clusterProperties.size() > 0) {