public Map<String, Object> getSensorIndexingConfig(String sensorType, boolean emptyMapOnNonExistent) { Map<String, Object> ret = (Map<String, Object>) getConfigurations().get(getKey(sensorType)); if(ret == null) { return emptyMapOnNonExistent?new HashMap<>():null; } else { return ret; } }
public Map<String, Object> getSensorIndexingConfig(String sensorType, String writerName) { String key = getKey(sensorType); Map<String, Object> ret = (Map<String, Object>) getConfigurations().get(key); if(ret == null) { return new HashMap(); } else { Map<String, Object> writerConfig = (Map<String, Object>)ret.get(writerName); return writerConfig != null?writerConfig:new HashMap<>(); } }
public boolean isDefault(String sensorName, String writerName) { Map<String, Object> ret = (Map<String, Object>) getConfigurations().get(getKey(sensorName)); if(ret == null) { return true; } else { Map<String, Object> writerConfig = (Map<String, Object>)ret.get(writerName); return writerConfig != null?false:true; } }
public void delete(String sensorType) { getConfigurations().remove(getKey(sensorType)); }
public void updateSensorIndexingConfig(String sensorType, Map<String, Object> sensorIndexingConfig) { getConfigurations().put(getKey(sensorType), sensorIndexingConfig); }
/** * 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; }