@Test public void configurationTest() throws Exception { File file = new File(getClass().getResource("/conf_test.properties").getPath()); LindenConfig lindenConf = LindenConfigBuilder.build(file); Assert.assertEquals("./target/tmp", lindenConf.getIndexDirectory()); Assert.assertEquals("127.0.0.1:2181,127.0.0.2:2181/linden_test", lindenConf.getClusterUrl()); Assert.assertEquals(9091, lindenConf.getPort()); Assert.assertTrue(lindenConf.isEnableParallelSearch()); Assert.assertEquals(LindenConfig.LindenCoreMode.MULTI, lindenConf.getLindenCoreMode()); Assert.assertEquals(LindenConfig.MultiIndexDivisionType.TIME_MONTH, lindenConf.getMultiIndexDivisionType()); Assert.assertEquals(10, lindenConf.getMultiIndexMaxLiveIndexNum()); }
public static LindenConfig build(File confFile) throws Exception { Properties props = new Properties(); FileInputStream inputStream = new FileInputStream(confFile); props.load(inputStream); inputStream.close(); LindenConfig lindenConf = new LindenConfig(); Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); FieldInfo fieldInfo = fieldMap.get(key); if (fieldInfo != null) { Method method = LindenConfig.class.getDeclaredMethod(fieldInfo.setMethod(), fieldInfo.getType()); if (fieldInfo.type == int.class) { method.invoke(lindenConf, Integer.valueOf(props.getProperty(key))); } else if (fieldInfo.type == String.class) { method.invoke(lindenConf, props.getProperty(key)); } else if (fieldInfo.type == boolean.class) { method.invoke(lindenConf, Boolean.valueOf(props.getProperty(key))); } else if (fieldInfo.type == LindenConfig.LindenCoreMode.class) { method.invoke(lindenConf, LindenConfig.LindenCoreMode.valueOf(props.getProperty(key).toUpperCase())); } else if (fieldInfo.type == LindenConfig.MultiIndexDivisionType.class) { method.invoke(lindenConf, LindenConfig.MultiIndexDivisionType.valueOf(props.getProperty(key).toUpperCase())); } } lindenConf.putToProperties(key, props.getProperty(key)); } if (lindenConf.getAdminPort() != 0 && lindenConf.getWebapp() == null) { throw new IOException("Webapp is required if admin port is set"); } return lindenConf; }
LindenConfigBuilder { public static LindenConfig build(File confFile) throws Exception { Properties props = new Properties(); FileInputStream inputStream = new FileInputStream(confFile); props.load(inputStream); inputStream.close(); LindenConfig lindenConf = new LindenConfig(); Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); FieldInfo fieldInfo = fieldMap.get(key); if (fieldInfo != null) { Method method = LindenConfig.class.getDeclaredMethod(fieldInfo.setMethod(), fieldInfo.getType()); if (fieldInfo.type == int.class) { method.invoke(lindenConf, Integer.valueOf(props.getProperty(key))); } else if (fieldInfo.type == String.class) { method.invoke(lindenConf, props.getProperty(key)); } else if (fieldInfo.type == boolean.class) { method.invoke(lindenConf, Boolean.valueOf(props.getProperty(key))); } else if (fieldInfo.type == LindenConfig.LindenCoreMode.class) { method.invoke(lindenConf, LindenConfig.LindenCoreMode.valueOf(props.getProperty(key).toUpperCase())); } else if (fieldInfo.type == LindenConfig.MultiIndexDivisionType.class) { method.invoke(lindenConf, LindenConfig.MultiIndexDivisionType.valueOf(props.getProperty(key).toUpperCase())); } } lindenConf.putToProperties(key, props.getProperty(key)); } if (lindenConf.getAdminPort() != 0 && lindenConf.getWebapp() == null) { throw new IOException("Webapp is required if admin port is set"); } return lindenConf; } }
LindenConfigBuilder { public static LindenConfig build(File confFile) throws Exception { Properties props = new Properties(); FileInputStream inputStream = new FileInputStream(confFile); props.load(inputStream); inputStream.close(); LindenConfig lindenConf = new LindenConfig(); Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); FieldInfo fieldInfo = fieldMap.get(key); if (fieldInfo != null) { Method method = LindenConfig.class.getDeclaredMethod(fieldInfo.setMethod(), fieldInfo.getType()); if (fieldInfo.type == int.class) { method.invoke(lindenConf, Integer.valueOf(props.getProperty(key))); } else if (fieldInfo.type == String.class) { method.invoke(lindenConf, props.getProperty(key)); } else if (fieldInfo.type == boolean.class) { method.invoke(lindenConf, Boolean.valueOf(props.getProperty(key))); } else if (fieldInfo.type == LindenConfig.LindenCoreMode.class) { method.invoke(lindenConf, LindenConfig.LindenCoreMode.valueOf(props.getProperty(key).toUpperCase())); } else if (fieldInfo.type == LindenConfig.MultiIndexDivisionType.class) { method.invoke(lindenConf, LindenConfig.MultiIndexDivisionType.valueOf(props.getProperty(key).toUpperCase())); } } lindenConf.putToProperties(key, props.getProperty(key)); } if (lindenConf.getAdminPort() != 0 && lindenConf.getWebapp() == null) { throw new IOException("Webapp is required if admin port is set"); } return lindenConf; }  }
LindenConfigBuilder { public static LindenConfig build(File confFile) throws Exception { Properties props = new Properties(); FileInputStream inputStream = new FileInputStream(confFile); props.load(inputStream); inputStream.close(); LindenConfig lindenConf = new LindenConfig(); Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); FieldInfo fieldInfo = fieldMap.get(key); if (fieldInfo != null) { Method method = LindenConfig.class.getDeclaredMethod(fieldInfo.setMethod(), fieldInfo.getType()); if (fieldInfo.type == int.class) { method.invoke(lindenConf, Integer.valueOf(props.getProperty(key))); } else if (fieldInfo.type == String.class) { method.invoke(lindenConf, props.getProperty(key)); } else if (fieldInfo.type == boolean.class) { method.invoke(lindenConf, Boolean.valueOf(props.getProperty(key))); } else if (fieldInfo.type == LindenConfig.LindenCoreMode.class) { method.invoke(lindenConf, LindenConfig.LindenCoreMode.valueOf(props.getProperty(key).toUpperCase())); } else if (fieldInfo.type == LindenConfig.MultiIndexDivisionType.class) { method.invoke(lindenConf, LindenConfig.MultiIndexDivisionType.valueOf(props.getProperty(key).toUpperCase())); } } lindenConf.putToProperties(key, props.getProperty(key)); } if (lindenConf.getAdminPort() != 0 && lindenConf.getWebapp() == null) { throw new IOException("Webapp is required if admin port is set"); } return lindenConf; }  static LindenConfig build(File confFile); }
LindenConfigBuilder { public static LindenConfig build(File confFile) throws Exception { Properties props = new Properties(); FileInputStream inputStream = new FileInputStream(confFile); props.load(inputStream); inputStream.close(); LindenConfig lindenConf = new LindenConfig(); Iterator<Object> iter = props.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); FieldInfo fieldInfo = fieldMap.get(key); if (fieldInfo != null) { Method method = LindenConfig.class.getDeclaredMethod(fieldInfo.setMethod(), fieldInfo.getType()); if (fieldInfo.type == int.class) { method.invoke(lindenConf, Integer.valueOf(props.getProperty(key))); } else if (fieldInfo.type == String.class) { method.invoke(lindenConf, props.getProperty(key)); } else if (fieldInfo.type == boolean.class) { method.invoke(lindenConf, Boolean.valueOf(props.getProperty(key))); } else if (fieldInfo.type == LindenConfig.LindenCoreMode.class) { method.invoke(lindenConf, LindenConfig.LindenCoreMode.valueOf(props.getProperty(key).toUpperCase())); } else if (fieldInfo.type == LindenConfig.MultiIndexDivisionType.class) { method.invoke(lindenConf, LindenConfig.MultiIndexDivisionType.valueOf(props.getProperty(key).toUpperCase())); } } lindenConf.putToProperties(key, props.getProperty(key)); } if (lindenConf.getAdminPort() != 0 && lindenConf.getWebapp() == null) { throw new IOException("Webapp is required if admin port is set"); } return lindenConf; }  static LindenConfig build(File confFile); static final String PORT; static final String INDEX_ANALYZER; static final String SEARCH_ANALYZER; static final String SEARCH_SIMILARITY; static final String CLUSTER_FUTURE_AWAIT_TIMEOUT; static final String CLUSTER_FUTURE_POOL_WAIT_TIMEOUT; static final String INSTANCE_FUTURE_POOL_WAIT_TIMEOUT; static final String ADMIN_PORT; static final String INDEX_DIRECTORY; static final String CLUSTER_URL; static final String SHARD_ID; static final String LOG_PATH; static final String PLUGIN_PATH; static final String GATEWAY; static final String ENABLE_PARALLEL_SEARCH; static final String MERGE_POLICY; static final String USE_CACHE; static final String CACHE_DURATION; static final String CACHE_SIZE; static final String INDEX_REFRESH_TIME; static final String LINDEN_CORE_MODE; static final String WEBAPP; static final String MULTI_INDEX_DIVISION_TYPE; static final String MULTI_INDEX_PREFIX_NAME; static final String MULTI_INDEX_DOC_NUM_LIMIT; static final String MULTI_INDEX_MAX_LIVE_INDEX_NUM; static final String SEARCH_TIME_LIMIT; static final String LINDEN_METRIC_FACTORY; static final String LINDEN_WARMER_FACTORY; static final String INDEX_MANAGER_THREAD_NUM; static final String SEARCH_THREAD_POOL_JSON_CONFIG; static final String ENABLE_SOURCE_FIELD_CACHE; static final String INDEX_SEARCHER_PARALLEL_THREAD_NUM; static final String SLOW_QUERY_THRESHOLD_MILLIS; }