public Map<String, Object> getSensorIndexingConfig(String sensorType) { return getSensorIndexingConfig(sensorType, true); }
@Override public Map<String, Object> getSensorConfig(String sensorName) { return config.orElse(new IndexingConfigurations()).getSensorIndexingConfig(sensorName, writerName); }
public void updateSensorIndexingConfig(String sensorType, byte[] data) throws IOException { updateSensorIndexingConfig(sensorType, new ByteArrayInputStream(data)); }
public String getOutputPathFunction(String sensorName, String writerName) { return getOutputPathFunction(getSensorIndexingConfig(sensorName, writerName), sensorName); }
public boolean isEnabled(String sensorName, String writerName) { return isEnabled(getSensorIndexingConfig(sensorName, writerName)); }
public String getIndex(String sensorName, String writerName) { return getIndex(getSensorIndexingConfig(sensorName, writerName), sensorName); }
assertEventually(() -> Assert.assertNull(config.getGlobalConfig(false))); assertEventually(() -> Assert.assertNull(config.getSensorIndexingConfig("test", false))); assertEventually(() -> Assert.assertNull(config.getGlobalConfig(false)));
private WriterConfiguration createConfig(String writer, String sensor, String json) throws Exception { IndexingConfigurations indexingConfig = new IndexingConfigurations(); indexingConfig.updateSensorIndexingConfig(sensor, json.getBytes()); return new IndexingWriterConfiguration(writer, indexingConfig); }
public int getBatchSize(String sensorName, String writerName ) { return getBatchSize(getSensorIndexingConfig(sensorName, writerName)); }
public int getBatchTimeout(String sensorName, String writerName ) { return getBatchTimeout(getSensorIndexingConfig(sensorName, writerName)); }
public String getFieldNameConverter(String sensorName, String writerName) { return getFieldNameConverter(getSensorIndexingConfig(sensorName, writerName), sensorName); }
public static IndexingConfigurations getSampleIndexingConfigs() throws IOException { IndexingConfigurations configurations = new IndexingConfigurations(); configurations.updateGlobalConfig(ConfigurationsUtils.readGlobalConfigFromFile(TestConstants.SAMPLE_CONFIG_PATH)); Map<String, byte[]> sensorIndexingConfigs = ConfigurationsUtils.readSensorIndexingConfigsFromFile(TestConstants.SAMPLE_CONFIG_PATH); for(String sensorType: sensorIndexingConfigs.keySet()) { configurations.updateSensorIndexingConfig(sensorType, sensorIndexingConfigs.get(sensorType)); } return configurations; } }
@Override public String getIndex(String sensorName) { return config.orElse(new IndexingConfigurations()).getIndex(sensorName, writerName); }
@Override public Map<String, Object> getGlobalConfig() { return config.orElse(new IndexingConfigurations()).getGlobalConfig(); }
@Override public boolean isEnabled(String sensorName) { return config.orElse(new IndexingConfigurations()).isEnabled(sensorName, writerName); }
@Override public IndexingConfigurations defaultConfigurations() { return new IndexingConfigurations(); }
/** * Get a list of index names for a given writer (e.g. elasticsearch, solr, hdfs). * This functions in the following way: * * If an index config exists, then the index name will be returned. If unspecified, then the sensor name is used * * If a parser exists and an index does NOT exist, then it will be included. * * If the writer is disabled in the index config, then it will NOT be included. * @param writerName The writer name to use * @return An iterable of index names * @throws RestException */ @Override public Iterable<String> getAllIndices(String writerName) throws RestException { if(StringUtils.isEmpty(writerName)) { return Collections.emptyList(); } IndexingConfigurations indexingConfigs = cache.get( IndexingConfigurations.class); ParserConfigurations parserConfigs = cache.get( ParserConfigurations.class); Set<String> ret = new HashSet<>(); for(String sensorName : Iterables.concat(parserConfigs.getTypes(), indexingConfigs.getTypes())) { if(indexingConfigs.isEnabled(sensorName, writerName)) { String indexName = indexingConfigs.getIndex(sensorName, writerName); ret.add(indexName == null ? sensorName : indexName); } } return ret; }
@Override public List<Integer> getAllConfiguredTimeouts() { return config.orElse(new IndexingConfigurations()).getAllConfiguredTimeouts(writerName); }
@Override public String getFieldNameConverter(String sensorName) { return config.orElse(new IndexingConfigurations()).getFieldNameConverter(sensorName, writerName); } }
@Override public int getBatchSize(String sensorName) { return config.orElse(new IndexingConfigurations()).getBatchSize(sensorName, writerName); }