first strike against crazy CWD usages
This commit is contained in:
parent
d164526d27
commit
a7d16a1dd1
|
@ -175,26 +175,13 @@ public class Environment {
|
|||
}
|
||||
|
||||
public URL resolveConfig(String path) throws FailedToResolveConfigException {
|
||||
String origPath = path;
|
||||
// first, try it as a path on the file system
|
||||
Path f1 = PathUtils.get(path);
|
||||
if (Files.exists(f1)) {
|
||||
// first, try it as a path in the config directory
|
||||
Path f = configFile.resolve(path);
|
||||
if (Files.exists(f)) {
|
||||
try {
|
||||
return f1.toUri().toURL();
|
||||
return f.toUri().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new FailedToResolveConfigException("Failed to resolve path [" + f1 + "]", e);
|
||||
}
|
||||
}
|
||||
if (path.startsWith("/")) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
// next, try it relative to the config location
|
||||
Path f2 = configFile.resolve(path);
|
||||
if (Files.exists(f2)) {
|
||||
try {
|
||||
return f2.toUri().toURL();
|
||||
} catch (MalformedURLException e) {
|
||||
throw new FailedToResolveConfigException("Failed to resolve path [" + f1 + "]", e);
|
||||
throw new FailedToResolveConfigException("Failed to resolve path [" + f + "]", e);
|
||||
}
|
||||
}
|
||||
// try and load it from the classpath directly
|
||||
|
@ -209,6 +196,6 @@ public class Environment {
|
|||
return resource;
|
||||
}
|
||||
}
|
||||
throw new FailedToResolveConfigException("Failed to resolve config path [" + origPath + "], tried file path [" + f1 + "], path file [" + f2 + "], and classpath");
|
||||
throw new FailedToResolveConfigException("Failed to resolve config path [" + path + "], tried config path [" + f + "] and classpath");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class HunspellService extends AbstractComponent {
|
|||
|
||||
public final static String HUNSPELL_LAZY_LOAD = "indices.analysis.hunspell.dictionary.lazy";
|
||||
public final static String HUNSPELL_IGNORE_CASE = "indices.analysis.hunspell.dictionary.ignore_case";
|
||||
public final static String HUNSPELL_LOCATION = "indices.analysis.hunspell.dictionary.location";
|
||||
private final static String OLD_HUNSPELL_LOCATION = "indices.analysis.hunspell.dictionary.location";
|
||||
private final LoadingCache<String, Dictionary> dictionaries;
|
||||
private final Map<String, Dictionary> knownDictionaries;
|
||||
|
||||
|
@ -116,9 +116,9 @@ public class HunspellService extends AbstractComponent {
|
|||
}
|
||||
|
||||
private Path resolveHunspellDirectory(Settings settings, Environment env) {
|
||||
String location = settings.get(HUNSPELL_LOCATION, null);
|
||||
String location = settings.get(OLD_HUNSPELL_LOCATION, null);
|
||||
if (location != null) {
|
||||
return PathUtils.get(location);
|
||||
throw new IllegalArgumentException("please, put your hunspell dictionaries under config/hunspell !");
|
||||
}
|
||||
return env.configFile().resolve("hunspell");
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ grant {
|
|||
permission java.io.FilePermission "${java.io.tmpdir}${/}-", "read,write,delete";
|
||||
|
||||
// paths used for running tests
|
||||
// project base directory
|
||||
permission java.io.FilePermission "${project.basedir}${/}target${/}-", "read";
|
||||
// compiled classes
|
||||
permission java.io.FilePermission "${project.basedir}${/}target${/}classes${/}-", "read";
|
||||
permission java.io.FilePermission "${project.basedir}${/}target${/}test-classes${/}-", "read";
|
||||
// read permission for lib sigar
|
||||
permission java.io.FilePermission "${project.basedir}${/}lib/sigar{/}-", "read";
|
||||
// mvn custom ./m2/repository for dependency jars
|
||||
|
|
|
@ -79,17 +79,6 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest {
|
|||
assertIgnoreCase(true, dictionary);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomizeLocaleDirectory() throws Exception {
|
||||
Settings settings = ImmutableSettings.settingsBuilder()
|
||||
.put(HUNSPELL_LOCATION, getDataPath("/indices/analyze/conf_dir/hunspell"))
|
||||
.build();
|
||||
|
||||
internalCluster().startNode(settings);
|
||||
Dictionary dictionary = internalCluster().getInstance(HunspellService.class).getDictionary("en_US");
|
||||
assertThat(dictionary, notNullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDicWithNoAff() throws Exception {
|
||||
Settings settings = ImmutableSettings.settingsBuilder()
|
||||
|
|
|
@ -805,7 +805,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
/* no sniff client for now - doesn't work will all tests since it might throw NoNodeAvailableException if nodes are shut down.
|
||||
* we first need support of transportClientRatio as annotations or so
|
||||
*/
|
||||
return transportClient = TransportClientFactory.noSniff(settingsSource.transportClient()).client(node, clusterName);
|
||||
return transportClient = new TransportClientFactory(false, settingsSource.transportClient(), baseDir).client(node, clusterName);
|
||||
}
|
||||
|
||||
void resetClient() throws IOException {
|
||||
|
@ -859,29 +859,14 @@ public final class InternalTestCluster extends TestCluster {
|
|||
|
||||
public static final String TRANSPORT_CLIENT_PREFIX = "transport_client_";
|
||||
static class TransportClientFactory {
|
||||
private static TransportClientFactory NO_SNIFF_CLIENT_FACTORY = new TransportClientFactory(false, ImmutableSettings.EMPTY);
|
||||
private static TransportClientFactory SNIFF_CLIENT_FACTORY = new TransportClientFactory(true, ImmutableSettings.EMPTY);
|
||||
|
||||
private final boolean sniff;
|
||||
private final Settings settings;
|
||||
private final Path baseDir;
|
||||
|
||||
public static TransportClientFactory noSniff(Settings settings) {
|
||||
if (settings == null || settings.names().isEmpty()) {
|
||||
return NO_SNIFF_CLIENT_FACTORY;
|
||||
}
|
||||
return new TransportClientFactory(false, settings);
|
||||
}
|
||||
|
||||
public static TransportClientFactory sniff(Settings settings) {
|
||||
if (settings == null || settings.names().isEmpty()) {
|
||||
return SNIFF_CLIENT_FACTORY;
|
||||
}
|
||||
return new TransportClientFactory(true, settings);
|
||||
}
|
||||
|
||||
TransportClientFactory(boolean sniff, Settings settings) {
|
||||
TransportClientFactory(boolean sniff, Settings settings, Path baseDir) {
|
||||
this.sniff = sniff;
|
||||
this.settings = settings != null ? settings : ImmutableSettings.EMPTY;
|
||||
this.baseDir = baseDir;
|
||||
}
|
||||
|
||||
public Client client(Node node, String clusterName) {
|
||||
|
@ -889,6 +874,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
Settings nodeSettings = node.settings();
|
||||
Builder builder = settingsBuilder()
|
||||
.put("client.transport.nodes_sampler_interval", "1s")
|
||||
.put("path.home", baseDir)
|
||||
.put("name", TRANSPORT_CLIENT_PREFIX + node.settings().get("name"))
|
||||
.put("plugins." + PluginsService.LOAD_PLUGIN_FROM_CLASSPATH, false)
|
||||
.put(ClusterName.SETTING, clusterName).put("client.transport.sniff", sniff)
|
||||
|
|
Loading…
Reference in New Issue