Adds a watch from a foreign server. Remote notifications will send a copy
to the foreign server.
421404
public void addForeignWatch(TableKraken table, byte []key, String serverId)
  {
    WatchForeign watch = new WatchForeign(key, table, serverId);

    WatchTable watchTable = getWatchTable(table);
    
    watchTable.addWatchForeign(watch, key);
  }
139401
@Deprecated
    public void addWatcher(Path file, Watcher watcher) {
        addWatcher(file, (Listener) watcher);
    }
655413
function updateTerriaClockWatcher(catalogItem) {
  if (
    catalogItem._mirroringTerriaClock &&
    !defined(catalogItem._removeTerriaClockWatch)
  ) {
    // We are using the terria clock, add a subscription to copy the current time into this items clock.
    catalogItem._removeTerriaClockWatch = catalogItem.terria.clock.onTick.addEventListener(
      terriaClock => {
        if (
          !JulianDate.equals(
            terriaClock.currentTime,
            catalogItem.clock.currentTime
          )
        ) {
          updateCurrentTime(catalogItem, terriaClock.currentTime);
        }
      }
    );
  } else if (
    !catalogItem._mirroringTerriaClock &&
    defined(catalogItem._removeTerriaClockWatch)
  ) {
    // We are no longer using the terria clock, remove the subscription.
    catalogItem._removeTerriaClockWatch();
    catalogItem._removeTerriaClockWatch = undefined;
  }
}
459715
public synchronized ApptentiveNotificationCenter addObserver(String notification, ApptentiveNotificationObserver observer) {
		addObserver(notification, observer, false);
		return this;
	}
1167446
public static WatchMonitor create(URL url, int maxDepth, WatchEvent.Kind<?>... events){
		return create(URLUtil.toURI(url), maxDepth, events);
	}
800169
function(self, agent, msg, cb) {
  logger.debug('[%s] receive addServer signal: %j', self.app.serverId, msg);
  if(!msg || !msg.server) {
    logger.warn('monitorwatcher addServer receive empty message: %j', msg);
    utils.invokeCallback(cb, Constants.SIGNAL.FAIL);
    return;
  }
  addServers(self, [msg.server]);
  utils.invokeCallback(cb, Constants.SIGNAL.OK);
}
1253068
function notifyWatchers(objJoint, source_ws){
	var objUnit = objJoint.unit;
	var arrAddresses = objUnit.authors.map(function(author){ return author.address; });
	if (!objUnit.messages) // voided unit
		return;
	for (var i=0; i<objUnit.messages.length; i++){
		var message = objUnit.messages[i];
		if (message.app !== "payment" || !message.payload)
			continue;
		var payload = message.payload;
		for (var j=0; j<payload.outputs.length; j++){
			var address = payload.outputs[j].address;
			if (arrAddresses.indexOf(address) === -1)
				arrAddresses.push(address);
		}
	}
	if (_.intersection(arrWatchedAddresses, arrAddresses).length > 0){
		eventBus.emit("new_my_transactions", [objJoint.unit.unit]);
		eventBus.emit("new_my_unit-"+objJoint.unit.unit, objJoint);
	}
	else
		db.query(
			"SELECT 1 FROM my_addresses WHERE address IN(?) UNION SELECT 1 FROM shared_addresses WHERE shared_address IN(?)", 
			[arrAddresses, arrAddresses], 
			function(rows){
				if (rows.length > 0){
					eventBus.emit("new_my_transactions", [objJoint.unit.unit]);
					eventBus.emit("new_my_unit-"+objJoint.unit.unit, objJoint);
				}
			}
		);
	
	if (conf.bLight)
		return;
	if (objJoint.ball) // already stable, light clients will require a proof
		return;
	if (!bWatchingForLight)
		return;
	// this is a new unstable joint, light clients will accept it without proof
	db.query("SELECT peer FROM watched_light_addresses WHERE address IN(?)", [arrAddresses], function(rows){
		if (rows.length === 0)
			return;
		objUnit.timestamp = Math.round(Date.now()/1000); // light clients need timestamp
		rows.forEach(function(row){
			var ws = getPeerWebSocket(row.peer);
			if (ws && ws.readyState === ws.OPEN && ws !== source_ws)
				sendJoint(ws, objJoint);
		});
	});
}
595475
def push(item, remote_addr, trg_queue, protocol=u'jsonrpc'):
    '''  '''
    if protocol == u'jsonrpc':
        try:
            server = Server(remote_addr, encoding=_c.FSQ_CHARSET)
            return server.enqueue(item.id, trg_queue, item.item.read())
        except Exception, e:
            raise FSQPushError(e)

    raise ValueError('Unknown protocol: {0}'.format(protocol))
891111
private void deployWatcher(Object target, Method method, String watchedKey) throws Exception {

        configurationUtil.subscribe(watchedKey, (key, value) -> {

            if (Objects.equals(watchedKey, key)) {

                try {
                    if (String.class.equals(method.getParameters()[0].getType())) {
                        method.invoke(target, value);
                    } else if (Boolean.class.equals(method.getParameters()[0].getType()) || boolean.class.equals(method
                            .getParameters()[0].getType())) {
                        method.invoke(target, Boolean.parseBoolean(value));
                    } else if (Float.class.equals(method.getParameters()[0].getType()) || float.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Float.parseFloat(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. " +
                                    "Expected: Float. Value: " + value);
                        }
                    } else if (Double.class.equals(method.getParameters()[0].getType()) || double.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Double.parseDouble(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Double. Value: " + value);
                        }
                    } else if (Integer.class.equals(method.getParameters()[0].getType()) || int.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Integer.parseInt(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Integer. Value: " + value);
                        }
                    } else if (Long.class.equals(method.getParameters()[0].getType()) || long.class.equals(method
                            .getParameters()[0].getType())) {
                        try {
                            method.invoke(target, Long.parseLong(value));
                        } catch (NumberFormatException e) {
                            log.severe("Exception while storing new value: Number format exception. Expected:" +
                                    " Long. Value: " + value);
                        }
                    }
                } catch (IllegalAccessException e) {
                    log.severe("Illegal access exception: " + e.toString());
                } catch (InvocationTargetException e) {
                    log.severe("Invocation target exception: " + e.toString());
                }

            }
        });
    }
376659
private void sendHubHeartbeats()
  {
    RackHeartbeat rack = _rack;
    
    UpdateRackHeartbeat updateRack = rack.getUpdate();
    UpdatePodSystem updatePod = getUpdatePodSystem();
    
    long now = CurrentTime.currentTime();
    
    if (! isJoinComplete()) {
      updatePod = null;
    }

    // send hub update to all servers in the rack
    for (ServerHeartbeat rackServer : _rack.getServers()) {
      if (rackServer == null || rackServer == _serverSelf) {
        continue;
      }

      ServerTarget target = createTargetServer(rackServer);
      
      target.hubHeartbeat(getServerSelf().getUpdate(),
                             updateRack,
                             updatePod,
                             now);
    }
  }
274738
def register_watchers(self, type_callback_dict, register_timeout=None):
        
        for event_type, callback in type_callback_dict.items():
            self._push_watchers[event_type].add(callback)
        self.wait_for_response(
            RegisterMessage(event_list=type_callback_dict.keys()),
            timeout=register_timeout)
2879
static void setupWatch(final Map<String, ParseConfigFile> configFileMap) throws IOException {
    Preconditions.checkNotNull(configFileMap);
    Preconditions.checkArgument(configFileMap.size() > 0);

    final WatchService watchService;
    try {
      watchService = FileSystems.getDefault().newWatchService();
    } catch (IOException e) {
      log.warn(" Failed to create WatchService " + e.getMessage());
      throw e;
    }

    // Map to store WatchKey to Dir mapping
    final Map<WatchKey, Path> keys = new HashMap<>();
    // A directory to config files multimap
    final Multimap<Path, String> dirToFilesMap = HashMultimap.create();

    // Iterate over each file.
    for (Map.Entry<String, ParseConfigFile> entry : configFileMap.entrySet()) {
      String fileName = entry.getKey();
      ParseConfigFile parser = entry.getValue();
      Preconditions.checkNotNull(fileName);
      Preconditions.checkNotNull(parser);

      final File file = new File(fileName);
      if (!file.exists()) {
        log.warn("Failed to setup watch service, user provided file " + fileName + " does not "
            + "exist.");
        continue;
      }

      try {
        Path dir = Paths.get(fileName).getParent();
        if (!dirToFilesMap.containsKey(dir)) {
          // There is not entry for this directory, create a watchkey
          WatchKey watchKey = dir.register(watchService,
              new WatchEvent.Kind[]{StandardWatchEventKinds.ENTRY_MODIFY},
              SensitivityWatchEventModifier.HIGH);
          keys.put(watchKey, dir);
        }
        // Add the config file to dir map
        dirToFilesMap.put(dir, fileName);
      } catch (IOException e) {
        // Ignore the IOException
        log.warn("IOException while setting up watch on conf " + fileName + ". "
            + e.getMessage());
      }
    }

    // Return if WatchService is not initialized
    if (keys.size() == 0) {
      log.warn("Watchservice was not setup for any config file(s).");
      try {
        watchService.close();
      } catch (IOException e) {
        log.warn("IOException while closing watchService. " + e.getMessage());
      }
      return;
    }

    Runnable runnable = () -> {
      // Watchservice is established, now listen for the events till eternity!
      for (;; ) {
        WatchKey watchKey;
        try {
          watchKey = watchService.take();
        } catch (InterruptedException ie) {
          log.warn(ie.getMessage());
          Thread.currentThread().interrupt();
          return;
        }

        // Get the directory for which watch service event triggered.
        Path dir = keys.get(watchKey);
        for (WatchEvent<?> event : watchKey.pollEvents()) {
          // Make sure the modification happened to user config file
          @SuppressWarnings("unchecked")
          final Path name = ((WatchEvent<Path>) event).context();
          final String filename = dir.resolve(name).toString();
          // Lookup the file in dirToFilesMap
          if (dirToFilesMap.containsEntry(dir, filename)) {
            // Match!
            // reparse the config file
            log.info("Modification detected, reloading config file " + filename);
            configFileMap.get(filename).parseConfigFile();
            break;
          }
        }
        watchKey.reset();
      }
    };

    final Thread thread = new Thread(runnable);
    log.info("Starting configuration watching thread.");
    thread.start();
  }
1064015
def addWatchedDirectory(self, dirname, watching=Purr.WATCHED, save_config=True):
        """"""
        # see if we're alredy watching this exact set of directories -- do nothing if so
        dirname = Purr.canonizePath(dirname)
        # do nothing if already watching
        if dirname in self.watched_dirs:
            dprint(1, "addWatchDirectory(): already watching %s\n", dirname)
            # watching=None means do not change the watch-state
            if watching is None:
                return
        else:
            if watching is None:
                watching = Purr.WATCHED
            # make watcher object
            wdir = Purrer.WatchedDir(dirname, mtime=self.timestamp,
                                     watch_patterns=self._watch_patterns, ignore_patterns=self._ignore_patterns)
            # fileset=None indicates error reading directory, so ignore it
            if wdir.fileset is None:
                print("There was an error reading the directory %s, will stop watching it." % dirname)
                self.setWatchingState(dirname, Purr.REMOVED, save_config=True)
                return
            self.watchers[dirname] = wdir
            self.watched_dirs.append(dirname)
            dprintf(2, "watching directory %s, mtime %s, %d files\n",
                    dirname, time.strftime("%x %X", time.localtime(wdir.mtime)), len(wdir.fileset))
            # find files in this directory matching the watch_patterns, and watch them for changes
            watchset = set()
            for patt in self._watch_patterns:
                watchset.update(fnmatch.filter(wdir.fileset, patt))
            for fname in watchset:
                quiet = matches_patterns(fname, self._quiet_patterns)
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if fullname not in self.watchers:
                    wfile = Purrer.WatchedFile(fullname, quiet=quiet, mtime=self.timestamp)
                    self.watchers[fullname] = wfile
                    dprintf(3, "watching file %s, timestamp %s, quiet %d\n",
                            fullname, time.strftime("%x %X", time.localtime(wfile.mtime)), quiet)
            # find subdirectories  matching the subdir_patterns, and watch them for changes
            for fname in wdir.fileset:
                fullname = Purr.canonizePath(os.path.join(dirname, fname))
                if os.path.isdir(fullname):
                    for desc, dir_patts, canary_patts in self._subdir_patterns:
                        if matches_patterns(fname, dir_patts):
                            quiet = matches_patterns(fname, self._quiet_patterns)
                            wdir = Purrer.WatchedSubdir(fullname, canary_patterns=canary_patts, quiet=quiet,
                                                        mtime=self.timestamp)
                            self.watchers[fullname] = wdir
                            dprintf(3, "watching subdirectory %s/{%s}, timestamp %s, quiet %d\n",
                                    fullname, ",".join(canary_patts),
                                    time.strftime("%x %X", time.localtime(wdir.mtime)), quiet)
                            break
        # set state and save config
        self.setWatchingState(dirname, watching, save_config=save_config)
1006189
public void addWatcher(String name, Watcher watcher){
        if(LOGGER.isTraceEnabled()){
            LOGGER.trace("Add a watcher, name={}", name);
        }

        synchronized(watchers){

            if (watchers.containsKey(name)) {
                watchers.get(name).add(watcher);
            } else {
                Set<Watcher> set = new HashSet<Watcher>();
                set.add(watcher);
                watchers.put(name, set);
            }
        }
    }
731204
def set_watchpoint(self, addr, size, type):
        
        return self.dwt.set_watchpoint(addr, size, type)
1310637
def ack_watch(self, watch_id, action_id=None, params=None):
        
        if watch_id in SKIP_IN_PATH:
            raise ValueError("Empty value passed for a required argument 'watch_id'.")
        return self.transport.perform_request(
            "PUT",
            _make_path("_watcher", "watch", watch_id, "_ack", action_id),
            params=params,
        )
472806
public void addWatcher(final MongoNamespace namespace,
                                     final Callback<ChangeEvent<BsonDocument>, Object> watcher) {
    instanceChangeStreamListener.addWatcher(namespace, watcher);
  }