Skip to content

Commit

Permalink
Merge pull request #4107 from jeclrsg/comms-topology-service-use-wsdl
Browse files Browse the repository at this point in the history
feat(comms): convert wsTopology to use service generated from wsdl
  • Loading branch information
GordonSmith authored Aug 23, 2023
2 parents 22324cd + 07e5933 commit a5815ed
Show file tree
Hide file tree
Showing 4 changed files with 712 additions and 1,230 deletions.
22 changes: 11 additions & 11 deletions packages/comms/src/ecl/targetCluster.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Cache, StateObject } from "@hpcc-js/util";
import { IConnection, IOptions } from "../connection";
import { WsMachine, WsMachineEx, MachineService } from "../services/wsMachine";
import { TopologyService, TpListTargetClusters, TpTargetClusterQuery } from "../services/wsTopology";
import { TopologyService, WsTopology } from "../services/wsTopology";
import { Machine } from "./machine";

export class TargetClusterCache extends Cache<{ BaseUrl: string, Name: string }, TargetCluster> {
Expand All @@ -17,8 +17,8 @@ export interface TpTargetClusterEx {
MachineInfoEx: WsMachine.MachineInfoEx[];
}

export type UTargetClusterState = TpTargetClusterQuery.TpTargetCluster & TpListTargetClusters.TpClusterNameType & TpTargetClusterEx;
export type ITargetClusterState = TpTargetClusterQuery.TpTargetCluster | TpListTargetClusters.TpClusterNameType | TpTargetClusterEx;
export type UTargetClusterState = WsTopology.TpTargetCluster & WsTopology.TpClusterNameType & TpTargetClusterEx;
export type ITargetClusterState = WsTopology.TpTargetCluster | WsTopology.TpClusterNameType | TpTargetClusterEx;
export class TargetCluster extends StateObject<UTargetClusterState, ITargetClusterState> implements UTargetClusterState {
protected connection: TopologyService;
protected machineConnection: MachineService;
Expand All @@ -28,11 +28,11 @@ export class TargetCluster extends StateObject<UTargetClusterState, ITargetClust
get Prefix(): string { return this.get("Prefix"); }
get Type(): string { return this.get("Type"); }
get IsDefault(): boolean { return this.get("IsDefault"); }
get TpClusters(): TpTargetClusterQuery.TpClusters { return this.get("TpClusters"); }
get TpEclCCServers(): TpTargetClusterQuery.TpEclCCServers { return this.get("TpEclCCServers"); }
get TpEclServers(): TpTargetClusterQuery.TpEclServers { return this.get("TpEclServers"); }
get TpEclAgents(): TpTargetClusterQuery.TpEclAgents { return this.get("TpEclAgents"); }
get TpEclSchedulers(): TpTargetClusterQuery.TpEclSchedulers { return this.get("TpEclSchedulers"); }
get TpClusters(): WsTopology.TpClusters { return this.get("TpClusters"); }
get TpEclCCServers(): WsTopology.TpEclCCServers { return this.get("TpEclCCServers"); }
get TpEclServers(): WsTopology.TpEclServers { return this.get("TpEclServers"); }
get TpEclAgents(): WsTopology.TpEclAgents { return this.get("TpEclAgents"); }
get TpEclSchedulers(): WsTopology.TpEclSchedulers { return this.get("TpEclSchedulers"); }
get MachineInfoEx(): WsMachine.MachineInfoEx[] { return this.get("MachineInfoEx", []); }
get CMachineInfoEx(): Machine[] {
return this.MachineInfoEx.map(machineInfoEx => Machine.attach(this.machineConnection, machineInfoEx.Address, machineInfoEx));
Expand Down Expand Up @@ -129,9 +129,9 @@ export function defaultTargetCluster(optsConnection: IOptions | IConnection | To
connection = new TopologyService(optsConnection);
}
_defaultTargetCluster[optsConnection.baseUrl] = connection.TpListTargetClusters({}).then(response => {
let firstItem: TpListTargetClusters.TpClusterNameType;
let defaultItem: TpListTargetClusters.TpClusterNameType;
let hthorItem: TpListTargetClusters.TpClusterNameType;
let firstItem: WsTopology.TpClusterNameType;
let defaultItem: WsTopology.TpClusterNameType;
let hthorItem: WsTopology.TpClusterNameType;
response.TargetClusters.TpClusterNameType.forEach(item => {
if (!firstItem) {
firstItem = item;
Expand Down
18 changes: 9 additions & 9 deletions packages/comms/src/ecl/topology.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Cache, exists, StateCallback, StateEvents, StateObject, StatePropCallback } from "@hpcc-js/util";
import { IConnection, IOptions } from "../connection";
import { TopologyService, TpLogicalClusterQuery, TpServiceQuery, TpTargetClusterQuery } from "../services/wsTopology";
import { TopologyService, WsTopology } from "../services/wsTopology";
import { TargetCluster } from "./targetCluster";

export class TopologyCache extends Cache<{ BaseUrl: string }, Topology> {
Expand All @@ -13,22 +13,22 @@ export class TopologyCache extends Cache<{ BaseUrl: string }, Topology> {
const _topology = new TopologyCache();

export interface TopologyStateEx {
TargetClusters?: TpTargetClusterQuery.TpTargetCluster[];
LogicalClusters?: TpLogicalClusterQuery.TpLogicalCluster[];
Services?: TpServiceQuery.ServiceList;
TargetClusters?: WsTopology.TpTargetCluster[];
LogicalClusters?: WsTopology.TpLogicalCluster[];
Services?: WsTopology.ServiceList;
}
export class Topology extends StateObject<TopologyStateEx, TopologyStateEx> implements TopologyStateEx {
protected connection: TopologyService;
get BaseUrl() { return this.connection.baseUrl; }

// Accessors ---
get properties(): TopologyStateEx { return this.get(); }
get TargetClusters(): TpTargetClusterQuery.TpTargetCluster[] { return this.get("TargetClusters"); }
get TargetClusters(): WsTopology.TpTargetCluster[] { return this.get("TargetClusters"); }
get CTargetClusters(): TargetCluster[] {
return this.TargetClusters.map(tc => TargetCluster.attach(this.connection, tc.Name, tc));
}
get LogicalClusters(): TpLogicalClusterQuery.TpLogicalCluster[] { return this.get("LogicalClusters"); }
get Services(): TpServiceQuery.ServiceList { return this.get("Services"); }
get LogicalClusters(): WsTopology.TpLogicalCluster[] { return this.get("LogicalClusters"); }
get Services(): WsTopology.ServiceList { return this.get("Services"); }

static attach(optsConnection: IOptions | IConnection | TopologyService) {
const retVal: Topology = _topology.get({ BaseUrl: optsConnection.baseUrl }, () => {
Expand Down Expand Up @@ -75,7 +75,7 @@ export class Topology extends StateObject<TopologyStateEx, TopologyStateEx> impl
});
}

fetchLogicalClusters(request: TpLogicalClusterQuery.Request = {}): Promise<TpLogicalClusterQuery.TpLogicalCluster[]> {
fetchLogicalClusters(request: WsTopology.TpLogicalClusterQueryRequest = {}): Promise<WsTopology.TpLogicalCluster[]> {
return this.connection.TpLogicalClusterQuery(request).then(response => {
this.set({
LogicalClusters: response.TpLogicalClusters.TpLogicalCluster
Expand All @@ -84,7 +84,7 @@ export class Topology extends StateObject<TopologyStateEx, TopologyStateEx> impl
});
}

fetchServices(request: TpServiceQuery.Request = {}): Promise<TpServiceQuery.ServiceList> {
fetchServices(request: WsTopology.TpServiceQueryRequest = {}): Promise<WsTopology.ServiceList> {
return this.connection.TpServiceQuery(request).then(response => {
this.set({
Services: response.ServiceList
Expand Down
Loading

0 comments on commit a5815ed

Please sign in to comment.