@hpcc-js/comms 3.14.4 → 3.15.1
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/LICENSE +43 -43
- package/README.md +50 -50
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.cjs +1 -1
- package/dist/browser/index.umd.cjs.map +1 -1
- package/dist/node/index.cjs +8 -8
- package/dist/node/index.cjs.map +3 -3
- package/dist/node/index.js +7 -7
- package/dist/node/index.js.map +3 -3
- package/package.json +7 -7
- package/src/__package__.ts +3 -3
- package/src/clienttools/eclMeta.ts +506 -506
- package/src/clienttools/eclcc.ts +628 -628
- package/src/connection.ts +288 -288
- package/src/ecl/activity.ts +82 -82
- package/src/ecl/dfuWorkunit.ts +363 -363
- package/src/ecl/graph.ts +196 -196
- package/src/ecl/logicalFile.ts +196 -196
- package/src/ecl/machine.ts +63 -63
- package/src/ecl/query.ts +265 -265
- package/src/ecl/queryGraph.ts +813 -813
- package/src/ecl/resource.ts +39 -39
- package/src/ecl/result.ts +245 -245
- package/src/ecl/scope.ts +188 -188
- package/src/ecl/sourceFile.ts +34 -34
- package/src/ecl/store.ts +154 -154
- package/src/ecl/targetCluster.ts +149 -149
- package/src/ecl/timer.ts +42 -42
- package/src/ecl/topology.ts +131 -131
- package/src/ecl/workunit.ts +1340 -1340
- package/src/ecl/xsdParser.ts +267 -267
- package/src/espConnection.ts +164 -164
- package/src/index.browser.ts +1 -1
- package/src/index.common.ts +40 -40
- package/src/index.node.ts +48 -48
- package/src/pem/trustwave.ts +909 -909
- package/src/services/fileSpray.ts +73 -48
- package/src/services/wsAccess.ts +8 -8
- package/src/services/wsAccount.ts +27 -27
- package/src/services/wsCloud.ts +73 -73
- package/src/services/wsCodesign.ts +18 -18
- package/src/services/wsDFU.ts +34 -34
- package/src/services/wsDFUXRef.ts +121 -121
- package/src/services/wsDali.ts +8 -8
- package/src/services/wsEcl.ts +123 -123
- package/src/services/wsElk.ts +8 -8
- package/src/services/wsLogaccess.ts +267 -267
- package/src/services/wsMachine.ts +89 -89
- package/src/services/wsPackageProcess.ts +8 -8
- package/src/services/wsResources.ts +8 -8
- package/src/services/wsSMC.ts +80 -80
- package/src/services/wsSasha.ts +7 -7
- package/src/services/wsStore.ts +32 -32
- package/src/services/wsTopology.ts +45 -45
- package/src/services/wsWorkunits.ts +151 -151
- package/src/services/wsdl/FileSpray/v1.23/FileSpray.ts +1008 -1008
- package/src/services/wsdl/FileSpray/v1.25/FileSpray.ts +1040 -1040
- package/src/services/wsdl/FileSpray/v1.26/FileSpray.ts +929 -929
- package/src/services/wsdl/FileSpray/v1.27/FileSpray.ts +930 -930
- package/src/services/wsdl/WsCloud/v1/WsCloud.ts +38 -38
- package/src/services/wsdl/WsCloud/v1.02/WsCloud.ts +77 -77
- package/src/services/wsdl/WsDFUXRef/v1.02/WsDFUXRef.ts +224 -224
- package/src/services/wsdl/WsDFUXRef/v1.04/WsDFUXRef.ts +227 -227
- package/src/services/wsdl/WsDali/v1.04/WsDali.ts +216 -216
- package/src/services/wsdl/WsDfu/v1.62/WsDfu.ts +1455 -1455
- package/src/services/wsdl/WsDfu/v1.63/WsDfu.ts +1465 -1465
- package/src/services/wsdl/WsDfu/v1.65/WsDfu.ts +1244 -1244
- package/src/services/wsdl/WsDfu/v1.66/WsDfu.ts +1267 -1267
- package/src/services/wsdl/WsDfu/v1.67/WsDfu.ts +1268 -1268
- package/src/services/wsdl/WsFileIO/v1.01/WsFileIO.ts +104 -104
- package/src/services/wsdl/WsPackageProcess/v1.04/WsPackageProcess.ts +519 -519
- package/src/services/wsdl/WsPackageProcess/v1.07/WsPackageProcess.ts +500 -500
- package/src/services/wsdl/WsResources/v1.01/WsResources.ts +119 -119
- package/src/services/wsdl/WsSMC/v1.24/WsSMC.ts +665 -665
- package/src/services/wsdl/WsSMC/v1.27/WsSMC.ts +591 -591
- package/src/services/wsdl/WsSMC/v1.28/WsSMC.ts +645 -645
- package/src/services/wsdl/WsSMC/v1.29/WsSMC.ts +660 -660
- package/src/services/wsdl/WsTopology/v1.31/WsTopology.ts +856 -856
- package/src/services/wsdl/WsTopology/v1.32/WsTopology.ts +786 -786
- package/src/services/wsdl/WsTopology/v1.33/WsTopology.ts +835 -835
- package/src/services/wsdl/WsWorkunits/v1.88/WsWorkunits.ts +2944 -2944
- package/src/services/wsdl/WsWorkunits/v1.94/WsWorkunits.ts +3072 -3072
- package/src/services/wsdl/WsWorkunits/v1.95/WsWorkunits.ts +3073 -3073
- package/src/services/wsdl/WsWorkunits/v1.97/WsWorkunits.ts +3134 -3134
- package/src/services/wsdl/WsWorkunits/v1.98/WsWorkunits.ts +3182 -3182
- package/src/services/wsdl/WsWorkunits/v1.99/WsWorkunits.ts +3162 -3162
- package/src/services/wsdl/WsWorkunits/v2/WsWorkunits.ts +3153 -3153
- package/src/services/wsdl/WsWorkunits/v2.02/WsWorkunits.ts +3162 -3162
- package/src/services/wsdl/WsWorkunits/v2.03/WsWorkunits.ts +3164 -3164
- package/src/services/wsdl/WsWorkunits/v2.04/WsWorkunits.ts +3171 -3171
- package/src/services/wsdl/ws_access/v1.16/ws_access.ts +1086 -1086
- package/src/services/wsdl/ws_access/v1.17/ws_access.ts +1023 -1023
- package/src/services/wsdl/ws_account/v1.05/ws_account.ts +111 -111
- package/src/services/wsdl/ws_account/v1.06/ws_account.ts +109 -109
- package/src/services/wsdl/ws_account/v1.07/ws_account.ts +114 -114
- package/src/services/wsdl/ws_codesign/v1.1/ws_codesign.ts +95 -95
- package/src/services/wsdl/ws_elk/v1/ws_elk.ts +47 -47
- package/src/services/wsdl/ws_logaccess/v1/ws_logaccess.ts +83 -83
- package/src/services/wsdl/ws_logaccess/v1.02/ws_logaccess.ts +161 -161
- package/src/services/wsdl/ws_logaccess/v1.03/ws_logaccess.ts +190 -190
- package/src/services/wsdl/ws_logaccess/v1.04/ws_logaccess.ts +215 -215
- package/src/services/wsdl/ws_logaccess/v1.05/ws_logaccess.ts +219 -219
- package/src/services/wsdl/ws_logaccess/v1.08/ws_logaccess.ts +267 -267
- package/src/services/wsdl/ws_machine/v1.17/ws_machine.ts +567 -567
- package/src/services/wsdl/ws_machine/v1.18/ws_machine.ts +497 -497
- package/src/services/wsdl/ws_machine/v1.19/ws_machine.ts +497 -497
- package/src/services/wsdl/wsstore/v1.02/wsstore.ts +239 -239
- package/types/services/fileSpray.d.ts +13 -0
package/src/ecl/store.ts
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import { Cache, Dispatch, IObserverHandle, Message } from "@hpcc-js/util";
|
|
2
|
-
import { IConnection, IOptions } from "../connection.ts";
|
|
3
|
-
import { StoreService } from "../services/wsStore.ts";
|
|
4
|
-
|
|
5
|
-
export class StoreCache extends Cache<{ BaseUrl: string, Name: string, UserSpecific: boolean, Namespace: string }, Store> {
|
|
6
|
-
constructor() {
|
|
7
|
-
super((obj) => {
|
|
8
|
-
return `${obj.BaseUrl}-${obj.Name}:${obj.UserSpecific}-${obj.Namespace}`;
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const _store = new StoreCache();
|
|
13
|
-
|
|
14
|
-
export class ValueChangedMessage extends Message {
|
|
15
|
-
|
|
16
|
-
constructor(readonly key: string, public value: any, public oldValue?: any) {
|
|
17
|
-
super();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get canConflate(): boolean { return true; }
|
|
21
|
-
conflate(other: ValueChangedMessage): boolean {
|
|
22
|
-
if (this.key === other.key) {
|
|
23
|
-
this.value = other.value;
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
void(): boolean {
|
|
30
|
-
return this.value === this.oldValue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class Store {
|
|
35
|
-
protected connection: StoreService;
|
|
36
|
-
get BaseUrl() { return this.connection.baseUrl; }
|
|
37
|
-
readonly Name: string;
|
|
38
|
-
readonly UserSpecific: boolean;
|
|
39
|
-
readonly Namespace: string;
|
|
40
|
-
|
|
41
|
-
protected _dispatch = new Dispatch<ValueChangedMessage>();
|
|
42
|
-
|
|
43
|
-
static attach(optsConnection: IOptions | IConnection | StoreService, Name: string = "HPCCApps", Namespace: string, UserSpecific: boolean = true): Store {
|
|
44
|
-
const retVal: Store = _store.get({ BaseUrl: optsConnection.baseUrl, Name, UserSpecific, Namespace }, () => {
|
|
45
|
-
return new Store(optsConnection, Name, Namespace, UserSpecific);
|
|
46
|
-
});
|
|
47
|
-
return retVal;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected constructor(optsConnection: IOptions | IConnection | StoreService, Name: string, Namespace: string, UserSpecific: boolean) {
|
|
51
|
-
if (optsConnection instanceof StoreService) {
|
|
52
|
-
this.connection = optsConnection;
|
|
53
|
-
} else {
|
|
54
|
-
this.connection = new StoreService(optsConnection);
|
|
55
|
-
}
|
|
56
|
-
this.Name = Name;
|
|
57
|
-
this.UserSpecific = UserSpecific;
|
|
58
|
-
this.Namespace = Namespace;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
private _knownValues: { [key: string]: any } = {};
|
|
62
|
-
|
|
63
|
-
protected create() {
|
|
64
|
-
this.connection.CreateStore({ Name: this.Name, Type: "", Description: "" });
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
set(key: string, value: string, broadcast = true): Promise<void> {
|
|
68
|
-
return this.connection.Set({
|
|
69
|
-
StoreName: this.Name,
|
|
70
|
-
UserSpecific: this.UserSpecific,
|
|
71
|
-
Namespace: this.Namespace,
|
|
72
|
-
Key: key,
|
|
73
|
-
Value: value
|
|
74
|
-
}).then(response => {
|
|
75
|
-
const oldValue = this._knownValues[key];
|
|
76
|
-
this._knownValues[key] = value;
|
|
77
|
-
if (broadcast) {
|
|
78
|
-
this._dispatch.post(new ValueChangedMessage(key, value, oldValue));
|
|
79
|
-
}
|
|
80
|
-
}).catch(e => {
|
|
81
|
-
console.error(`Store.set("${key}", "${value}") failed:`, e);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
get(key: string, broadcast = true): Promise<string | undefined> {
|
|
86
|
-
return this.connection.Fetch({
|
|
87
|
-
StoreName: this.Name,
|
|
88
|
-
UserSpecific: this.UserSpecific,
|
|
89
|
-
Namespace: this.Namespace,
|
|
90
|
-
Key: key
|
|
91
|
-
}).then(response => {
|
|
92
|
-
const oldValue = this._knownValues[key];
|
|
93
|
-
this._knownValues[key] = response.Value;
|
|
94
|
-
if (broadcast) {
|
|
95
|
-
this._dispatch.post(new ValueChangedMessage(key, response.Value, oldValue));
|
|
96
|
-
}
|
|
97
|
-
return response.Value;
|
|
98
|
-
}).catch(e => {
|
|
99
|
-
console.error(`Store.get(${key}) failed:`, e);
|
|
100
|
-
return undefined;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
getAll(broadcast = true): Promise<{ [key: string]: string }> {
|
|
105
|
-
return this.connection.FetchAll({
|
|
106
|
-
StoreName: this.Name,
|
|
107
|
-
UserSpecific: this.UserSpecific,
|
|
108
|
-
Namespace: this.Namespace
|
|
109
|
-
}).then(response => {
|
|
110
|
-
const retVal: { [key: string]: string } = {};
|
|
111
|
-
const deletedValues = this._knownValues;
|
|
112
|
-
this._knownValues = {};
|
|
113
|
-
response.Pairs.Pair.forEach(pair => {
|
|
114
|
-
const oldValue = this._knownValues[pair.Key];
|
|
115
|
-
this._knownValues[pair.Key] = pair.Value;
|
|
116
|
-
delete deletedValues[pair.Key];
|
|
117
|
-
retVal[pair.Key] = pair.Value;
|
|
118
|
-
if (broadcast) {
|
|
119
|
-
this._dispatch.post(new ValueChangedMessage(pair.Key, pair.Value, oldValue));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (broadcast) {
|
|
123
|
-
for (const key in deletedValues) {
|
|
124
|
-
this._dispatch.post(new ValueChangedMessage(key, undefined, deletedValues[key]));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return retVal;
|
|
128
|
-
}).catch(e => {
|
|
129
|
-
console.error("Store.getAll failed:", e);
|
|
130
|
-
return {};
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
delete(key: string, broadcast = true): Promise<void> {
|
|
135
|
-
return this.connection.Delete({
|
|
136
|
-
StoreName: this.Name,
|
|
137
|
-
UserSpecific: this.UserSpecific,
|
|
138
|
-
Namespace: this.Namespace,
|
|
139
|
-
Key: key
|
|
140
|
-
}).then(response => {
|
|
141
|
-
const oldValue = this._knownValues[key];
|
|
142
|
-
delete this._knownValues[key];
|
|
143
|
-
if (broadcast) {
|
|
144
|
-
this._dispatch.post(new ValueChangedMessage(key, undefined, oldValue));
|
|
145
|
-
}
|
|
146
|
-
}).catch(e => {
|
|
147
|
-
console.error(`Store.delete(${key}) failed:`, e);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
monitor(callback: (messages: ValueChangedMessage[]) => void): IObserverHandle {
|
|
152
|
-
return this._dispatch.attach(callback);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
1
|
+
import { Cache, Dispatch, IObserverHandle, Message } from "@hpcc-js/util";
|
|
2
|
+
import { IConnection, IOptions } from "../connection.ts";
|
|
3
|
+
import { StoreService } from "../services/wsStore.ts";
|
|
4
|
+
|
|
5
|
+
export class StoreCache extends Cache<{ BaseUrl: string, Name: string, UserSpecific: boolean, Namespace: string }, Store> {
|
|
6
|
+
constructor() {
|
|
7
|
+
super((obj) => {
|
|
8
|
+
return `${obj.BaseUrl}-${obj.Name}:${obj.UserSpecific}-${obj.Namespace}`;
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const _store = new StoreCache();
|
|
13
|
+
|
|
14
|
+
export class ValueChangedMessage extends Message {
|
|
15
|
+
|
|
16
|
+
constructor(readonly key: string, public value: any, public oldValue?: any) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get canConflate(): boolean { return true; }
|
|
21
|
+
conflate(other: ValueChangedMessage): boolean {
|
|
22
|
+
if (this.key === other.key) {
|
|
23
|
+
this.value = other.value;
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void(): boolean {
|
|
30
|
+
return this.value === this.oldValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Store {
|
|
35
|
+
protected connection: StoreService;
|
|
36
|
+
get BaseUrl() { return this.connection.baseUrl; }
|
|
37
|
+
readonly Name: string;
|
|
38
|
+
readonly UserSpecific: boolean;
|
|
39
|
+
readonly Namespace: string;
|
|
40
|
+
|
|
41
|
+
protected _dispatch = new Dispatch<ValueChangedMessage>();
|
|
42
|
+
|
|
43
|
+
static attach(optsConnection: IOptions | IConnection | StoreService, Name: string = "HPCCApps", Namespace: string, UserSpecific: boolean = true): Store {
|
|
44
|
+
const retVal: Store = _store.get({ BaseUrl: optsConnection.baseUrl, Name, UserSpecific, Namespace }, () => {
|
|
45
|
+
return new Store(optsConnection, Name, Namespace, UserSpecific);
|
|
46
|
+
});
|
|
47
|
+
return retVal;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
protected constructor(optsConnection: IOptions | IConnection | StoreService, Name: string, Namespace: string, UserSpecific: boolean) {
|
|
51
|
+
if (optsConnection instanceof StoreService) {
|
|
52
|
+
this.connection = optsConnection;
|
|
53
|
+
} else {
|
|
54
|
+
this.connection = new StoreService(optsConnection);
|
|
55
|
+
}
|
|
56
|
+
this.Name = Name;
|
|
57
|
+
this.UserSpecific = UserSpecific;
|
|
58
|
+
this.Namespace = Namespace;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private _knownValues: { [key: string]: any } = {};
|
|
62
|
+
|
|
63
|
+
protected create() {
|
|
64
|
+
this.connection.CreateStore({ Name: this.Name, Type: "", Description: "" });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set(key: string, value: string, broadcast = true): Promise<void> {
|
|
68
|
+
return this.connection.Set({
|
|
69
|
+
StoreName: this.Name,
|
|
70
|
+
UserSpecific: this.UserSpecific,
|
|
71
|
+
Namespace: this.Namespace,
|
|
72
|
+
Key: key,
|
|
73
|
+
Value: value
|
|
74
|
+
}).then(response => {
|
|
75
|
+
const oldValue = this._knownValues[key];
|
|
76
|
+
this._knownValues[key] = value;
|
|
77
|
+
if (broadcast) {
|
|
78
|
+
this._dispatch.post(new ValueChangedMessage(key, value, oldValue));
|
|
79
|
+
}
|
|
80
|
+
}).catch(e => {
|
|
81
|
+
console.error(`Store.set("${key}", "${value}") failed:`, e);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
get(key: string, broadcast = true): Promise<string | undefined> {
|
|
86
|
+
return this.connection.Fetch({
|
|
87
|
+
StoreName: this.Name,
|
|
88
|
+
UserSpecific: this.UserSpecific,
|
|
89
|
+
Namespace: this.Namespace,
|
|
90
|
+
Key: key
|
|
91
|
+
}).then(response => {
|
|
92
|
+
const oldValue = this._knownValues[key];
|
|
93
|
+
this._knownValues[key] = response.Value;
|
|
94
|
+
if (broadcast) {
|
|
95
|
+
this._dispatch.post(new ValueChangedMessage(key, response.Value, oldValue));
|
|
96
|
+
}
|
|
97
|
+
return response.Value;
|
|
98
|
+
}).catch(e => {
|
|
99
|
+
console.error(`Store.get(${key}) failed:`, e);
|
|
100
|
+
return undefined;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getAll(broadcast = true): Promise<{ [key: string]: string }> {
|
|
105
|
+
return this.connection.FetchAll({
|
|
106
|
+
StoreName: this.Name,
|
|
107
|
+
UserSpecific: this.UserSpecific,
|
|
108
|
+
Namespace: this.Namespace
|
|
109
|
+
}).then(response => {
|
|
110
|
+
const retVal: { [key: string]: string } = {};
|
|
111
|
+
const deletedValues = this._knownValues;
|
|
112
|
+
this._knownValues = {};
|
|
113
|
+
response.Pairs.Pair.forEach(pair => {
|
|
114
|
+
const oldValue = this._knownValues[pair.Key];
|
|
115
|
+
this._knownValues[pair.Key] = pair.Value;
|
|
116
|
+
delete deletedValues[pair.Key];
|
|
117
|
+
retVal[pair.Key] = pair.Value;
|
|
118
|
+
if (broadcast) {
|
|
119
|
+
this._dispatch.post(new ValueChangedMessage(pair.Key, pair.Value, oldValue));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
if (broadcast) {
|
|
123
|
+
for (const key in deletedValues) {
|
|
124
|
+
this._dispatch.post(new ValueChangedMessage(key, undefined, deletedValues[key]));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return retVal;
|
|
128
|
+
}).catch(e => {
|
|
129
|
+
console.error("Store.getAll failed:", e);
|
|
130
|
+
return {};
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
delete(key: string, broadcast = true): Promise<void> {
|
|
135
|
+
return this.connection.Delete({
|
|
136
|
+
StoreName: this.Name,
|
|
137
|
+
UserSpecific: this.UserSpecific,
|
|
138
|
+
Namespace: this.Namespace,
|
|
139
|
+
Key: key
|
|
140
|
+
}).then(response => {
|
|
141
|
+
const oldValue = this._knownValues[key];
|
|
142
|
+
delete this._knownValues[key];
|
|
143
|
+
if (broadcast) {
|
|
144
|
+
this._dispatch.post(new ValueChangedMessage(key, undefined, oldValue));
|
|
145
|
+
}
|
|
146
|
+
}).catch(e => {
|
|
147
|
+
console.error(`Store.delete(${key}) failed:`, e);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
monitor(callback: (messages: ValueChangedMessage[]) => void): IObserverHandle {
|
|
152
|
+
return this._dispatch.attach(callback);
|
|
153
|
+
}
|
|
154
|
+
}
|
package/src/ecl/targetCluster.ts
CHANGED
|
@@ -1,149 +1,149 @@
|
|
|
1
|
-
import { Cache, StateObject } from "@hpcc-js/util";
|
|
2
|
-
import { IConnection, IOptions } from "../connection.ts";
|
|
3
|
-
import { WsMachine, WsMachineEx, MachineService } from "../services/wsMachine.ts";
|
|
4
|
-
import { TopologyService, WsTopology } from "../services/wsTopology.ts";
|
|
5
|
-
import { Machine } from "./machine.ts";
|
|
6
|
-
|
|
7
|
-
export class TargetClusterCache extends Cache<{ BaseUrl: string, Name: string }, TargetCluster> {
|
|
8
|
-
constructor() {
|
|
9
|
-
super((obj) => {
|
|
10
|
-
return `${obj.BaseUrl}-${obj.Name}`;
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const _targetCluster = new TargetClusterCache();
|
|
15
|
-
|
|
16
|
-
export interface TpTargetClusterEx {
|
|
17
|
-
MachineInfoEx: WsMachine.MachineInfoEx[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type UTargetClusterState = WsTopology.TpTargetCluster & WsTopology.TpClusterNameType & TpTargetClusterEx;
|
|
21
|
-
export type ITargetClusterState = WsTopology.TpTargetCluster | WsTopology.TpClusterNameType | TpTargetClusterEx;
|
|
22
|
-
export class TargetCluster extends StateObject<UTargetClusterState, ITargetClusterState> implements UTargetClusterState {
|
|
23
|
-
protected connection: TopologyService;
|
|
24
|
-
protected machineConnection: MachineService;
|
|
25
|
-
get BaseUrl() { return this.connection.baseUrl; }
|
|
26
|
-
|
|
27
|
-
get Name(): string { return this.get("Name"); }
|
|
28
|
-
get Prefix(): string { return this.get("Prefix"); }
|
|
29
|
-
get Type(): string { return this.get("Type"); }
|
|
30
|
-
get IsDefault(): boolean { return this.get("IsDefault"); }
|
|
31
|
-
get TpClusters(): WsTopology.TpClusters { return this.get("TpClusters"); }
|
|
32
|
-
get TpEclCCServers(): WsTopology.TpEclCCServers { return this.get("TpEclCCServers"); }
|
|
33
|
-
get TpEclServers(): WsTopology.TpEclServers { return this.get("TpEclServers"); }
|
|
34
|
-
get TpEclAgents(): WsTopology.TpEclAgents { return this.get("TpEclAgents"); }
|
|
35
|
-
get TpEclSchedulers(): WsTopology.TpEclSchedulers { return this.get("TpEclSchedulers"); }
|
|
36
|
-
get MachineInfoEx(): WsMachine.MachineInfoEx[] { return this.get("MachineInfoEx", []); }
|
|
37
|
-
get CMachineInfoEx(): Machine[] {
|
|
38
|
-
return this.MachineInfoEx.map(machineInfoEx => Machine.attach(this.machineConnection, machineInfoEx.Address, machineInfoEx));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static attach(optsConnection: IOptions | IConnection | TopologyService, name: string, state?: ITargetClusterState): TargetCluster {
|
|
42
|
-
const retVal: TargetCluster = _targetCluster.get({ BaseUrl: optsConnection.baseUrl, Name: name }, () => {
|
|
43
|
-
return new TargetCluster(optsConnection, name);
|
|
44
|
-
});
|
|
45
|
-
if (state) {
|
|
46
|
-
retVal.set(state);
|
|
47
|
-
}
|
|
48
|
-
return retVal;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected constructor(optsConnection: IOptions | IConnection | TopologyService, name: string) {
|
|
52
|
-
super();
|
|
53
|
-
if (optsConnection instanceof TopologyService) {
|
|
54
|
-
this.connection = optsConnection;
|
|
55
|
-
this.machineConnection = new MachineService(optsConnection.connectionOptions());
|
|
56
|
-
} else {
|
|
57
|
-
this.connection = new TopologyService(optsConnection);
|
|
58
|
-
this.machineConnection = new MachineService(optsConnection);
|
|
59
|
-
}
|
|
60
|
-
this.clear({
|
|
61
|
-
Name: name
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
fetchMachines(request: WsMachine.GetTargetClusterInfoRequest = {}): Promise<Machine[]> {
|
|
66
|
-
return this.machineConnection.GetTargetClusterInfo({
|
|
67
|
-
TargetClusters: {
|
|
68
|
-
Item: [`${this.Type}:${this.Name}`]
|
|
69
|
-
},
|
|
70
|
-
...request
|
|
71
|
-
}).then(response => {
|
|
72
|
-
const retVal: WsMachine.MachineInfoEx[] = [];
|
|
73
|
-
for (const machineInfo of response.TargetClusterInfoList.TargetClusterInfo) {
|
|
74
|
-
for (const machineInfoEx of machineInfo.Processes.MachineInfoEx) {
|
|
75
|
-
retVal.push(machineInfoEx);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
this.set("MachineInfoEx", retVal);
|
|
79
|
-
return this.CMachineInfoEx;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
machineStats(): { maxDisk: number; meanDisk: number } {
|
|
84
|
-
let maxDisk = 0;
|
|
85
|
-
let totalFree = 0;
|
|
86
|
-
let total = 0;
|
|
87
|
-
for (const machine of this.CMachineInfoEx) {
|
|
88
|
-
for (const storageInfo of machine.Storage.StorageInfo) {
|
|
89
|
-
totalFree += storageInfo.Available;
|
|
90
|
-
total += storageInfo.Total;
|
|
91
|
-
const usage = 1 - storageInfo.Available / storageInfo.Total;
|
|
92
|
-
if (usage > maxDisk) {
|
|
93
|
-
maxDisk = usage;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
maxDisk,
|
|
99
|
-
meanDisk: 1 - (total ? totalFree / total : 1)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
fetchUsage(): Promise<WsMachineEx.TargetClusterUsage[]> {
|
|
104
|
-
return this.machineConnection.GetTargetClusterUsageEx([this.Name]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function targetClusters(optsConnection: IOptions | IConnection | TopologyService): Promise<TargetCluster[]> {
|
|
109
|
-
let connection: TopologyService;
|
|
110
|
-
if (optsConnection instanceof TopologyService) {
|
|
111
|
-
connection = optsConnection;
|
|
112
|
-
} else {
|
|
113
|
-
connection = new TopologyService(optsConnection);
|
|
114
|
-
}
|
|
115
|
-
return connection.TpListTargetClusters({}).then(response => {
|
|
116
|
-
return response.TargetClusters.TpClusterNameType.map(item => TargetCluster.attach(optsConnection, item.Name, item));
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const _defaultTargetCluster: { [baseUrl: string]: Promise<TargetCluster> } = {};
|
|
121
|
-
export function defaultTargetCluster(optsConnection: IOptions | IConnection | TopologyService): Promise<TargetCluster> {
|
|
122
|
-
if (!_defaultTargetCluster[optsConnection.baseUrl]) {
|
|
123
|
-
let connection: TopologyService;
|
|
124
|
-
if (optsConnection instanceof TopologyService) {
|
|
125
|
-
connection = optsConnection;
|
|
126
|
-
} else {
|
|
127
|
-
connection = new TopologyService(optsConnection);
|
|
128
|
-
}
|
|
129
|
-
_defaultTargetCluster[optsConnection.baseUrl] = connection.TpListTargetClusters({}).then(response => {
|
|
130
|
-
let firstItem: WsTopology.TpClusterNameType;
|
|
131
|
-
let defaultItem: WsTopology.TpClusterNameType;
|
|
132
|
-
let hthorItem: WsTopology.TpClusterNameType;
|
|
133
|
-
response.TargetClusters.TpClusterNameType.forEach(item => {
|
|
134
|
-
if (!firstItem) {
|
|
135
|
-
firstItem = item;
|
|
136
|
-
}
|
|
137
|
-
if (!defaultItem && item.IsDefault === true) {
|
|
138
|
-
defaultItem = item;
|
|
139
|
-
}
|
|
140
|
-
if (!hthorItem && item.Type === "hthor") {
|
|
141
|
-
hthorItem = item;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const defItem = defaultItem || hthorItem || firstItem;
|
|
145
|
-
return TargetCluster.attach(optsConnection, defItem.Name, defItem);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
return _defaultTargetCluster[optsConnection.baseUrl];
|
|
149
|
-
}
|
|
1
|
+
import { Cache, StateObject } from "@hpcc-js/util";
|
|
2
|
+
import { IConnection, IOptions } from "../connection.ts";
|
|
3
|
+
import { WsMachine, WsMachineEx, MachineService } from "../services/wsMachine.ts";
|
|
4
|
+
import { TopologyService, WsTopology } from "../services/wsTopology.ts";
|
|
5
|
+
import { Machine } from "./machine.ts";
|
|
6
|
+
|
|
7
|
+
export class TargetClusterCache extends Cache<{ BaseUrl: string, Name: string }, TargetCluster> {
|
|
8
|
+
constructor() {
|
|
9
|
+
super((obj) => {
|
|
10
|
+
return `${obj.BaseUrl}-${obj.Name}`;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const _targetCluster = new TargetClusterCache();
|
|
15
|
+
|
|
16
|
+
export interface TpTargetClusterEx {
|
|
17
|
+
MachineInfoEx: WsMachine.MachineInfoEx[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type UTargetClusterState = WsTopology.TpTargetCluster & WsTopology.TpClusterNameType & TpTargetClusterEx;
|
|
21
|
+
export type ITargetClusterState = WsTopology.TpTargetCluster | WsTopology.TpClusterNameType | TpTargetClusterEx;
|
|
22
|
+
export class TargetCluster extends StateObject<UTargetClusterState, ITargetClusterState> implements UTargetClusterState {
|
|
23
|
+
protected connection: TopologyService;
|
|
24
|
+
protected machineConnection: MachineService;
|
|
25
|
+
get BaseUrl() { return this.connection.baseUrl; }
|
|
26
|
+
|
|
27
|
+
get Name(): string { return this.get("Name"); }
|
|
28
|
+
get Prefix(): string { return this.get("Prefix"); }
|
|
29
|
+
get Type(): string { return this.get("Type"); }
|
|
30
|
+
get IsDefault(): boolean { return this.get("IsDefault"); }
|
|
31
|
+
get TpClusters(): WsTopology.TpClusters { return this.get("TpClusters"); }
|
|
32
|
+
get TpEclCCServers(): WsTopology.TpEclCCServers { return this.get("TpEclCCServers"); }
|
|
33
|
+
get TpEclServers(): WsTopology.TpEclServers { return this.get("TpEclServers"); }
|
|
34
|
+
get TpEclAgents(): WsTopology.TpEclAgents { return this.get("TpEclAgents"); }
|
|
35
|
+
get TpEclSchedulers(): WsTopology.TpEclSchedulers { return this.get("TpEclSchedulers"); }
|
|
36
|
+
get MachineInfoEx(): WsMachine.MachineInfoEx[] { return this.get("MachineInfoEx", []); }
|
|
37
|
+
get CMachineInfoEx(): Machine[] {
|
|
38
|
+
return this.MachineInfoEx.map(machineInfoEx => Machine.attach(this.machineConnection, machineInfoEx.Address, machineInfoEx));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static attach(optsConnection: IOptions | IConnection | TopologyService, name: string, state?: ITargetClusterState): TargetCluster {
|
|
42
|
+
const retVal: TargetCluster = _targetCluster.get({ BaseUrl: optsConnection.baseUrl, Name: name }, () => {
|
|
43
|
+
return new TargetCluster(optsConnection, name);
|
|
44
|
+
});
|
|
45
|
+
if (state) {
|
|
46
|
+
retVal.set(state);
|
|
47
|
+
}
|
|
48
|
+
return retVal;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected constructor(optsConnection: IOptions | IConnection | TopologyService, name: string) {
|
|
52
|
+
super();
|
|
53
|
+
if (optsConnection instanceof TopologyService) {
|
|
54
|
+
this.connection = optsConnection;
|
|
55
|
+
this.machineConnection = new MachineService(optsConnection.connectionOptions());
|
|
56
|
+
} else {
|
|
57
|
+
this.connection = new TopologyService(optsConnection);
|
|
58
|
+
this.machineConnection = new MachineService(optsConnection);
|
|
59
|
+
}
|
|
60
|
+
this.clear({
|
|
61
|
+
Name: name
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
fetchMachines(request: WsMachine.GetTargetClusterInfoRequest = {}): Promise<Machine[]> {
|
|
66
|
+
return this.machineConnection.GetTargetClusterInfo({
|
|
67
|
+
TargetClusters: {
|
|
68
|
+
Item: [`${this.Type}:${this.Name}`]
|
|
69
|
+
},
|
|
70
|
+
...request
|
|
71
|
+
}).then(response => {
|
|
72
|
+
const retVal: WsMachine.MachineInfoEx[] = [];
|
|
73
|
+
for (const machineInfo of response.TargetClusterInfoList.TargetClusterInfo) {
|
|
74
|
+
for (const machineInfoEx of machineInfo.Processes.MachineInfoEx) {
|
|
75
|
+
retVal.push(machineInfoEx);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
this.set("MachineInfoEx", retVal);
|
|
79
|
+
return this.CMachineInfoEx;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
machineStats(): { maxDisk: number; meanDisk: number } {
|
|
84
|
+
let maxDisk = 0;
|
|
85
|
+
let totalFree = 0;
|
|
86
|
+
let total = 0;
|
|
87
|
+
for (const machine of this.CMachineInfoEx) {
|
|
88
|
+
for (const storageInfo of machine.Storage.StorageInfo) {
|
|
89
|
+
totalFree += storageInfo.Available;
|
|
90
|
+
total += storageInfo.Total;
|
|
91
|
+
const usage = 1 - storageInfo.Available / storageInfo.Total;
|
|
92
|
+
if (usage > maxDisk) {
|
|
93
|
+
maxDisk = usage;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
maxDisk,
|
|
99
|
+
meanDisk: 1 - (total ? totalFree / total : 1)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
fetchUsage(): Promise<WsMachineEx.TargetClusterUsage[]> {
|
|
104
|
+
return this.machineConnection.GetTargetClusterUsageEx([this.Name]);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function targetClusters(optsConnection: IOptions | IConnection | TopologyService): Promise<TargetCluster[]> {
|
|
109
|
+
let connection: TopologyService;
|
|
110
|
+
if (optsConnection instanceof TopologyService) {
|
|
111
|
+
connection = optsConnection;
|
|
112
|
+
} else {
|
|
113
|
+
connection = new TopologyService(optsConnection);
|
|
114
|
+
}
|
|
115
|
+
return connection.TpListTargetClusters({}).then(response => {
|
|
116
|
+
return response.TargetClusters.TpClusterNameType.map(item => TargetCluster.attach(optsConnection, item.Name, item));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const _defaultTargetCluster: { [baseUrl: string]: Promise<TargetCluster> } = {};
|
|
121
|
+
export function defaultTargetCluster(optsConnection: IOptions | IConnection | TopologyService): Promise<TargetCluster> {
|
|
122
|
+
if (!_defaultTargetCluster[optsConnection.baseUrl]) {
|
|
123
|
+
let connection: TopologyService;
|
|
124
|
+
if (optsConnection instanceof TopologyService) {
|
|
125
|
+
connection = optsConnection;
|
|
126
|
+
} else {
|
|
127
|
+
connection = new TopologyService(optsConnection);
|
|
128
|
+
}
|
|
129
|
+
_defaultTargetCluster[optsConnection.baseUrl] = connection.TpListTargetClusters({}).then(response => {
|
|
130
|
+
let firstItem: WsTopology.TpClusterNameType;
|
|
131
|
+
let defaultItem: WsTopology.TpClusterNameType;
|
|
132
|
+
let hthorItem: WsTopology.TpClusterNameType;
|
|
133
|
+
response.TargetClusters.TpClusterNameType.forEach(item => {
|
|
134
|
+
if (!firstItem) {
|
|
135
|
+
firstItem = item;
|
|
136
|
+
}
|
|
137
|
+
if (!defaultItem && item.IsDefault === true) {
|
|
138
|
+
defaultItem = item;
|
|
139
|
+
}
|
|
140
|
+
if (!hthorItem && item.Type === "hthor") {
|
|
141
|
+
hthorItem = item;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const defItem = defaultItem || hthorItem || firstItem;
|
|
145
|
+
return TargetCluster.attach(optsConnection, defItem.Name, defItem);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return _defaultTargetCluster[optsConnection.baseUrl];
|
|
149
|
+
}
|