ing
This commit is contained in:
parent
485dc7e8c1
commit
7e94b5eb30
|
@ -50,8 +50,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
private readonly maxScale: number;
|
||||
private readonly minScale: number;
|
||||
|
||||
hosts: Host[];
|
||||
ports: Port[];
|
||||
hosts: Map<string, Host>;
|
||||
ports: Map<string, Map<number, Port>>;
|
||||
|
||||
resultMsg: Message[] = [];
|
||||
|
||||
|
@ -87,8 +87,8 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
) {
|
||||
this.nodes = [];
|
||||
this.links = [];
|
||||
this.hosts = [];
|
||||
this.ports = [];
|
||||
this.hosts = new Map();
|
||||
this.ports = new Map();
|
||||
|
||||
this.discoveryRequestID = null;
|
||||
|
||||
|
@ -511,6 +511,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
case 'zone':
|
||||
const zone: Zone = node.target;
|
||||
zone.hostList = [];
|
||||
|
||||
this.hosts.forEach(_host => {
|
||||
if (_host.zone.network === zone.network) {
|
||||
zone.hostList.push(_host);
|
||||
|
@ -520,11 +521,11 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
case 'host':
|
||||
const host: Host = node.target;
|
||||
host.portList = [];
|
||||
this.ports.forEach(port => {
|
||||
if (port.host.address === host.address) {
|
||||
if (this.ports.has(host.address)) {
|
||||
this.ports.get(host.address).forEach(port => {
|
||||
host.portList.push(port);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -661,16 +662,22 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredHost' })
|
||||
public DiscoveredHost(host: Host) {
|
||||
console.log('DiscoveredHost', host);
|
||||
let dup = false;
|
||||
this.hosts.forEach((item) => {
|
||||
if (item.address === host.address) {
|
||||
dup = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (!dup) {
|
||||
this.hosts.push(host);
|
||||
}
|
||||
|
||||
// if (this.hosts.has(host.address)) {
|
||||
|
||||
// }
|
||||
|
||||
// let dup = false;
|
||||
// this.hosts.forEach((item) => {
|
||||
// if (item.address === host.address) {
|
||||
// dup = true;
|
||||
// return;
|
||||
// }
|
||||
// });
|
||||
// if (!dup) {
|
||||
// this.hosts.push(host);
|
||||
// }
|
||||
this.hosts.set(host.address, host);
|
||||
|
||||
const hostId = `${host.address}`;
|
||||
|
||||
|
@ -698,7 +705,16 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
@RPCSubscriber({ method: 'DiscoveryService.DiscoveredPort' })
|
||||
public DiscoveredPort(port: Port) {
|
||||
console.log('DiscoveredPort', port);
|
||||
this.ports.push(port);
|
||||
|
||||
let _ports: Map<number, Port>;
|
||||
if (!this.ports.has(port.host.address)) {
|
||||
_ports = new Map();
|
||||
this.ports.set(port.host.address, _ports);
|
||||
} else {
|
||||
_ports = this.ports.get(port.host.address);
|
||||
}
|
||||
|
||||
_ports.set(port.portNumber, port);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -708,7 +724,7 @@ export class HomePageComponent implements OnInit, OnDestroy {
|
|||
public DiscoveredService(service: Service) {
|
||||
console.log('DiscoveredService', service);
|
||||
const hostId = service.port.host.address;
|
||||
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.key}`;
|
||||
const serviceId = `${service.port.host.address}-${service.port.portNumber}-${service.port.metaPortType.key}`;
|
||||
|
||||
const hostNode = this.getNode(hostId);
|
||||
let serviceNode = this.getNode(serviceId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user