This is an automated email from the ASF dual-hosted git repository.
mdrob pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 03a053a SOLR-15919 Replace File with Path for many ZK operations
(#524)
03a053a is described below
commit 03a053aad059efeba6a60359f703196e57c0a81a
Author: Mike Drob <[email protected]>
AuthorDate: Fri Jan 14 09:16:38 2022 -0600
SOLR-15919 Replace File with Path for many ZK operations (#524)
---
solr/CHANGES.txt | 2 ++
.../TestEmbeddedSolrServerConstructors.java | 6 ++---
.../client/solrj/embedded/TestJettySolrRunner.java | 3 +--
.../solr/cloud/DistribJoinFromCollectionTest.java | 3 +--
.../solr/cloud/NestedShardedAtomicUpdateTest.java | 5 ++--
.../apache/solr/cloud/TestCloudDeleteByQuery.java | 3 +--
.../TestCloudPhrasesIdentificationComponent.java | 5 ++--
.../solr/cloud/TestCloudPseudoReturnFields.java | 5 ++--
.../apache/solr/cloud/TestRandomFlRTGCloud.java | 3 +--
.../cloud/TestStressCloudBlindAtomicUpdates.java | 5 ++--
.../apache/solr/core/TestShardHandlerFactory.java | 3 +--
.../component/TestHttpShardHandlerFactory.java | 5 ++--
.../org/apache/solr/metrics/JvmMetricsTest.java | 10 ++++----
.../solr/metrics/SolrMetricsIntegrationTest.java | 8 +++----
.../transform/TestSubQueryTransformerDistrib.java | 5 ++--
.../search/facet/TestCloudJSONFacetJoinDomain.java | 3 +--
.../solr/search/facet/TestCloudJSONFacetSKG.java | 3 +--
.../search/facet/TestCloudJSONFacetSKGEquiv.java | 3 +--
.../solr/search/join/TestCloudNestedDocsSort.java | 3 +--
.../update/TestInPlaceUpdateWithRouteField.java | 3 +--
.../org/apache/solr/common/cloud/SolrZkClient.java | 18 +++++++--------
.../solr/common/cloud/ZkMaintenanceUtils.java | 14 +++++------
.../src/java/org/apache/solr/SolrTestCaseJ4.java | 2 ++
.../org/apache/solr/cloud/AbstractZkTestCase.java | 7 +++---
.../java/org/apache/solr/cloud/ZkTestServer.java | 27 +++++++++++-----------
25 files changed, 68 insertions(+), 86 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 30d3b05..480f5db 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -511,6 +511,8 @@ Bug Fixes
to take advantage of it's "Workload Identity" and other
role-based access feature. (Jacek Kikiewicz, Martin Stocker
via Jason Gerlowski)
+* SOLR-15919: Replace File with Path for many ZK operations (Mike Drob)
+
================== 8.11.2 ==================
Bug Fixes
diff --git
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
index 912a35c..20aaa79 100644
---
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
+++
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerConstructors.java
@@ -18,7 +18,6 @@ package org.apache.solr.client.solrj.embedded;
import java.io.IOException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrQuery;
@@ -32,8 +31,7 @@ public class TestEmbeddedSolrServerConstructors extends
SolrTestCaseJ4 {
@Test
@SuppressWarnings({"try"})
public void testPathConstructor() throws IOException {
- Path path = Paths.get(TEST_HOME());
- try (EmbeddedSolrServer server = new EmbeddedSolrServer(path,
"collection1")) {
+ try (EmbeddedSolrServer server = new EmbeddedSolrServer(TEST_PATH(),
"collection1")) {
}
}
@@ -43,7 +41,7 @@ public class TestEmbeddedSolrServerConstructors extends
SolrTestCaseJ4 {
Path path = createTempDir();
NodeConfig config = new NodeConfig.NodeConfigBuilder("testnode", path)
-
.setConfigSetBaseDirectory(Paths.get(TEST_HOME()).resolve("configsets").toString())
+
.setConfigSetBaseDirectory(TEST_PATH().resolve("configsets").toString())
.build();
try (EmbeddedSolrServer server = new EmbeddedSolrServer(config,
"newcore")) {
diff --git
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java
index ae8312e..ead3b09 100644
---
a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java
+++
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestJettySolrRunner.java
@@ -28,7 +28,6 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Properties;
public class TestJettySolrRunner extends SolrTestCaseJ4 {
@@ -42,7 +41,7 @@ public class TestJettySolrRunner extends SolrTestCaseJ4 {
Path solrHome = createTempDir();
Path coresDir = createTempDir("crazy_path_to_cores");
- Path configsets = Paths.get(TEST_HOME()).resolve("configsets");
+ Path configsets = TEST_PATH().resolve("configsets");
String solrxml
= "<solr><str name=\"configSetBaseDir\">CONFIGSETS</str><str
name=\"coreRootDirectory\">COREROOT</str></solr>"
diff --git
a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
index a823c2e..9406594 100644
---
a/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
+++
b/solr/core/src/test/org/apache/solr/cloud/DistribJoinFromCollectionTest.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -65,7 +64,7 @@ public class DistribJoinFromCollectionTest extends
SolrCloudTestCase{
@BeforeClass
public static void setupCluster() throws Exception {
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
String configName = "solrCloudCollectionConfig";
int nodeCount = 5;
diff --git
a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
index 464fcdc..7e2ed1b 100644
---
a/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
+++
b/solr/core/src/test/org/apache/solr/cloud/NestedShardedAtomicUpdateTest.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
@@ -52,8 +51,8 @@ public class NestedShardedAtomicUpdateTest extends
SolrCloudTestCase { // used t
.addConfig("_default", configset("cloud-minimal"))
.configure();
// replace schema.xml with schema-test.xml
- Path schemaPath =
Paths.get(TEST_HOME()).resolve("collection1").resolve("conf").resolve("schema-nest.xml");
- cluster.getZkClient().setData("/configs/_default/schema.xml",
schemaPath.toFile(),true);
+ Path schemaPath = TEST_COLL1_CONF().resolve("schema-nest.xml");
+ cluster.getZkClient().setData("/configs/_default/schema.xml", schemaPath,
true);
cloudClient = cluster.getSolrClient();
cloudClient.setDefaultCollection(DEFAULT_COLLECTION);
diff --git
a/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java
b/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java
index e895fe3..7db38db 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudDeleteByQuery.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -113,7 +112,7 @@ public class TestCloudDeleteByQuery extends
SolrCloudTestCase {
private static void createMiniSolrCloudCluster() throws Exception {
final String configName = "solrCloudCollectionConfig";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
configureCluster(NUM_SERVERS)
.addConfig(configName, configDir)
diff --git
a/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
b/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
index ff2af57..7170da8 100644
---
a/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
+++
b/solr/core/src/test/org/apache/solr/cloud/TestCloudPhrasesIdentificationComponent.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -68,8 +67,8 @@ public class TestCloudPhrasesIdentificationComponent extends
SolrCloudTestCase {
final int numNodes = (numShards * repFactor);
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
-
+ final Path configDir = TEST_COLL1_CONF();
+
configureCluster(numNodes).addConfig(configName, configDir).configure();
Map<String, String> collectionProperties = new LinkedHashMap<>();
diff --git
a/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
b/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
index aa1a6e5..23d2f93 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudPseudoReturnFields.java
@@ -18,7 +18,6 @@ package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -70,8 +69,8 @@ public class TestCloudPseudoReturnFields extends
SolrCloudTestCase {
final int numNodes = 1 + (numShards * repFactor);
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
-
+ final Path configDir = TEST_COLL1_CONF();
+
configureCluster(numNodes).addConfig(configName, configDir).configure();
Map<String, String> collectionProperties = new HashMap<>();
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
index af586d8..34b0279 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -133,7 +132,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase
{
final int numNodes = 1 + (singleCoreMode ? 0 : (numShards * repFactor));
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
configureCluster(numNodes).addConfig(configName, configDir).configure();
diff --git
a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
index 789136e..4e2a027 100644
---
a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
+++
b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java
@@ -19,7 +19,6 @@ package org.apache.solr.cloud;
import java.lang.invoke.MethodHandles;
import java.net.URL;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -123,8 +122,8 @@ public class TestStressCloudBlindAtomicUpdates extends
SolrCloudTestCase {
final int numNodes = numShards * repFactor;
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
-
+ final Path configDir = TEST_COLL1_CONF();
+
configureCluster(numNodes).addConfig(configName, configDir).configure();
CLOUD_CLIENT = cluster.getSolrClient();
diff --git
a/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
b/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
index 4ca31ef..cb18e6a 100644
--- a/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
+++ b/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
@@ -17,7 +17,6 @@
package org.apache.solr.core;
import java.nio.file.Path;
-import java.nio.file.Paths;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.util.NamedList;
@@ -29,7 +28,7 @@ import org.apache.solr.handler.component.ShardHandlerFactory;
public class TestShardHandlerFactory extends SolrTestCaseJ4 {
public void testXML() throws Exception {
- Path home = Paths.get(TEST_HOME());
+ Path home = TEST_PATH();
CoreContainer cc = CoreContainer.createAndLoad(home,
home.resolve("solr-shardhandler.xml"));
ShardHandlerFactory factory = cc.getShardHandlerFactory();
assertTrue(factory instanceof MockShardHandlerFactory);
diff --git
a/solr/core/src/test/org/apache/solr/handler/component/TestHttpShardHandlerFactory.java
b/solr/core/src/test/org/apache/solr/handler/component/TestHttpShardHandlerFactory.java
index db2313d..822a09f 100644
---
a/solr/core/src/test/org/apache/solr/handler/component/TestHttpShardHandlerFactory.java
+++
b/solr/core/src/test/org/apache/solr/handler/component/TestHttpShardHandlerFactory.java
@@ -17,7 +17,6 @@
package org.apache.solr.handler.component;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -65,7 +64,7 @@ public class TestHttpShardHandlerFactory extends
SolrTestCaseJ4 {
}
public void testLoadBalancerRequestsMinMax() throws Exception {
- final Path home = Paths.get(TEST_HOME());
+ final Path home = TEST_PATH();
CoreContainer cc = null;
ShardHandlerFactory factory = null;
try {
@@ -114,7 +113,7 @@ public class TestHttpShardHandlerFactory extends
SolrTestCaseJ4 {
CoreContainer cc = null;
ShardHandlerFactory factory = null;
try {
- final Path home = Paths.get(TEST_HOME());
+ final Path home = TEST_PATH();
cc = CoreContainer.createAndLoad(home, home.resolve("solr.xml"));
factory = cc.getShardHandlerFactory();
assertTrue(factory instanceof HttpShardHandlerFactory);
diff --git a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java
b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java
index 7c007cb..7862612 100644
--- a/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/JvmMetricsTest.java
@@ -16,14 +16,14 @@
*/
package org.apache.solr.metrics;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Map;
import com.codahale.metrics.Gauge;
import com.codahale.metrics.Metric;
-import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.core.NodeConfig;
import org.apache.solr.core.SolrXmlConfig;
@@ -116,17 +116,17 @@ public class JvmMetricsTest extends SolrJettyTestBase {
@Test
public void testHiddenSysProps() throws Exception {
- Path home = Paths.get(TEST_HOME());
+ Path home = TEST_PATH();
// default config
- String solrXml = FileUtils.readFileToString(Paths.get(home.toString(),
"solr.xml").toFile(), "UTF-8");
+ String solrXml = Files.readString(home.resolve("solr.xml"),
StandardCharsets.UTF_8);
NodeConfig config = SolrXmlConfig.fromString(home, solrXml);
NodeConfig.NodeConfigBuilder.DEFAULT_HIDDEN_SYS_PROPS.forEach(s -> {
assertTrue(s, config.getMetricsConfig().getHiddenSysProps().contains(s));
});
// custom config
- solrXml =
FileUtils.readFileToString(home.resolve("solr-hiddensysprops.xml").toFile(),
"UTF-8");
+ solrXml = Files.readString(home.resolve("solr-hiddensysprops.xml"),
StandardCharsets.UTF_8);
NodeConfig config2 = SolrXmlConfig.fromString(home, solrXml);
Arrays.asList("foo", "bar", "baz").forEach(s -> {
assertTrue(s,
config2.getMetricsConfig().getHiddenSysProps().contains(s));
diff --git
a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
index e0c9e11..f527cc8 100644
--- a/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/metrics/SolrMetricsIntegrationTest.java
@@ -17,8 +17,9 @@
package org.apache.solr.metrics;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Map;
import java.util.Random;
@@ -26,7 +27,6 @@ import com.codahale.metrics.Gauge;
import com.codahale.metrics.Metric;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
-import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.TestUtil;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.core.CoreContainer;
@@ -66,11 +66,11 @@ public class SolrMetricsIntegrationTest extends
SolrTestCaseJ4 {
@Before
public void beforeTest() throws Exception {
- Path home = Paths.get(TEST_HOME());
+ Path home = TEST_PATH();
// define these properties, they are used in solrconfig.xml
System.setProperty("solr.test.sys.prop1", "propone");
System.setProperty("solr.test.sys.prop2", "proptwo");
- String solrXml = FileUtils.readFileToString(Paths.get(home.toString(),
"solr-metricreporter.xml").toFile(), "UTF-8");
+ String solrXml = Files.readString(home.resolve("solr-metricreporter.xml"),
StandardCharsets.UTF_8);
NodeConfig cfg = SolrXmlConfig.fromString(home, solrXml);
cc = createCoreContainer(cfg, new TestHarness.TestCoresLocator
(DEFAULT_TEST_CORENAME,
initAndGetDataDir().getAbsolutePath(),
diff --git
a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
index 6047df4..e85afe6 100644
---
a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
+++
b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -60,8 +59,8 @@ public class TestSubQueryTransformerDistrib extends
SolrCloudTestCase {
public static void setupCluster() throws Exception {
differentUniqueId = random().nextBoolean();
-
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+
+ final Path configDir = TEST_COLL1_CONF();
String configName = "solrCloudCollectionConfig";
int nodeCount = 5;
diff --git
a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
index c67c9d3..7b2c277 100644
---
a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
+++
b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetJoinDomain.java
@@ -19,7 +19,6 @@ package org.apache.solr.search.facet;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -101,7 +100,7 @@ public class TestCloudJSONFacetJoinDomain extends
SolrCloudTestCase {
final int numNodes = (numShards * repFactor);
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
configureCluster(numNodes).addConfig(configName, configDir).configure();
diff --git
a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
index 6f24519..9c93420 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKG.java
@@ -19,7 +19,6 @@ package org.apache.solr.search.facet;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -130,7 +129,7 @@ public class TestCloudJSONFacetSKG extends
SolrCloudTestCase {
final int numNodes = (numShards * repFactor);
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
configureCluster(numNodes).addConfig(configName, configDir).configure();
diff --git
a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
index c0d6035..b3ec3ea 100644
---
a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
+++
b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
@@ -19,7 +19,6 @@ package org.apache.solr.search.facet;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -124,7 +123,7 @@ public class TestCloudJSONFacetSKGEquiv extends
SolrCloudTestCase {
final int numNodes = (numShards * repFactor);
final String configName = DEBUG_LABEL + "_config-set";
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
configureCluster(numNodes).addConfig(configName, configDir).configure();
diff --git
a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
index 8ecd198..f01e73d 100644
---
a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
+++
b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
@@ -18,7 +18,6 @@ package org.apache.solr.search.join;
import java.io.IOException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -55,7 +54,7 @@ public class TestCloudNestedDocsSort extends
SolrCloudTestCase {
vals.add(""+Integer.toString(random().nextInt(1000000),
Character.MAX_RADIX));
}
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
String configName = "solrCloudCollectionConfig";
int nodeCount = 5;
diff --git
a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdateWithRouteField.java
b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdateWithRouteField.java
index 6a0ec28..41e6aa2 100644
---
a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdateWithRouteField.java
+++
b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdateWithRouteField.java
@@ -21,7 +21,6 @@ import static org.hamcrest.CoreMatchers.is;
import java.io.IOException;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -58,7 +57,7 @@ public class TestInPlaceUpdateWithRouteField extends
SolrCloudTestCase {
@BeforeClass
public static void setupCluster() throws Exception {
- final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
+ final Path configDir = TEST_COLL1_CONF();
String configName = "solrCloudCollectionConfig";
int nodeCount = TestUtil.nextInt(random(), 1, 3);
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
index a9d981f..24562af 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java
@@ -17,7 +17,6 @@
package org.apache.solr.common.cloud;
import java.io.Closeable;
-import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.invoke.MethodHandles;
@@ -425,15 +424,15 @@ public class SolrZkClient implements Closeable {
makePath(path, null, CreateMode.PERSISTENT, null, failOnExists,
retryOnConnLoss, 0);
}
- public void makePath(String path, File file, boolean failOnExists, boolean
retryOnConnLoss)
+ public void makePath(String path, Path data, boolean failOnExists, boolean
retryOnConnLoss)
throws IOException, KeeperException, InterruptedException {
- makePath(path, Files.readAllBytes(file.toPath()),
+ makePath(path, Files.readAllBytes(data),
CreateMode.PERSISTENT, null, failOnExists, retryOnConnLoss, 0);
}
- public void makePath(String path, File file, boolean retryOnConnLoss) throws
IOException,
+ public void makePath(String path, Path data, boolean retryOnConnLoss) throws
IOException,
KeeperException, InterruptedException {
- makePath(path, Files.readAllBytes(file.toPath()), retryOnConnLoss);
+ makePath(path, Files.readAllBytes(data), retryOnConnLoss);
}
public void makePath(String path, CreateMode createMode, boolean
retryOnConnLoss) throws KeeperException,
@@ -579,15 +578,14 @@ public class SolrZkClient implements Closeable {
* Write file to ZooKeeper - default system encoding used.
*
* @param path path to upload file to e.g. /solr/conf/solrconfig.xml
- * @param file path to file to be uploaded
+ * @param data a filepath to read data from
*/
- public Stat setData(String path, File file, boolean retryOnConnLoss) throws
IOException,
+ public Stat setData(String path, Path data, boolean retryOnConnLoss) throws
IOException,
KeeperException, InterruptedException {
if (log.isDebugEnabled()) {
- log.debug("Write to ZooKeeper: {} to {}", file.getAbsolutePath(), path);
+ log.debug("Write to ZooKeeper: {} to {}", data.toAbsolutePath(), path);
}
- byte[] data = Files.readAllBytes(file.toPath());
- return setData(path, data, retryOnConnLoss);
+ return setData(path, Files.readAllBytes(data), retryOnConnLoss);
}
public List<OpResult> multi(final Iterable<Op> ops, boolean retryOnConnLoss)
throws InterruptedException, KeeperException {
diff --git
a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
index 645b80d..aff7fde 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkMaintenanceUtils.java
@@ -295,12 +295,12 @@ public class ZkMaintenanceUtils {
try {
// if the path exists (and presumably we're uploading data to it)
just set its data
if (file.toFile().getName().equals(ZKNODE_DATA_FILE) &&
zkClient.exists(zkNode, true)) {
- zkClient.setData(zkNode, file.toFile(), true);
+ zkClient.setData(zkNode, file, true);
} else {
- zkClient.makePath(zkNode, file.toFile(), false, true);
+ zkClient.makePath(zkNode, file, false, true);
}
} catch (KeeperException | InterruptedException e) {
- throw new IOException("Error uploading file " + file.toString() + "
to zookeeper path " + zkNode,
+ throw new IOException("Error uploading file " + file + " to
zookeeper path " + zkNode,
SolrZkClient.checkInterrupted(e));
}
return FileVisitResult.CONTINUE;
@@ -320,11 +320,11 @@ public class ZkMaintenanceUtils {
return znodeStat.getEphemeralOwner() != 0;
}
- private static int copyDataDown(SolrZkClient zkClient, String zkPath, File
file) throws IOException, KeeperException, InterruptedException {
+ private static int copyDataDown(SolrZkClient zkClient, String zkPath, Path
file) throws IOException, KeeperException, InterruptedException {
byte[] data = zkClient.getData(zkPath, null, null, true);
if (data != null && data.length > 0) { // There are apparently basically
empty ZNodes.
log.info("Writing file {}", file);
- Files.write(file.toPath(), data);
+ Files.write(file, data);
return data.length;
}
return 0;
@@ -338,14 +338,14 @@ public class ZkMaintenanceUtils {
if (children.size() == 0) {
// If we didn't copy data down, then we also didn't create the file.
But we still need a marker on the local
// disk so create an empty file.
- if (copyDataDown(zkClient, zkPath, file.toFile()) == 0) {
+ if (copyDataDown(zkClient, zkPath, file) == 0) {
Files.createFile(file);
}
} else {
Files.createDirectories(file); // Make parent dir.
// ZK nodes, whether leaf or not can have data. If it's a non-leaf
node and
// has associated data write it into the special file.
- copyDataDown(zkClient, zkPath, new File(file.toFile(),
ZKNODE_DATA_FILE));
+ copyDataDown(zkClient, zkPath, file.resolve(ZKNODE_DATA_FILE));
for (String child : children) {
String zkChild = zkPath;
diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
index 5a1bb26..3af84c0 100644
--- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
+++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java
@@ -2130,6 +2130,8 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase
{
public static Path TEST_PATH() { return
getFile("solr/collection1").getParentFile().toPath(); }
+ public static Path TEST_COLL1_CONF() { return
TEST_PATH().resolve("collection1").resolve("conf"); }
+
public static Path configset(String name) {
return TEST_PATH().resolve("configsets").resolve(name).resolve("conf");
}
diff --git
a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
index f27525e..646270b 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractZkTestCase.java
@@ -16,7 +16,6 @@
*/
package org.apache.solr.cloud;
-import java.io.File;
import java.lang.invoke.MethodHandles;
import java.nio.file.Path;
@@ -36,12 +35,12 @@ public abstract class AbstractZkTestCase extends
SolrTestCaseJ4 {
private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static File SOLRHOME;
+ public static Path SOLRHOME;
static {
try {
- SOLRHOME = new File(SolrTestCaseJ4.TEST_HOME());
+ SOLRHOME = SolrTestCaseJ4.TEST_PATH();
} catch (RuntimeException e) {
- log.warn("TEST_HOME() does not exist - solrj test?");
+ log.warn("TEST_PATH() does not exist - solrj test?");
// solrj tests not working with TEST_HOME()
// must override getSolrHome
}
diff --git
a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
index d5eee2d..dcdbfdb 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ZkTestServer.java
@@ -47,7 +47,6 @@ import org.slf4j.LoggerFactory;
import javax.management.JMException;
import java.io.BufferedReader;
-import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
@@ -57,6 +56,7 @@ import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
@@ -72,13 +72,13 @@ public class ZkTestServer {
private static final Logger log =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- public static File SOLRHOME;
+ public static Path SOLRHOME;
static {
try {
- SOLRHOME = new File(SolrTestCaseJ4.TEST_HOME());
+ SOLRHOME = SolrTestCaseJ4.TEST_PATH();
} catch (RuntimeException e) {
- log.warn("TEST_HOME() does not exist - solrj test?");
- // solrj tests not working with TEST_HOME()
+ log.warn("TEST_PATH() does not exist - solrj test?");
+ // solrj tests not working with TEST_PATH()
// must override getSolrHome
}
}
@@ -780,24 +780,23 @@ public class ZkTestServer {
buildZooKeeper(SOLRHOME, config, schema);
}
- public static void putConfig(String confName, SolrZkClient zkClient, File
solrhome, final String name)
+ public static void putConfig(String confName, SolrZkClient zkClient, Path
solrhome, final String name)
throws Exception {
putConfig(confName, zkClient, null, solrhome, name, name);
}
- public static void putConfig(String confName, SolrZkClient zkClient, File
solrhome, final String srcName,
+ public static void putConfig(String confName, SolrZkClient zkClient, Path
solrhome, final String srcName,
String destName) throws Exception {
putConfig(confName, zkClient, null, solrhome, srcName, destName);
}
- public static void putConfig(String confName, SolrZkClient zkClient, String
zkChroot, File solrhome,
+ public static void putConfig(String confName, SolrZkClient zkClient, String
zkChroot, Path solrhome,
final String srcName, String destName) throws
Exception {
- File file = new File(solrhome, "collection1"
- + File.separator + "conf" + File.separator + srcName);
- if (!file.exists()) {
+ Path file =
solrhome.resolve("collection1").resolve("conf").resolve(srcName);
+ if (!Files.exists(file)) {
if (log.isInfoEnabled()) {
- log.info("skipping {} because it doesn't exist",
file.getAbsolutePath());
+ log.info("skipping {} because it doesn't exist",
file.toAbsolutePath());
}
return;
}
@@ -807,13 +806,13 @@ public class ZkTestServer {
destPath = zkChroot + destPath;
}
if (log.isInfoEnabled()) {
- log.info("put {} to {}", file.getAbsolutePath(), destPath);
+ log.info("put {} to {}", file.toAbsolutePath(), destPath);
}
zkClient.makePath(destPath, file, false, true);
}
// static to share with distrib test
- public void buildZooKeeper(File solrhome, String config, String schema)
throws Exception {
+ public void buildZooKeeper(Path solrhome, String config, String schema)
throws Exception {
Map<String,Object> props = new HashMap<>();
props.put("configName", "conf1");