use of org.apache.gora.elasticsearch.utils.ElasticsearchParameters in project gora by apache.
the class ElasticsearchStore method initialize.
@Override
public void initialize(Class<K> keyClass, Class<T> persistentClass, Properties properties) throws GoraException {
try {
LOG.debug("Initializing Elasticsearch store");
ElasticsearchParameters parameters = ElasticsearchParameters.load(properties, getConf());
super.initialize(keyClass, persistentClass, properties);
ElasticsearchMappingBuilder<K, T> builder = new ElasticsearchMappingBuilder<>(this);
InputStream mappingStream;
if (properties.containsKey(XML_MAPPING_DEFINITION)) {
if (LOG.isTraceEnabled()) {
LOG.trace("{} = {}", XML_MAPPING_DEFINITION, properties.getProperty(XML_MAPPING_DEFINITION));
}
mappingStream = org.apache.commons.io.IOUtils.toInputStream(properties.getProperty(XML_MAPPING_DEFINITION), (Charset) null);
} else {
mappingStream = getClass().getClassLoader().getResourceAsStream(properties.getProperty(PARSE_MAPPING_FILE_KEY, DEFAULT_MAPPING_FILE));
}
String xsdValidation = properties.getProperty(XSD_VALIDATION, "false");
builder.readMappingFile(mappingStream, Boolean.parseBoolean(xsdValidation));
elasticsearchMapping = builder.getElasticsearchMapping();
client = createClient(parameters);
LOG.info("Elasticsearch store was successfully initialized.");
} catch (Exception ex) {
LOG.error("Error while initializing Elasticsearch store", ex);
throw new GoraException(ex);
}
}
use of org.apache.gora.elasticsearch.utils.ElasticsearchParameters in project gora by apache.
the class TestElasticsearchStore method testLoadElasticsearchParameters.
@Test
public void testLoadElasticsearchParameters() throws IOException {
log.info("test method: testLoadElasticsearchParameters");
Properties properties = DataStoreFactory.createProps();
ElasticsearchParameters parameters = ElasticsearchParameters.load(properties, testDriver.getConfiguration());
Assert.assertEquals("localhost", parameters.getHost());
Assert.assertEquals(AuthenticationType.BASIC, parameters.getAuthenticationType());
Assert.assertEquals("elastic", parameters.getUsername());
Assert.assertEquals("password", parameters.getPassword());
}
use of org.apache.gora.elasticsearch.utils.ElasticsearchParameters in project gora by apache.
the class ElasticsearchStoreMetadataAnalyzer method initialize.
@Override
public void initialize() throws GoraException {
ElasticsearchParameters parameters = ElasticsearchParameters.load(properties, getConf());
elasticsearchClient = ElasticsearchStore.createClient(parameters);
}
Aggregations