Example usage for org.eclipse.jgit.storage.file WindowCacheConfig setPackedGitOpenFiles

List of usage examples for org.eclipse.jgit.storage.file WindowCacheConfig setPackedGitOpenFiles

Introduction

In this page you can find the example usage for org.eclipse.jgit.storage.file WindowCacheConfig setPackedGitOpenFiles.

Prototype

public void setPackedGitOpenFiles(int fdLimit) 

Source Link

Document

Set maximum number of streams to open at a time.

Usage

From source file:com.gitblit.GitBlit.java

License:Apache License

/**
 * Configure the Gitblit singleton with the specified settings source. This
 * source may be file settings (Gitblit GO) or may be web.xml settings
 * (Gitblit WAR)./*  www .  j ava  2 s .  c  o  m*/
 * 
 * @param settings
 */
public void configureContext(IStoredSettings settings, boolean startFederation) {
    logger.info("Reading configuration from " + settings.toString());
    this.settings = settings;
    repositoriesFolder = getRepositoriesFolder();
    logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath());
    repositoryResolver = new FileResolver<Void>(repositoriesFolder, true);

    // calculate repository list settings checksum for future config changes
    repositoryListSettingsChecksum.set(getRepositoryListSettingsChecksum());

    // build initial repository list
    if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
        logger.info("Identifying available repositories...");
        getRepositoryList();
    }

    logTimezone("JVM", TimeZone.getDefault());
    logTimezone(Constants.NAME, getTimezone());

    serverStatus = new ServerStatus(isGO());
    String realm = settings.getString(Keys.realm.userService, "users.properties");
    IUserService loginService = null;
    try {
        // check to see if this "file" is a login service class
        Class<?> realmClass = Class.forName(realm);
        loginService = (IUserService) realmClass.newInstance();
    } catch (Throwable t) {
        loginService = new GitblitUserService();
    }
    setUserService(loginService);

    // load and cache the project metadata
    projectConfigs = new FileBasedConfig(getFileOrFolder(Keys.web.projectsFile, "projects.conf"), FS.detect());
    getProjectConfigs();

    mailExecutor = new MailExecutor(settings);
    if (mailExecutor.isReady()) {
        logger.info("Mail executor is scheduled to process the message queue every 2 minutes.");
        scheduledExecutor.scheduleAtFixedRate(mailExecutor, 1, 2, TimeUnit.MINUTES);
    } else {
        logger.warn("Mail server is not properly configured.  Mail services disabled.");
    }
    luceneExecutor = new LuceneExecutor(settings, repositoriesFolder);
    logger.info("Lucene executor is scheduled to process indexed branches every 2 minutes.");
    scheduledExecutor.scheduleAtFixedRate(luceneExecutor, 1, 2, TimeUnit.MINUTES);
    if (startFederation) {
        configureFederation();
    }

    // Configure JGit
    WindowCacheConfig cfg = new WindowCacheConfig();

    cfg.setPackedGitWindowSize(
            settings.getFilesize(Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
    cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
    cfg.setDeltaBaseCacheLimit(
            settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
    cfg.setPackedGitOpenFiles(settings.getFilesize(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
    cfg.setStreamFileThreshold(
            settings.getFilesize(Keys.git.streamFileThreshold, cfg.getStreamFileThreshold()));
    cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));

    try {
        WindowCache.reconfigure(cfg);
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize,
                cfg.getPackedGitWindowSize()));
        logger.debug(
                MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit,
                cfg.getDeltaBaseCacheLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitOpenFiles,
                cfg.getPackedGitOpenFiles()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.streamFileThreshold,
                cfg.getStreamFileThreshold()));
        logger.debug(MessageFormat.format("{0} = {1}", Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
    } catch (IllegalArgumentException e) {
        logger.error("Failed to configure JGit parameters!", e);
    }

    ContainerUtils.CVE_2007_0450.test();
}

From source file:com.gitblit.manager.RepositoryManager.java

License:Apache License

protected void configureJGit() {
    // Configure JGit
    WindowCacheConfig cfg = new WindowCacheConfig();

    cfg.setPackedGitWindowSize(// w w w  . ja  v a  2s.  co  m
            settings.getFilesize(Keys.git.packedGitWindowSize, cfg.getPackedGitWindowSize()));
    cfg.setPackedGitLimit(settings.getFilesize(Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
    cfg.setDeltaBaseCacheLimit(
            settings.getFilesize(Keys.git.deltaBaseCacheLimit, cfg.getDeltaBaseCacheLimit()));
    cfg.setPackedGitOpenFiles(settings.getInteger(Keys.git.packedGitOpenFiles, cfg.getPackedGitOpenFiles()));
    cfg.setPackedGitMMAP(settings.getBoolean(Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));

    try {
        cfg.install();
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitWindowSize,
                cfg.getPackedGitWindowSize()));
        logger.debug(
                MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitLimit, cfg.getPackedGitLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.deltaBaseCacheLimit,
                cfg.getDeltaBaseCacheLimit()));
        logger.debug(MessageFormat.format("{0} = {1,number,0}", Keys.git.packedGitOpenFiles,
                cfg.getPackedGitOpenFiles()));
        logger.debug(MessageFormat.format("{0} = {1}", Keys.git.packedGitMmap, cfg.isPackedGitMMAP()));
    } catch (IllegalArgumentException e) {
        logger.error("Failed to configure JGit parameters!", e);
    }

    try {
        // issue-486/ticket-151: UTF-9 & UTF-18
        // issue-560/ticket-237: 'UTF8'
        Field field = RawParseUtils.class.getDeclaredField("encodingAliases");
        field.setAccessible(true);
        Map<String, Charset> encodingAliases = (Map<String, Charset>) field.get(null);
        encodingAliases.put("'utf8'", RawParseUtils.UTF8_CHARSET);
        encodingAliases.put("utf-9", RawParseUtils.UTF8_CHARSET);
        encodingAliases.put("utf-18", RawParseUtils.UTF8_CHARSET);
        logger.info("Alias 'UTF8', UTF-9 & UTF-18 encodings as UTF-8 in JGit");
    } catch (Throwable t) {
        logger.error("Failed to inject UTF-9 & UTF-18 encoding aliases into JGit", t);
    }
}