@Override public int getBatchTimeout(String sensorName) { return config.orElse(new IndexingConfigurations()).getBatchTimeout(sensorName, writerName); }
public int getBatchTimeout(String sensorName, String writerName ) { return getBatchTimeout(getSensorIndexingConfig(sensorName, writerName)); }
/** * Returns all configured values of batchTimeout, for all configured sensors, * but only for the specific writer identified by {@code writerName}. So, if it is * an hdfs writer, it will return the batchTimeouts for hdfs writers for all the sensors. * The goal is to return to a {@link org.apache.metron.common.bolt.ConfiguredBolt} * the set of all and only batchTimeouts relevant to that ConfiguredBolt. * * @param writerName * @return list of integer batchTimeouts, one per configured sensor */ public List<Integer> getAllConfiguredTimeouts(String writerName) { // The configuration infrastructure was not designed to enumerate sensors, so we synthesize. // Since getKey is in this same class, we know we can pass it a null string to get the key prefix // for all sensor types within this capability. We then enumerate all keys in configurations.keySet // and select those that match the key prefix, as being sensor keys. The suffix substring of // each such key is used as a sensor name to query the batchTimeout settings, if any. String keyPrefixString = getKey(""); int prefixStringLength = keyPrefixString.length(); List<Integer> configuredBatchTimeouts = new ArrayList<>(); for (String sensorKeyString : getConfigurations().keySet()) { if (sensorKeyString.startsWith(keyPrefixString)) { String configuredSensorName = sensorKeyString.substring(prefixStringLength); configuredBatchTimeouts.add(getBatchTimeout(configuredSensorName, writerName)); } } return configuredBatchTimeouts; }