Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 | 41x 41x 41x 41x 41x 41x 41x 41x 10x 10x 10x 10x 10x 10x 10x 10x 10x 10x 41x 41x 6x 6x 6x 6x 41x 41x 12x 2x 2x 10x 12x 1x 1x 9x 9x 12x 41x 41x 41x 41x 7x 7x 41x 41x 14x 6x 6x 6x 6x 6x 6x 6x 10x 14x 41x 41x 2x 2x 2x 2x 41x 41x 8x 8x 8x 8x 8x 5x 5x 5x 8x 41x 41x 7x 7x 41x 41x 20x 20x 41x 41x 41x 41x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 41x | // Copyright (c) ZeroC, Inc. import { HashMap } from "./HashMap.js"; import { NoEndpointException } from "./LocalExceptions.js"; import { ObjectPrx } from "./ObjectPrx.js"; export class RouterInfo { constructor(router) { this._router = router; console.assert(this._router !== null); this._clientEndpoints = null; this._adapter = null; this._identities = new HashMap(HashMap.compareEquals); // Set<Identity> = Map<Identity, 1> this._evictedIdentities = []; this._hasRoutingTable = false; } destroy() { this._clientEndpoints = []; this._adapter = null; this._identities.clear(); } equals(rhs) { if (this === rhs) { return true; } if (rhs instanceof RouterInfo) { return this._router.equals(rhs._router); } return false; } hashCode() { return this._router.hashCode(); } getRouter() { return this._router; } async getClientEndpoints() { if (this._clientEndpoints === null) { const [clientProxy, hasRoutingTable] = await this._router.getClientProxy(); this._hasRoutingTable = hasRoutingTable ?? true; this._clientEndpoints = clientProxy === null ? this._router._getReference().getEndpoints() : clientProxy._getReference().getEndpoints(); } return this._clientEndpoints; } async getServerEndpoints() { let serverProxy = await this._router.getServerProxy(); if (serverProxy === null) { throw new NoEndpointException("Router::getServerProxy returned a null proxy."); } return serverProxy._getReference().getEndpoints(); } async addProxy(reference) { console.assert(reference !== null); const identity = reference.getIdentity(); // If the router maintains a routing table, and the proxy is not already in our local map, // add it to the router. if (this._hasRoutingTable && !this._identities.has(identity)) { const evictedProxies = await this._router.addProxies([new ObjectPrx(reference)]); this.addAndEvictProxies(identity, evictedProxies); } } setAdapter(adapter) { this._adapter = adapter; } getAdapter() { return this._adapter; } clearCache(ref) { this._identities.delete(ref.getIdentity()); } addAndEvictProxies(identity, evictedProxies) { // Check if the proxy hasn't already been evicted by a concurrent addProxies call. If it's the case, don't add // it to our local map. const index = this._evictedIdentities.findIndex(e => e.equals(identity)); if (index >= 0) { this._evictedIdentities.splice(index, 1); } else { // If we successfully added the proxy to the router, we add it to our local map. this._identities.set(identity, 1); } // Remove the evicted proxies from our local map. for (const proxy of evictedProxies) { this._identities.delete(proxy.ice_getIdentity()); } } } |