зеркало из https://github.com/Azure/YCSB.git
[elasticsearch] require path.home in embedded mode
Today when running the Elasticsearch binding in embedded mode, a temporary directory is used. This can be confusing for running usual load-then-run style workflows because the temporary directory will not be the same between runs. Instead, we should just require a directory when running in embedded mode and this commit makes this the case.
This commit is contained in:
Родитель
9871296717
Коммит
f8072b92a0
|
@ -82,20 +82,29 @@ public class ElasticsearchClient extends DB {
|
|||
*/
|
||||
@Override
|
||||
public void init() throws DBException {
|
||||
Properties props = getProperties();
|
||||
final Properties props = getProperties();
|
||||
|
||||
// Check if transport client needs to be used (To connect to multiple
|
||||
// elasticsearch nodes)
|
||||
remoteMode = Boolean.parseBoolean(props.getProperty("es.remote", "false"));
|
||||
|
||||
final String pathHome = props.getProperty("path.home");
|
||||
|
||||
// when running in embedded mode, require path.home
|
||||
if (!remoteMode && (pathHome == null || pathHome.isEmpty())) {
|
||||
throw new IllegalArgumentException("path.home must be specified when running in embedded mode");
|
||||
}
|
||||
|
||||
this.indexKey = props.getProperty("es.index.key", DEFAULT_INDEX_KEY);
|
||||
|
||||
int numberOfShards = parseIntegerProperty(props, "es.number_of_shards", NUMBER_OF_SHARDS);
|
||||
int numberOfReplicas = parseIntegerProperty(props, "es.number_of_replicas", NUMBER_OF_REPLICAS);
|
||||
|
||||
// Check if transport client needs to be used (To connect to multiple
|
||||
// elasticsearch nodes)
|
||||
remoteMode = Boolean.parseBoolean(props.getProperty("es.remote", "false"));
|
||||
Boolean newdb = Boolean.parseBoolean(props.getProperty("es.newdb", "false"));
|
||||
Builder settings = Settings.settingsBuilder()
|
||||
.put("cluster.name", DEFAULT_CLUSTER_NAME)
|
||||
.put("node.local", Boolean.toString(!remoteMode))
|
||||
.put("path.home", System.getProperty("java.io.tmpdir"));
|
||||
.put("path.home", pathHome);
|
||||
|
||||
// if properties file contains elasticsearch user defined properties
|
||||
// add it to the settings file (will overwrite the defaults).
|
||||
|
|
|
@ -29,9 +29,13 @@ import org.junit.After;
|
|||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
|
@ -39,6 +43,7 @@ import static org.junit.Assert.assertEquals;
|
|||
|
||||
public class ElasticsearchClientTest {
|
||||
|
||||
@ClassRule public final static TemporaryFolder temp = new TemporaryFolder();
|
||||
protected final static ElasticsearchClient instance = new ElasticsearchClient();
|
||||
protected final static HashMap<String, ByteIterator> MOCK_DATA;
|
||||
protected final static String MOCK_TABLE = "MOCK_TABLE";
|
||||
|
@ -55,6 +60,9 @@ public class ElasticsearchClientTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws DBException {
|
||||
final Properties props = new Properties();
|
||||
props.put("path.home", temp.getRoot().toString());
|
||||
instance.setProperties(props);
|
||||
instance.init();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче