List of usage examples for org.eclipse.jgit.storage.file FileBasedConfig getInt
public int getInt(final String section, String subsection, final String name, final int defaultValue)
From source file:com.google.gerrit.lucene.IndexVersionCheck.java
License:Apache License
@Override public void start() { File file = gerritIndexConfig(sitePaths); try {/*from ww w.j a v a 2s . c o m*/ FileBasedConfig cfg = new FileBasedConfig(file, FS.detect()); cfg.load(); for (Map.Entry<String, Integer> e : SCHEMA_VERSIONS.entrySet()) { int schemaVersion = cfg.getInt("index", e.getKey(), "schemaVersion", 0); if (schemaVersion != e.getValue()) { throw new ProvisionException( String.format("wrong index schema version for \"%s\": expected %d, found %d%s", e.getKey(), e.getValue(), schemaVersion, upgrade())); } } @SuppressWarnings("deprecation") Version luceneVersion = cfg.getEnum("lucene", null, "version", LUCENE_CURRENT); if (luceneVersion != LUCENE_VERSION) { throw new ProvisionException(String.format("wrong Lucene version: expected %d, found %d%s", luceneVersion, LUCENE_VERSION, upgrade())); } } catch (IOException e) { throw new ProvisionException("unable to read " + file); } catch (ConfigInvalidException e) { throw new ProvisionException("invalid config file " + file); } }
From source file:com.google.gerrit.solr.IndexVersionCheck.java
License:Apache License
@Override public void start() { // TODO Query schema version from a special meta-document File file = solrIndexConfig(sitePaths); try {//from ww w .j ava2 s .c o m FileBasedConfig cfg = new FileBasedConfig(file, FS.detect()); cfg.load(); for (Map.Entry<String, Integer> e : SCHEMA_VERSIONS.entrySet()) { int schemaVersion = cfg.getInt("index", e.getKey(), "schemaVersion", 0); if (schemaVersion != e.getValue()) { throw new ProvisionException( String.format("wrong index schema version for \"%s\": expected %d, found %d%s", e.getKey(), e.getValue(), schemaVersion, upgrade())); } } } catch (IOException e) { throw new ProvisionException("unable to read " + file); } catch (ConfigInvalidException e) { throw new ProvisionException("invalid config file " + file); } }