mirror of https://github.com/apache/lucene.git
SOLR-9381: Snitch for freedisk uses '/' instead of 'coreRootDirectory'
This commit is contained in:
parent
8347944378
commit
ced96c5fd5
|
@ -73,6 +73,9 @@ Bug Fixes
|
|||
|
||||
* SOLR-9444: Fix path usage for cloud backup/restore. (Hrishikesh Gadre, Uwe Schindler, Varun Thacker)
|
||||
|
||||
* SOLR-9381: Snitch for freedisk uses '/' instead of 'coreRootDirectory' (Tim Owen, noble)
|
||||
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -100,21 +100,21 @@ public class ImplicitSnitch extends Snitch implements CoreAdminHandler.Invocable
|
|||
}
|
||||
}
|
||||
|
||||
static long getUsableSpaceInGB() throws IOException {
|
||||
long space = Files.getFileStore(Paths.get("/")).getUsableSpace();
|
||||
static long getUsableSpaceInGB(Path path) throws IOException {
|
||||
long space = Files.getFileStore(path).getUsableSpace();
|
||||
long spaceInGB = space / 1024 / 1024 / 1024;
|
||||
return spaceInGB;
|
||||
}
|
||||
|
||||
public Map<String, Object> invoke(SolrQueryRequest req) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
CoreContainer cc = (CoreContainer) req.getContext().get(CoreContainer.class.getName());
|
||||
if (req.getParams().getInt(CORES, -1) == 1) {
|
||||
CoreContainer cc = (CoreContainer) req.getContext().get(CoreContainer.class.getName());
|
||||
result.put(CORES, cc.getCoreNames().size());
|
||||
}
|
||||
if (req.getParams().getInt(DISK, -1) == 1) {
|
||||
try {
|
||||
final long spaceInGB = getUsableSpaceInGB();
|
||||
final long spaceInGB = getUsableSpaceInGB(cc.getCoreRootDirectory());
|
||||
result.put(DISK, spaceInGB);
|
||||
} catch (IOException e) {
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.cloud.rule;
|
|||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
@ -52,7 +53,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
|
|||
@ShardsFixed(num = 5)
|
||||
public void doIntegrationTest() throws Exception {
|
||||
final long minGB = (random().nextBoolean() ? 1 : 0);
|
||||
assumeTrue("doIntegrationTest needs minGB="+minGB+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB);
|
||||
assumeTrue("doIntegrationTest needs minGB="+minGB+" usable disk space", ImplicitSnitch.getUsableSpaceInGB(Paths.get("/")) > minGB);
|
||||
String rulesColl = "rulesColl";
|
||||
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
|
||||
CollectionAdminResponse rsp;
|
||||
|
@ -208,8 +209,8 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
|
|||
public void testModifyColl() throws Exception {
|
||||
final long minGB1 = (random().nextBoolean() ? 1 : 0);
|
||||
final long minGB2 = 5;
|
||||
assumeTrue("testModifyColl needs minGB1="+minGB1+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB1);
|
||||
assumeTrue("testModifyColl needs minGB2="+minGB2+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB2);
|
||||
assumeTrue("testModifyColl needs minGB1="+minGB1+" usable disk space", ImplicitSnitch.getUsableSpaceInGB(Paths.get("/")) > minGB1);
|
||||
assumeTrue("testModifyColl needs minGB2="+minGB2+" usable disk space", ImplicitSnitch.getUsableSpaceInGB(Paths.get("/")) > minGB2);
|
||||
String rulesColl = "modifyColl";
|
||||
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
|
||||
CollectionAdminResponse rsp;
|
||||
|
|
Loading…
Reference in New Issue