teraslice 3.3.0 → 3.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +202 -0
  2. package/package.json +25 -28
  3. package/dist/src/interfaces.js +0 -12
  4. package/dist/src/lib/cluster/cluster_master.js +0 -246
  5. package/dist/src/lib/cluster/node_master.js +0 -355
  6. package/dist/src/lib/cluster/services/api.js +0 -663
  7. package/dist/src/lib/cluster/services/assets.js +0 -224
  8. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/index.js +0 -192
  9. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/interfaces.js +0 -2
  10. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8s.js +0 -419
  11. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sDeploymentResource.js +0 -60
  12. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sJobResource.js +0 -55
  13. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sResource.js +0 -357
  14. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sServiceResource.js +0 -37
  15. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/k8sState.js +0 -60
  16. package/dist/src/lib/cluster/services/cluster/backends/kubernetesV2/utils.js +0 -170
  17. package/dist/src/lib/cluster/services/cluster/backends/native/dispatch.js +0 -13
  18. package/dist/src/lib/cluster/services/cluster/backends/native/index.js +0 -526
  19. package/dist/src/lib/cluster/services/cluster/backends/native/messaging.js +0 -548
  20. package/dist/src/lib/cluster/services/cluster/backends/state-utils.js +0 -26
  21. package/dist/src/lib/cluster/services/cluster/index.js +0 -13
  22. package/dist/src/lib/cluster/services/execution.js +0 -435
  23. package/dist/src/lib/cluster/services/index.js +0 -6
  24. package/dist/src/lib/cluster/services/interfaces.js +0 -2
  25. package/dist/src/lib/cluster/services/jobs.js +0 -458
  26. package/dist/src/lib/config/default-sysconfig.js +0 -25
  27. package/dist/src/lib/config/index.js +0 -20
  28. package/dist/src/lib/config/schemas/system.js +0 -360
  29. package/dist/src/lib/storage/analytics.js +0 -86
  30. package/dist/src/lib/storage/assets.js +0 -401
  31. package/dist/src/lib/storage/backends/elasticsearch_store.js +0 -496
  32. package/dist/src/lib/storage/backends/mappings/analytics.js +0 -20
  33. package/dist/src/lib/storage/backends/mappings/asset.js +0 -32
  34. package/dist/src/lib/storage/backends/mappings/ex.js +0 -53
  35. package/dist/src/lib/storage/backends/mappings/job.js +0 -42
  36. package/dist/src/lib/storage/backends/mappings/state.js +0 -16
  37. package/dist/src/lib/storage/backends/s3_store.js +0 -237
  38. package/dist/src/lib/storage/execution.js +0 -302
  39. package/dist/src/lib/storage/index.js +0 -7
  40. package/dist/src/lib/storage/jobs.js +0 -81
  41. package/dist/src/lib/storage/state.js +0 -254
  42. package/dist/src/lib/utils/api_utils.js +0 -128
  43. package/dist/src/lib/utils/asset_utils.js +0 -94
  44. package/dist/src/lib/utils/date_utils.js +0 -52
  45. package/dist/src/lib/utils/encoding_utils.js +0 -27
  46. package/dist/src/lib/utils/events.js +0 -4
  47. package/dist/src/lib/utils/file_utils.js +0 -124
  48. package/dist/src/lib/utils/id_utils.js +0 -15
  49. package/dist/src/lib/utils/port_utils.js +0 -32
  50. package/dist/src/lib/workers/assets/index.js +0 -3
  51. package/dist/src/lib/workers/assets/loader-executable.js +0 -40
  52. package/dist/src/lib/workers/assets/loader.js +0 -73
  53. package/dist/src/lib/workers/assets/spawn.js +0 -55
  54. package/dist/src/lib/workers/context/execution-context.js +0 -12
  55. package/dist/src/lib/workers/context/terafoundation-context.js +0 -8
  56. package/dist/src/lib/workers/execution-controller/execution-analytics.js +0 -188
  57. package/dist/src/lib/workers/execution-controller/index.js +0 -1024
  58. package/dist/src/lib/workers/execution-controller/recovery.js +0 -151
  59. package/dist/src/lib/workers/execution-controller/scheduler.js +0 -390
  60. package/dist/src/lib/workers/execution-controller/slice-analytics.js +0 -96
  61. package/dist/src/lib/workers/helpers/job.js +0 -80
  62. package/dist/src/lib/workers/helpers/op-analytics.js +0 -22
  63. package/dist/src/lib/workers/helpers/terafoundation.js +0 -34
  64. package/dist/src/lib/workers/helpers/worker-shutdown.js +0 -147
  65. package/dist/src/lib/workers/metrics/index.js +0 -108
  66. package/dist/src/lib/workers/worker/index.js +0 -378
  67. package/dist/src/lib/workers/worker/slice.js +0 -122
  68. package/dist/test/config/schemas/system_schema-spec.js +0 -26
  69. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8s-v2-spec.js +0 -458
  70. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sResource-v2-spec.js +0 -818
  71. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-multicluster-v2-spec.js +0 -67
  72. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/k8sState-v2-spec.js +0 -84
  73. package/dist/test/lib/cluster/services/cluster/backends/kubernetes/v2/utils-v2-spec.js +0 -320
  74. package/dist/test/lib/cluster/services/cluster/backends/state-utils-spec.js +0 -37
  75. package/dist/test/node_master-spec.js +0 -194
  76. package/dist/test/services/api-spec.js +0 -79
  77. package/dist/test/services/assets-spec.js +0 -158
  78. package/dist/test/services/messaging-spec.js +0 -440
  79. package/dist/test/storage/assets_storage-spec.js +0 -95
  80. package/dist/test/storage/s3_store-spec.js +0 -149
  81. package/dist/test/test.config.js +0 -23
  82. package/dist/test/test.setup.js +0 -6
  83. package/dist/test/utils/api_utils-spec.js +0 -25
  84. package/dist/test/utils/asset_utils-spec.js +0 -141
  85. package/dist/test/utils/elastic_utils-spec.js +0 -25
  86. package/dist/test/workers/execution-controller/execution-controller-spec.js +0 -371
  87. package/dist/test/workers/execution-controller/execution-special-test-cases-spec.js +0 -519
  88. package/dist/test/workers/execution-controller/execution-test-cases-spec.js +0 -343
  89. package/dist/test/workers/execution-controller/recovery-spec.js +0 -160
  90. package/dist/test/workers/execution-controller/scheduler-spec.js +0 -249
  91. package/dist/test/workers/execution-controller/slice-analytics-spec.js +0 -121
  92. package/dist/test/workers/fixtures/ops/example-op/processor.js +0 -20
  93. package/dist/test/workers/fixtures/ops/example-op/schema.js +0 -19
  94. package/dist/test/workers/fixtures/ops/example-reader/fetcher.js +0 -20
  95. package/dist/test/workers/fixtures/ops/example-reader/schema.js +0 -41
  96. package/dist/test/workers/fixtures/ops/example-reader/slicer.js +0 -37
  97. package/dist/test/workers/fixtures/ops/new-op/processor.js +0 -29
  98. package/dist/test/workers/fixtures/ops/new-op/schema.js +0 -18
  99. package/dist/test/workers/fixtures/ops/new-reader/fetcher.js +0 -19
  100. package/dist/test/workers/fixtures/ops/new-reader/schema.js +0 -23
  101. package/dist/test/workers/fixtures/ops/new-reader/slicer.js +0 -13
  102. package/dist/test/workers/helpers/configs.js +0 -128
  103. package/dist/test/workers/helpers/execution-controller-helper.js +0 -49
  104. package/dist/test/workers/helpers/index.js +0 -5
  105. package/dist/test/workers/helpers/test-context.js +0 -210
  106. package/dist/test/workers/helpers/zip-directory.js +0 -25
  107. package/dist/test/workers/worker/slice-spec.js +0 -333
  108. package/dist/test/workers/worker/worker-spec.js +0 -356
@@ -1,496 +0,0 @@
1
- import ms from 'ms';
2
- import { TSError, parseError, isTest, pDelay, pRetry, logError, pWhile, isString, getTypeOf, get, random, isInteger } from '@terascope/core-utils';
3
- import elasticsearchApi from '@terascope/elasticsearch-api';
4
- import { getClient } from '@terascope/job-components';
5
- import { DataType } from '@terascope/data-types';
6
- import { makeLogger } from '../../workers/helpers/terafoundation.js';
7
- import { timeseriesIndex } from '../../utils/date_utils.js';
8
- import { analyticsDataTypeConfig, analyticsTemplate } from './mappings/analytics.js';
9
- import { assetDataTypeConfig, assetMappingOverrides } from './mappings/asset.js';
10
- import { executionDataTypeConfig } from './mappings/ex.js';
11
- import { jobDataTypeConfig } from './mappings/job.js';
12
- import { stateDataTypeConfig, stateTemplate } from './mappings/state.js';
13
- function validateId(recordId, recordType) {
14
- if (!recordId || !isString(recordId)) {
15
- throw new TSError(`Invalid ${recordType} id given ${getTypeOf(recordId)}`, {
16
- statusCode: 422
17
- });
18
- }
19
- }
20
- function validateIdAndRecord(recordId, record, recordType, idField) {
21
- validateId(recordId, recordType);
22
- const id = record[idField];
23
- if (id && id !== recordId) {
24
- throw new TSError(`${recordType}.${idField} doesn't match request id`, {
25
- statusCode: 406
26
- });
27
- }
28
- }
29
- // TODO: fix types here
30
- function _getTimeout(timeout) {
31
- if (isInteger(timeout)) {
32
- // don't allow a timeout of less than 1 second
33
- if (timeout <= 1000)
34
- return undefined;
35
- return ms(timeout);
36
- }
37
- if (isString(timeout)) {
38
- return timeout;
39
- }
40
- return undefined;
41
- }
42
- // TODO: type this better
43
- export class TerasliceElasticsearchStorage {
44
- context;
45
- logger;
46
- recordType;
47
- // TODO: should this be here?
48
- defaultIndexName;
49
- storageName;
50
- flushInterval;
51
- isShuttingDown = false;
52
- // flag to know if already in a bulk call
53
- savingBulk = false;
54
- // Buffer to build up bulk requests. TODO: fix type
55
- bulkQueue = [];
56
- idField;
57
- options;
58
- mapping;
59
- api;
60
- indexSettings;
61
- constructor(backendConfig) {
62
- const { context, indexName, recordType, idField, storageName, bulkSize = 1000, fullResponse = false, logRecord = true, forceRefresh = true, logger } = backendConfig;
63
- this.context = context;
64
- this.storageName = storageName;
65
- this.logger = logger ?? makeLogger(context, 'elasticsearch_backend', { storageName });
66
- this.recordType = recordType;
67
- // Validate recordType
68
- const validRecordTypes = ['analytics', 'asset', 'ex', 'job', 'state'];
69
- if (!validRecordTypes.includes(recordType)) {
70
- throw new Error(`Could not find mapping for recordType: ${recordType}`);
71
- }
72
- const config = this.context.sysconfig.teraslice;
73
- this.indexSettings = get(config, ['index_settings', this.storageName], {
74
- number_of_shards: 5,
75
- number_of_replicas: 1,
76
- });
77
- this.defaultIndexName = indexName;
78
- this.idField = idField;
79
- this.options = {
80
- bulkSize,
81
- fullResponse,
82
- logRecord,
83
- forceRefresh
84
- };
85
- }
86
- async initialize() {
87
- const config = this.context.sysconfig.teraslice;
88
- const isMultiIndex = this.defaultIndexName[this.defaultIndexName.length - 1] === '*';
89
- let newIndex = this.defaultIndexName;
90
- if (isMultiIndex) {
91
- // @ts-expect-error TODO: fix this
92
- const storeType = this.defaultIndexName.match(/__(.*)\*/)[1];
93
- const timeseriesFormat = config.index_rollover_frequency[storeType];
94
- const nameSize = this.defaultIndexName.length - 1;
95
- newIndex = timeseriesIndex(timeseriesFormat, this.defaultIndexName.slice(0, nameSize)).index;
96
- }
97
- const clientName = JSON.stringify({
98
- connection: config.state.connection,
99
- index: this.defaultIndexName,
100
- });
101
- const connectionConfig = Object.assign({}, config.state);
102
- if (connectionConfig.connection_cache == null) {
103
- connectionConfig.connection_cache = true;
104
- }
105
- const { connection } = config.state;
106
- const options = {
107
- full_response: !!this.options.fullResponse,
108
- connection,
109
- };
110
- await pWhile(async () => {
111
- try {
112
- const client = await getClient(this.context, connectionConfig, 'elasticsearch-next');
113
- this.api = elasticsearchApi(client, this.logger, options);
114
- this._generateMapping();
115
- await this._createIndex(newIndex);
116
- await this.api.isAvailable(newIndex);
117
- return true;
118
- }
119
- catch (err) {
120
- const error = new TSError(err, {
121
- reason: `Failure initializing ${this.recordType} index: ${this.defaultIndexName}`,
122
- });
123
- if (error.statusCode >= 400 && error.statusCode < 500) {
124
- throw error;
125
- }
126
- logError(this.logger, error, `Failed attempt connecting to elasticsearch: ${clientName} (will retry)`);
127
- await pDelay(isTest ? 0 : random(2000, 4000));
128
- return false;
129
- }
130
- });
131
- // Periodically flush the bulkQueue so we don't end up with cached data lingering.
132
- this.flushInterval = setInterval(() => {
133
- // TODO: this might be undefined
134
- this._flush().catch((err) => {
135
- logError(this.logger, err, 'background flush failure');
136
- return null;
137
- });
138
- // stager the interval to avoid collisions
139
- }, random(9000, 11000));
140
- }
141
- async get(recordId, index = this.defaultIndexName, fields) {
142
- validateId(recordId, this.recordType);
143
- this.logger.trace(`getting record id: ${recordId}`);
144
- const query = {
145
- index,
146
- id: recordId,
147
- };
148
- if (fields) {
149
- query._source_includes = fields;
150
- }
151
- return this.api.get(query);
152
- }
153
- async search(query, from = 0, size = 10000, sort, fields, index = this.defaultIndexName) {
154
- if (from != null && !isInteger(from)) {
155
- throw new Error(`from parameter must be a integer, got ${from}`);
156
- }
157
- if (size != null && !isInteger(size)) {
158
- throw new Error(`size parameter must be a integer, got ${size}`);
159
- }
160
- if (sort != null && !isString(sort)) {
161
- throw new Error(`sort parameter must be a string, got ${sort}`);
162
- }
163
- const esQuery = {
164
- index,
165
- from,
166
- size,
167
- sort,
168
- };
169
- if (typeof query === 'string') {
170
- esQuery.q = query;
171
- }
172
- else {
173
- esQuery.body = query;
174
- }
175
- if (fields) {
176
- esQuery._source_includes = fields;
177
- }
178
- return this.api.search(esQuery);
179
- }
180
- /*
181
- * index saves a record to elasticsearch allowing automatic
182
- * ID creation
183
- */
184
- async index(record, indexArg = this.defaultIndexName) {
185
- this.logger.trace('indexing record', this.options.logRecord ? record : undefined);
186
- const query = {
187
- index: indexArg,
188
- body: record,
189
- refresh: this.options.forceRefresh,
190
- };
191
- return this.api.index(query);
192
- }
193
- /*
194
- * index saves a record to opensearch with a specified ID.
195
- * If the document is already there it will be replaced.
196
- */
197
- async indexWithId(recordId, record, index = this.defaultIndexName, timeout) {
198
- validateIdAndRecord(recordId, record, this.recordType, this.idField);
199
- this.logger.trace(`indexWithId call with id: ${recordId}, record`, this.options.logRecord ? record : null);
200
- const query = {
201
- index,
202
- id: recordId,
203
- body: record,
204
- refresh: this.options.forceRefresh,
205
- timeout: _getTimeout(timeout)
206
- };
207
- return this.api.indexWithId(query);
208
- }
209
- /*
210
- * Create saves a record to opensearch under the provided id.
211
- * If the record already exists it will not be inserted.
212
- */
213
- async create(record, index = this.defaultIndexName) {
214
- this.logger.trace('creating record', this.options.logRecord ? record : null);
215
- const query = {
216
- index,
217
- id: record[this.idField],
218
- body: record,
219
- refresh: this.options.forceRefresh,
220
- };
221
- return this.api.create(query);
222
- }
223
- async count(query, from, sort, index = this.defaultIndexName) {
224
- if (from != null && !isInteger(from)) {
225
- throw new Error(`from parameter must be a integer, got ${from}`);
226
- }
227
- if (sort != null && !isString(sort)) {
228
- throw new Error(`sort parameter must be a string, got ${sort}`);
229
- }
230
- // TODO: check from
231
- const esQuery = {
232
- index,
233
- // @ts-expect-error
234
- from,
235
- sort,
236
- };
237
- if (isString(query)) {
238
- esQuery.q = query;
239
- }
240
- else {
241
- esQuery.body = query;
242
- }
243
- return this.api.count(esQuery);
244
- }
245
- async update(recordId, updateSpec, index = this.defaultIndexName) {
246
- validateIdAndRecord(recordId, updateSpec, this.recordType, this.idField);
247
- this.logger.trace(`updating record ${recordId}, `, this.options.logRecord ? updateSpec : null);
248
- const query = {
249
- index,
250
- id: recordId,
251
- body: {
252
- doc: updateSpec,
253
- },
254
- refresh: this.options.forceRefresh,
255
- // TODO: check this retry
256
- retry_on_conflict: 3,
257
- };
258
- return this.api.update(query);
259
- }
260
- async updatePartial(recordId, applyChanges, index = this.defaultIndexName) {
261
- if (typeof applyChanges !== 'function') {
262
- throw new Error('Update Partial expected a applyChanges function');
263
- }
264
- validateId(recordId, this.recordType);
265
- const getParams = {
266
- index,
267
- id: recordId,
268
- };
269
- const existing = await pRetry(() => this.api.get(getParams, true), {
270
- matches: ['no_shard_available_action_exception'],
271
- delay: 1000,
272
- retries: 10,
273
- backoff: 5
274
- });
275
- const doc = await applyChanges(Object.assign({}, existing._source));
276
- this.logger.trace(`updating partial record ${recordId}, `, this.options.logRecord ? doc : null);
277
- validateIdAndRecord(recordId, doc, this.recordType, this.idField);
278
- const query = {
279
- index,
280
- id: recordId,
281
- body: doc,
282
- refresh: this.options.forceRefresh,
283
- };
284
- query.if_seq_no = existing._seq_no;
285
- query.if_primary_term = existing._primary_term;
286
- try {
287
- await this.api.indexWithId(query);
288
- return doc;
289
- }
290
- catch (err) {
291
- // if there is a version conflict
292
- if (err.statusCode === 409 && err.message.includes('version conflict')) {
293
- this.logger.debug({ error: err }, `version conflict when updating "${recordId}" (${this.recordType})`);
294
- return this.updatePartial(recordId, applyChanges, index);
295
- }
296
- throw new TSError(err);
297
- }
298
- }
299
- async remove(recordId, index = this.defaultIndexName) {
300
- validateId(recordId, this.recordType);
301
- this.logger.trace(`removing record ${recordId}`);
302
- const query = {
303
- index,
304
- id: recordId,
305
- refresh: this.options.forceRefresh,
306
- };
307
- return this.api.remove(query);
308
- }
309
- async bulk(record, type = 'index', index = this.defaultIndexName) {
310
- if (this.isShuttingDown) {
311
- throw new TSError('Unable to send bulk record after shutdown', {
312
- context: {
313
- recordType: this.recordType,
314
- record,
315
- },
316
- });
317
- }
318
- const action = {
319
- [type]: { _index: index }
320
- };
321
- this.bulkQueue.push({
322
- action,
323
- data: type === 'delete' ? undefined : record
324
- });
325
- // We only flush once enough records have accumulated for it to make sense.
326
- if (this.bulkQueue.length >= this.options.bulkSize) {
327
- this.logger.trace(`flushing bulk queue ${this.bulkQueue.length}`);
328
- return this._flush();
329
- }
330
- // Bulk saving is a background operation so we don't have
331
- // anything meaningful to return.
332
- return Promise.resolve(true);
333
- }
334
- _destroy(err) {
335
- this.bulkQueue = [];
336
- this.isShuttingDown = true;
337
- if (err) {
338
- throw err;
339
- }
340
- return true;
341
- }
342
- async shutdown(forceShutdown = false) {
343
- const startTime = Date.now();
344
- this.logger.trace(`shutdown store, took ${ms(Date.now() - startTime)}`);
345
- clearInterval(this.flushInterval);
346
- if (forceShutdown !== true) {
347
- return this._flush(true);
348
- }
349
- const destroy = this._destroy.bind(this);
350
- const timeout = this.context.sysconfig.teraslice.shutdown_timeout;
351
- this.logger.trace(`attempting to shutdown, will destroy in ${timeout}`);
352
- setTimeout(destroy, timeout).unref();
353
- try {
354
- await this._flush(true);
355
- this._destroy();
356
- }
357
- catch (err) {
358
- this._destroy(err);
359
- }
360
- }
361
- async bulkSend(bulkRequest) {
362
- return this.api.bulkSend(bulkRequest);
363
- }
364
- async _flush(shuttingDown = false) {
365
- if (!this.bulkQueue.length)
366
- return;
367
- if (!shuttingDown && this.savingBulk)
368
- return;
369
- this.savingBulk = true;
370
- const bulkRequest = this.bulkQueue.slice();
371
- this.bulkQueue = [];
372
- try {
373
- const recordCount = await this.bulkSend(bulkRequest);
374
- const extraMsg = shuttingDown ? ', on shutdown' : '';
375
- this.logger.debug(`flushed ${recordCount}${extraMsg} records to index ${this.defaultIndexName}`);
376
- }
377
- finally {
378
- this.savingBulk = false;
379
- }
380
- }
381
- async sendTemplate(mapping) {
382
- if (mapping.template) {
383
- const clusterName = this.context.sysconfig.teraslice.name;
384
- const name = `${clusterName}_${this.recordType}_template`;
385
- // setting template name to reflect current teraslice instance name to help prevent
386
- // conflicts with differing versions of teraslice with same elastic db
387
- if (mapping.template) {
388
- if (!mapping.template.match(clusterName)) {
389
- mapping.template = `${clusterName}${mapping.template}`;
390
- }
391
- }
392
- return this.putTemplate(mapping, name);
393
- }
394
- return Promise.resolve(true);
395
- }
396
- _getDataTypeConfig() {
397
- switch (this.recordType) {
398
- case 'analytics':
399
- return {
400
- config: analyticsDataTypeConfig,
401
- template: analyticsTemplate
402
- };
403
- case 'asset':
404
- return {
405
- config: assetDataTypeConfig,
406
- overrides: assetMappingOverrides
407
- };
408
- case 'ex':
409
- return { config: executionDataTypeConfig };
410
- case 'job':
411
- return { config: jobDataTypeConfig };
412
- case 'state':
413
- return {
414
- config: stateDataTypeConfig,
415
- template: stateTemplate
416
- };
417
- default:
418
- throw new Error(`Could not find DataType config for recordType: ${this.recordType}`);
419
- }
420
- }
421
- _generateMapping() {
422
- const clientMetadata = this.api.getClientMetadata();
423
- const { config, overrides, template } = this._getDataTypeConfig();
424
- const dataType = new DataType(config);
425
- // Generate the mapping using DataType with client metadata for version-specific mappings
426
- this.mapping = dataType.toESMapping({
427
- ...clientMetadata,
428
- overrides: {
429
- ...overrides,
430
- settings: {
431
- 'index.number_of_shards': this.indexSettings.number_of_shards,
432
- 'index.number_of_replicas': this.indexSettings.number_of_replicas,
433
- }
434
- }
435
- });
436
- // Add template pattern if this is an index that
437
- // adds time at the end of the index (analytics/state)
438
- if (template) {
439
- this.mapping.template = template;
440
- }
441
- }
442
- async _createIndex(index = this.defaultIndexName) {
443
- // @ts-expect-error TODO: check type missing id
444
- const existQuery = { index };
445
- const exists = await this.api.indexExists(existQuery);
446
- if (!exists) {
447
- // Make sure the index exists before we do anything else.
448
- const createQuery = {
449
- index,
450
- body: this.mapping,
451
- };
452
- try {
453
- await this.sendTemplate(this.mapping);
454
- return await this.api.indexCreate(createQuery);
455
- }
456
- catch (err) {
457
- // It's not really an error if it's just that the index is already there
458
- if (parseError(err).includes('already_exists_exception')) {
459
- return true;
460
- }
461
- const error = new TSError(err, {
462
- reason: `Could not create index: ${index}`,
463
- });
464
- throw error;
465
- }
466
- }
467
- // Index already exists. nothing to do.
468
- return true;
469
- }
470
- async refresh(index = this.defaultIndexName) {
471
- const query = { index };
472
- return this.api.indexRefresh(query);
473
- }
474
- // TODO: fix type here
475
- async putTemplate(template, name) {
476
- return this.api.putTemplate(template, name);
477
- }
478
- verifyClient() {
479
- if (this.isShuttingDown)
480
- return false;
481
- return this.api.verifyClient();
482
- }
483
- async waitForClient() {
484
- if (this.api.verifyClient())
485
- return;
486
- await pWhile(async () => {
487
- if (this.isShuttingDown)
488
- throw new Error('Elasticsearch store is shutdown');
489
- if (this.api.verifyClient())
490
- return true;
491
- await pDelay(100);
492
- return false;
493
- });
494
- }
495
- }
496
- //# sourceMappingURL=elasticsearch_store.js.map
@@ -1,20 +0,0 @@
1
- import { FieldType } from '@terascope/types';
2
- export const analyticsDataTypeConfig = {
3
- version: 1,
4
- fields: {
5
- ex_id: { type: FieldType.Keyword },
6
- job_id: { type: FieldType.Keyword },
7
- worker_id: { type: FieldType.Keyword },
8
- slice_id: { type: FieldType.Keyword },
9
- slicer_id: { type: FieldType.Keyword },
10
- op: { type: FieldType.Keyword },
11
- order: { type: FieldType.Integer },
12
- count: { type: FieldType.Integer },
13
- state: { type: FieldType.Keyword },
14
- time: { type: FieldType.Integer },
15
- memory: { type: FieldType.Long },
16
- '@timestamp': { type: FieldType.Date }
17
- }
18
- };
19
- export const analyticsTemplate = '__analytics*';
20
- //# sourceMappingURL=analytics.js.map
@@ -1,32 +0,0 @@
1
- import { FieldType } from '@terascope/types';
2
- export const assetDataTypeConfig = {
3
- version: 1,
4
- fields: {
5
- name: { type: FieldType.Keyword },
6
- version: { type: FieldType.Keyword },
7
- id: { type: FieldType.Keyword },
8
- description: { type: FieldType.Keyword },
9
- arch: { type: FieldType.Keyword },
10
- platform: { type: FieldType.Keyword },
11
- node_version: { type: FieldType.Integer },
12
- _created: { type: FieldType.Date }
13
- }
14
- };
15
- /**
16
- * Override for the blob field which uses ES binary type.
17
- * I could not find the datatype equivalent
18
- * so we must add this field manually via mapping overrides.
19
- * Once the issue below is resolved we can remove this.
20
- * https://github.com/terascope/teraslice/issues/4296
21
- */
22
- export const assetMappingOverrides = {
23
- mappings: {
24
- properties: {
25
- blob: {
26
- type: 'binary',
27
- doc_values: false
28
- }
29
- }
30
- }
31
- };
32
- //# sourceMappingURL=asset.js.map
@@ -1,53 +0,0 @@
1
- import { FieldType } from '@terascope/types';
2
- export const executionDataTypeConfig = {
3
- version: 1,
4
- fields: {
5
- // ExecutionConfig fields
6
- job_id: { type: FieldType.Keyword },
7
- ex_id: { type: FieldType.Keyword },
8
- _context: { type: FieldType.Keyword },
9
- _created: { type: FieldType.Date },
10
- _updated: { type: FieldType.Date },
11
- _deleted: { type: FieldType.Boolean },
12
- _deleted_on: { type: FieldType.Date },
13
- _status: { type: FieldType.Keyword },
14
- _has_errors: { type: FieldType.Boolean },
15
- _slicer_stats: { type: FieldType.Object },
16
- _failureReason: { type: FieldType.Text },
17
- metadata: { type: FieldType.Object, indexed: false },
18
- recovered_execution: { type: FieldType.Keyword },
19
- recovered_slice_type: { type: FieldType.Keyword },
20
- slicer_port: { type: FieldType.Integer },
21
- slicer_hostname: { type: FieldType.Keyword },
22
- teraslice_version: { type: FieldType.Keyword },
23
- // ValidatedJobConfig fields
24
- active: { type: FieldType.Boolean },
25
- analytics: { type: FieldType.Boolean },
26
- assets: { type: FieldType.Keyword },
27
- autorecover: { type: FieldType.Boolean },
28
- lifecycle: { type: FieldType.Keyword },
29
- max_retries: { type: FieldType.Integer },
30
- name: { type: FieldType.Text },
31
- probation_window: { type: FieldType.Integer },
32
- performance_metrics: { type: FieldType.Boolean },
33
- log_level: { type: FieldType.Keyword },
34
- slicers: { type: FieldType.Integer },
35
- workers: { type: FieldType.Integer },
36
- stateful: { type: FieldType.Boolean },
37
- // k8s field
38
- cpu: { type: FieldType.Float },
39
- cpu_execution_controller: { type: FieldType.Float },
40
- ephemeral_storage: { type: FieldType.Boolean },
41
- memory: { type: FieldType.Integer },
42
- memory_execution_controller: { type: FieldType.Integer },
43
- resources_requests_cpu: { type: FieldType.Float },
44
- resources_requests_memory: { type: FieldType.Integer },
45
- resources_limits_cpu: { type: FieldType.Float },
46
- resources_limits_memory: { type: FieldType.Integer },
47
- kubernetes_image: { type: FieldType.Keyword },
48
- prom_metrics_enabled: { type: FieldType.Boolean },
49
- prom_metrics_port: { type: FieldType.Integer },
50
- prom_metrics_add_default: { type: FieldType.Boolean }
51
- }
52
- };
53
- //# sourceMappingURL=ex.js.map
@@ -1,42 +0,0 @@
1
- import { FieldType } from '@terascope/types';
2
- export const jobDataTypeConfig = {
3
- version: 1,
4
- fields: {
5
- // JobConfig fields
6
- job_id: { type: FieldType.Keyword },
7
- _context: { type: FieldType.Keyword },
8
- _created: { type: FieldType.Date },
9
- _updated: { type: FieldType.Date },
10
- _deleted: { type: FieldType.Boolean },
11
- _deleted_on: { type: FieldType.Date },
12
- // ValidatedJobConfig fields
13
- active: { type: FieldType.Boolean },
14
- analytics: { type: FieldType.Boolean },
15
- assets: { type: FieldType.Keyword },
16
- autorecover: { type: FieldType.Boolean },
17
- lifecycle: { type: FieldType.Keyword },
18
- max_retries: { type: FieldType.Integer },
19
- name: { type: FieldType.Text },
20
- probation_window: { type: FieldType.Integer },
21
- performance_metrics: { type: FieldType.Boolean },
22
- log_level: { type: FieldType.Keyword },
23
- slicers: { type: FieldType.Integer },
24
- workers: { type: FieldType.Integer },
25
- stateful: { type: FieldType.Boolean },
26
- // K8s fields
27
- cpu: { type: FieldType.Float },
28
- cpu_execution_controller: { type: FieldType.Float },
29
- ephemeral_storage: { type: FieldType.Boolean },
30
- memory: { type: FieldType.Integer },
31
- memory_execution_controller: { type: FieldType.Integer },
32
- resources_requests_cpu: { type: FieldType.Float },
33
- resources_requests_memory: { type: FieldType.Integer },
34
- resources_limits_cpu: { type: FieldType.Float },
35
- resources_limits_memory: { type: FieldType.Integer },
36
- kubernetes_image: { type: FieldType.Keyword },
37
- prom_metrics_enabled: { type: FieldType.Boolean },
38
- prom_metrics_port: { type: FieldType.Integer },
39
- prom_metrics_add_default: { type: FieldType.Boolean }
40
- }
41
- };
42
- //# sourceMappingURL=job.js.map
@@ -1,16 +0,0 @@
1
- import { FieldType } from '@terascope/types';
2
- export const stateDataTypeConfig = {
3
- version: 1,
4
- fields: {
5
- ex_id: { type: FieldType.Keyword },
6
- slice_id: { type: FieldType.Keyword },
7
- slicer_id: { type: FieldType.Keyword },
8
- slicer_order: { type: FieldType.Integer },
9
- state: { type: FieldType.Keyword },
10
- _created: { type: FieldType.Date },
11
- _updated: { type: FieldType.Date },
12
- error: { type: FieldType.Keyword }
13
- }
14
- };
15
- export const stateTemplate = '__state*';
16
- //# sourceMappingURL=state.js.map