lib/js/NetworkMap.js
function() {
      var t = this,
          map = {},
          router = Monitor.getRouter(),
          hostName = Monitor.getRouter().getHostName(),
          appName = Monitor.Config.Monitor.appName,
          appInstance = process.env.NODE_APP_INSTANCE;

      // Add this process to the map
      map[hostName] = {};
      map[hostName][appName] = {
        instances: [appInstance],
        probeClasses: _.keys(Probe.classes)
      };

      // Process all known connections
      var connections = router.findConnections();
      connections.forEach(function(connection) {
        hostName = connection.get('hostName') || connection.get('remoteHostName');
        appName = connection.get('remoteAppName') || '';
        appInstance = connection.get('remoteAppInstance') || '';

        // Don't add to the map not yet connected
        if (connection.connecting || !connection.connected) {
          return;
        }

        // Add the hostname to the map
        var host = map[hostName];
        if (!host) {
          host = map[hostName] = {};
        }

        // Add the app to the map
        var app = host[appName];
        if (!app) {
          app = host[appName] = {
            instances: [appInstance],
            probeClasses: connection.get('remoteProbeClasses')
          };
        } else {
          app.instances.push(appInstance);
        }
      });
      log.info('buildMap', map);

      // Set the map if it's changed.  This method is called whenever
      // connections come and go - including firewalled connections which
      // aren't visible in the map.  Only update if the map has changed.
      if (!_.isEqual(map, t.get('map'))) {
        log.info('mapChanged');
        t.set({
          map: map,
          updateSequence: t.updateSequence++
        });
      } else {
        log.info('mapNotChanged');
      }
    }
function() {
      var t = this,
          map = {},
          router = Monitor.getRouter(),
          hostName = Monitor.getRouter().getHostName(),
          appName = Monitor.Config.Monitor.appName,
          appInstance = process.env.NODE_APP_INSTANCE;

      // Add this process to the map
      map[hostName] = {};
      map[hostName][appName] = {
        instances: [appInstance],
        probeClasses: _.keys(Probe.classes)
      };

      // Process all known connections
      var connections = router.findConnections();
      connections.forEach(function(connection) {
        hostName = connection.get('hostName') || connection.get('remoteHostName');
        appName = connection.get('remoteAppName') || '';
        appInstance = connection.get('remoteAppInstance') || '';

        // Don't add to the map not yet connected
        if (connection.connecting || !connection.connected) {
          return;
        }

        // Add the hostname to the map
        var host = map[hostName];
        if (!host) {
          host = map[hostName] = {};
        }

        // Add the app to the map
        var app = host[appName];
        if (!app) {
          app = host[appName] = {
            instances: [appInstance],
            probeClasses: connection.get('remoteProbeClasses')
          };
        } else {
          app.instances.push(appInstance);
        }
      });
      log.info('buildMap', map);

      // Set the map if it's changed.  This method is called whenever
      // connections come and go - including firewalled connections which
      // aren't visible in the map.  Only update if the map has changed.
      if (!_.isEqual(map, t.get('map'))) {
        log.info('mapChanged');
        t.set({
          map: map,
          updateSequence: t.updateSequence++
        });
      } else {
        log.info('mapNotChanged');
      }
    }
function ( ) { var t = this , map = { } , router = Monitor . getRouter ( ) , hostName = Monitor . getRouter ( ) . getHostName ( ) , appName = Monitor . Config . Monitor . appName , appInstance = process . env . NODE_APP_INSTANCE ; // Add this process to the map map [ hostName ] = { } ; map [ hostName ] [ appName ] = { instances : [ appInstance ] , probeClasses : _ . keys ( Probe . classes ) } ; // Process all known connections var connections = router . findConnections ( ) ; connections . forEach ( function ( connection ) { hostName = connection . get ( 'hostName' ) || connection . get ( 'remoteHostName' ) ; appName = connection . get ( 'remoteAppName' ) || '' ; appInstance = connection . get ( 'remoteAppInstance' ) || '' ; // Don't add to the map not yet connected if ( connection . connecting || ! connection . connected ) { return ; } // Add the hostname to the map var host = map [ hostName ] ; if ( ! host ) { host = map [ hostName ] = { } ; } // Add the app to the map var app = host [ appName ] ; if ( ! app ) { app = host [ appName ] = { instances : [ appInstance ] , probeClasses : connection . get ( 'remoteProbeClasses' ) } ; } else { app . instances . push ( appInstance ) ; } } ) ; log . info ( 'buildMap' , map ) ; // Set the map if it's changed.  This method is called whenever // connections come and go - including firewalled connections which // aren't visible in the map.  Only update if the map has changed. if ( ! _ . isEqual ( map , t . get ( 'map' ) ) ) { log . info ( 'mapChanged' ) ; t . set ( { map : map , updateSequence : t . updateSequence ++ } ) ; } else { log . info ( 'mapNotChanged' ) ; } }
This builds a new site map, and sets it into the map property if it is different from the current map.
This builds a new site map and sets it into the map property if it is different from the current map .