Remove "additional config" from hdfs repositories

This commit is contained in:
Ryan Ernst 2015-12-21 15:55:13 -08:00
parent 2cbfc54a81
commit 26eaa16a89
4 changed files with 3 additions and 77 deletions

View File

@ -52,8 +52,6 @@ import org.elasticsearch.repositories.blobstore.BlobStoreRepository;
public final class HdfsRepository extends BlobStoreRepository implements FileContextFactory {
public final static String TYPE = "hdfs";
private final BlobPath basePath;
private final ByteSizeValue chunkSize;
private final boolean compress;
@ -77,7 +75,7 @@ public final class HdfsRepository extends BlobStoreRepository implements FileCon
this.chunkSize = repositorySettings.settings().getAsBytesSize("chunk_size", settings.getAsBytesSize("chunk_size", null));
this.compress = repositorySettings.settings().getAsBoolean("compress", settings.getAsBoolean("compress", false));
}
@Override
protected void doStart() {
if (!Strings.hasText(uri)) {
@ -183,13 +181,6 @@ public final class HdfsRepository extends BlobStoreRepository implements FileCon
cfg.setClassLoader(this.getClass().getClassLoader());
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();
for (Entry<String, String> entry : map.entrySet()) {
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
protected BlobStore blobStore() {
return blobStore;

View File

@ -54,7 +54,6 @@ public class HdfsTests extends ESIntegTestCase {
.put("uri", "hdfs:///")
.put("conf.fs.AbstractFileSystem.hdfs.impl", TestingFs.class.getName())
.put("path", "foo")
.put("conf", "additional-cfg.xml, conf-2.xml")
.put("chunk_size", randomIntBetween(100, 1000) + "k")
.put("compress", randomBoolean())
).get();
@ -143,7 +142,7 @@ public class HdfsTests extends ESIntegTestCase {
// expected
}
}
public void testNonHdfsUri() {
Client client = client();
try {
@ -191,4 +190,4 @@ public class HdfsTests extends ESIntegTestCase {
private long count(Client client, String index) {
return client.prepareSearch(index).setSize(0).get().getHits().totalHits();
}
}
}

View File

@ -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>

View File

@ -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>