-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement an ElasticSearchActivationStore #4724
Merged
style95
merged 20 commits into
apache:master
from
jiangpengcheng:feature/add_elastcisearch
Mar 3, 2020
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9a46d82
Implement an ElasticSearchActivationStore
jiangpengcheng 7206fa5
Remove short headers and mismatched comments
jiangpengcheng 959b822
typo fix
jiangpengcheng 7d3f894
Use TestContainers
jiangpengcheng 782e2c1
Neat changes
jiangpengcheng 36db83f
Merge branch 'master' into feature/add_elastcisearch
jiangpengcheng 0f280fa
Update build.gradle
jiangpengcheng 93a38fb
Fix TestContainers
jiangpengcheng 17d973b
fix mistake
jiangpengcheng 2fb586f
Merge branch 'master' into feature/add_elastcisearch
jiangpengcheng 809514e
Remove cache and add configuration example
jiangpengcheng 1a77e22
Merge remote-tracking branch 'upstream/master' into feature/add_elast…
jiangpengcheng 747e4fd
Fix pureconfig
jiangpengcheng f36b835
Apply review comments
jiangpengcheng 811b602
Add result and annotations to mock WhiskActivations
jiangpengcheng 047e7a3
Add instructions about how to use it
jiangpengcheng 3f38f19
Update ansible/README.md
jiangpengcheng 541fce1
Remove vagrant changes
jiangpengcheng 46957d7
Add elasticsearch to `redo` and remove whitespace
jiangpengcheng 34b7e27
Fix tests
jiangpengcheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--- | ||
# This playbook deploys a ElasticSearch cluster | ||
|
||
- hosts: elasticsearch | ||
vars: | ||
# | ||
# host_group - usually "{{ groups['...'] }}" where '...' is what was used | ||
# for 'hosts' above. The hostname of each host will be looked up in this | ||
# group to assign a zero-based index. That index will be used in concert | ||
# with 'name_prefix' below to assign a host/container name. | ||
host_group: "{{ groups['elasticsearch'] }}" | ||
# | ||
# name_prefix - a unique prefix for this set of elasticsearches. The prefix | ||
# will be used in combination with an index (determined using | ||
# 'host_group' above) to name host/elasticsearcher. | ||
name_prefix: "elasticsearch" | ||
roles: | ||
- elasticsearch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--- | ||
# Remove ElasticSearch server | ||
|
||
- name: set elasticsearch container name and volume | ||
set_fact: | ||
elasticsearch_name: "{{ name_prefix ~ host_group.index(inventory_hostname) }}" | ||
volume_name: "{{ db.elasticsearch.base_volume ~ host_group.index(inventory_hostname) }}" | ||
|
||
- name: remove ElasticSearch | ||
vars: | ||
elasticsearch_image: "{{ elasticsearch.docker_image | default('docker.elastic.co/elasticsearch/elasticsearch:' ~ elasticsearch.version ) }}" | ||
docker_container: | ||
name: "{{ elasticsearch_name }}" | ||
image: "{{ elasticsearch_image }}" | ||
keep_volumes: False | ||
state: absent | ||
ignore_errors: True | ||
|
||
- name: remove ElasticSearch conf dir | ||
file: | ||
path: "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}" | ||
state: absent | ||
become: "{{ db.elasticsearch.dir.become }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--- | ||
# This role will run a ElasticSearch server on the db group | ||
|
||
- name: set the vm.max_map_count to 262144 | ||
sysctl: | ||
name: vm.max_map_count | ||
value: '262144' | ||
become: true | ||
|
||
- name: set elasticsearch container name, volume and port | ||
set_fact: | ||
elasticsearch_name: "{{ name_prefix ~ host_group.index(inventory_hostname) }}" | ||
volume_name: "{{ db.elasticsearch.base_volume ~ host_group.index(inventory_hostname) }}" | ||
http_port: "{{ (db.elasticsearch.port|int) + host_group.index(inventory_hostname) }}" | ||
transport_port: "{{ (db.elasticsearch.base_transport_port|int) + host_group.index(inventory_hostname) }}" | ||
|
||
- name: ensure elasticserach config directory is created with permissions | ||
file: | ||
path: "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}" | ||
state: directory | ||
mode: 0755 | ||
become: "{{ db.elasticsearch.dir.become }}" | ||
|
||
# create volume direcotry if it's a directory path(not a named volume) | ||
- name: ensure elasticserach volume directory is created with permissions | ||
file: | ||
path: "{{ volume_name }}" | ||
state: directory | ||
mode: 0700 | ||
owner: "{{ db.elasticsearch.uid }}" | ||
become: true | ||
when: volume_name is search("/") | ||
|
||
- name: copy elasticsearch config file | ||
template: | ||
src: "elasticsearch.yml.j2" | ||
dest: "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}/elasticsearch.yml" | ||
mode: 0644 | ||
become: "{{ db.elasticsearch.dir.become }}" | ||
|
||
- name: copy elasticsearch log config file | ||
template: | ||
src: "log4j2.properties.j2" | ||
dest: "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}/log4j2.properties" | ||
mode: 0644 | ||
become: "{{ db.elasticsearch.dir.become }}" | ||
|
||
- name: "(re)start ElasticSearch from '{{ elasticsearch_image }} ' " | ||
vars: | ||
elasticsearch_image: "{{ elasticsearch.docker_image | default('docker.elastic.co/elasticsearch/elasticsearch:' ~ elasticsearch.version ) }}" | ||
docker_container: | ||
name: "{{ elasticsearch_name }}" | ||
image: "{{ elasticsearch_image }}" | ||
state: started | ||
recreate: true | ||
restart_policy: "{{ docker.restart.policy }}" | ||
ports: | ||
- "{{ http_port }}:9200" | ||
- "{{ transport_port }}:{{ transport_port }}" | ||
volumes: | ||
- "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml" | ||
- "{{ db.elasticsearch.confdir }}/{{ elasticsearch_name }}/log4j2.properties:/usr/share/elasticsearch/config/log4j2.properties" | ||
- "{{ volume_name }}:/usr/share/elasticsearch/data" | ||
pull: "{{ docker.pull_elasticsearch | default(true) }}" | ||
ulimits: | ||
- "nofile:262144:262144" | ||
- "memlock:-1:-1" | ||
env: | ||
TZ: "{{ docker.timezone }}" | ||
ES_JAVA_OPTS: "{{ db.elasticsearch.java_opts }}" | ||
|
||
- name: wait until ElasticSearch in this host is up and running | ||
uri: | ||
url: "{{ db.elasticsearch.protocol }}:https://{{ ansible_host }}:{{ http_port }}" | ||
status_code: 200 | ||
return_content: yes | ||
register: result | ||
until: result.json is defined | ||
retries: 12 | ||
delay: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
--- | ||
# This role will deploy a database server. Use the role if you want to use ElasticSearch locally. | ||
# In deploy mode it will start the ElasticSearch container. | ||
# In clean mode it will remove the ElasticSearch container. | ||
|
||
- import_tasks: deploy.yml | ||
when: mode == "deploy" | ||
|
||
- import_tasks: clean.yml | ||
when: mode == "clean" |
23 changes: 23 additions & 0 deletions
23
ansible/roles/elasticsearch/templates/elasticsearch.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
cluster.name: "{{ db.elasticsearch.cluster_name }}" | ||
node.name: "{{ elasticsearch_name }}" | ||
network.host: 0.0.0.0 | ||
network.publish_host: {{ ansible_default_ipv4.address }} | ||
|
||
http.port: 9200 | ||
transport.tcp.port: {{ transport_port }} | ||
|
||
# minimum_master_nodes need to be explicitly set when bound on a public IP | ||
# set to 1 to allow single node clusters | ||
# Details: https://github.com/elastic/elasticsearch/pull/17282 | ||
discovery.zen.ping.unicast.hosts: | ||
{% for es in groups['elasticsearch'] %} | ||
- {{ hostvars[es].ansible_host }}:{{ db.elasticsearch.base_transport_port + host_group.index(es)|int }} | ||
{% endfor %} | ||
discovery.zen.minimum_master_nodes: {{ (host_group|length / 2 + 1) | int}} | ||
|
||
gateway.recover_after_nodes: {{ (host_group|length / 2 + 1) | int }} | ||
gateway.expected_nodes: {{ host_group|length }} | ||
gateway.recover_after_time: 5m | ||
|
||
xpack.security.enabled: false | ||
bootstrap.memory_lock: true |
10 changes: 10 additions & 0 deletions
10
ansible/roles/elasticsearch/templates/log4j2.properties.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
status = error | ||
|
||
appender.console.type = Console | ||
appender.console.name = console | ||
appender.console.layout.type = PatternLayout | ||
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n | ||
|
||
rootLogger.appenderRef.console.ref = console | ||
|
||
rootLogger.level = {{ db.elasticsearch.loglevel }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of
db
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means elasticsearch nodes will be deployed on the same hosts specified in the
db
section.