Probe constructor.

@constructor
@param {Collector} collector instance
@api public
349629
function Probe(collector) {
  this.fuse();

  //
  // Add _auth if username and password are provided via options.
  //
  var config = collector.options.npm || { loglevel: 'silent' };
  if (config.username && config.password) {
    config._auth = new Buffer(config.username +':'+ config.password).toString('base64');
  }

  //
  // Name of the probe and the registries the probe should run against.
  //
  this.readable('name', 'publish');
  this.readable('list', ['npmjs']);
  this.readable('config', config);
  this.readable('collector', collector);

  //
  // References to the test package that will be published.
  //
  this.readable('live', require('../registries').npmjs.href + 'npm-publish-probe');
  this.readable('map', path.join(__dirname, '..', 'publish'));
  this.readable('package', path.join(this.map, 'package.json'));
  this.writable('module', require(this.package));

  //
  // Test the publish module every 6 minutes.
  //
  this.readable('interval', interval);
}
833559
function ConnectorEndsInspector()
{
	this.inspect = function(connector)
	{
		var children = connector.htmlElement.childNodes;
		var i;
		for(i = 0; i < children.length; i++)
		{
			if(hasClass(children[i], "connector-end"))
			{
				var newElement = new ConnectorEnd(children[i], connector, END);
				newElement.repaint();
				connector.moveListeners.push(newElement);
			}
			else if(hasClass(children[i], "connector-start"))
			{
				var newElement = new ConnectorEnd(children[i], connector, START);
				newElement.repaint();
				connector.moveListeners.push(newElement);
			}
		}
	}
}
1037655
func NewCollector(probes []Probe, config Config) *Collector {
	c := &Collector{
		config:         config,
		stop:           make(chan struct{}, 0),
		staleProbes:    make(map[string]struct{}),
		probeStartTime: make(map[string]time.Time),
	}

	if c.config.Interval == time.Duration(0) {
		c.config.Interval = defaults.StatusCollectorInterval
	}

	if c.config.FailureThreshold == time.Duration(0) {
		c.config.FailureThreshold = defaults.StatusCollectorFailureThreshold
	}

	if c.config.WarningThreshold == time.Duration(0) {
		c.config.WarningThreshold = defaults.StatusCollectorWarningThreshold
	}

	for i := range probes {
		c.spawnProbe(&probes[i])
	}

	return c
}
755065
function( model ) {
			var coll =  _.detect( this._collections, function( c ) {
					// Check if model is the type itself (a ref to the constructor), or is of type c.model
					return model === c.model || model instanceof c.model;
				});
			
			if ( !coll ) {
				coll = this._createCollection( model );
			}
			
			return coll;
		}
909024
public static OClass probeOClass(Iterable<ODocument> it, int probeLimit) {
		return probeOClass(it.iterator(), probeLimit);
	}
410448
function Probe(connection, done) {
  if (!(this instanceof Probe)) {
    return new Probe(connection, done);
  }

  if (typeof connection === 'string') {
    connection = Connection.from(
      Deployment.getId(connection));
  }
  debug('connection is `%j`', connection);

  this.deployment = new Deployment({
    _id: Instance.getId(connection.getId()),
    name: connection.name
  });

  this.connection = connection;

  this.db = null;
  this.metadata = null;

  if (typeof done === 'function') {
    this.exec(done);
  }
}
472752
function discover(waitForCount, callback) {
    var listenAddress='0.0.0.0';
    var listenPort=30000;
    var probePort=30050;
    var probeAddress='255.255.255.255';
    var probeAttempts=10;
    var probeInterval=500;
    var probeData = new Buffer('DAIKIN_UDP/common/basic_info');
    var probeTimeout;

    var discoveredDevices = {};

    var udpSocket = udp.createSocket({type:"udp4", reuseAddr:true});

    udpSocket.on('error', function (err) {
        console.log('ERROR udpSocket: ' + err);
    });

    udpSocket.bind(listenPort, listenAddress, function() {
        udpSocket.addMembership('224.0.0.1');
        udpSocket.setBroadcast(true);
    });

    udpSocket.on("message", function (message, remote) {
        console.log(remote.address + ':' + remote.port +' - ' + message);
        discoveredDevices[remote.address] = message.toString();
        if (Object.keys(discoveredDevices).length >= waitForCount) {
            finalizeDiscovery();
        }
    });

    udpSocket.on('listening', function() {
        sendProbes(probeAttempts);
    });

    function sendProbes(attemptsLeft) {
        probeTimeout = null;
        if (attemptsLeft > 0) {
            console.log('Send UDP discovery package ' + attemptsLeft);
            udpSocket.send(probeData, 0, probeData.length, probePort, probeAddress);
            probeTimeout = setTimeout(sendProbes, probeInterval, --attemptsLeft);
        }
        else {
            finalizeDiscovery();
        }
    }

    function finalizeDiscovery() {
        if (probeTimeout) clearTimeout(probeTimeout);
        udpSocket.close();
        console.log('Discovery finished with ' + Object.keys(discoveredDevices).length + ' devices found');
        callback(discoveredDevices);
    }
}
1300209
def addCollector(self, collector):
        
        collector.setSchema(self)
        self.__collectors[collector.name()] = collector
192182
function inspectConstructor(target, cache) {
        // If browser has no define property it means it is too old and
        // in that case we return the target itself.
        // This could be improved but I think it does not worth the trouble
        if (!hasDefineProperty) {
            return target;
        }

        var def,
            methodsCache,
            propertiesCache,
            membersCache,
            obj,
            tmp,
            key;

        obj = fetchCache(target, cache.constructors);
        if (obj) {
            return obj;
        }

        def = target[$class];
        obj = def.simpleConstructor;
        methodsCache = target[cacheKeyword].methods;
        propertiesCache = target[cacheKeyword].properties;

        cache.constructors.push({ target: target, inspect: obj });

        // Constructor methods
        for (key in methodsCache) {
            obj[key] = inspect(methodsCache[key], cache, true);
        }

        // Constructor properties
        for (key in propertiesCache) {
            tmp = propertiesCache[key];
            obj[key] = inspect(tmp, cache, true);
        }

        // Handle constructor undeclared properties
        methodsCache = def.methods;
        propertiesCache = def.properties;
        for (key in target) {
            if (hasOwn(target, key) && !hasOwn(obj, key) && !propertiesCache[key] && !methodsCache[key]) {
                obj[key] = inspect(target[key], cache, true);
            }
        }

        obj = obj.prototype;

        // Prototype members
        target = target.prototype;
        membersCache = def.ownMembers;
        methodsCache = def.methods;
        propertiesCache = def.properties;

        for (key in membersCache) {
            tmp = methodsCache[key] ? methodsCache[key].implementation : propertiesCache[key].value;
            obj[key] = inspect(tmp, cache, true);
        }

        // Handle undeclared prototype members
        for (key in target) {
            if (hasOwn(target, key) && !hasOwn(obj, key) && !membersCache[key]) {
                obj[key] = inspect(target[key], cache, true);
            }
        }

        return obj;
    }
1128787
def probe(cls, resource, enable, disable, test, host, interval,
              http_method, http_response, threshold, timeout, url, window):
        
        params = {
            'host': host,
            'interval': interval,
            'method': http_method,
            'response': http_response,
            'threshold': threshold,
            'timeout': timeout,
            'url': url,
            'window': window
        }
        if enable:
            params['enable'] = True
        elif disable:
            params['enable'] = False
        if test:
            result = cls.call(
                'hosting.rproxy.probe.test', cls.usable_id(resource), params)
        else:
            result = cls.call(
                'hosting.rproxy.probe.update', cls.usable_id(resource), params)
            cls.display_progress(result)
        return result
1223580
function(connect, callback) {
      callback = callback || function(){};
      var t = this,
          needsConnecting = false,
          logMethod = (connect ? 'connectMonitor' : 'disconnectMonitor'),
          originalParams = null,
          monitor = t.model.get('monitor'),
          isConnected = monitor.isConnected();

      // Determine if we need to connect/disconnect
      if (
          (connect && !isConnected && monitor.get('probeClass')) ||
          (!connect && isConnected)) {
        needsConnecting = true;
      }

      // If no need to connect, callback on next tick.  This makes the
      // call stack consistent regardless of the presence of monitors.
      if (!needsConnecting) {
        log.info(logMethod + '.alreadyConnected', t.logCtxt);
        setTimeout(function(){
          callback(null);
        },0);
        return;
      }

      // If connecting, override the init params with url params
      if (connect) {
        originalParams = monitor.get('initParams');
        monitor.set(
          {initParams: _.extend({}, originalParams, initOverrides)},
          {silent: true}
        );
      }
      else {
        // If disconnecting, remove all change listeners
        monitor.off('change');
      }

      // Connect or disconnect, calling the callback when done
      var connectFn = connect ? 'connect' : 'disconnect';
      log.info(logMethod, t.logCtxt);
      monitor[connectFn](function(error) {

        // Replace original initParams (so the page isn't dirty)
        // Acutal init params will become attributes of the monitor object
        if (originalParams) {
          monitor.set(
            {initParams: originalParams},
            {silent: true}
          );
        }

        // If disconnecting, clear the probe data
        if (!connect) {
          var probeElems = monitor.toProbeJSON();
          delete probeElems.id;
          monitor.set(probeElems, {unset:true});
        }

        // Callback passing error if set
        return callback(error);
      });
    }
1072858
function bindIndicators(indicator) {
    // Parent process will send three type of data
    const collectorHandler = {
        'process': function (value) {
            indicator.rss = value.rss;
            indicator.heapTotal = value.heapTotal;
            indicator.heapUsed = value.heapUsed;
        },
        'os': function (value) {
            indicator.totalMem = value.totalMem;
            indicator.freeMem = value.freeMem;
            indicator.cpus = value.cpus;
        },
        'v8': function (value) {
            indicator.newSpace = value.heapSpace[0];
            indicator.oldSpace = value.heapSpace[1];
            indicator.codeSpace = value.heapSpace[2];
            indicator.mapSpace = value.heapSpace[3];
            indicator.largeObjectSpace = value.heapSpace[4];
        }
    }

    process.on('message', (msg) => {
        if (Array.isArray(msg)) {
            msg.forEach((data) => {
                let handler = collectorHandler[data.type];
                if (typeof handler === 'function') collectorHandler[data.type](data.value);
            });
        }
    });
}
1078561
Set<ProbeListener> removeListenersForMonitor(Object monitor) {
        Set<ProbeListener> listeners = null;

        listenersLock.writeLock().lock();
        try {
            listeners = listenersForMonitor.remove(monitor);
            if (listeners == null) {
                listeners = Collections.emptySet();
            } else {
                allRegisteredListeners.removeAll(listeners);
            }
        } finally {
            listenersLock.writeLock().unlock();
        }

        return listeners;
    }
806323
private void probeExtensionIntrospectors(PrintWriter writer) {
    	 
    	 List<ProbeExtension> registeredProbeExtensions = RequestProbeService.getProbeExtensions();
         List<String> probeExtensionRefList = new ArrayList<String>() {{add("Probe extension"); add("");  add("");}};
         List<String> sampleRateList = new ArrayList<String>() {{add("Sample"); add("Rate"); add("");}};
         List<String> contextInfoRequiredList = new ArrayList<String>() { { add("ContextInfo"); add("required"); add(""); }};
         List<String> invokeOnyForRootList = new ArrayList<String>() {{add("Invoke only"); add("for root"); add(""); }};
         List<String> entryEnabledList = new ArrayList<String>( ) {{ add("Entry"); add("enabled"); add("");  }};
         List<String> exitEnabledList = new ArrayList<String>() {{ add("Exit"); add("enabled"); add(""); }};
         List<String> includeTypeList = new ArrayList<String>() {{ add("Include Types"); add(""); add("");}};
         List<Integer> indentationLength = new ArrayList<Integer>();
         int maxSpaceRequired = 0;
        
         
         for(ProbeExtension probeExtension : registeredProbeExtensions) {
         	
         	probeExtensionRefList.add(probeExtension.toString());
         	sampleRateList.add(""+probeExtension.getRequestSampleRate());
         	invokeOnyForRootList.add(probeExtension.invokeForRootEventsOnly() ? "True" : "False");
         	entryEnabledList.add(probeExtension.invokeForEventEntry() ? "True" : "False");
         	exitEnabledList.add(probeExtension.invokeForEventExit() ? "True" : "False");
         	
         	if(probeExtension.getContextInfoRequirement() == 0) {
         		contextInfoRequiredList.add("ALL_EVENTS");
         	} else if(probeExtension.getContextInfoRequirement() == 1) {
         		contextInfoRequiredList.add("EVENTS_MATCHING_SPECIFIED_EVENT_TYPES");
         	} else {
         		contextInfoRequiredList.add("NONE");
         	}
         	
         	StringBuilder eventTypes= new StringBuilder();
         	String eventTypeStr = "";
         	
         	if(probeExtension.invokeForEventTypes() == null) {
         		eventTypeStr = "ALL";
         	} else {
         		
         		for(String eventType: probeExtension.invokeForEventTypes()) {
         			eventTypes.append(eventType + ",");
         		}
         		eventTypeStr = eventTypes.toString().substring(0, eventTypes.length() - 1);
         	}
         	includeTypeList.add(eventTypeStr);
         	
         }
         
         // Find the indentation required for Probe Extension Reference.. 
         for(String probeExtensionRef : probeExtensionRefList) {
         	
         	if(probeExtensionRef.length() > maxSpaceRequired) {
         		maxSpaceRequired = probeExtensionRef.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
         // Find the indentation required for Sample Rate .. 
         maxSpaceRequired = 0;
         for(String sampleRate : sampleRateList) {
         	if(sampleRate.length() > maxSpaceRequired) {
         		maxSpaceRequired = sampleRate.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
         // Find the indentation required for context info required.. 
         maxSpaceRequired = 0;
         for(String contextInfoRequired : contextInfoRequiredList) {
         	if(contextInfoRequired.length() > maxSpaceRequired) {
         		maxSpaceRequired = contextInfoRequired.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
         // Find the indentation required for  invokeOnyForRoot.. 
         maxSpaceRequired = 0;
         for(String invokeOnyForRoot : invokeOnyForRootList) {
         	if(invokeOnyForRoot.length() > maxSpaceRequired) {
         		maxSpaceRequired = invokeOnyForRoot.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
         // Find the indentation required for  entryEnabledList..
         maxSpaceRequired = 0;
         for(String entryEnabled : entryEnabledList) {
         	if(entryEnabled.length() > maxSpaceRequired) {
         		maxSpaceRequired = entryEnabled.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
       // Find the indentation required for  exitEnabledList..
         maxSpaceRequired = 0;
         for(String exitEnabled : exitEnabledList) {
         	if(exitEnabled.length() > maxSpaceRequired) {
         		maxSpaceRequired = exitEnabled.length();
         	}
         }
         indentationLength.add(maxSpaceRequired + EXTRA_SPACE_REQUIRED);
         
         writer.println();
         writer.println("------------------------------------------------------------------------------");
         writer.println("              Registered Probe Extensions ");   
         writer.println("------------------------------------------------------------------------------");

        
        for(int i = 0 ; i < probeExtensionRefList.size() ; i ++) {

         	writer.println(
 							String.format(
	 							"%-" + indentationLength.get(0)+ "s%-"+ indentationLength.get(1)+ "s%-" + indentationLength.get(2)+ "s" +
	 							"%-" + indentationLength.get(3)+ "s%-"+ indentationLength.get(4)+ "s%-" + indentationLength.get(5)+ "s%s", 
	 							probeExtensionRefList.get(i) ,
	 							sampleRateList.get(i) ,
	 							contextInfoRequiredList.get(i),
	 							invokeOnyForRootList.get(i),
	 							entryEnabledList.get(i),
	 							exitEnabledList.get(i),
	 							includeTypeList.get(i)
 						    )					
            );
         }
         
        if(registeredProbeExtensions.size() ==  0) { // No active probe extensions available
       	 writer.println("----- No probe extensions are registered ----- ");
        }
		
	}
7475
function Device(Connection) {
  var self = this;

  // call super class
  EventEmitter2.call(this, {
    wildcard: true,
    delimiter: ':',
    maxListeners: 1000 // default would be 10!
  });

  if (this.log) {
    this.log = _.wrap(this.log, function(func, msg) {
      func(self.constructor.name + ': ' + msg);
    });
  } else if (Device.prototype.log) {
    Device.prototype.log = _.wrap(Device.prototype.log, function(func, msg) {
      func(self.constructor.name + ': ' + msg);
    });
    this.log = Device.prototype.log;
  } else {
    var debug = require('debug')(this.constructor.name);
    this.log = function(msg) {
      debug(msg);
    };
  }

  this.id = uuid();
  this.Connection = Connection;

  this.attributes = { id: this.id };

  this.on('disconnect', function() {
    self.connection = null;
  });
}
1295117
Set<ProbeListener> buildListenersFromAnnotated(Object monitor) {
        Set<ProbeListener> listeners = new HashSet<ProbeListener>();

        Class<?> clazz = monitor.getClass();
        for (Method method : ReflectionHelper.getMethods(clazz)) {
            ProbeSite probeSite = method.getAnnotation(ProbeSite.class);
            if (probeSite == null) {
                continue;
            }
            synchronized (notMonitorable) {
                Class<?> rClass = null;
                for (Class<?> tClass : notMonitorable) {
                    if (tClass != null && ((tClass.getName()).equals(probeSite.clazz()))) {
                        rClass = tClass;
                        monitorable.add(tClass);
                        break;
                    }
                }
                if (rClass != null) {
                    notMonitorable.remove(rClass);
                }
            }
            // TODO: Handle monitoring groups
            Monitor monitorData = clazz.getAnnotation(Monitor.class);
            ListenerConfiguration config = new ListenerConfiguration(monitorData, probeSite, method);
            //            ProbeListener listener = new ProbeListener(this, config, monitor, method);
            ProbeListener listener = new ProbeListener(null, config, monitor, method);
            listeners.add(listener);
        }

        return listeners;
    }
403549
public boolean tryProbe(BaseRow record) throws IOException {
		if (!this.probeIterator.hasSource()) {
			// set the current probe value when probeIterator is null at the begging.
			this.probeIterator.setInstance(record);
		}
		// calculate the hash
		BinaryRow probeKey = probeSideProjection.apply(record);
		final int hash = hash(probeKey.hashCode(), this.currentRecursionDepth);

		BinaryHashPartition p = this.partitionsBeingBuilt.get(hash % partitionsBeingBuilt.size());

		// for an in-memory partition, process set the return iterators, else spill the probe records
		if (p.isInMemory()) {
			this.probeKey = probeKey;
			this.probeRow = record;
			p.bucketArea.startLookup(hash);
			return true;
		} else {
			if (p.testHashBloomFilter(hash)) {
				BinaryRow row = originProbeSideSerializer.baseRowToBinary(record);
				p.insertIntoProbeBuffer(row);
			}
			return false;
		}
	}