This repository was archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathroJob.yaml
More file actions
194 lines (163 loc) · 5.78 KB
/
roJob.yaml
File metadata and controls
194 lines (163 loc) · 5.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
jobs:
#-----------------
- name: roJob Exec
help: >
Tries to execute a oJob remotely. Expects:
url (String/Array) An url or an array of urls os roJob services
apikey (String) The roJob API key to use.
file (String) The filepath for a yaml/json file to execute remotely
rojob (Map) The oJob map to execute remotely
rargs (Map) The remote oJob arguments.
async (Boolean) Determines if a roJob should be executed async (defaults to false)
Returns:
res (Map) A map with the roJob execution response.
exec: |
if (isUnDef(args.file) && isUnDef(args.rojob)) throw "Please provide a file or a ojob.";
args.rargs = _$(args.rargs).isMap().default({});
loadLib("rojob.js");
var rj;
if (isUnDef(args.url) && isUnDef(args.apikey) && isDef(global.ROJOB) && isDef(global.ROJOB.client))
rj = global.ROJOB.client;
else
rj = new roJob(args.url, args.apikey);
if (isDef(args.rojob) && isMap(args.rojob)) {
if (isUnDef(args.rojob.rojob)) args.rojob.rojob = {};
if (isDef(args.async)) args.rojob.rojob.async = true;
args.res = rj.execJob(args.rojob, args.rargs);
} else {
if (isDef(args.async)) {
args.res = rj.execAsync(args.file, args.rargs);
} else {
args.res = rj.exec(args.file, args.rargs);
}
}
#----------------
- name: roJob Run
help: >
Tries to execute a oJob remotely. Expects:
url (String/Array) An url or an array of urls os roJob services
apikey (String) The roJob API key to use.
file (String) The relative run filepath to execute remotely
rargs (Map) The remote oJob arguments.
async (Boolean) Determines if a roJob should be executed async (defaults to false)
Returns:
res (Map) A map with the roJob execution response.
exec: |
if (isUnDef(args.file)) throw "Please provide a file.";
args.url = _$(args.url).default(void 0);
args.apikey = _$(args.apikey).default(void 0);
loadLib("rojob.js");
var rj;
if (isUnDef(args.url) && isUnDef(args.apikey) && isDef(global.ROJOB) && isDef(global.ROJOB.client))
rj = global.ROJOB.client;
else
rj = new roJob(args.url, args.apikey);
if (args.async) {
args.res = rj.runAsync(args.file, args.rargs);
} else {
args.res = rj.run(args.file, args.rargs);
}
#-----------------------
- name: roJob List nodes
help: >
Returns a list of the existing nodes.
to : roJob Run
args:
file: rojob/listnodes.yaml
#----------------------
- name: roJob List work
help: >
Returns a list of the files on the remote work folder on path. Expects:
path (String) The remote work folder path.
to : roJob Run
args:
file: rojob/listwork.yaml
exec: |
args.rargs = { path: args.path };
#-----------------------
- name: roJob Get memory
help: >
Returns a map with the java heap memory stats. Expects:
notFormat (Boolean) If notFormat = true values will be returned in bytes instead of human readable.
to : roJob Run
args:
file: rojob/getmem.yaml
exec: |
args.rargs = { format: !args.notFormat };
#-----------------------
- name: roJob Clean work
help: >
Cleans all files on the remote work folder under a path. Expects:
work (String) The remote work folder path.
to : roJob Run
args:
file: rojob/cleanwork.yaml
exec: |
args.rargs = { path: args.path };
#---------------------
- name: roJob Kill job
help: >
Tries to stop a remote job. Expects:
job (String) The job id string.
to : roJob Run
args:
file: rojob/killjob.yaml
exec: |
args.rargs = { job: args.job };
#-----------------------
- name: roJob Get result
help: >
Returns the result of a async job, identified by aUUID. Optionally the result can be cleaned
from the remote work folder. Expects:
uuid (String) The async job UUID.
shouldClean (Boolean) If true the result will be cleaned from the remote work folder.
args:
file: rojob/getresult.yaml
exec: |
args.url = _$(args.url).default(void 0);
args.apikey = _$(args.apikey).default(void 0);
loadLib("rojob.js");
var rj = new roJob(args.url, args.apikey);
args.res = rj.getResult(args.uuid, args.shouldClean);
#-------------------------
- name: roJob Set init job
to : roJob Run
args:
file: rojob/setinitjob.yaml
exec: |
args.rargs = { name: args.name, job: io.readFileString(args.file) };
#---------------------------
- name: roJob Clean init job
to : roJob Run
args:
file: rojob/clearinitjobs.yaml
#---------------------
- name: roJob Add node
to : roJob Run
args:
file: rojob/addnode.yaml
exec: |
args.rargs = { host: args.host, port: args.port };
#----------------------
- name: roJob Show vars
to : roJob Run
args:
file: rojob/showvars.yaml
#-----------------
- name: roJob Stop
to : roJob Run
args:
file: rojob/stop.yaml
#---------------------
- name: roJob Stop all
to : roJob Run
args:
file: rojob/stopall.yaml
#-------------------------
- name: roJob Print result
exec: |
if (args.json) {
sprint(args.res);
} else {
print(af.toYAML(args.res));
}