verteilen-core 1.2.4 → 1.2.7
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.
- package/dist/client/analysis.d.ts +35 -0
- package/dist/client/analysis.js +382 -0
- package/dist/client/client.d.ts +25 -0
- package/dist/client/client.js +227 -0
- package/dist/client/cluster.d.ts +1 -0
- package/dist/{src/client → client}/cluster.js +1 -2
- package/dist/client/database.d.ts +13 -0
- package/dist/client/database.js +37 -0
- package/dist/client/execute.d.ts +24 -0
- package/dist/{src/client → client}/execute.js +61 -51
- package/dist/client/http.d.ts +7 -0
- package/dist/client/http.js +40 -0
- package/dist/client/javascript.d.ts +47 -0
- package/dist/{src/client → client}/javascript.js +110 -136
- package/dist/client/job_database.d.ts +10 -0
- package/dist/client/job_database.js +34 -0
- package/dist/client/job_execute.d.ts +20 -0
- package/dist/client/job_execute.js +173 -0
- package/dist/client/os.d.ts +29 -0
- package/dist/client/os.js +197 -0
- package/dist/client/resource.d.ts +7 -0
- package/dist/client/resource.js +107 -0
- package/dist/client/shell.d.ts +16 -0
- package/dist/client/shell.js +122 -0
- package/dist/computed.d.ts +13 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -3
- package/dist/interface/base.d.ts +70 -0
- package/dist/interface/bus.d.ts +90 -0
- package/dist/interface/enum.d.ts +143 -0
- package/dist/interface/execute.d.ts +20 -0
- package/dist/interface/record.d.ts +93 -0
- package/dist/interface/server.d.ts +76 -0
- package/dist/interface/struct.d.ts +182 -0
- package/dist/interface/table.d.ts +20 -0
- package/dist/interface/ui.d.ts +29 -0
- package/dist/interface.d.ts +29 -0
- package/dist/plugins/i18n.d.ts +1666 -0
- package/dist/script/console_manager.d.ts +18 -0
- package/dist/script/console_manager.js +131 -0
- package/dist/script/console_server_manager.d.ts +13 -0
- package/dist/script/console_server_manager.js +40 -0
- package/dist/script/execute/base.d.ts +45 -0
- package/dist/script/execute/base.js +200 -0
- package/dist/script/execute/feedback.d.ts +12 -0
- package/dist/script/execute/feedback.js +179 -0
- package/dist/script/execute/interface.d.ts +8 -0
- package/dist/script/execute/region_job.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_job.js +1 -0
- package/dist/script/execute/region_project.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_project.js +4 -0
- package/dist/script/execute/region_subtask.d.ts +5 -0
- package/dist/{src/script → script}/execute/region_subtask.js +1 -0
- package/dist/script/execute/region_task.d.ts +10 -0
- package/dist/{src/script → script}/execute/region_task.js +4 -0
- package/dist/script/execute/runner.d.ts +14 -0
- package/dist/script/execute/runner.js +264 -0
- package/dist/script/execute/util_parser.d.ts +14 -0
- package/dist/script/execute/util_parser.js +135 -0
- package/dist/script/execute_manager.d.ts +25 -0
- package/dist/script/execute_manager.js +297 -0
- package/dist/script/socket_manager.d.ts +31 -0
- package/dist/script/socket_manager.js +263 -0
- package/dist/script/webhook_manager.d.ts +3 -0
- package/dist/script/webhook_server_manager.d.ts +13 -0
- package/dist/script/webhook_server_manager.js +133 -0
- package/dist/server/detail.d.ts +72 -0
- package/dist/server/detail.js +451 -0
- package/dist/server/io.d.ts +46 -0
- package/dist/{src/server → server}/io.js +42 -51
- package/dist/server/plugin.d.ts +18 -0
- package/dist/{src/server → server}/plugin.js +45 -54
- package/dist/server/server.d.ts +27 -0
- package/dist/server/server.js +53 -0
- package/dist/server.d.ts +4 -0
- package/dist/util/console_handle.d.ts +20 -0
- package/dist/util/console_handle.js +244 -0
- package/dist/util/log_handle.d.ts +23 -0
- package/dist/util/log_handle.js +224 -0
- package/index.ts +1 -6
- package/package.json +1 -1
- package/src/index.ts +6 -0
- package/test/TEST.d.ts +1 -0
- package/test/TEST.js +88 -0
- package/test/client/execute.test.d.ts +1 -0
- package/{dist/test → test}/client/execute.test.js +6 -15
- package/test/client/javascript.test.d.ts +1 -0
- package/{dist/test → test}/client/javascript.test.js +21 -30
- package/test/client/server.test.d.ts +1 -0
- package/test/client/task.test.d.ts +1 -0
- package/{dist/test → test}/client/task.test.js +1 -1
- package/test/script/parser.test.d.ts +1 -0
- package/test/script/socket.test.d.ts +1 -0
- package/tsconfig.json +8 -4
- package/dist/jest.config.js +0 -8
- package/dist/src/client/analysis.js +0 -383
- package/dist/src/client/client.js +0 -233
- package/dist/src/client/database.js +0 -36
- package/dist/src/client/http.js +0 -37
- package/dist/src/client/job_database.js +0 -36
- package/dist/src/client/job_execute.js +0 -171
- package/dist/src/client/job_parameter.js +0 -36
- package/dist/src/client/os.js +0 -202
- package/dist/src/client/parameter.js +0 -36
- package/dist/src/client/resource.js +0 -118
- package/dist/src/client/shell.js +0 -118
- package/dist/src/script/console_manager.js +0 -125
- package/dist/src/script/console_server_manager.js +0 -37
- package/dist/src/script/execute/base.js +0 -197
- package/dist/src/script/execute/feedback.js +0 -188
- package/dist/src/script/execute/runner.js +0 -274
- package/dist/src/script/execute/util_parser.js +0 -137
- package/dist/src/script/execute_manager.js +0 -309
- package/dist/src/script/socket_manager.js +0 -260
- package/dist/src/script/webhook_server_manager.js +0 -140
- package/dist/src/server/detail.js +0 -428
- package/dist/src/server/server.js +0 -51
- package/dist/src/util/console_handle.js +0 -248
- package/dist/src/util/log_handle.js +0 -230
- package/dist/src/util/server/console_handle.js +0 -248
- package/dist/src/util/server/log_handle.js +0 -230
- package/dist/test/TEST.js +0 -105
- /package/dist/{src/computed.js → computed.js} +0 -0
- /package/dist/{src/interface → interface}/base.js +0 -0
- /package/dist/{src/interface → interface}/bus.js +0 -0
- /package/dist/{src/interface → interface}/enum.js +0 -0
- /package/dist/{src/interface → interface}/execute.js +0 -0
- /package/dist/{src/interface → interface}/record.js +0 -0
- /package/dist/{src/interface → interface}/server.js +0 -0
- /package/dist/{src/interface → interface}/struct.js +0 -0
- /package/dist/{src/interface → interface}/table.js +0 -0
- /package/dist/{src/interface → interface}/ui.js +0 -0
- /package/dist/{src/interface.js → interface.js} +0 -0
- /package/dist/{src/lan → lan}/en.json +0 -0
- /package/dist/{src/lan → lan}/zh_TW.json +0 -0
- /package/dist/{src/plugins → plugins}/i18n.js +0 -0
- /package/dist/{src/script → script}/execute/interface.js +0 -0
- /package/dist/{src/script → script}/webhook_manager.js +0 -0
- /package/dist/{src/server.js → server.js} +0 -0
- /package/{dist/test → test}/client/server.test.js +0 -0
- /package/{dist/test → test}/script/parser.test.js +0 -0
- /package/{dist/test → test}/script/socket.test.js +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BusType, EmitterProxy, Header, RawSend } from "../interface";
|
|
2
|
+
export type Listener = (...args: any[]) => void;
|
|
3
|
+
export declare class ConsoleManager {
|
|
4
|
+
url: string;
|
|
5
|
+
ws: WebSocket;
|
|
6
|
+
emitter: EmitterProxy<BusType>;
|
|
7
|
+
messager_log: Function;
|
|
8
|
+
events: Array<[string, Array<Listener>]>;
|
|
9
|
+
events_once: Array<[string, Array<Listener>]>;
|
|
10
|
+
buffer: Array<Header>;
|
|
11
|
+
constructor(_url: string, _messager_log: Function, _emitter: EmitterProxy<BusType>);
|
|
12
|
+
get connected(): boolean;
|
|
13
|
+
on: (channel: string, listener: Listener) => void;
|
|
14
|
+
once: (channel: string, listener: Listener) => void;
|
|
15
|
+
off: (channel: string, listener: Listener) => void;
|
|
16
|
+
send: (data: RawSend) => void;
|
|
17
|
+
received: (h: Header) => void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleManager = void 0;
|
|
4
|
+
class ConsoleManager {
|
|
5
|
+
url;
|
|
6
|
+
ws;
|
|
7
|
+
emitter;
|
|
8
|
+
messager_log;
|
|
9
|
+
events;
|
|
10
|
+
events_once;
|
|
11
|
+
buffer = [];
|
|
12
|
+
constructor(_url, _messager_log, _emitter) {
|
|
13
|
+
this.messager_log = _messager_log;
|
|
14
|
+
this.url = _url;
|
|
15
|
+
this.emitter = _emitter;
|
|
16
|
+
this.events = [];
|
|
17
|
+
this.events_once = [];
|
|
18
|
+
this.ws = new WebSocket(this.url);
|
|
19
|
+
this.ws.onerror = (err) => {
|
|
20
|
+
this.messager_log(`[Error] Express Connection failed ${this.url}`);
|
|
21
|
+
};
|
|
22
|
+
this.ws.onclose = (ev) => {
|
|
23
|
+
this.messager_log(`[Close] Express Client close, ${ev.code}, ${ev.reason}`);
|
|
24
|
+
this.buffer = [];
|
|
25
|
+
};
|
|
26
|
+
this.ws.onopen = () => {
|
|
27
|
+
this.messager_log('[Connection] Express New Connection !');
|
|
28
|
+
for (let i = 0; i < this.buffer.length; i++) {
|
|
29
|
+
this.ws.send(JSON.stringify(this.buffer[i]));
|
|
30
|
+
}
|
|
31
|
+
this.buffer = [];
|
|
32
|
+
};
|
|
33
|
+
this.ws.onmessage = (ev) => {
|
|
34
|
+
this.received(JSON.parse(ev.data.toString()));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
get connected() {
|
|
38
|
+
return this.ws.readyState === 1;
|
|
39
|
+
}
|
|
40
|
+
on = (channel, listener) => {
|
|
41
|
+
const index = this.events.findIndex(x => x[0] == channel);
|
|
42
|
+
if (index == -1) {
|
|
43
|
+
this.events.push([channel, [listener]]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.events[index][1].push(listener);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
once = (channel, listener) => {
|
|
50
|
+
const index = this.events.findIndex(x => x[0] == channel);
|
|
51
|
+
if (index == -1) {
|
|
52
|
+
this.events_once.push([channel, [listener]]);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.events_once[index][1].push(listener);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
off = (channel, listener) => {
|
|
59
|
+
const index = this.events.findIndex(x => x[0] == channel);
|
|
60
|
+
if (index == -1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const index2 = this.events[index][1].findIndex(x => x == listener);
|
|
65
|
+
if (index2 != -1)
|
|
66
|
+
this.events[index][1].splice(index2, 1);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
send = (data) => {
|
|
70
|
+
const d = {
|
|
71
|
+
name: data.name,
|
|
72
|
+
token: data.token,
|
|
73
|
+
data: data.data
|
|
74
|
+
};
|
|
75
|
+
if (this.ws.readyState !== WebSocket.OPEN) {
|
|
76
|
+
this.buffer.push(d);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.ws.send(JSON.stringify(d));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
received = (h) => {
|
|
83
|
+
if (h == undefined) {
|
|
84
|
+
this.messager_log('[Source Analysis] Analysis Failed, Value is undefined');
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (h.message != undefined && h.message.length > 0) {
|
|
88
|
+
this.messager_log(`[Source Analysis] ${h.message}`);
|
|
89
|
+
}
|
|
90
|
+
if (h.data == undefined)
|
|
91
|
+
return;
|
|
92
|
+
const index = this.events.findIndex(x => x[0] == h.name);
|
|
93
|
+
const index2 = this.events_once.findIndex(x => x[0] == h.name);
|
|
94
|
+
let p = false;
|
|
95
|
+
if (index != -1) {
|
|
96
|
+
const castingFunc = this.events[index][1];
|
|
97
|
+
castingFunc.forEach(x => {
|
|
98
|
+
if (h.data instanceof Array) {
|
|
99
|
+
if (h.data.length == 1)
|
|
100
|
+
x(h.data[0]);
|
|
101
|
+
else
|
|
102
|
+
x(...h.data);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
x(h.data);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
p = true;
|
|
109
|
+
}
|
|
110
|
+
if (index2 != -1) {
|
|
111
|
+
const castingFunc = this.events_once[index2][1];
|
|
112
|
+
castingFunc.forEach(x => {
|
|
113
|
+
if (h.data instanceof Array) {
|
|
114
|
+
if (h.data.length == 1)
|
|
115
|
+
x(h.data[0]);
|
|
116
|
+
else
|
|
117
|
+
x(...h.data);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
x(h.data);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
this.events_once.splice(index2, 1);
|
|
124
|
+
p = true;
|
|
125
|
+
}
|
|
126
|
+
if (!p) {
|
|
127
|
+
this.messager_log(`[Source Analysis] Analysis Failed, Unknowed header, name: ${h.name}, meta: ${h.meta}`);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
exports.ConsoleManager = ConsoleManager;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as ws from 'ws';
|
|
2
|
+
import { Header } from "../interface";
|
|
3
|
+
type calltype = {
|
|
4
|
+
[key: string]: Function;
|
|
5
|
+
};
|
|
6
|
+
export declare class ConsoleServerManager {
|
|
7
|
+
ws: ws.WebSocket;
|
|
8
|
+
typeMap: calltype;
|
|
9
|
+
messager_log: Function;
|
|
10
|
+
constructor(_ws: ws.WebSocket, _messager_log: Function, _typeMap: calltype);
|
|
11
|
+
Analysis: (h: Header) => void;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleServerManager = void 0;
|
|
4
|
+
class ConsoleServerManager {
|
|
5
|
+
ws;
|
|
6
|
+
typeMap;
|
|
7
|
+
messager_log;
|
|
8
|
+
constructor(_ws, _messager_log, _typeMap) {
|
|
9
|
+
this.messager_log = _messager_log;
|
|
10
|
+
this.ws = _ws;
|
|
11
|
+
this.typeMap = _typeMap;
|
|
12
|
+
}
|
|
13
|
+
Analysis = (h) => {
|
|
14
|
+
if (h == undefined) {
|
|
15
|
+
this.messager_log('[Source Analysis] Failed, Get a undefined value');
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (h.message != undefined && h.message.length > 0) {
|
|
19
|
+
this.messager_log(`[Source Analysis] ${h.message}`);
|
|
20
|
+
}
|
|
21
|
+
if (h.data == undefined)
|
|
22
|
+
return;
|
|
23
|
+
if (this.typeMap.hasOwnProperty(h.name)) {
|
|
24
|
+
const castingFunc = this.typeMap[h.name];
|
|
25
|
+
if (h.data instanceof Array) {
|
|
26
|
+
if (h.data.length == 1)
|
|
27
|
+
castingFunc(this.ws, h.data[0]);
|
|
28
|
+
else
|
|
29
|
+
castingFunc(this.ws, ...h.data);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
castingFunc(this.ws, h.data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.messager_log(`[Source Analysis] Failed, Unknown, name: ${h.name}, meta: ${h.meta}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.ConsoleServerManager = ConsoleServerManager;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CronJobState, ExecuteProxy, ExecuteState, Job, Libraries, Messager, Database, Project, Record, Task, WebsocketPack, WorkState } from "../../interface";
|
|
2
|
+
import { WebsocketManager } from "../socket_manager";
|
|
3
|
+
import { Util_Parser } from './util_parser';
|
|
4
|
+
export declare class ExecuteManager_Base {
|
|
5
|
+
uuid: string;
|
|
6
|
+
name: string;
|
|
7
|
+
record: Record;
|
|
8
|
+
current_t: Task | undefined;
|
|
9
|
+
current_p: Project | undefined;
|
|
10
|
+
current_projects: Array<Project>;
|
|
11
|
+
current_nodes: Array<WebsocketPack>;
|
|
12
|
+
current_cron: Array<CronJobState>;
|
|
13
|
+
current_job: Array<WorkState>;
|
|
14
|
+
current_multithread: number;
|
|
15
|
+
current_task_count: number;
|
|
16
|
+
state: ExecuteState;
|
|
17
|
+
t_state: ExecuteState;
|
|
18
|
+
jobstack: number;
|
|
19
|
+
first: boolean;
|
|
20
|
+
libs: Libraries | undefined;
|
|
21
|
+
proxy: ExecuteProxy | undefined;
|
|
22
|
+
localPara: Database | undefined;
|
|
23
|
+
websocket_manager: WebsocketManager;
|
|
24
|
+
messager_log: Messager;
|
|
25
|
+
constructor(_name: string, _websocket_manager: WebsocketManager, _messager_log: Messager, _record: Record);
|
|
26
|
+
protected sync_local_para: (target: Database) => void;
|
|
27
|
+
protected sync_para: (target: Database, source: WebsocketPack) => void;
|
|
28
|
+
protected release: (source: WebsocketPack) => void;
|
|
29
|
+
protected check_all_cron_end: () => boolean;
|
|
30
|
+
protected check_cron_end: (cron: CronJobState) => boolean;
|
|
31
|
+
protected check_single_end: () => boolean;
|
|
32
|
+
protected validation: (projects: Array<Project>) => boolean;
|
|
33
|
+
protected filter_lib: (projects: Array<Project>, lib: Libraries) => Libraries;
|
|
34
|
+
protected get_task_multi_count: (t: Task) => number;
|
|
35
|
+
get_task_state_count(t: Task): number;
|
|
36
|
+
protected get_number(key: string): number;
|
|
37
|
+
static get_number_global(key: string, localPara: Database | undefined): number;
|
|
38
|
+
protected removeDups: (arr: any[]) => any[];
|
|
39
|
+
protected get_idle: () => Array<WebsocketPack>;
|
|
40
|
+
protected get_idle_open: () => Array<WebsocketPack>;
|
|
41
|
+
protected check_socket_state: (target: WebsocketPack) => ExecuteState.NONE | ExecuteState.RUNNING;
|
|
42
|
+
static string_args_transform: (task: Task, job: Job, messager_log: Messager, localPara: Database, n: number) => void;
|
|
43
|
+
static property_update: (task: Task, e: Util_Parser) => Util_Parser;
|
|
44
|
+
static database_update: (localPara: Database, n?: number) => Util_Parser;
|
|
45
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteManager_Base = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
const interface_1 = require("../../interface");
|
|
6
|
+
const util_parser_1 = require("./util_parser");
|
|
7
|
+
class ExecuteManager_Base {
|
|
8
|
+
uuid;
|
|
9
|
+
name;
|
|
10
|
+
record;
|
|
11
|
+
current_t = undefined;
|
|
12
|
+
current_p = undefined;
|
|
13
|
+
current_projects = [];
|
|
14
|
+
current_nodes = [];
|
|
15
|
+
current_cron = [];
|
|
16
|
+
current_job = [];
|
|
17
|
+
current_multithread = 1;
|
|
18
|
+
current_task_count = -1;
|
|
19
|
+
state = interface_1.ExecuteState.NONE;
|
|
20
|
+
t_state = interface_1.ExecuteState.NONE;
|
|
21
|
+
jobstack = 0;
|
|
22
|
+
first = false;
|
|
23
|
+
libs = undefined;
|
|
24
|
+
proxy = undefined;
|
|
25
|
+
localPara = undefined;
|
|
26
|
+
websocket_manager;
|
|
27
|
+
messager_log;
|
|
28
|
+
constructor(_name, _websocket_manager, _messager_log, _record) {
|
|
29
|
+
this.name = _name;
|
|
30
|
+
this.uuid = (0, uuid_1.v6)();
|
|
31
|
+
this.record = _record;
|
|
32
|
+
this.websocket_manager = _websocket_manager;
|
|
33
|
+
this.messager_log = _messager_log;
|
|
34
|
+
}
|
|
35
|
+
sync_local_para = (target) => {
|
|
36
|
+
this.current_nodes.forEach(x => this.sync_para(target, x));
|
|
37
|
+
this.proxy?.updateDatabase(target);
|
|
38
|
+
};
|
|
39
|
+
sync_para = (target, source) => {
|
|
40
|
+
const h = {
|
|
41
|
+
name: 'set_database',
|
|
42
|
+
channel: this.uuid,
|
|
43
|
+
data: target
|
|
44
|
+
};
|
|
45
|
+
const h2 = {
|
|
46
|
+
name: 'set_libs',
|
|
47
|
+
channel: this.uuid,
|
|
48
|
+
data: this.libs
|
|
49
|
+
};
|
|
50
|
+
source.websocket.send(JSON.stringify(h));
|
|
51
|
+
source.websocket.send(JSON.stringify(h2));
|
|
52
|
+
};
|
|
53
|
+
release = (source) => {
|
|
54
|
+
const h = {
|
|
55
|
+
name: 'release',
|
|
56
|
+
channel: this.uuid,
|
|
57
|
+
data: 0
|
|
58
|
+
};
|
|
59
|
+
source.websocket.send(JSON.stringify(h));
|
|
60
|
+
};
|
|
61
|
+
check_all_cron_end = () => {
|
|
62
|
+
return this.current_cron.filter(x => !this.check_cron_end(x)).length == 0;
|
|
63
|
+
};
|
|
64
|
+
check_cron_end = (cron) => {
|
|
65
|
+
return cron.work.filter(x => x.state == interface_1.ExecuteState.RUNNING || x.state == interface_1.ExecuteState.NONE).length == 0;
|
|
66
|
+
};
|
|
67
|
+
check_single_end = () => {
|
|
68
|
+
if (this.current_t == undefined)
|
|
69
|
+
return false;
|
|
70
|
+
return this.current_job.length == this.current_t.jobs.length &&
|
|
71
|
+
this.current_job.filter(y => y.state == interface_1.ExecuteState.RUNNING || y.state == interface_1.ExecuteState.NONE).length == 0;
|
|
72
|
+
};
|
|
73
|
+
validation = (projects) => {
|
|
74
|
+
if (this.websocket_manager.targets.length == 0) {
|
|
75
|
+
this.messager_log(`[Execute State] The execute node does not exists`);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
projects.forEach(x => {
|
|
79
|
+
x.task.forEach(t => {
|
|
80
|
+
if (t.cronjob) {
|
|
81
|
+
const index = x.database?.containers.findIndex(x => x.name == t.cronjobKey && x.type == interface_1.DataType.Number) ?? -1;
|
|
82
|
+
if (index == -1) {
|
|
83
|
+
this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
|
|
84
|
+
this.messager_log(`[Execute:CronJob] Cron task registerd key not found`);
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
else if (x.database?.containers[index].value == 0) {
|
|
88
|
+
this.messager_log(`[Execute:CronJob] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.cronjobKey}\"`);
|
|
89
|
+
this.messager_log(`[Execute:CronJob] Cron task value must bigger than 0`);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (t.cronjob && t.multi) {
|
|
94
|
+
const index = x.database?.containers.findIndex(x => x.name == t.multiKey && x.type == interface_1.DataType.Number) ?? -1;
|
|
95
|
+
if (index == -1) {
|
|
96
|
+
this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
|
|
97
|
+
this.messager_log(`[Execute:Multi] Cron task registerd key not found`);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
else if (x.database?.containers[index].value == 0) {
|
|
101
|
+
this.messager_log(`[Execute:Multi] Project ${x.title} (${x.uuid}), Task ${t.title} (${t.uuid}), Has unknoed database: \"${t.multiKey}\"`);
|
|
102
|
+
this.messager_log(`[Execute:Multi] Cron task value must bigger than 0`);
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
return true;
|
|
109
|
+
};
|
|
110
|
+
filter_lib = (projects, lib) => {
|
|
111
|
+
const r = { libs: [] };
|
|
112
|
+
projects.forEach(x => {
|
|
113
|
+
x.task.forEach(y => {
|
|
114
|
+
y.jobs.forEach(z => {
|
|
115
|
+
let code = -1;
|
|
116
|
+
if ((z.category == interface_1.JobCategory.Execution && z.type == interface_1.JobType.JAVASCRIPT) || (z.category == interface_1.JobCategory.Condition && z.type == interface_1.JobType2.JAVASCRIPT))
|
|
117
|
+
code = 0;
|
|
118
|
+
if (code == -1)
|
|
119
|
+
return;
|
|
120
|
+
z.string_args.forEach(s1 => {
|
|
121
|
+
const target = lib.libs.find(l => l.name == s1);
|
|
122
|
+
if (target != undefined)
|
|
123
|
+
r.libs.push(target);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
return JSON.parse(JSON.stringify(r));
|
|
129
|
+
};
|
|
130
|
+
get_task_multi_count = (t) => {
|
|
131
|
+
const r = this.get_number(t.multiKey);
|
|
132
|
+
return r == -1 ? 1 : r;
|
|
133
|
+
};
|
|
134
|
+
get_task_state_count(t) {
|
|
135
|
+
if (t.setupjob)
|
|
136
|
+
return this.current_nodes.length;
|
|
137
|
+
if (t.cronjob)
|
|
138
|
+
return this.get_number(t.cronjobKey);
|
|
139
|
+
else
|
|
140
|
+
return 1;
|
|
141
|
+
}
|
|
142
|
+
get_number(key) {
|
|
143
|
+
return ExecuteManager_Base.get_number_global(key, this.localPara);
|
|
144
|
+
}
|
|
145
|
+
static get_number_global(key, localPara) {
|
|
146
|
+
const e = ExecuteManager_Base.database_update(localPara);
|
|
147
|
+
const a = e.replacePara(`%{${key}}%`);
|
|
148
|
+
return Number(a);
|
|
149
|
+
}
|
|
150
|
+
removeDups = (arr) => {
|
|
151
|
+
return [...new Set(arr)];
|
|
152
|
+
};
|
|
153
|
+
get_idle = () => {
|
|
154
|
+
return this.current_nodes.filter(x => this.check_socket_state(x) != interface_1.ExecuteState.RUNNING && x.websocket.readyState == 1);
|
|
155
|
+
};
|
|
156
|
+
get_idle_open = () => {
|
|
157
|
+
return this.current_nodes.filter(x => x.websocket.readyState == 1);
|
|
158
|
+
};
|
|
159
|
+
check_socket_state = (target) => {
|
|
160
|
+
return target.current_job.length == 0 ? interface_1.ExecuteState.NONE : interface_1.ExecuteState.RUNNING;
|
|
161
|
+
};
|
|
162
|
+
static string_args_transform = (task, job, messager_log, localPara, n) => {
|
|
163
|
+
let e = ExecuteManager_Base.database_update(localPara, n);
|
|
164
|
+
e = ExecuteManager_Base.property_update(task, e);
|
|
165
|
+
for (let i = 0; i < job.string_args.length; i++) {
|
|
166
|
+
const b = job.string_args[i];
|
|
167
|
+
if (b == null || b == undefined || b.length == 0)
|
|
168
|
+
continue;
|
|
169
|
+
if (job.category == interface_1.JobCategory.Execution && job.type == interface_1.JobType.CREATE_FILE && i == 1)
|
|
170
|
+
continue;
|
|
171
|
+
job.string_args[i] = e.replacePara(job.string_args[i]);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
static property_update = (task, e) => {
|
|
175
|
+
for (let j = 0; j < task.properties.length; j++) {
|
|
176
|
+
const target = task.properties[j];
|
|
177
|
+
const times = target.deep ? target.deep : 1;
|
|
178
|
+
let act = target.expression;
|
|
179
|
+
for (let k = 0; k < times; k++) {
|
|
180
|
+
act = e.replacePara(`%{${act}}%`);
|
|
181
|
+
}
|
|
182
|
+
e.paras.push({ key: task.properties[j].name, value: act });
|
|
183
|
+
}
|
|
184
|
+
return e;
|
|
185
|
+
};
|
|
186
|
+
static database_update = (localPara, n) => {
|
|
187
|
+
const e = new util_parser_1.Util_Parser([...util_parser_1.Util_Parser.to_keyvalue(localPara)]);
|
|
188
|
+
if (n != undefined) {
|
|
189
|
+
e.paras.push({ key: 'ck', value: n.toString() });
|
|
190
|
+
}
|
|
191
|
+
localPara.containers.forEach((c, index) => {
|
|
192
|
+
if (c.type != interface_1.DataType.Expression)
|
|
193
|
+
return;
|
|
194
|
+
c.value = e.replacePara(`%{${c.meta}}%`);
|
|
195
|
+
e.paras.find(p => p.key == c.name).value = c.value;
|
|
196
|
+
});
|
|
197
|
+
return e;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
exports.ExecuteManager_Base = ExecuteManager_Base;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BusAnalysis } from "../../interface";
|
|
2
|
+
import { ExecuteManager_Base } from "./base";
|
|
3
|
+
export declare class ExecuteManager_Feedback extends ExecuteManager_Base {
|
|
4
|
+
Analysis: (d: BusAnalysis) => void;
|
|
5
|
+
private feedback_message;
|
|
6
|
+
private feedback_job;
|
|
7
|
+
private feedback_string;
|
|
8
|
+
private feedback_number;
|
|
9
|
+
private feedback_object;
|
|
10
|
+
private feedback_boolean;
|
|
11
|
+
private GetCronAndWork;
|
|
12
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecuteManager_Feedback = void 0;
|
|
4
|
+
const interface_1 = require("../../interface");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
class ExecuteManager_Feedback extends base_1.ExecuteManager_Base {
|
|
7
|
+
Analysis = (d) => {
|
|
8
|
+
const targetn = this.current_nodes.find(x => x.uuid == d.c?.uuid);
|
|
9
|
+
if (targetn == undefined) {
|
|
10
|
+
this.messager_log("Not inside");
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const typeMap = {
|
|
14
|
+
'feedback_message': this.feedback_message,
|
|
15
|
+
'feedback_job': this.feedback_job,
|
|
16
|
+
'feedback_string': this.feedback_string,
|
|
17
|
+
'feedback_boolean': this.feedback_boolean,
|
|
18
|
+
'feedback_number': this.feedback_number,
|
|
19
|
+
'feedback_object': this.feedback_object,
|
|
20
|
+
};
|
|
21
|
+
if (typeMap.hasOwnProperty(d.name)) {
|
|
22
|
+
const castingFunc = typeMap[d.h.name];
|
|
23
|
+
castingFunc(d.h.data, targetn, d.h.meta);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.messager_log(`[Source Data Analysis] Decode failed, Unknowed header, name: ${d.name}, meta: ${d.h.meta}`);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
feedback_message = (data, source, meta) => {
|
|
30
|
+
if (source == undefined) {
|
|
31
|
+
this.messager_log("[Server Feedback Warn] source is none");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (this.state == interface_1.ExecuteState.NONE) {
|
|
35
|
+
this.messager_log("[Server Feedback Warn] state is none, should not received feedback");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.messager_log(`[Execute] Single Received data: ${data.data}, cron length: ${this.current_cron.length}`);
|
|
39
|
+
let index = 0;
|
|
40
|
+
if (this.current_cron.length > 0 && meta != undefined) {
|
|
41
|
+
const r = this.GetCronAndWork(meta, source);
|
|
42
|
+
const cron = r[0];
|
|
43
|
+
const work = r[1];
|
|
44
|
+
if (cron != undefined && work != undefined) {
|
|
45
|
+
index = cron.id;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const d = {
|
|
49
|
+
node_uuid: source.uuid,
|
|
50
|
+
index: index,
|
|
51
|
+
job_uuid: '',
|
|
52
|
+
runtime_uuid: '',
|
|
53
|
+
meta: 0,
|
|
54
|
+
message: data.data
|
|
55
|
+
};
|
|
56
|
+
this.proxy?.feedbackMessage(d);
|
|
57
|
+
};
|
|
58
|
+
feedback_job = (data, source) => {
|
|
59
|
+
if (source == undefined)
|
|
60
|
+
return;
|
|
61
|
+
if (this.state == interface_1.ExecuteState.NONE)
|
|
62
|
+
return;
|
|
63
|
+
this.jobstack = Math.max(this.jobstack - 1, 0);
|
|
64
|
+
if (this.current_t == undefined) {
|
|
65
|
+
console.error("Cannot feedback when task is null");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.messager_log(`[Execute] Job Feedback: ${data.job_uuid} ${data.runtime_uuid} ${data.message} ${data.meta}`);
|
|
69
|
+
if (this.current_job.length > 0) {
|
|
70
|
+
const work = this.current_job.find(x => x.uuid == source.uuid && x.state == interface_1.ExecuteState.RUNNING);
|
|
71
|
+
if (work == undefined) {
|
|
72
|
+
console.error("Cannot find the feedback container, work", work);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
data.index = 0;
|
|
76
|
+
this.proxy?.executeJobFinish([work.job, 0, source.uuid, data.meta]);
|
|
77
|
+
work.state = data.meta == 0 ? interface_1.ExecuteState.FINISH : interface_1.ExecuteState.ERROR;
|
|
78
|
+
if (this.check_single_end()) {
|
|
79
|
+
this.proxy?.executeSubtaskFinish([this.current_t, 0, source.uuid]);
|
|
80
|
+
this.messager_log(`[Execute] Subtask finish: ${this.current_t.uuid}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (this.current_cron.length > 0) {
|
|
84
|
+
const r = this.GetCronAndWork(data.runtime_uuid, source);
|
|
85
|
+
const cron = r[0];
|
|
86
|
+
const work = r[1];
|
|
87
|
+
if (cron == undefined || work == undefined) {
|
|
88
|
+
console.error("Cannot find the feedback container, cron or work", data.runtime_uuid, cron, work);
|
|
89
|
+
console.error("Full current cron instance", this.current_cron);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.proxy?.executeJobFinish([work.job, cron.id, source.uuid, data.meta]);
|
|
93
|
+
data.index = cron.id;
|
|
94
|
+
work.state = data.meta == 0 ? interface_1.ExecuteState.FINISH : interface_1.ExecuteState.ERROR;
|
|
95
|
+
if (this.check_cron_end(cron)) {
|
|
96
|
+
this.proxy?.executeSubtaskFinish([this.current_t, cron.id, cron.uuid]);
|
|
97
|
+
this.messager_log(`[Execute] Subtask finish: ${this.current_t.uuid}`);
|
|
98
|
+
cron.uuid = '';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const index = source.current_job.findIndex(x => x == data.runtime_uuid);
|
|
102
|
+
if (index == -1) {
|
|
103
|
+
this.messager_log(`[Execute] Cannot find runtime uuid: ${data.runtime_uuid} in websocket pack source: ${source.uuid}`);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
source.current_job.splice(index, 1);
|
|
107
|
+
}
|
|
108
|
+
data.node_uuid = source.uuid;
|
|
109
|
+
this.proxy?.feedbackMessage(data);
|
|
110
|
+
};
|
|
111
|
+
feedback_string = (data) => {
|
|
112
|
+
if (this.current_p == undefined)
|
|
113
|
+
return;
|
|
114
|
+
const index = this.localPara.containers.findIndex(x => x.name == data.key && x.type == interface_1.DataType.String);
|
|
115
|
+
if (index != -1)
|
|
116
|
+
this.localPara.containers[index].value = data.value;
|
|
117
|
+
else
|
|
118
|
+
this.localPara.containers.push({ name: data.key, value: data.value, type: interface_1.DataType.String, hidden: true, runtimeOnly: true });
|
|
119
|
+
this.messager_log(`[String Feedback] ${data.key} = ${data.value}`);
|
|
120
|
+
const d = { name: 'set_database', data: this.localPara };
|
|
121
|
+
this.current_nodes.forEach(x => x.websocket.send(JSON.stringify(d)));
|
|
122
|
+
this.proxy?.updateDatabase(this.localPara);
|
|
123
|
+
};
|
|
124
|
+
feedback_number = (data) => {
|
|
125
|
+
if (this.current_p == undefined)
|
|
126
|
+
return;
|
|
127
|
+
const index = this.localPara.containers.findIndex(x => x.name == data.key && x.type == interface_1.DataType.Number);
|
|
128
|
+
if (index != -1)
|
|
129
|
+
this.localPara.containers[index].value = data.value;
|
|
130
|
+
else
|
|
131
|
+
this.localPara.containers.push({ name: data.key, value: data.value, type: interface_1.DataType.Number, hidden: true, runtimeOnly: true });
|
|
132
|
+
this.messager_log(`[Number Feedback] ${data.key} = ${data.value}`);
|
|
133
|
+
const d = { name: 'set_database', data: this.localPara };
|
|
134
|
+
this.current_nodes.forEach(x => x.websocket.send(JSON.stringify(d)));
|
|
135
|
+
this.proxy?.updateDatabase(this.localPara);
|
|
136
|
+
};
|
|
137
|
+
feedback_object = (data) => {
|
|
138
|
+
if (this.current_p == undefined)
|
|
139
|
+
return;
|
|
140
|
+
const index = this.localPara.containers.findIndex(x => x.name == data.key && x.type == interface_1.DataType.Object);
|
|
141
|
+
if (index != -1)
|
|
142
|
+
this.localPara.containers[index].value = data.value;
|
|
143
|
+
else
|
|
144
|
+
this.localPara.containers.push({ name: data.key, value: data.value, type: interface_1.DataType.Object, hidden: true, runtimeOnly: true });
|
|
145
|
+
this.messager_log(`[Object Feedback] ${data.key}`);
|
|
146
|
+
const d = { name: 'set_database', data: this.localPara };
|
|
147
|
+
this.current_nodes.forEach(x => x.websocket.send(JSON.stringify(d)));
|
|
148
|
+
this.proxy?.updateDatabase(this.localPara);
|
|
149
|
+
};
|
|
150
|
+
feedback_boolean = (data) => {
|
|
151
|
+
if (this.current_p == undefined)
|
|
152
|
+
return;
|
|
153
|
+
const index = this.localPara.containers.findIndex(x => x.name == data.key && x.type == interface_1.DataType.Boolean);
|
|
154
|
+
if (index != -1)
|
|
155
|
+
this.localPara.containers[index].value = data.value;
|
|
156
|
+
else
|
|
157
|
+
this.localPara.containers.push({ name: data.key, value: data.value, type: interface_1.DataType.Boolean, hidden: true, runtimeOnly: true });
|
|
158
|
+
this.messager_log(`[Boolean Feedback] ${data.key} = ${data.value}`);
|
|
159
|
+
const d = { name: 'set_database', data: this.localPara };
|
|
160
|
+
this.current_nodes.forEach(x => x.websocket.send(JSON.stringify(d)));
|
|
161
|
+
this.proxy?.updateDatabase(this.localPara);
|
|
162
|
+
};
|
|
163
|
+
GetCronAndWork = (runtime, source) => {
|
|
164
|
+
let cron = undefined;
|
|
165
|
+
let work = undefined;
|
|
166
|
+
const crons = this.current_cron.filter(x => x.uuid == source.uuid);
|
|
167
|
+
for (let i = 0; i < crons.length; i++) {
|
|
168
|
+
const c = crons[i];
|
|
169
|
+
const a = c.work.find(x => x.runtime == runtime);
|
|
170
|
+
if (a != undefined) {
|
|
171
|
+
cron = c;
|
|
172
|
+
work = a;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return [cron, work];
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
exports.ExecuteManager_Feedback = ExecuteManager_Feedback;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExecuteState, Project } from "../../interface";
|
|
2
|
+
import { ExecuteManager } from "../execute_manager";
|
|
3
|
+
import { Region_Task } from "./region_task";
|
|
4
|
+
export declare class Region_Project {
|
|
5
|
+
target: ExecuteManager;
|
|
6
|
+
state: ExecuteState;
|
|
7
|
+
project: Project;
|
|
8
|
+
task: Region_Task | undefined;
|
|
9
|
+
constructor(_target: ExecuteManager, _project: Project);
|
|
10
|
+
}
|