Skip to content

Commit

Permalink
HC-487: Test out and deploy locally a Elasticsearch service in cluste…
Browse files Browse the repository at this point in the history
…red mode (multi-node) (#63)

* HC-487: Add support for ES cluster mode

* HC-487: Add support for ES cluster mode

* Fix typo

Co-authored-by: Michael Cayanan <42812746+mcayanan@users.noreply.github.com>

* HC-487: Bump version

---------

Co-authored-by: Michael Cayanan <42812746+mcayanan@users.noreply.github.com>
  • Loading branch information
drewm-swe and mcayanan authored Sep 11, 2023
1 parent 10dd330 commit ddb5bff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
7 changes: 3 additions & 4 deletions grq2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
class ReverseProxied(object):
"""
Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
In nginx:
Expand Down Expand Up @@ -93,8 +93,7 @@ def resource_not_found(e):
grq_es = get_grq_es()

# initializing connection to Mozart's Elasticsearch
MOZART_ES_URL = app.config['MOZART_ES_URL']
mozart_es = get_mozart_es(MOZART_ES_URL)
mozart_es = get_mozart_es()

# services blueprints
from grq2.services.main import mod as main_module
Expand Down
17 changes: 14 additions & 3 deletions grq2/es_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
GRQ_ES = None


def get_mozart_es(es_url, logger=None):
def get_mozart_es(logger=None):
global MOZART_ES
es_cluster_mode = app.conf['ES_CLUSTER_MODE']

if MOZART_ES is None:
MOZART_ES = ElasticsearchUtility(es_url, logger)
if es_cluster_mode:
hosts = [app.conf.JOBS_ES_URL, app.conf.GRQ_ES_URL, app.conf.METRICS_ES_URL]
else:
hosts = [app.conf.JOBS_ES_URL]
MOZART_ES = ElasticsearchUtility(hosts, logger)
return MOZART_ES


Expand All @@ -28,6 +34,7 @@ def get_grq_es(logger=None):
es_host = app.conf['GRQ_ES_HOST']
es_url = app.conf['GRQ_ES_URL']
region = app.conf['AWS_REGION']
es_cluster_mode = app.conf['ES_CLUSTER_MODE']

if aws_es is True:
aws_auth = BotoAWSRequestsAuth(aws_host=es_host, aws_region=region, aws_service='es')
Expand All @@ -44,5 +51,9 @@ def get_grq_es(logger=None):
retry_on_timeout=True,
)
else:
GRQ_ES = ElasticsearchUtility(es_url, logger)
if es_cluster_mode:
hosts = [app.conf.JOBS_ES_URL, app.conf.GRQ_ES_URL, app.conf.METRICS_ES_URL]
else:
hosts = [es_url]
GRQ_ES = ElasticsearchUtility(hosts, logger)
return GRQ_ES
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='grq2',
version='2.0.24',
version='2.0.25',
long_description='GeoRegionQuery REST API using ElasticSearch backend',
packages=find_packages(),
include_package_data=True,
Expand Down

0 comments on commit ddb5bff

Please sign in to comment.