Example usage for org.eclipse.jgit.lib Config getTimeUnit

List of usage examples for org.eclipse.jgit.lib Config getTimeUnit

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib Config getTimeUnit.

Prototype

public long getTimeUnit(String section, String subsection, String name, long defaultValue, TimeUnit wantUnit) 

Source Link

Document

Parse a numerical time unit, such as "1 minute", from the configuration.

Usage

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 {/* w  w  w.  j  a  v  a  2 s.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.server.notedb.PrimaryStorageMigrator.java

License:Apache License

@VisibleForTesting
public PrimaryStorageMigrator(Config cfg, Provider<ReviewDb> db, GitRepositoryManager repoManager,
        AllUsersName allUsers, ChangeRebuilder rebuilder,
        @Nullable Retryer<NoteDbChangeState> testEnsureRebuiltRetryer,
        ChangeControl.GenericFactory changeControlFactory, Provider<InternalChangeQuery> queryProvider,
        ChangeUpdate.Factory updateFactory, InternalUser.Factory internalUserFactory,
        BatchUpdate.Factory batchUpdateFactory) {
    this.db = db;
    this.repoManager = repoManager;
    this.allUsers = allUsers;
    this.rebuilder = rebuilder;
    this.testEnsureRebuiltRetryer = testEnsureRebuiltRetryer;
    this.changeControlFactory = changeControlFactory;
    this.queryProvider = queryProvider;
    this.updateFactory = updateFactory;
    this.internalUserFactory = internalUserFactory;
    this.batchUpdateFactory = batchUpdateFactory;
    skewMs = NoteDbChangeState.getReadOnlySkew(cfg);

    String s = "notedb";
    timeoutMs = cfg.getTimeUnit(s, null, "primaryStorageMigrationTimeout", MILLISECONDS.convert(60, SECONDS),
            MILLISECONDS);//  w  ww.j  a va2 s  . co  m
}