private void monitorInputRegexes() {
    log.debug("Running monitorInputRegexes");

    try {
      // obtain the list of SysStreams that match given patterns for all systems
      Set<SystemStream> inputStreamsMatchingPattern = new HashSet<>();

      // For each input system, for which we have a regex to monitor
      for (String systemName : this.systemRegexesToMonitor.keySet()) {

        try {
          // obtain the list of SysStreams that match the regex for this system
          // using the systemAdmin in the metadataCache
          inputStreamsMatchingPattern.addAll(
              JavaConverters.setAsJavaSetConverter(this.metadataCache.getAllSystemStreams(systemName))
                  .asJava()
                  .stream()
                  .filter(x -> x.getStream().matches(this.systemRegexesToMonitor.get(systemName).pattern()))
                  .collect(Collectors.toSet()));
        } catch (UnsupportedOperationException e) {
          log.error("UnsupportedOperationException while monitoring input regexes for system {}", systemName, e);
        }
      }

      // if there is a stream that is in the input-Set but not in the streamsToMonitor
      // since streamsToMonitor = task.inputs
      if (!streamsToMonitor.containsAll(inputStreamsMatchingPattern)) {
        log.info("New input system-streams discovered. InputStreamsMatchingPattern: {} but streamsToMonitor: {} ",
            inputStreamsMatchingPattern, streamsToMonitor);

        // invoke notify callback with new input streams
        this.callbackMethod.onInputStreamsChanged(streamsToMonitor,
            Sets.difference(inputStreamsMatchingPattern, streamsToMonitor), systemRegexesToMonitor);
      } else {
        log.info("No new input system-Streams discovered streamsToMonitor {} inputStreamsMatchingPattern {}",
            streamsToMonitor, inputStreamsMatchingPattern);
      }
    } catch (Exception e) {
      log.error("Exception while monitoring input regexes.", e);
    }
  }
Stops the monitor. Once it stops, it cannot be restarted.
samza-core/src/main/java/org/apache/samza/coordinator/StreamRegexMonitor.java