Adjust configs
This commit is contained in:
15
README.md
15
README.md
@@ -115,3 +115,18 @@ The server may be configured with subscription support by enabling properties in
|
||||
* `subscription.email.enabled` - Enables email subscriptions. Note that you must also provide the connection details for a usable SMTP server.
|
||||
|
||||
* `subscription.websocket.enabled` - Enables websocket subscriptions. With this enabled, your server will accept incoming websocket connections on the following URL (this example uses the default context path and port, you may need to tweak depending on your deployment environment): [ws://localhost:8080/hapi-fhir-jpaserver/websocket](ws://localhost:8080/hapi-fhir-jpaserver/websocket)
|
||||
|
||||
# Using ElasticSearch
|
||||
|
||||
By default, the server will use embedded lucene indexes for terminology and fulltext indexing purposes. You can switch this to using lucene by editing the properties in [hapi.properties](https://github.com/hapifhir/hapi-fhir-jpaserver-starter/blob/master/src/main/resources/hapi.properties)
|
||||
|
||||
For example:
|
||||
|
||||
```properties
|
||||
elasticsearch.enabled=true
|
||||
elasticsearch.rest_url=http://localhost:9200
|
||||
elasticsearch.username=SomeUsername
|
||||
elasticsearch.password=SomePassword
|
||||
elasticsearch.required_index_status=YELLOW
|
||||
elasticsearch.schema_management_strategy=CREATE
|
||||
```
|
||||
3
pom.xml
3
pom.xml
@@ -11,10 +11,9 @@
|
||||
<parent>
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||
<artifactId>hapi-fhir-jpaserver-starter</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FhirServerConfigDstu2 extends BaseJavaConfigDstu2 {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
retVal.setJpaProperties(HapiProperties.getJpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
retVal.setJpaProperties(HapiProperties.getJpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
retVal.setJpaProperties(HapiProperties.getJpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
|
||||
import ca.uhn.fhir.jpa.config.BaseJavaConfigR5;
|
||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -44,7 +43,7 @@ public class FhirServerConfigR5 extends BaseJavaConfigR5 {
|
||||
throw new ConfigurationException("Could not set the data source due to a configuration issue", e);
|
||||
}
|
||||
|
||||
retVal.setJpaProperties(HapiProperties.getProperties());
|
||||
retVal.setJpaProperties(HapiProperties.getJpaProperties());
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,13 @@ package ca.uhn.fhir.jpa.starter;
|
||||
|
||||
import ca.uhn.fhir.context.ConfigurationException;
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.jpa.search.elastic.ElasticsearchHibernatePropertiesBuilder;
|
||||
import ca.uhn.fhir.rest.api.EncodingEnum;
|
||||
import ca.uhn.fhir.rest.server.ETagSupportEnum;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.hibernate.search.elasticsearch.cfg.ElasticsearchIndexStatus;
|
||||
import org.hibernate.search.elasticsearch.cfg.IndexSchemaManagementStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
@@ -57,13 +61,17 @@ public class HapiProperties {
|
||||
private static final String VALIDATE_RESPONSES_ENABLED = "validation.responses.enabled";
|
||||
private static final String FILTER_SEARCH_ENABLED = "filter_search.enabled";
|
||||
private static final String GRAPHQL_ENABLED = "graphql.enabled";
|
||||
private static Properties properties;
|
||||
private static Properties ourProperties;
|
||||
|
||||
public static boolean isElasticSearchEnabled() {
|
||||
return HapiProperties.getPropertyBoolean("elasticsearch.enabled", false);
|
||||
}
|
||||
|
||||
/*
|
||||
* Force the configuration to be reloaded
|
||||
*/
|
||||
public static void forceReload() {
|
||||
properties = null;
|
||||
ourProperties = null;
|
||||
getProperties();
|
||||
}
|
||||
|
||||
@@ -76,12 +84,40 @@ public class HapiProperties {
|
||||
getProperties().setProperty(theKey, theValue);
|
||||
}
|
||||
|
||||
public static Properties getProperties() {
|
||||
if (properties == null) {
|
||||
public static Properties getJpaProperties() {
|
||||
Properties retVal = loadProperties();
|
||||
|
||||
if (isElasticSearchEnabled()) {
|
||||
ElasticsearchHibernatePropertiesBuilder builder = new ElasticsearchHibernatePropertiesBuilder();
|
||||
builder.setRequiredIndexStatus(getPropertyEnum("elasticsearch.required_index_status", ElasticsearchIndexStatus.class, ElasticsearchIndexStatus.YELLOW));
|
||||
builder.setRestUrl(getProperty("elasticsearch.rest_url"));
|
||||
builder.setUsername(getProperty("elasticsearch.username"));
|
||||
builder.setPassword(getProperty("elasticsearch.password"));
|
||||
builder.setIndexSchemaManagementStrategy(getPropertyEnum("elasticsearch.schema_management_strateg", IndexSchemaManagementStrategy.class, IndexSchemaManagementStrategy.CREATE));
|
||||
builder.setDebugRefreshAfterWrite(getPropertyBoolean("elasticsearch.debug.refresh_after_write", false));
|
||||
builder.setDebugPrettyPrintJsonLog(getPropertyBoolean("elasticsearch.debug.pretty_print_json_log", false));
|
||||
builder.apply(retVal);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private static Properties getProperties() {
|
||||
if (ourProperties == null) {
|
||||
Properties properties = loadProperties();
|
||||
HapiProperties.ourProperties = properties;
|
||||
}
|
||||
|
||||
return ourProperties;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Properties loadProperties() {
|
||||
// Load the configurable properties file
|
||||
Properties properties;
|
||||
try (InputStream in = HapiProperties.class.getClassLoader().getResourceAsStream(HAPI_PROPERTIES)) {
|
||||
HapiProperties.properties = new Properties();
|
||||
HapiProperties.properties.load(in);
|
||||
properties = new Properties();
|
||||
properties.load(in);
|
||||
} catch (Exception e) {
|
||||
throw new ConfigurationException("Could not load HAPI properties", e);
|
||||
}
|
||||
@@ -90,8 +126,6 @@ public class HapiProperties {
|
||||
if (overrideProps != null) {
|
||||
properties.putAll(overrideProps);
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
@@ -375,5 +409,15 @@ public class HapiProperties {
|
||||
return HapiProperties.getBooleanProperty(GRAPHQL_ENABLED, true);
|
||||
}
|
||||
|
||||
private static boolean getPropertyBoolean(String thePropertyName, boolean theDefaultValue) {
|
||||
String value = getProperty(thePropertyName, Boolean.toString(theDefaultValue));
|
||||
return Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
private static <T extends Enum> T getPropertyEnum(String thePropertyName, Class<T> theEnumType, T theDefaultValue) {
|
||||
String value = getProperty(thePropertyName, theDefaultValue.name());
|
||||
return (T) Enum.valueOf(theEnumType, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,24 @@ hibernate.search.default.indexBase=target/lucenefiles
|
||||
hibernate.search.lucene_version=LUCENE_CURRENT
|
||||
tester.config.refuse_to_fetch_third_party_urls=false
|
||||
|
||||
##################################################
|
||||
# ElasticSearch
|
||||
# Note that using ElasticSearch is disabled by
|
||||
# default and the server will use Lucene instead.
|
||||
##################################################
|
||||
elasticsearch.enabled=false
|
||||
elasticsearch.rest_url=http://localhost:9200
|
||||
elasticsearch.username=SomeUsername
|
||||
elasticsearch.password=SomePassword
|
||||
elasticsearch.rest_url=http://localhost:9200
|
||||
elasticsearch.required_index_status=YELLOW
|
||||
elasticsearch.schema_management_strategy=CREATE
|
||||
# Immediately refresh indexes after every write. This is very bad for
|
||||
# performance, but can be helpful for testing.
|
||||
elasticsearch.debug.refresh_after_write=false
|
||||
elasticsearch.debug.pretty_print_json_log=false
|
||||
|
||||
|
||||
##################################################
|
||||
# Binary Storage Operations
|
||||
##################################################
|
||||
|
||||
Reference in New Issue
Block a user