diff --git a/src/main/assemblies/files/fess.in.sh b/src/main/assemblies/files/fess.in.sh index b01831fc5..7ef69832e 100755 --- a/src/main/assemblies/files/fess.in.sh +++ b/src/main/assemblies/files/fess.in.sh @@ -71,7 +71,7 @@ JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" APP_NAME=fess ES_HOME=$FESS_HOME/es FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.home=$FESS_HOME" -FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.context.path=/$APP_NAME" +FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.context.path=/" FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.port=8080" FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.webapp.path=$FESS_HOME/app" FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.temp.path=$FESS_HOME/temp" diff --git a/src/main/java/org/codelibs/fess/FessBoot.java b/src/main/java/org/codelibs/fess/FessBoot.java index 69960f735..1dd0f4ee2 100644 --- a/src/main/java/org/codelibs/fess/FessBoot.java +++ b/src/main/java/org/codelibs/fess/FessBoot.java @@ -97,7 +97,7 @@ public class FessBoot extends TomcatBoot { if (value != null) { return value; } - return "/fess"; + return "/"; } protected static String getTomcatConfigPath() { diff --git a/src/main/java/org/codelibs/fess/api/es/EsApiManager.java b/src/main/java/org/codelibs/fess/api/es/EsApiManager.java index ea07e4029..cccbee39b 100644 --- a/src/main/java/org/codelibs/fess/api/es/EsApiManager.java +++ b/src/main/java/org/codelibs/fess/api/es/EsApiManager.java @@ -95,7 +95,7 @@ public class EsApiManager extends BaseApiManager { protected void processRequest(final HttpServletRequest request, final HttpServletResponse response, final String path) { final FessConfig fessConfig = ComponentUtil.getFessConfig(); final Method httpMethod = Method.valueOf(request.getMethod().toUpperCase(Locale.ROOT)); - final CurlRequest curlRequest = new CurlRequest(httpMethod, fessConfig.getElasticsearchUrl() + path); + final CurlRequest curlRequest = new CurlRequest(httpMethod, fessConfig.getElasticsearchHttpUrl() + path); request.getParameterMap().entrySet().stream().forEach(entry -> { if (entry.getValue().length > 1) { curlRequest.param(entry.getKey(), String.join(",", entry.getValue())); diff --git a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java index d724b9c18..78b020491 100644 --- a/src/main/java/org/codelibs/fess/dict/DictionaryManager.java +++ b/src/main/java/org/codelibs/fess/dict/DictionaryManager.java @@ -56,7 +56,7 @@ public class DictionaryManager { public DictionaryFile[] getDictionaryFiles() { final FessConfig fessConfig = ComponentUtil.getFessConfig(); try (CurlResponse response = - Curl.get(fessConfig.getElasticsearchUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) { + Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("fields", "path,@timestamp").execute()) { final Map contentMap = response.getContentAsMap(); @SuppressWarnings("unchecked") final List> fileList = (List>) contentMap.get("file"); @@ -102,7 +102,7 @@ public class DictionaryManager { // TODO use stream try (CurlResponse response = - Curl.post(fessConfig.getElasticsearchUrl() + "/_configsync/file").param("path", dictFile.getPath()) + Curl.post(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()) .body(FileUtil.readUTF8(file)).execute()) { final Map contentMap = response.getContentAsMap(); if (!Constants.TRUE.equalsIgnoreCase(contentMap.get("acknowledged").toString())) { @@ -120,7 +120,7 @@ public class DictionaryManager { public InputStream getContentInputStream(final DictionaryFile dictFile) { final FessConfig fessConfig = ComponentUtil.getFessConfig(); try { - return Curl.get(fessConfig.getElasticsearchUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute() + return Curl.get(fessConfig.getElasticsearchHttpUrl() + "/_configsync/file").param("path", dictFile.getPath()).execute() .getContentAsStream(); } catch (final IOException e) { throw new DictionaryException("Failed to access " + dictFile.getPath(), e); diff --git a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java index 3306da53f..2a1da869c 100644 --- a/src/main/java/org/codelibs/fess/es/client/FessEsClient.java +++ b/src/main/java/org/codelibs/fess/es/client/FessEsClient.java @@ -176,8 +176,6 @@ public class FessEsClient implements Client { protected Client client; - protected String clusterName = "fess"; - protected Map settings; protected String indexConfigPath = "fess_indices"; @@ -207,14 +205,6 @@ public class FessEsClient implements Client { this.settings = settings; } - public String getClusterName() { - return clusterName; - } - - public void setClusterName(final String clusterName) { - this.clusterName = clusterName; - } - public String getStatus() { return admin().cluster().prepareHealth().execute().actionGet().getStatus().name(); } @@ -233,10 +223,8 @@ public class FessEsClient implements Client { @PostConstruct public void open() { - final String clusterNameValue = System.getProperty(Constants.FESS_ES_CLUSTER_NAME); - if (StringUtil.isNotBlank(clusterNameValue)) { - clusterName = clusterNameValue; - } + FessConfig fessConfig = ComponentUtil.getFessConfig(); + final String transportAddressesValue = System.getProperty(Constants.FESS_ES_TRANSPORT_ADDRESSES); if (StringUtil.isNotBlank(transportAddressesValue)) { for (final String transportAddressValue : transportAddressesValue.split(",")) { @@ -257,7 +245,7 @@ public class FessEsClient implements Client { if (transportAddressList.isEmpty()) { if (runner == null) { runner = new ElasticsearchClusterRunner(); - final Configs config = newConfigs().clusterName(clusterName).numOfNode(1).useLogger(); + final Configs config = newConfigs().clusterName(fessConfig.getElasticsearchClusterName()).numOfNode(1).useLogger(); final String esDir = System.getProperty("fess.es.dir"); if (esDir != null) { config.basePath(esDir); @@ -279,7 +267,7 @@ public class FessEsClient implements Client { addTransportAddress("localhost", runner.node().settings().getAsInt("transport.tcp.port", 9300)); } else { final Builder settingsBuilder = Settings.settingsBuilder(); - settingsBuilder.put("cluster.name", clusterName); + settingsBuilder.put("cluster.name", fessConfig.getElasticsearchClusterName()); final Settings settings = settingsBuilder.build(); final TransportClient transportClient = TransportClient.builder().settings(settings).build(); for (final TransportAddress address : transportAddressList) { @@ -288,10 +276,6 @@ public class FessEsClient implements Client { client = transportClient; } - if (StringUtil.isBlank(clusterNameValue)) { - System.setProperty(Constants.FESS_ES_CLUSTER_NAME, clusterName); - } - if (StringUtil.isBlank(transportAddressesValue)) { final StringBuilder buf = new StringBuilder(); for (final TransportAddress transportAddress : transportAddressList) { diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 2a8fb5f65..7423258e8 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -25,8 +25,11 @@ public interface FessConfig extends FessEnv { /** The key of the configuration. e.g. Fess */ String DOMAIN_TITLE = "domain.title"; + /** The key of the configuration. e.g. elasticsearch */ + String ELASTICSEARCH_CLUSTER_NAME = "elasticsearch.cluster.name"; + /** The key of the configuration. e.g. http://localhost:9201 */ - String ELASTICSEARCH_URL = "elasticsearch.url"; + String ELASTICSEARCH_HTTP_URL = "elasticsearch.http.url"; /** The key of the configuration. e.g. false */ String CRAWLER_DOCUMENT_CACHE_ENABLE = "crawler.document.cache.enable"; @@ -311,12 +314,19 @@ public interface FessConfig extends FessEnv { String getDomainTitle(); /** - * Get the value for the key 'elasticsearch.url'.
- * The value is, e.g. http://localhost:9201
+ * Get the value for the key 'elasticsearch.cluster.name'.
+ * The value is, e.g. elasticsearch
* comment: elasticsearch * @return The value of found property. (NotNull: if not found, exception but basically no way) */ - String getElasticsearchUrl(); + String getElasticsearchClusterName(); + + /** + * Get the value for the key 'elasticsearch.http.url'.
+ * The value is, e.g. http://localhost:9201
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getElasticsearchHttpUrl(); /** * Get the value for the key 'crawler.document.cache.enable'.
@@ -1109,8 +1119,12 @@ public interface FessConfig extends FessEnv { return get(FessConfig.DOMAIN_TITLE); } - public String getElasticsearchUrl() { - return get(FessConfig.ELASTICSEARCH_URL); + public String getElasticsearchClusterName() { + return get(FessConfig.ELASTICSEARCH_CLUSTER_NAME); + } + + public String getElasticsearchHttpUrl() { + return get(FessConfig.ELASTICSEARCH_HTTP_URL); } public String getCrawlerDocumentCacheEnable() { diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index dc45aa970..8bd34a5d9 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -9,7 +9,8 @@ domain.title = Fess # elasticsearch -elasticsearch.url=http://localhost:9201 +elasticsearch.cluster.name=elasticsearch +elasticsearch.http.url=http://localhost:9201 # ======================================================================================== # Index