Skip to content

Commit fd3b583

Browse files
committed
combine elastic server setup funcs, add log toggle
1 parent 384e7bc commit fd3b583

File tree

5 files changed

+32
-43
lines changed

5 files changed

+32
-43
lines changed

dev-system/src/cmr/dev_system/system.clj

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[cmr.common.util :as u]
1313
[cmr.dev-system.config :as dev-config]
1414
[cmr.dev-system.control :as control]
15-
[cmr.elastic-utils.config :as elastic-config]
15+
[cmr.elastic-utils.config :as es-config]
1616
[cmr.elastic-utils.embedded-elastic-server :as elastic-server]
1717
[cmr.indexer.config :as indexer-config]
1818
[cmr.indexer.system :as indexer-system]
@@ -100,46 +100,24 @@
100100
(def in-memory-elastic-log-level-atom
101101
(atom :info))
102102

103-
(defmulti create-gran-elastic-server
104-
"Sets elastic configuration values and returns an instance of an Elasticsearch component representing the granule cluster to run
105-
in memory if applicable. A granule elasticsearch cluster will hold only the granule and deleted granule indexes."
106-
(fn [type]
107-
type))
108-
109-
(defmethod create-gran-elastic-server :in-memory
110-
[_]
111-
(let [http-port (elastic-config/gran-elastic-port)]
112-
(elastic-server/create-server http-port
113-
{:log-level (name @in-memory-elastic-log-level-atom)
114-
:kibana-port (dev-config/embedded-kibana-gran-port)
115-
:image-cfg {"Dockerfile" "elasticsearch/Dockerfile.elasticsearch"
116-
"es_libs" "elasticsearch/es_libs"
117-
"embedded-security.policy" "elasticsearch/embedded-security.policy"
118-
"plugins" "elasticsearch/plugins"}})))
119-
120-
(defmethod create-gran-elastic-server :external
121-
[_]
122-
nil)
123-
124103
(defmulti create-elastic-server
125-
"Sets elastic configuration values and returns an instance of an Elasticsearch component representing the non-granule cluster to run
126-
in memory if applicable. This non-granule cluster will hold all CMR concept indexes that are NOT the granule or deleted granule indexes."
127-
(fn [type]
128-
type))
104+
"Sets elastic configuration values and returns an instance of an Elasticsearch component representing the non-granule cluster to run
105+
in memory if applicable. This non-granule cluster will hold all CMR concept indexes that are NOT the granule or deleted granule indexes."
106+
(fn [type elastic-port kibana-port]
107+
type))
129108

130109
(defmethod create-elastic-server :in-memory
131-
[_]
132-
(let [http-port (elastic-config/elastic-port)]
133-
(elastic-server/create-server http-port
134-
{:log-level (name @in-memory-elastic-log-level-atom)
135-
:kibana-port (dev-config/embedded-kibana-port)
136-
:image-cfg {"Dockerfile" "elasticsearch/Dockerfile.elasticsearch"
137-
"es_libs" "elasticsearch/es_libs"
138-
"embedded-security.policy" "elasticsearch/embedded-security.policy"
139-
"plugins" "elasticsearch/plugins"}})))
110+
[type elastic-port kibana-port]
111+
(elastic-server/create-server elastic-port
112+
{:log-level (name @in-memory-elastic-log-level-atom)
113+
:kibana-port kibana-port
114+
:image-cfg {"Dockerfile" "elasticsearch/Dockerfile.elasticsearch"
115+
"es_libs" "elasticsearch/es_libs"
116+
"embedded-security.policy" "elasticsearch/embedded-security.policy"
117+
"plugins" "elasticsearch/plugins"}}))
140118

141119
(defmethod create-elastic-server :external
142-
[_]
120+
[type elastic-port kibana-port]
143121
nil)
144122

145123
(defmulti create-redis
@@ -307,8 +285,8 @@
307285
db-component (create-db db)
308286
echo-component (create-echo echo)
309287
queue-broker (create-queue-broker message-queue)
310-
gran-elastic-server (create-gran-elastic-server elastic)
311-
elastic-server (create-elastic-server elastic)
288+
gran-elastic-server (create-elastic-server elastic (es-config/gran-elastic-port) (dev-config/embedded-kibana-gran-port))
289+
elastic-server (create-elastic-server elastic (es-config/elastic-port) (dev-config/embedded-kibana-port))
312290
redis-server (create-redis redis)
313291
sqs-server (create-sqs-server sqs-server)
314292
control-server (control/create-server)]

elastic-utils-lib/src/cmr/elastic_utils/config.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
[cmr.common.config :refer [defconfig]]
66
[cmr.common.services.errors :as errors]))
77

8+
(declare split-cluster-log-toggle)
9+
(defconfig split-cluster-log-toggle
10+
"This is the temporary feature toggle that will turn on and off the split cluster logs. True means on."
11+
{:default false
12+
:type Boolean})
13+
814
(declare elastic-name)
915
(def elastic-name
1016
"Defining the elastic cluster name for non-gran elastic cluster.

elastic-utils-lib/src/cmr/elastic_utils/es_helper.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"Performs a search query across one or more indexes and one or more mapping types"
1717
[conn index _mapping-type opts]
1818
;; Temporarily putting in this log to check which indexes are going to which cluster during ES cluster split
19-
(info "CMR-10600 ES search for index: " index " connected to " conn)
19+
(when (es-config/split-cluster-log-toggle)
20+
(info "CMR-10600 ES search for index: " index " connected to " conn))
2021
(let [qk [:search_type :scroll :routing :preference :ignore_unavailable]
2122
qp (merge {:track_total_hits true}
2223
(select-keys opts qk))

indexer-app/src/cmr/indexer/data/elasticsearch.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@
442442
(doseq [es-index es-indexes]
443443
(let [conn (get-es-cluster-conn context es-index)
444444
;; Temporarily putting in this log to check which indexes are going to which cluster during ES cluster split
445-
_ (info "CMR-10600 Saving doc for concept " concept-id " under index " es-index " in es cluster " conn)
445+
_ (when (es-config/split-cluster-log-toggle)
446+
(info "CMR-10600 Saving doc for concept " concept-id " under index " es-index " in es cluster " conn))
446447
{:keys [ignore-conflict? all-revisions-index?]} options
447448
elastic-id (get-elastic-id concept-id revision-id all-revisions-index?)
448449
result (try-elastic-operation
@@ -462,7 +463,8 @@
462463
[context es-index es-type elastic-id]
463464
(let [es-cluster-name (es-index/get-es-cluster-name-from-concept-id elastic-id)]
464465
;; Temporarily putting in this log to check which indexes are going to which cluster during ES cluster split
465-
(info "CMR-10600 Get document of index " es-index " from ES cluster " es-cluster-name)
466+
(when (es-config/split-cluster-log-toggle)
467+
(info "CMR-10600 Get document of index " es-index " from ES cluster " es-cluster-name))
466468
(es-helper/doc-get (indexer-util/context->conn context es-cluster-name) es-index es-type elastic-id)))
467469

468470
(defn delete-document
@@ -474,7 +476,8 @@
474476
;; Cannot use elasticsearch for deletion as we require special headers on delete
475477
(let [es-cluster-name (es-index/get-es-cluster-name-from-concept-id concept-id)
476478
;; Temporarily putting in this log to check which indexes are going to which cluster during ES cluster split
477-
_ (info "CMR-10600 Deleting concept " concept-id " with index " es-index " in ES cluster " es-cluster-name)
479+
_ (when (es-config/split-cluster-log-toggle)
480+
(info "CMR-10600 Deleting concept " concept-id " with index " es-index " in ES cluster " es-cluster-name))
478481
{:keys [admin-token]} (context->es-config context es-cluster-name)
479482
{:keys [uri http-opts]} (indexer-util/context->conn context es-cluster-name)
480483
{:keys [ignore-conflict? all-revisions-index?]} options

indexer-app/src/cmr/indexer/data/index_set_elasticsearch.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@
120120
This func should only be called once during the first time we transition to the split cluster.
121121
It may be deleted after the transition is determined to be successful and permanent with the ticket CMR-10949."
122122
[context es-cluster-name index-set-id]
123-
(info "CMR 10600 Getting old index set to copy over to new split cluster index set indexes.")
123+
(when (es-config/split-cluster-log-toggle)
124+
(info "CMR-10600 Getting old index set to copy over to new split cluster index set indexes."))
124125
(let [es-cluster-name-keyword (es-config/elastic-name-str->keyword es-cluster-name)
125126
{:keys [mapping]} (config/idx-cfg-for-index-sets es-cluster-name)
126127
idx-mapping-type (first (keys mapping))]

0 commit comments

Comments
 (0)