Parse the content of the system property that describes the polling intervals,
and in case of errors
use the default of one poller running every minute.
765092
static long[] parse(String pollers) {
    String[] periods = pollers.split(",\\s*");
    long[] result = new long[periods.length];

    boolean errors = false;
    Logger logger = LoggerFactory.getLogger(Pollers.class);
    for (int i = 0; i < periods.length; ++i) {
      String period = periods[i];
      try {
        result[i] = Long.parseLong(period);
        if (result[i] <= 0) {
          logger.error("Invalid polling interval: {} must be positive.", period);
          errors = true;
        }
      } catch (NumberFormatException e) {
        logger.error("Cannot parse '{}' as a long: {}", period, e.getMessage());
        errors = true;
      }
    }

    if (errors || periods.length == 0) {
      logger.info("Using a default configuration for poller intervals: {}",
          join(DEFAULT_PERIODS));
      return DEFAULT_PERIODS;
    } else {
      return result;
    }
  }
744822
void parse(Reader reader) throws ParseException {
        if (reader == null) {
            //just log and return default properties
            Log.warn("parsing NULL reader, so fallback on default configuration!");
            return;
        }
        
        BufferedReader br = new BufferedReader(reader);
        String line;
        try {
            while ((line = br.readLine()) != null) {
                int commentMarker = line.indexOf('#');
                if (commentMarker != -1) {
                    if (commentMarker == 0) {
                        //skip its a comment
                        continue;
                    } else {
                        //it's a malformed comment
                        throw new ParseException(line, commentMarker);
                    }
                } else {
                    if (line.isEmpty() || line.matches("^\\s*$")) {
                        //skip it's a black line
                        continue;
                    }
                    
                    //split till the first space
                    int deilimiterIdx = line.indexOf(' ');
                    String key = line.substring(0, deilimiterIdx).trim();
                    String value = line.substring(deilimiterIdx).trim();
                    
                    m_properties.put(key, value);
                }
            }
        } catch (IOException ex) {
            throw new ParseException("Failed to read", 1);
        }
    }
1114626
public static int getSystemPropertyAsInteger(String name, int defaultValue) {
        final String value = getSystemProperty(name, null);
        if (value != null) {
            try {
                return Integer.parseInt(value);
            } catch (Throwable exception) {
                //
            }
        }
        return defaultValue;
    }
409536
private static boolean repStep(
			BufferedReader in,
			boolean readConsoleInput) throws IOException, InterruptedException {

		// wait until CLIENT_POLLING_INTERVAL is over or the user entered something.
		long startTime = System.currentTimeMillis();
		while ((System.currentTimeMillis() - startTime) < CLIENT_POLLING_INTERVAL_MS
			&& (!readConsoleInput || !in.ready())) {
			Thread.sleep(200L);
		}
		//------------- handle interactive command by user. ----------------------

		if (readConsoleInput && in.ready()) {
			String command = in.readLine();
			switch (command) {
				case "quit":
				case "stop":
					return false;

				case "help":
					System.err.println(YARN_SESSION_HELP);
					break;
				default:
					System.err.println("Unknown command '" + command + "'. Showing help:");
					System.err.println(YARN_SESSION_HELP);
					break;
			}
		}

		return true;
	}
1232746
synchronized long systemUpdate(long value) {

        if (value == currValue) {
            currValue += increment;

            return value;
        }

        if (increment > 0) {
            if (value > currValue) {
                currValue = value + increment;
            }
        } else {
            if (value < currValue) {
                currValue = value + increment;
            }
        }

        return value;
    }
1212177
private void handleProperties(Properties properties) throws ParseException
    {
        if (properties == null)
        {
            return;
        }

        for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();)
        {
            String option = e.nextElement().toString();

            Option opt = options.getOption(option);
            if (opt == null)
            {
                throw new UnrecognizedOptionException("Default option wasn't defined", option);
            }

            // if the option is part of a group, check if another option of the group has been selected
            OptionGroup group = options.getOptionGroup(opt);
            boolean selected = group != null && group.getSelected() != null;

            if (!cmd.hasOption(option) && !selected)
            {
                // get the value from the properties
                String value = properties.getProperty(option);

                if (opt.hasArg())
                {
                    if (opt.getValues() == null || opt.getValues().length == 0)
                    {
                        opt.addValueForProcessing(value);
                    }
                }
                else if (!("yes".equalsIgnoreCase(value)
                        || "true".equalsIgnoreCase(value)
                        || "1".equalsIgnoreCase(value)))
                {
                    // if the value is not yes, true or 1 then don't add the option to the CommandLine
                    continue;
                }

                handleOption(opt);
                currentOption = null;
            }
        }
    }
975652
private static int getUpdatedInterval(int inputInterval, ExtractType extractType, WatermarkType watermarkType) {
    LOG.debug("Getting updated interval");
    if ((extractType == ExtractType.SNAPSHOT && watermarkType == WatermarkType.DATE)) {
      return inputInterval * 24;
    } else if (extractType == ExtractType.APPEND_DAILY) {
      return (inputInterval < 1 ? 1 : inputInterval) * 24;
    } else {
      return inputInterval;
    }
  }
435003
def _interval_split(interval, only=None, context=None, event_re=re.compile("[A-Z][0-9]+")):
    
    def split_event(event):
        "Helper to parse events."
        kind, val = event[:1], event[1:]
        try:
            return kind, float(val)
        except (TypeError, ValueError):
            return None, 0

    if hasattr(interval, "fetch"):
        interval = interval.fetch("custom_activations")
    ##import sys; print >>sys.stderr, "!!!!!isplit", interval, event_re.findall(interval)

    return list(reversed([split_event(i) for i in event_re.findall(interval) if not only or i.startswith(only)]))
1155579
def Poll(generator=None, condition=None, interval=None, timeout=None):
  """"""

  if not generator:
    raise ValueError("generator has to be a lambda")

  if not condition:
    raise ValueError("condition has to be a lambda")

  if interval is None:
    interval = DEFAULT_POLL_INTERVAL

  if timeout is None:
    timeout = DEFAULT_POLL_TIMEOUT

  started = time.time()
  while True:
    obj = generator()
    check_result = condition(obj)
    if check_result:
      return obj

    if timeout and (time.time() - started) > timeout:
      raise errors.PollTimeoutError(
          "Polling on %s timed out after %ds." % (obj, timeout))
    time.sleep(interval)
1208791
protected void processProperties(Properties properties) throws ParseException
    {
        if (properties == null)
        {
            return;
        }

        for (Enumeration<?> e = properties.propertyNames(); e.hasMoreElements();)
        {
            String option = e.nextElement().toString();
            
            Option opt = options.getOption(option);
            if (opt == null)
            {
                throw new UnrecognizedOptionException("Default option wasn't defined", option);
            }
            
            // if the option is part of a group, check if another option of the group has been selected
            OptionGroup group = options.getOptionGroup(opt);
            boolean selected = group != null && group.getSelected() != null;
            
            if (!cmd.hasOption(option) && !selected)
            {
                // get the value from the properties instance
                String value = properties.getProperty(option);

                if (opt.hasArg())
                {
                    if (opt.getValues() == null || opt.getValues().length == 0)
                    {
                        try
                        {
                            opt.addValueForProcessing(value);
                        }
                        catch (RuntimeException exp) //NOPMD
                        {
                            // if we cannot add the value don't worry about it
                        }
                    }
                }
                else if (!("yes".equalsIgnoreCase(value)
                        || "true".equalsIgnoreCase(value)
                        || "1".equalsIgnoreCase(value)))
                {
                    // if the value is not yes, true or 1 then don't add the
                    // option to the CommandLine
                    continue;
                }

                cmd.addOption(opt);
                updateRequiredOptions(opt);
            }
        }
    }
1060360
void polling_configure() {
	// Send a stop polling command to thread in order not to poll devices
	final DServer adm_dev = get_dserver_device();

	try {
	    adm_dev.stop_polling();
	} catch (final DevFailed e) {
	    Except.print_exception(e);
	}

	final Vector tmp_cl_list = adm_dev.get_class_list();// DeviceClass
	int upd;

	// Create the structure used to send data to the polling thread
	final DevVarLongStringArray send = new DevVarLongStringArray();
	send.lvalue = new int[1];
	send.svalue = new String[3];

	// A loop on each class and each device in class
	for (int i = 0; i < tmp_cl_list.size(); i++) {
	    final DeviceClass dc = (DeviceClass) tmp_cl_list.elementAt(i);
	    final Vector dev_list = dc.get_device_list(); // <DeviceImpl *
	    for (int j = 0; j < dev_list.size(); j++) {
		final DeviceImpl dev = (DeviceImpl) dev_list.elementAt(j);
		final Vector poll_cmd_list = dev.get_polled_cmd();
		final Vector poll_attr_list = dev.get_polled_attr();

		// Send a Add Object command to the polling thread only
		// if the polling period is different than zero
		for (int k = 0; k < poll_cmd_list.size(); k++) {
		    if (k == 0) {
			send.svalue[0] = dev.get_name();
			send.svalue[1] = "command";
		    }

		    // Convert polling period to a number
		    final String strval = (String) poll_cmd_list.elementAt(k + 1);
		    upd = Integer.parseInt(strval);

		    // Send command to the polling thread
		    if (upd != 0) {
			send.lvalue[0] = upd;
			send.svalue[2] = (String) poll_cmd_list.elementAt(k);

			try {
			    adm_dev.add_obj_polling(send, false);
			} catch (final DevFailed e) {
			}
		    }
		    k++;
		}

		// Send a Add Object attribute to the polling thread only
		// if the polling period is different than zero
		for (int k = 0; k < poll_attr_list.size(); k++) {

		    if (k == 0) {
			send.svalue[0] = dev.get_name();
			send.svalue[1] = "attribute";
		    }
		    // Convert polling period to a number
		    final String strval = (String) poll_attr_list.elementAt(k + 1);
		    upd = Integer.parseInt(strval);

		    // Send command to the polling thread
		    if (upd != 0) {
			send.lvalue[0] = upd;
			send.svalue[2] = (String) poll_attr_list.elementAt(k);

			try {
			    adm_dev.add_obj_polling(send, false);
			} catch (final DevFailed e) {
			}
		    }
		    k++;
		}
	    }
	}

	// Now, start the real polling
	try {
	    adm_dev.start_polling();
	} catch (final DevFailed e) {
	    Except.print_exception(e);
	}
    }
211148
def _process_incoming_data(self):
        
        while self._running.is_set():
            if self.poller.is_ready:
                self.data_in += self._receive()
                self.data_in = self._on_read_impl(self.data_in)
1310068
public void setPollInterval( long pollInterval ) {

		this.pollInterval = pollInterval;
		this.logger.fine( "Template watcher poll interval set to " + pollInterval );
		synchronized( this.watcherLock ) {
			if( this.templateWatcher != null )
				resetWatcher();
		}
	}
1273847
def receive(self, poll_interval):
        
        readable, writeable, errored = select.select(self._readlist, [], [],
                                                     poll_interval)
        for s in readable:
            data, addr = s.recvfrom(self.BUFFER_SIZE)
            if data:
                return data

        return None
268214
@Override
	public String formatStatusMessage(IntervalProperty[] properties) {

		StringBuffer buff = new StringBuffer(500);	
		buff.append( "Watchdog: ");
		
		for( IntervalProperty p : properties ) {
			buff.append(p.getName());
			buff.append("=");
			buff.append(p.getValue());
			buff.append(", ");
		}
		
		if( buff.toString().endsWith(","))
			buff.setLength(buff.length()-1);

		return buff.toString();
		
	}
1233686
public Response updateSystemProperty(SystemProperty property) {
		return restClient.put("system/properties/" + property.getKey(), property, new HashMap<String, String>());
	}
1145648
def _needs_update(self):
        ''

        if self.poll_interval:
            delta = timeit.default_timer() - self._last_update_timer
            poll_status = delta > self.poll_interval.total_seconds()
        else:
            delta = 0
            poll_status = False

        # Do not update if value increment is not large enough to
        # add more bars to progressbar (according to current
        # terminal width)
        try:
            divisor = self.max_value / self.term_width  # float division
            if self.value // divisor == self.previous_value // divisor:
                return poll_status or self.end_time
            else:
                return True
        except Exception:
            # ignore any division errors
            pass

        return poll_status or self.end_time