Remove "additional config" from hdfs repositories
This commit is contained in:
parent
2cbfc54a81
commit
26eaa16a89
|
@ -52,8 +52,6 @@ import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
|
||||||
|
|
||||||
public final class HdfsRepository extends BlobStoreRepository implements FileContextFactory {
|
public final class HdfsRepository extends BlobStoreRepository implements FileContextFactory {
|
||||||
|
|
||||||
public final static String TYPE = "hdfs";
|
|
||||||
|
|
||||||
private final BlobPath basePath;
|
private final BlobPath basePath;
|
||||||
private final ByteSizeValue chunkSize;
|
private final ByteSizeValue chunkSize;
|
||||||
private final boolean compress;
|
private final boolean compress;
|
||||||
|
@ -183,13 +181,6 @@ public final class HdfsRepository extends BlobStoreRepository implements FileCon
|
||||||
cfg.setClassLoader(this.getClass().getClassLoader());
|
cfg.setClassLoader(this.getClass().getClassLoader());
|
||||||
cfg.reloadConfiguration();
|
cfg.reloadConfiguration();
|
||||||
|
|
||||||
String confLocation = repositorySettings.settings().get("conf_location", settings.get("conf_location"));
|
|
||||||
if (Strings.hasText(confLocation)) {
|
|
||||||
for (String entry : Strings.commaDelimitedListToStringArray(confLocation)) {
|
|
||||||
addConfigLocation(cfg, entry.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> map = repositorySettings.settings().getByPrefix("conf.").getAsMap();
|
Map<String, String> map = repositorySettings.settings().getByPrefix("conf.").getAsMap();
|
||||||
for (Entry<String, String> entry : map.entrySet()) {
|
for (Entry<String, String> entry : map.entrySet()) {
|
||||||
cfg.set(entry.getKey(), entry.getValue());
|
cfg.set(entry.getKey(), entry.getValue());
|
||||||
|
@ -214,46 +205,6 @@ public final class HdfsRepository extends BlobStoreRepository implements FileCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressForbidden(reason = "Where is this reading configuration files from? It should use Environment for ES conf dir")
|
|
||||||
private void addConfigLocation(Configuration cfg, String confLocation) {
|
|
||||||
URL cfgURL = null;
|
|
||||||
// it's an URL
|
|
||||||
if (!confLocation.contains(":")) {
|
|
||||||
cfgURL = cfg.getClassLoader().getResource(confLocation);
|
|
||||||
|
|
||||||
// fall back to file
|
|
||||||
if (cfgURL == null) {
|
|
||||||
java.nio.file.Path path = PathUtils.get(confLocation);
|
|
||||||
if (!Files.isReadable(path)) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
String.format(Locale.ROOT,
|
|
||||||
"Cannot find classpath resource or file 'conf_location' [%s] defined for hdfs snapshot/restore",
|
|
||||||
confLocation));
|
|
||||||
}
|
|
||||||
String pathLocation = path.toUri().toString();
|
|
||||||
logger.debug("Adding path [{}] as file [{}]", confLocation, pathLocation);
|
|
||||||
confLocation = pathLocation;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("Resolving path [{}] to classpath [{}]", confLocation, cfgURL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("Adding path [{}] as URL", confLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cfgURL == null) {
|
|
||||||
try {
|
|
||||||
cfgURL = new URL(confLocation);
|
|
||||||
} catch (MalformedURLException ex) {
|
|
||||||
throw new IllegalArgumentException(String.format(Locale.ROOT,
|
|
||||||
"Invalid 'conf_location' URL [%s] defined for hdfs snapshot/restore", confLocation), ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.addResource(cfgURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlobStore blobStore() {
|
protected BlobStore blobStore() {
|
||||||
return blobStore;
|
return blobStore;
|
||||||
|
|
|
@ -54,7 +54,6 @@ public class HdfsTests extends ESIntegTestCase {
|
||||||
.put("uri", "hdfs:///")
|
.put("uri", "hdfs:///")
|
||||||
.put("conf.fs.AbstractFileSystem.hdfs.impl", TestingFs.class.getName())
|
.put("conf.fs.AbstractFileSystem.hdfs.impl", TestingFs.class.getName())
|
||||||
.put("path", "foo")
|
.put("path", "foo")
|
||||||
.put("conf", "additional-cfg.xml, conf-2.xml")
|
|
||||||
.put("chunk_size", randomIntBetween(100, 1000) + "k")
|
.put("chunk_size", randomIntBetween(100, 1000) + "k")
|
||||||
.put("compress", randomBoolean())
|
.put("compress", randomBoolean())
|
||||||
).get();
|
).get();
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
|
||||||
<configuration>
|
|
||||||
<property>
|
|
||||||
<name>foo</name>
|
|
||||||
<value>foo</value>
|
|
||||||
</property>
|
|
||||||
<property>
|
|
||||||
<name>paradise</name>
|
|
||||||
<value>lost</value>
|
|
||||||
</property>
|
|
||||||
</configuration>
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
|
|
||||||
<configuration>
|
|
||||||
<property>
|
|
||||||
<name>foo</name>
|
|
||||||
<value>foo</value>
|
|
||||||
</property>
|
|
||||||
<property>
|
|
||||||
<name>paradise</name>
|
|
||||||
<value>lost</value>
|
|
||||||
</property>
|
|
||||||
</configuration>
|
|
Loading…
Reference in New Issue