@hpcc-js/comms 2.83.0 → 2.83.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/ecl/query.ts CHANGED
@@ -1,7 +1,10 @@
1
- import { Cache, StateObject } from "@hpcc-js/util";
1
+ import { Cache, StateObject, scopedLogger } from "@hpcc-js/util";
2
2
  import { IConnection, IOptions } from "../connection";
3
3
  import { EclService, IWsEclRequest, IWsEclResponse, IWsEclResult } from "../services/wsEcl";
4
4
  import { WorkunitsService, WUQueryDetails } from "../services/wsWorkunits";
5
+ import { Topology } from "./topology";
6
+
7
+ const logger = scopedLogger("@hpcc-js/comms/ecl/query.ts");
5
8
 
6
9
  export interface QueryEx extends WUQueryDetails.Response {
7
10
  BaseUrl: string;
@@ -17,11 +20,9 @@ class QueryCache extends Cache<QueryEx, Query> {
17
20
  const _queries = new QueryCache();
18
21
 
19
22
  export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
20
- protected connection: EclService;
21
- get BaseUrl() { return this.connection.baseUrl; }
22
- // protected _topology: Topology;
23
- protected _wsWorkunits: WorkunitsService;
24
- // protected _wu: Workunit;
23
+ protected wsWorkunitsService: WorkunitsService;
24
+ get BaseUrl() { return this.wsWorkunitsService.baseUrl; }
25
+ protected topology: Topology;
25
26
  protected _requestSchema: IWsEclRequest;
26
27
  protected _responseSchema: IWsEclResponse;
27
28
 
@@ -51,17 +52,14 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
51
52
  get WUGraphs(): WUQueryDetails.WUGraphs { return this.get("WUGraphs"); }
52
53
  get WUTimers(): WUQueryDetails.WUTimers { return this.get("WUTimers"); }
53
54
 
54
- private constructor(optsConnection: IOptions | IConnection | EclService, querySet: string, queryID: string, queryDetails?: WUQueryDetails.Response) {
55
+ private constructor(optsConnection: IOptions | IConnection | WorkunitsService, querySet: string, queryID: string, queryDetails?: WUQueryDetails.Response) {
55
56
  super();
56
- if (optsConnection instanceof EclService) {
57
- this.connection = optsConnection;
58
-
59
- // this._topology = new Topology(this.connection.opts());
57
+ if (optsConnection instanceof WorkunitsService) {
58
+ this.wsWorkunitsService = optsConnection;
60
59
  } else {
61
- this.connection = new EclService(optsConnection);
62
- // this._topology = new Topology(optsConnection);
60
+ this.wsWorkunitsService = new WorkunitsService(optsConnection);
63
61
  }
64
- this._wsWorkunits = new WorkunitsService(optsConnection);
62
+ this.topology = Topology.attach(this.wsWorkunitsService.opts());
65
63
  this.set({
66
64
  QuerySet: querySet,
67
65
  QueryId: queryID,
@@ -76,24 +74,56 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
76
74
  return retVal;
77
75
  }
78
76
 
77
+ private _eclService: Promise<EclService>;
78
+ protected async wsEclService(): Promise<EclService | undefined> {
79
+ if (!this._eclService) {
80
+ this._eclService = this.topology.fetchServices({}).then(services => {
81
+ for (const espServer of services?.TpEspServers?.TpEspServer ?? []) {
82
+ for (const binding of espServer?.TpBindings?.TpBinding ?? []) {
83
+ if (binding?.Service === "ws_ecl") {
84
+ const baseUrl = `${binding.Protocol}://${globalThis.location.hostname}:${binding.Port}`;
85
+ return new EclService({ baseUrl });
86
+ }
87
+ }
88
+ }
89
+ return undefined;
90
+ });
91
+ }
92
+ return this._eclService;
93
+ }
94
+
79
95
  private async fetchDetails(): Promise<void> {
80
- const queryDetails = await this._wsWorkunits.WUQueryDetails({
96
+ const queryDetails = await this.wsWorkunitsService.WUQueryDetails({
81
97
  QuerySet: this.QuerySet,
82
98
  QueryId: this.QueryId,
83
- IncludeStateOnClusters: false,
84
- IncludeSuperFiles: false,
85
- IncludeWsEclAddresses: false,
99
+ IncludeStateOnClusters: true,
100
+ IncludeSuperFiles: true,
101
+ IncludeWsEclAddresses: true,
86
102
  CheckAllNodes: false
87
103
  });
88
104
  this.set({ ...queryDetails } as QueryEx);
89
105
  }
90
106
 
91
107
  private async fetchRequestSchema(): Promise<void> {
92
- this._requestSchema = await this.connection.requestJson(this.QuerySet, this.QueryId);
108
+ const wsEclService = await this.wsEclService();
109
+ try {
110
+ this._requestSchema = await wsEclService?.requestJson(this.QuerySet, this.QueryId) ?? [];
111
+ } catch (e) {
112
+ // See: https://track.hpccsystems.com/browse/HPCC-29827
113
+ logger.debug(e);
114
+ this._requestSchema = [];
115
+ }
93
116
  }
94
117
 
95
118
  private async fetchResponseSchema(): Promise<void> {
96
- this._responseSchema = await this.connection.responseJson(this.QuerySet, this.QueryId);
119
+ const wsEclService = await this.wsEclService();
120
+ try {
121
+ this._responseSchema = await wsEclService?.responseJson(this.QuerySet, this.QueryId) ?? {};
122
+ } catch (e) {
123
+ // See: https://track.hpccsystems.com/browse/HPCC-29827
124
+ logger.debug(e);
125
+ this._responseSchema = {};
126
+ }
97
127
  }
98
128
 
99
129
  private async fetchSchema(): Promise<void> {
@@ -101,16 +131,23 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
101
131
  }
102
132
 
103
133
  fetchSummaryStats() {
104
- return this._wsWorkunits.WUQueryGetSummaryStats({ Target: this.QuerySet, QueryId: this.QueryId });
134
+ return this.wsWorkunitsService.WUQueryGetSummaryStats({ Target: this.QuerySet, QueryId: this.QueryId });
105
135
  }
106
136
 
107
- submit(request: object): Promise<Array<{ [key: string]: object[] }>> {
108
- return this.connection.submit(this.QuerySet, this.QueryId, request).then(results => {
109
- for (const key in results) {
110
- results[key] = results[key].Row;
111
- }
112
- return results;
113
- });
137
+ async submit(request: object): Promise<Array<{ [key: string]: object[] }>> {
138
+ const wsEclService = await this.wsEclService();
139
+ try {
140
+ return wsEclService?.submit(this.QuerySet, this.QueryId, request).then(results => {
141
+ for (const key in results) {
142
+ results[key] = results[key].Row;
143
+ }
144
+ return results;
145
+ }) ?? [];
146
+ } catch (e) {
147
+ // See: https://track.hpccsystems.com/browse/HPCC-29827
148
+ logger.debug(e);
149
+ return [];
150
+ }
114
151
  }
115
152
 
116
153
  async refresh(): Promise<this> {
@@ -143,18 +180,4 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
143
180
  if (!this._responseSchema[resultName]) return [];
144
181
  return this._responseSchema[resultName];
145
182
  }
146
-
147
- /*
148
- protected WUQueryDetails(): Promise<WUQueryDetails.Response> {
149
- const request: WUQueryDetails.Request = {} as WUQueryDetails.Request;
150
- request.QueryId = this.QueryId;
151
- request.QuerySet = this.QuerySet;
152
- request.IncludeSuperFiles = true;
153
- request.IncludeStateOnClusters = true;
154
- return this.connection.WUQueryDetails(request).then((response) => {
155
- this.set(response);
156
- return response;
157
- });
158
- }
159
- */
160
183
  }
@@ -1,4 +1,4 @@
1
- import { AccessServiceBase, WsAccess } from "./wsdl/ws_access/v1.16/ws_access";
1
+ import { AccessServiceBase, WsAccess } from "./wsdl/ws_access/v1.17/ws_access";
2
2
 
3
3
  export {
4
4
  WsAccess