teraslice 0.87.0 → 0.88.0

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 (69) hide show
  1. package/cluster-service.js +24 -18
  2. package/dist/src/index.js +42 -0
  3. package/package.json +11 -15
  4. package/service.js +4 -6
  5. package/worker-service.js +6 -6
  6. package/index.js +0 -21
  7. package/lib/cluster/cluster_master.js +0 -164
  8. package/lib/cluster/node_master.js +0 -393
  9. package/lib/cluster/services/api.js +0 -581
  10. package/lib/cluster/services/assets.js +0 -211
  11. package/lib/cluster/services/cluster/backends/kubernetes/deployments/worker.hbs +0 -86
  12. package/lib/cluster/services/cluster/backends/kubernetes/index.js +0 -225
  13. package/lib/cluster/services/cluster/backends/kubernetes/jobs/execution_controller.hbs +0 -69
  14. package/lib/cluster/services/cluster/backends/kubernetes/k8s.js +0 -450
  15. package/lib/cluster/services/cluster/backends/kubernetes/k8sResource.js +0 -443
  16. package/lib/cluster/services/cluster/backends/kubernetes/k8sState.js +0 -67
  17. package/lib/cluster/services/cluster/backends/kubernetes/utils.js +0 -58
  18. package/lib/cluster/services/cluster/backends/native/index.js +0 -611
  19. package/lib/cluster/services/cluster/backends/native/messaging.js +0 -563
  20. package/lib/cluster/services/cluster/backends/state-utils.js +0 -49
  21. package/lib/cluster/services/cluster/index.js +0 -15
  22. package/lib/cluster/services/execution.js +0 -459
  23. package/lib/cluster/services/jobs.js +0 -303
  24. package/lib/config/default-sysconfig.js +0 -47
  25. package/lib/config/index.js +0 -32
  26. package/lib/config/schemas/system.js +0 -333
  27. package/lib/processors/save_file/index.js +0 -9
  28. package/lib/processors/save_file/processor.js +0 -17
  29. package/lib/processors/save_file/schema.js +0 -17
  30. package/lib/processors/script.js +0 -130
  31. package/lib/processors/stdout/index.js +0 -9
  32. package/lib/processors/stdout/processor.js +0 -19
  33. package/lib/processors/stdout/schema.js +0 -18
  34. package/lib/storage/analytics.js +0 -106
  35. package/lib/storage/assets.js +0 -275
  36. package/lib/storage/backends/elasticsearch_store.js +0 -567
  37. package/lib/storage/backends/mappings/analytics.json +0 -49
  38. package/lib/storage/backends/mappings/asset.json +0 -40
  39. package/lib/storage/backends/mappings/ex.json +0 -55
  40. package/lib/storage/backends/mappings/job.json +0 -31
  41. package/lib/storage/backends/mappings/state.json +0 -37
  42. package/lib/storage/execution.js +0 -331
  43. package/lib/storage/index.js +0 -16
  44. package/lib/storage/jobs.js +0 -97
  45. package/lib/storage/state.js +0 -302
  46. package/lib/utils/api_utils.js +0 -173
  47. package/lib/utils/asset_utils.js +0 -117
  48. package/lib/utils/date_utils.js +0 -58
  49. package/lib/utils/encoding_utils.js +0 -29
  50. package/lib/utils/events.js +0 -7
  51. package/lib/utils/file_utils.js +0 -118
  52. package/lib/utils/id_utils.js +0 -19
  53. package/lib/utils/port_utils.js +0 -83
  54. package/lib/workers/assets/loader.js +0 -109
  55. package/lib/workers/assets/spawn.js +0 -78
  56. package/lib/workers/context/execution-context.js +0 -16
  57. package/lib/workers/context/terafoundation-context.js +0 -10
  58. package/lib/workers/execution-controller/execution-analytics.js +0 -211
  59. package/lib/workers/execution-controller/index.js +0 -1033
  60. package/lib/workers/execution-controller/recovery.js +0 -188
  61. package/lib/workers/execution-controller/scheduler.js +0 -461
  62. package/lib/workers/execution-controller/slice-analytics.js +0 -115
  63. package/lib/workers/helpers/job.js +0 -93
  64. package/lib/workers/helpers/op-analytics.js +0 -22
  65. package/lib/workers/helpers/terafoundation.js +0 -43
  66. package/lib/workers/helpers/worker-shutdown.js +0 -187
  67. package/lib/workers/metrics/index.js +0 -139
  68. package/lib/workers/worker/index.js +0 -344
  69. package/lib/workers/worker/slice.js +0 -143
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const { get, logError } = require('@terascope/utils');
4
- const { shutdownHandler } = require('./lib/workers/helpers/worker-shutdown');
5
- const makeTerafoundationContext = require('./lib/workers/context/terafoundation-context');
6
- const makeClusterMaster = require('./lib/cluster/cluster_master');
7
- const makeAssetService = require('./lib/cluster/services/assets');
4
+ const { shutdownHandler } = require('./dist/src/lib/workers/helpers/worker-shutdown');
5
+ const { makeTerafoundationContext } = require('./dist/src/lib/workers/context/terafoundation-context');
6
+ const { ClusterMaster } = require('./dist/src/lib/cluster/cluster_master');
7
+ const { AssetsService } = require('./dist/src/lib/cluster/services');
8
8
 
9
9
  class Service {
10
10
  constructor(context) {
@@ -19,10 +19,10 @@ class Service {
19
19
 
20
20
  if (assignment === 'cluster_master') {
21
21
  // require this here so node doesn't have load extra code into memory
22
- this.instance = makeClusterMaster(this.context);
22
+ this.instance = new ClusterMaster(this.context);
23
23
  } else if (assignment === 'assets_service') {
24
24
  // require this here so node doesn't have load extra code into memory
25
- this.instance = makeAssetService(this.context);
25
+ this.instance = new AssetsService(this.context);
26
26
  }
27
27
 
28
28
  await this.instance.initialize();
@@ -42,16 +42,22 @@ class Service {
42
42
  }
43
43
  }
44
44
 
45
- const context = makeTerafoundationContext();
46
- const cmd = new Service(context);
47
-
48
- cmd.shutdownHandler = shutdownHandler(context, () => {
49
- if (!cmd.instance) return Promise.resolve();
50
- return cmd.instance.shutdown();
51
- });
45
+ async function main() {
46
+ const context = makeTerafoundationContext();
47
+ const cmd = new Service(context);
48
+
49
+ cmd.shutdownHandler = shutdownHandler(context, () => {
50
+ if (!cmd.instance) return Promise.resolve();
51
+ return cmd.instance.shutdown();
52
+ });
53
+
54
+ try {
55
+ await cmd.initialize();
56
+ await cmd.run();
57
+ await cmd.shutdown();
58
+ } catch (err) {
59
+ cmd.shutdown(err);
60
+ }
61
+ }
52
62
 
53
- Promise.resolve()
54
- .then(() => cmd.initialize())
55
- .then(() => cmd.run())
56
- .then(() => cmd.shutdown())
57
- .catch((err) => cmd.shutdown(err));
63
+ main();
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * Export of internal components and functions of teraslice.
4
+ *
5
+ * WARNING:
6
+ * Since these are internal components, breaking changes may occur if using them.
7
+ * For best results teraslice with an exact semver match, i.e "0.38.0".
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.stores = exports.config = exports.makeTerafoundationContext = exports.initializeTestExecution = void 0;
34
+ const config = __importStar(require("./lib/config"));
35
+ exports.config = config;
36
+ const stores = __importStar(require("./lib/storage"));
37
+ exports.stores = stores;
38
+ const terafoundation_context_1 = require("./lib/workers/context/terafoundation-context");
39
+ Object.defineProperty(exports, "makeTerafoundationContext", { enumerable: true, get: function () { return terafoundation_context_1.makeTerafoundationContext; } });
40
+ const job_1 = require("./lib/workers/helpers/job");
41
+ Object.defineProperty(exports, "initializeTestExecution", { enumerable: true, get: function () { return job_1.initializeTestExecution; } });
42
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "teraslice",
3
3
  "displayName": "Teraslice",
4
- "version": "0.87.0",
4
+ "version": "0.88.0",
5
5
  "description": "Distributed computing platform for processing JSON data",
6
6
  "homepage": "https://github.com/terascope/teraslice#readme",
7
7
  "bugs": {
@@ -13,14 +13,8 @@
13
13
  },
14
14
  "license": "Apache-2.0",
15
15
  "author": "Terascope, LLC <info@terascope.io>",
16
- "main": "index.js",
17
- "bin": "service.js",
18
- "directories": {
19
- "lib": "lib",
20
- "bin": "service.js",
21
- "test": "test",
22
- "main": "index.js"
23
- },
16
+ "main": "dist/src/index.js",
17
+ "typings": "dist/src/index.d.ts",
24
18
  "files": [
25
19
  "*.js",
26
20
  "lib/**/*",
@@ -41,10 +35,11 @@
41
35
  "ms": "^2.1.3"
42
36
  },
43
37
  "dependencies": {
44
- "@terascope/elasticsearch-api": "^3.11.0",
45
- "@terascope/job-components": "^0.64.0",
46
- "@terascope/teraslice-messaging": "^0.34.0",
47
- "@terascope/utils": "^0.51.0",
38
+ "@terascope/elasticsearch-api": "^3.12.0",
39
+ "@terascope/job-components": "^0.65.0",
40
+ "@terascope/teraslice-messaging": "^0.35.0",
41
+ "@terascope/types": "^0.12.0",
42
+ "@terascope/utils": "^0.52.0",
48
43
  "async-mutex": "^0.4.0",
49
44
  "barbe": "^3.0.16",
50
45
  "body-parser": "^1.20.2",
@@ -66,11 +61,12 @@
66
61
  "semver": "^7.3.8",
67
62
  "socket.io": "^1.7.4",
68
63
  "socket.io-client": "^1.7.4",
69
- "terafoundation": "^0.51.0",
64
+ "terafoundation": "^0.53.0",
70
65
  "uuid": "^9.0.0"
71
66
  },
72
67
  "devDependencies": {
73
68
  "@terascope/teraslice-op-test-harness": "^1.24.1",
69
+ "@types/express": "^4.17.20",
74
70
  "archiver": "^5.3.1",
75
71
  "bufferstreams": "^3.0.0",
76
72
  "chance": "^1.1.11",
@@ -89,7 +85,7 @@
89
85
  "registry": "https://registry.npmjs.org/"
90
86
  },
91
87
  "terascope": {
92
- "main": true,
88
+ "main": false,
93
89
  "enableTypedoc": false,
94
90
  "testSuite": "elasticsearch"
95
91
  }
package/service.js CHANGED
@@ -3,8 +3,10 @@
3
3
  'use strict';
4
4
 
5
5
  const util = require('util');
6
-
7
- const { safeEncode, safeDecode } = require('./lib/utils/encoding_utils');
6
+ const { ClusterContext } = require('terafoundation');
7
+ const { safeEncode, safeDecode } = require('./dist/src/lib/utils/encoding_utils');
8
+ const { nodeMaster } = require('./dist/src/lib/cluster/node_master');
9
+ const { getTerasliceConfig } = require('./dist/src/lib/config');
8
10
 
9
11
  const assignment = process.env.assignment || process.env.NODE_TYPE;
10
12
 
@@ -28,10 +30,6 @@ if (['execution_controller', 'worker'].includes(assignment)) {
28
30
  process.env.assignment = 'node_master';
29
31
  process.env.NODE_TYPE = 'node_master';
30
32
 
31
- const { ClusterContext } = require('terafoundation');
32
- const nodeMaster = require('./lib/cluster/node_master');
33
- const { getTerasliceConfig } = require('./lib/config');
34
-
35
33
  const terasliceConfig = getTerasliceConfig({
36
34
  master: nodeMaster,
37
35
  cluster_master: deprecatedUseOf('cluster_master'),
package/worker-service.js CHANGED
@@ -3,12 +3,12 @@
3
3
  const {
4
4
  logError, get, isEmpty, isPlainObject
5
5
  } = require('@terascope/utils');
6
- const { shutdownHandler } = require('./lib/workers/helpers/worker-shutdown');
7
- const { safeDecode } = require('./lib/utils/encoding_utils');
8
- const makeExecutionContext = require('./lib/workers/context/execution-context');
9
- const makeTerafoundationContext = require('./lib/workers/context/terafoundation-context');
10
- const ExecutionController = require('./lib/workers/execution-controller');
11
- const Worker = require('./lib/workers/worker');
6
+ const { shutdownHandler } = require('./dist/src/lib/workers/helpers/worker-shutdown');
7
+ const { safeDecode } = require('./dist/src/lib/utils/encoding_utils');
8
+ const { makeExecutionContext } = require('./dist/src/lib/workers/context/execution-context');
9
+ const { makeTerafoundationContext } = require('./dist/src/lib/workers/context/terafoundation-context');
10
+ const { ExecutionController } = require('./dist/src/lib/workers/execution-controller');
11
+ const { Worker } = require('./dist/src/lib/workers/worker');
12
12
 
13
13
  class Service {
14
14
  constructor(context) {
package/index.js DELETED
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Export of internal components and functions of teraslice.
5
- *
6
- * WARNING:
7
- * Since these are internal components, breaking changes may occur if using them.
8
- * For best results teraslice with an exact semver match, i.e "0.38.0".
9
- */
10
-
11
- const config = require('./lib/config');
12
- const stores = require('./lib/storage');
13
- const makeTerafoundationContext = require('./lib/workers/context/terafoundation-context');
14
- const { initializeTestExecution } = require('./lib/workers/helpers/job');
15
-
16
- module.exports = {
17
- initializeTestExecution,
18
- makeTerafoundationContext,
19
- config,
20
- stores,
21
- };
@@ -1,164 +0,0 @@
1
- 'use strict';
2
-
3
- const express = require('express');
4
- const got = require('got');
5
- const {
6
- pDelay, logError, get, parseError
7
- } = require('@terascope/utils');
8
- const { ClusterMaster } = require('@terascope/teraslice-messaging');
9
- const { makeLogger } = require('../workers/helpers/terafoundation');
10
- const makeExecutionService = require('./services/execution');
11
- const makeApiService = require('./services/api');
12
- const makeJobsService = require('./services/jobs');
13
- const makeClusterService = require('./services/cluster');
14
- const makeJobStore = require('../storage/jobs');
15
- const makeExStore = require('../storage/execution');
16
- const makeStateStore = require('../storage/state');
17
-
18
- module.exports = function _clusterMaster(context) {
19
- const logger = makeLogger(context, 'cluster_master');
20
- const clusterConfig = context.sysconfig.teraslice;
21
- const assetsPort = process.env.assets_port;
22
- const assetsUrl = `http://127.0.0.1:${assetsPort}`;
23
- let running = false;
24
-
25
- // Initialize the HTTP service for handling incoming requests.
26
- const app = express();
27
-
28
- const clusterMasterServer = new ClusterMaster.Server({
29
- port: clusterConfig.port,
30
- nodeDisconnectTimeout: clusterConfig.node_disconnect_timeout,
31
- // setting request timeout to 5 minutes
32
- serverTimeout: clusterConfig.api_response_timeout,
33
- // we do this to override express final response handler
34
- requestListener(req, res) {
35
- app(req, res, (err) => {
36
- if (err) logger.warn(err, 'unexpected server error');
37
- res.setHeader('Content-Type', 'application/json');
38
- res.statusCode = 500;
39
- res.end(JSON.stringify({ error: 'api is not available' }));
40
- });
41
- },
42
- networkLatencyBuffer: clusterConfig.network_latency_buffer,
43
- actionTimeout: clusterConfig.action_timeout,
44
- logger,
45
- });
46
-
47
- async function isAssetServiceUp() {
48
- try {
49
- const response = await got.get('status', {
50
- prefixUrl: assetsUrl,
51
- responseType: 'json',
52
- throwHttpErrors: true,
53
- timeout: 900,
54
- retry: 0,
55
- });
56
- return get(response, 'body.available', false);
57
- } catch (err) {
58
- logger.debug(`asset service not up yet, error: ${parseError(err)}`);
59
- return false;
60
- }
61
- }
62
-
63
- function waitForAssetsService(timeoutAt) {
64
- if (Date.now() > timeoutAt) {
65
- return Promise.reject(new Error('Timeout waiting for asset service to come online'));
66
- }
67
- return isAssetServiceUp().then((isUp) => {
68
- if (isUp) return Promise.resolve();
69
- return pDelay(1000).then(() => waitForAssetsService(timeoutAt));
70
- });
71
- }
72
-
73
- const serviceOptions = { assetsUrl, app, clusterMasterServer };
74
- const services = Object.freeze({
75
- execution: makeExecutionService(context, serviceOptions),
76
- jobs: makeJobsService(context, serviceOptions),
77
- cluster: makeClusterService(context, serviceOptions),
78
- api: makeApiService(context, serviceOptions),
79
- });
80
-
81
- context.services = services;
82
-
83
- return {
84
- async initialize() {
85
- try {
86
- await clusterMasterServer.start();
87
- logger.info(`cluster master listening on port ${clusterConfig.port}`);
88
-
89
- const [exStore, stateStore, jobStore] = await Promise.all([
90
- makeExStore(context),
91
- makeStateStore(context),
92
- makeJobStore(context)
93
- ]);
94
-
95
- context.stores = {
96
- execution: exStore,
97
- state: stateStore,
98
- jobs: jobStore,
99
- };
100
-
101
- // order matters
102
- await services.cluster.initialize();
103
- await services.execution.initialize();
104
- await services.jobs.initialize();
105
-
106
- logger.debug('services has been initialized');
107
-
108
- // give the assets service a bit to come up
109
- const fiveMinutes = 5 * 60 * 1000;
110
- await waitForAssetsService(Date.now() + fiveMinutes);
111
-
112
- // this needs to be last
113
- await services.api.initialize();
114
-
115
- logger.info('cluster master is ready!');
116
- running = true;
117
- } catch (err) {
118
- logError(logger, err, 'error during service initialization');
119
- running = false;
120
- throw err;
121
- }
122
- },
123
- run() {
124
- return new Promise((resolve) => {
125
- if (!running) {
126
- resolve();
127
- return;
128
- }
129
- const runningInterval = setInterval(() => {
130
- if (!running) {
131
- clearInterval(runningInterval);
132
- resolve();
133
- }
134
- }, 1000);
135
- });
136
- },
137
- async shutdown() {
138
- running = false;
139
-
140
- logger.info('cluster_master is shutting down');
141
- clusterMasterServer.isShuttingDown = true;
142
-
143
- await Promise.all(Object.entries(context.services)
144
- .map(async ([name, service]) => {
145
- try {
146
- await service.shutdown();
147
- } catch (err) {
148
- logError(logger, err, `Failure to shutdown service ${name}`);
149
- }
150
- }));
151
-
152
- await Promise.all(Object.entries(context.stores)
153
- .map(async ([name, store]) => {
154
- try {
155
- await store.shutdown();
156
- } catch (err) {
157
- logError(logger, err, `Failure to shutdown store ${name}`);
158
- }
159
- }));
160
-
161
- await clusterMasterServer.shutdown();
162
- },
163
- };
164
- };