Skip to content

Commit 2404291

Browse files
committed
CMR-11067: removing worker functions in message file, adding a category of logs, fixing how logs are written in index-provider-data-later-than-date-time
1 parent 79a9d09 commit 2404291

2 files changed

Lines changed: 143 additions & 101 deletions

File tree

‎bootstrap-app/src/cmr/bootstrap/api/messages_bulk_index.clj‎

Lines changed: 134 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -21,204 +21,246 @@
2121
;; helpers
2222

2323
(defn bulk-index-msg-general
24-
"Message to return when indexing"
24+
"General Message to return when indexing, will format message according to this logging standard."
2525
[msg]
2626
(str msg/bulk-index-prefix-general msg))
2727

28-
(defn bulk-index-queue-msg
29-
"Message to return when indexing all providers from the SQS queue, not from the channels."
30-
[msg]
31-
(str bulk-index-prefix-queue msg))
28+
;; ***************************************************************************80
29+
;; called in data/bulk_index.clj
3230

33-
(defn bulk-index-channel-load-msg
34-
"Message to return when indexing all providers from the core.async channels, during channel load."
35-
[msg]
36-
(str bulk-index-prefix-channel-load msg))
31+
;; ***********************************40
32+
;; channel read messages from handle-bulk-index-requests
3733

38-
(defn bulk-index-channel-read-msg
39-
"Message to return when indexing all providers from the core.async channels, not from the SQS queue."
40-
[msg]
41-
(str bulk-index-prefix-channel-read msg))
34+
(defn index-granules-for-collection-start
35+
[collection-id]
36+
(format "%s Indexing granule data for collection [%s]." bulk-index-prefix-channel-read collection-id))
4237

43-
;; ***************************************************************************80
44-
;; called in data/bulk_index.clj
38+
(defn index-granules-for-collection-indexed
39+
[num-granules provider-id collection-id]
40+
(format "%s Indexed %d granule(s) for provider [%s] collection [%s]."
41+
bulk-index-prefix-channel-read
42+
num-granules
43+
provider-id
44+
collection-id))
45+
46+
(defn index-system-concepts
47+
[total]
48+
(format "%s Indexed %d system concepts." bulk-index-prefix-channel-read total))
49+
50+
(defn delete-concepts-by-id
51+
[total]
52+
(format "%s Deleted %d concepts." bulk-index-prefix-channel-read total))
53+
54+
(defn index-concepts-by-id
55+
[total]
56+
(format "%s Indexed %d concepts." bulk-index-prefix-channel-read total))
57+
58+
(defn migrate-index-start
59+
[source-index target-index elastic-name]
60+
(format "%s Migrating from index [%s] to index [%s] in es cluster [%s]"
61+
bulk-index-prefix-channel-read
62+
source-index
63+
target-index
64+
elastic-name))
65+
66+
(defn migrate-index-error
67+
[source-index target-index reason]
68+
(format "%s Migration from [%s] to [%s] failed: %s"
69+
bulk-index-prefix-channel-read
70+
source-index
71+
target-index
72+
reason))
73+
74+
;; ***********************************40
75+
;; queue functions
4576

4677
(defn index-provider-data-later-than-date-time
4778
[date-time provider-id]
48-
(bulk-index-queue-msg
49-
(format "Indexing concepts with revision-date later than [%s] for provider [%s] started."
50-
date-time
51-
provider-id)))
79+
(format "%s Indexing concepts with revision-date later than [%s] for provider [%s] started."
80+
bulk-index-prefix-queue
81+
date-time
82+
provider-id))
5283

5384
(defn index-provider-data-later-than-date-time-sys-concepts
5485
[num-indexed]
55-
(bulk-index-queue-msg (format "Indexed %d system concepts." num-indexed)))
86+
(format "%s Indexed %d system concepts." bulk-index-prefix-queue num-indexed))
5687

5788
(defn index-provider-data-later-than-date-post
5889
[provider-concept-count]
59-
(bulk-index-queue-msg (format "Indexed %d provider concepts." provider-concept-count)))
90+
(format "%s Indexed %d provider concepts." bulk-index-prefix-queue provider-concept-count))
6091

6192
(defn index-provider-data-later-than-date-time-completed
6293
[date-time provider-id]
63-
(bulk-index-queue-msg
64-
(format "Indexing concepts with revision-date later than [%s] for provider [%s] completed."
65-
date-time
66-
provider-id)))
94+
(format "%s Indexing concepts with revision-date later than [%s] for provider [%s] completed."
95+
bulk-index-prefix-queue
96+
date-time
97+
provider-id))
6798

6899
(defn index-provider-data-later-than-date-time-failed
69-
[date-time provider-id]
70-
(bulk-index-queue-msg
71-
(format "Indexing concepts with revision-date later than [%s] for provider [%s] failed!"
72-
date-time
73-
provider-id)))
100+
[date-time provider-id reason]
101+
(format
102+
"%s Indexing concepts with revision-date later than [%s] for provider [%s] completed but failed because << %s >>!"
103+
bulk-index-prefix-queue
104+
date-time
105+
provider-id
106+
reason))
74107

75108
(defn index-concepts-by-provider-start
76-
[concept-type provider-id]
77-
(bulk-index-queue-msg (format "Indexing %ss for provider %s" concept-type provider-id)))
109+
[concept-type provider-id]
110+
(format "%s Indexing %ss for provider %s" bulk-index-prefix-queue concept-type provider-id))
78111

79112
(defn index-concepts-by-provider-completed
80113
[concept-type provider-id num-concepts]
81-
(bulk-index-queue-msg
82-
(format "Indexed %d %s(s) for provider %s." num-concepts concept-type provider-id)))
114+
(format "%s Indexed %d %s(s) for provider %s."
115+
bulk-index-prefix-queue
116+
num-concepts
117+
concept-type
118+
provider-id))
83119

84120
(defn index-all-concepts-start
85121
[concept-type]
86-
(bulk-index-queue-msg (format "Indexing all %ss" concept-type)))
122+
(format "%s Indexing all %ss" bulk-index-prefix-queue concept-type))
87123

88124
(defn index-all-concepts-complete
89125
[concept-type]
90-
(bulk-index-queue-msg (format "Indexing of all %ss completed." concept-type)))
126+
(format "%s Indexing of all %ss completed." bulk-index-prefix-queue concept-type))
91127

92128
(defn fetch-and-index-new-concepts-batches-before
93129
[provider concept-type params]
94-
(bulk-index-queue-msg
95-
(format "About to fetch %s concepts in batches for [%s] with options %s."
96-
concept-type
97-
provider
98-
(pr-str params))))
130+
(format "%s About to fetch %s concepts in batches for [%s] with options %s."
131+
bulk-index-prefix-queue
132+
concept-type
133+
provider
134+
(pr-str params)))
99135

100136
(defn fetch-and-index-new-concepts-batches-after
101137
[provider concept-type count-of-items]
102-
(bulk-index-queue-msg
103-
(format "Finished finding all (%d) %s concepts for provider [%s] in db for fetch and index new concepts."
104-
count-of-items
105-
concept-type
106-
provider)))
138+
(format
139+
"%s Finished finding all (%d) %s concepts for provider [%s] in db for fetch and index new concepts."
140+
bulk-index-prefix-queue
141+
count-of-items
142+
concept-type
143+
provider))
107144

108145
;; ***************************************************************************80
109146
;; called in bootstrap_service.clj
110147

111148
(defn index-all-providers-start
112149
[]
113150
;; added the word started to the log message, check splunk reports
114-
(bulk-index-channel-load-msg "Indexing all providers started."))
151+
(format "%s Indexing all providers started." bulk-index-prefix-queue))
115152

116153
(defn index-all-providers-loop
117154
[provider-id]
118-
(bulk-index-channel-load-msg
119-
(format "Processing provider [%s] for bulk indexing" provider-id)))
155+
(format "%s Processing provider [%s] for bulk indexing" bulk-index-prefix-queue provider-id))
120156

121157
(defn index-all-providers-complete
122158
[]
123-
(bulk-index-channel-load-msg "Indexing of all providers scheduled/completed."))
159+
(format "%s Indexing of all providers scheduled/completed." bulk-index-prefix-queue))
124160

125161
;; ***************************************************************************80
126162
;; called in fingerprint.clj
127163

128164
(defn fingerprint-updating
129165
[provider]
130-
(bulk-index-queue-msg (format "Updating fingerprints for provider [%s]" provider)))
166+
(format "%s Updating fingerprints for provider [%s]." bulk-index-prefix-queue provider))
131167

132168
(defn fingerprint-variables
133169
[variable-count provider]
134-
(bulk-index-queue-msg
135-
(format "Updated fingerprints of %d variable(s) for provider %s" variable-count provider)))
170+
(format "%s Updated fingerprints of %d variable(s) for provider %s."
171+
bulk-index-prefix-queue
172+
variable-count
173+
provider))
136174

137175
(defn fingerprint-complete
138176
[provider]
139-
(bulk-index-queue-msg (format "Updating fingerprints for provider %s completed." provider)))
177+
(format "%s Updating fingerprints for provider %s completed." bulk-index-prefix-queue provider))
140178

141179
(defn fingerprint-all-updating
142180
[]
143-
(bulk-index-queue-msg "Updating fingerprints for all variables."))
181+
(format "%s Updating fingerprints for all variables." bulk-index-prefix-queue))
144182

145183
(defn fingerprint-all-complete
146184
[]
147-
(bulk-index-queue-msg "Updating fingerprints for all variables completed."))
185+
(format "%s Updating fingerprints for all variables completed." bulk-index-prefix-queue))
148186

149187
;; ***************************************************************************80
150188
;; data/message_queue.clj
151189

152190
(defn publish-bootstrap-provider-event
153191
[message]
154-
(bulk-index-queue-msg (format "Publishing bootstrap message: %s" message)))
192+
(format "%sPublishing bootstrap message: %s" bulk-index-prefix-queue message))
155193

156194
;; ***************************************************************************80
157-
;; async.clj
195+
;; async.clj - puts items into the channels
158196

159197
(defn async-not-implemented
160198
[action]
161-
(bulk-index-channel-load-msg (format "Async Dispatcher does not support %s action." action)))
199+
(format "%s Async Dispatcher does not support %s action." bulk-index-prefix-channel-load action))
162200

163201
(defn async-migrate-provider
164202
[provider-id]
165-
(bulk-index-channel-load-msg (format "Adding provider %s to provider channel" provider-id)))
203+
(format "%s Adding provider %s to provider channel." bulk-index-prefix-channel-load provider-id))
166204

167205
(defn async-migrate-collection
168206
[provider-id collection-id]
169-
(bulk-index-channel-load-msg
170-
(format "Adding collection %s for provider %s to collection channel" collection-id provider-id)))
207+
(format "%s Adding collection %s for provider %s to collection channel."
208+
bulk-index-prefix-channel-load
209+
collection-id
210+
provider-id))
171211

172212
(defn async-index-provider
173213
[provider-id start-index]
174214
;; Added start index to log message, check splunk reports
175-
(bulk-index-channel-load-msg
176-
(format "Adding provider %s to index channel starting at %d" provider-id start-index)))
215+
(format "%s Adding provider %s to index channel starting at %d."
216+
bulk-index-prefix-channel-load provider-id start-index))
177217

178218
(defn async-index-collection
179219
[collection-id provider-id]
180-
;; Added provider-id to log message, check splunk reports
181-
(bulk-index-channel-load-msg
182-
(format "Adding collection %s to collection index channel to provider %s"
183-
collection-id
184-
provider-id)))
220+
;; Added provider-id to log message, check splunk reports
221+
(format "%s Adding collection %s to collection index channel to provider %s."
222+
bulk-index-prefix-channel-load
223+
collection-id
224+
provider-id))
185225

186226
(defn async-index-system-concepts
187227
[start-index]
188-
(bulk-index-channel-load-msg
189-
;; added start index to log message, check splunk reports
190-
(format "Adding bulk index request to system concepts channel with start-index %s."
191-
start-index)))
228+
;; added start index to log message, check splunk reports
229+
(format "%s Adding bulk index request to system concepts channel with start-index %s."
230+
bulk-index-prefix-channel-load
231+
start-index))
192232

193233
(defn async-index-concepts-by-id
194234
[provider-id concept-type concept-ids]
195-
(bulk-index-channel-load-msg
196-
;; added concept details to log message, check splunk reports
197-
(format "Adding bulk index request to concept-id channel for provider %s, concept-type %s, concept-ids %s..."
198-
provider-id
199-
concept-type
200-
(pr-str (take 10 concept-ids)))))
235+
;; added concept details to log message, check splunk reports
236+
(format "%s Adding bulk index request to concept-id channel for provider %s, concept-type %s, concept-ids %s..."
237+
bulk-index-prefix-channel-load
238+
provider-id
239+
concept-type
240+
(pr-str (take 10 concept-ids))))
201241

202242
(defn async-migrate-index
203243
[source-index target-index elastic-name]
204-
(bulk-index-channel-load-msg
205-
;; added elastic name, check splunk reports
206-
(format "Migrating from index [%s] to index [%s] in [%s]"
207-
source-index
208-
target-index
209-
elastic-name)))
244+
;; added elastic name, check splunk reports
245+
(format "%s Migrating from index [%s] to index [%s] in [%s]."
246+
bulk-index-prefix-channel-load
247+
source-index
248+
target-index
249+
elastic-name))
210250

211251
(defn async-delete-concepts-from-index-by-id
212252
[provider-id concept-type concept-ids]
213253
;; added concept details to log message, check splunk reports
214-
(bulk-index-channel-load-msg
215-
(format "Adding bulk delete request to concept-id channel. %s %s %s..."
216-
provider-id
217-
concept-type
218-
(pr-str (take 10 concept-ids)))))
254+
(format "%s Adding bulk delete request to concept-id channel. %s %s %s..."
255+
bulk-index-prefix-channel-load
256+
provider-id
257+
concept-type
258+
(pr-str (take 10 concept-ids))))
219259

220260
(defn async-bootstrap-virtual-products
221261
[provider-id entry-title]
222262
;; added provider id and entry title to log message, check splunk reports
223-
(bulk-index-channel-load-msg
224-
(format "Adding message to virtual products channel. %s %s" provider-id entry-title)))
263+
(format "%s Adding message to virtual products channel. %s %s."
264+
bulk-index-prefix-channel-load
265+
provider-id
266+
entry-title))

0 commit comments

Comments
 (0)