List of usage examples for org.eclipse.jgit.lib Config getInt
public int getInt(final String section, String subsection, final String name, final int defaultValue)
From source file:com.gitblit.authority.NewCertificateConfig.java
License:Apache License
private NewCertificateConfig(final Config c) { duration = c.getInt("new", null, "duration", 0); OU = c.getString("new", null, "organizationalUnit"); O = c.getString("new", null, "organization"); L = c.getString("new", null, "locality"); ST = c.getString("new", null, "stateProvince"); C = c.getString("new", null, "countryCode"); }
From source file:com.google.gerrit.elasticsearch.ElasticConfiguration.java
License:Apache License
@Inject ElasticConfiguration(@GerritServerConfig Config cfg) { this.username = cfg.getString("elasticsearch", null, "username"); this.password = cfg.getString("elasticsearch", null, "password"); this.requestCompression = cfg.getBoolean("elasticsearch", null, "requestCompression", false); this.connectionTimeout = cfg.getTimeUnit("elasticsearch", null, "connectionTimeout", 3000, TimeUnit.MILLISECONDS); this.maxConnectionIdleTime = cfg.getTimeUnit("elasticsearch", null, "maxConnectionIdleTime", 3000, TimeUnit.MILLISECONDS); this.maxTotalConnection = cfg.getInt("elasticsearch", null, "maxTotalConnection", 1); this.readTimeout = (int) cfg.getTimeUnit("elasticsearch", null, "readTimeout", 3000, TimeUnit.MICROSECONDS); Set<String> subsections = cfg.getSubsections("elasticsearch"); if (subsections.isEmpty()) { this.urls = Arrays.asList(buildUrl(DEFAULT_PROTOCOL, DEFAULT_HOST, DEFAULT_PORT)); } else {// ww w. ja v a 2s .co m this.urls = new ArrayList<>(subsections.size()); for (String subsection : subsections) { String port = getString(cfg, subsection, "port", DEFAULT_PORT); String host = getString(cfg, subsection, "hostname", DEFAULT_HOST); String protocol = getString(cfg, subsection, "protocol", DEFAULT_PROTOCOL); this.urls.add(buildUrl(protocol, host, port)); } } }
From source file:com.google.gerrit.gpg.GerritPublicKeyChecker.java
License:Apache License
@Inject GerritPublicKeyChecker(@GerritServerConfig Config cfg, @CanonicalWebUrl String webUrl, Provider<IdentifiedUser> userProvider) { super(cfg.getInt("receive", null, "maxTrustDepth", 0), getTrustedFingerprints(cfg)); this.webUrl = webUrl; this.userProvider = userProvider; }
From source file:com.google.gerrit.lucene.GerritIndexWriterConfig.java
License:Apache License
GerritIndexWriterConfig(Config cfg, String name) { analyzer = new CustomMappingAnalyzer(new StandardAnalyzer(CharArraySet.EMPTY_SET), CUSTOM_CHAR_MAPPING); luceneConfig = new IndexWriterConfig(analyzer).setOpenMode(OpenMode.CREATE_OR_APPEND) .setCommitOnClose(true);/*from ww w . j a v a 2s.c om*/ double m = 1 << 20; luceneConfig.setRAMBufferSizeMB(cfg.getLong("index", name, "ramBufferSize", (long) (IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB * m)) / m); luceneConfig.setMaxBufferedDocs( cfg.getInt("index", name, "maxBufferedDocs", IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS)); try { commitWithinMs = ConfigUtil.getTimeUnit(cfg, "index", name, "commitWithin", MILLISECONDS.convert(5, MINUTES), MILLISECONDS); } catch (IllegalArgumentException e) { commitWithinMs = cfg.getLong("index", name, "commitWithin", 0); } }
From source file:com.google.gerrit.pgm.http.jetty.JettyServer.java
License:Apache License
private ThreadPool threadPool(Config cfg) { int maxThreads = cfg.getInt("httpd", null, "maxthreads", 25); int minThreads = cfg.getInt("httpd", null, "minthreads", 5); int maxQueued = cfg.getInt("httpd", null, "maxqueued", 200); int idleTimeout = (int) MILLISECONDS.convert(60, SECONDS); int maxCapacity = maxQueued == 0 ? Integer.MAX_VALUE : Math.max(minThreads, maxQueued); QueuedThreadPool pool = new QueuedThreadPool(maxThreads, minThreads, idleTimeout, new BlockingArrayQueue<Runnable>(minThreads, // capacity, minThreads, // growBy, maxCapacity // maxCapacity ));/*from w w w . j ava2s. co m*/ pool.setName("HTTP"); return pool; }
From source file:com.google.gerrit.server.account.externalids.ExternalId.java
License:Apache License
private static int readAccountId(String noteId, Config externalIdConfig, String externalIdKeyStr) throws ConfigInvalidException { String accountIdStr = externalIdConfig.getString(EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY); if (accountIdStr == null) { throw invalidConfig(noteId, String.format("Value for '%s.%s.%s' is missing, expected account ID", EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY)); }/* w ww .j a va 2s. c o m*/ try { int accountId = externalIdConfig.getInt(EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY, -1); if (accountId <= 0) { throw invalidConfig(noteId, String.format("Value %s for '%s.%s.%s' is invalid, expected account ID", accountIdStr, EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY)); } return accountId; } catch (IllegalArgumentException e) { throw invalidConfig(noteId, String.format("Value %s for '%s.%s.%s' is invalid, expected account ID", accountIdStr, EXTERNAL_ID_SECTION, externalIdKeyStr, ACCOUNT_ID_KEY)); } }
From source file:com.google.gerrit.server.account.QueryAccounts.java
License:Apache License
@Inject
QueryAccounts(AccountControl.Factory accountControlFactory, AccountLoader.Factory accountLoaderFactory,
AccountCache accountCache, AccountIndexCollection indexes, AccountQueryBuilder queryBuilder,
AccountQueryProcessor queryProcessor, ReviewDb db, @GerritServerConfig Config cfg) {
this.accountControl = accountControlFactory.get();
this.accountLoaderFactory = accountLoaderFactory;
this.accountCache = accountCache;
this.indexes = indexes;
this.queryBuilder = queryBuilder;
this.queryProcessor = queryProcessor;
this.db = db;
this.suggestFrom = cfg.getInt("suggest", null, "from", 0);
this.options = EnumSet.noneOf(ListAccountsOption.class);
if ("off".equalsIgnoreCase(cfg.getString("suggest", null, "accounts"))) {
suggestConfig = false;/*from w w w . ja v a 2s . c o m*/
} else {
boolean suggest;
try {
AccountVisibility av = cfg.getEnum("suggest", null, "accounts", AccountVisibility.ALL);
suggest = (av != AccountVisibility.NONE);
} catch (IllegalArgumentException err) {
suggest = cfg.getBoolean("suggest", null, "accounts", true);
}
this.suggestConfig = suggest;
}
}
From source file:com.google.gerrit.server.account.SuggestAccounts.java
License:Apache License
@Inject SuggestAccounts(AccountControl.Factory accountControlFactory, AccountLoader.Factory accountLoaderFactory, AccountCache accountCache, ReviewDb db, @GerritServerConfig Config cfg) { accountControl = accountControlFactory.get(); accountLoader = accountLoaderFactory.create(true); this.accountCache = accountCache; this.db = db; this.suggestFrom = cfg.getInt("suggest", null, "from", 0); if ("off".equalsIgnoreCase(cfg.getString("suggest", null, "accounts"))) { suggest = false;/*from www . j a va2 s. c o m*/ } else { boolean suggest; try { AccountVisibility av = cfg.getEnum("suggest", null, "accounts", AccountVisibility.ALL); suggest = (av != AccountVisibility.NONE); } catch (IllegalArgumentException err) { suggest = cfg.getBoolean("suggest", null, "accounts", true); } this.suggest = suggest; } }
From source file:com.google.gerrit.server.change.MergeabilityChecksExecutorModule.java
License:Apache License
@Provides @Singleton/* w w w. j a v a2s.c o m*/ @MergeabilityChecksExecutor(Priority.BACKGROUND) public WorkQueue.Executor createMergeabilityChecksExecutor(@GerritServerConfig Config config, WorkQueue queues) { int poolSize = config.getInt("changeMerge", null, "threadPoolSize", 1); return queues.createQueue(poolSize, "MergeabilityChecks-Background"); }
From source file:com.google.gerrit.server.change.MergeabilityChecksExecutorModule.java
License:Apache License
@Provides @Singleton//from w w w . java 2 s. c om @MergeabilityChecksExecutor(Priority.INTERACTIVE) public WorkQueue.Executor createMergeabilityChecksExecutor(@GerritServerConfig Config config, WorkQueue queues, @MergeabilityChecksExecutor(Priority.BACKGROUND) WorkQueue.Executor backgroundExecutor) { int poolSize = config.getInt("changeMerge", null, "interactiveThreadPoolSize", 1); if (poolSize <= 0) { return backgroundExecutor; } return queues.createQueue(poolSize, "MergeabilityChecks-Interactive"); }