Example usage for org.eclipse.jgit.storage.pack PackConfig PackConfig

List of usage examples for org.eclipse.jgit.storage.pack PackConfig PackConfig

Introduction

In this page you can find the example usage for org.eclipse.jgit.storage.pack PackConfig PackConfig.

Prototype

public PackConfig() 

Source Link

Document

Create a default configuration.

Usage

From source file:com.google.gerrit.server.git.TransferConfig.java

License:Apache License

@Inject
TransferConfig(@GerritServerConfig final Config cfg) {
    timeout = (int) ConfigUtil.getTimeUnit(cfg, "transfer", null, "timeout", //
            0, TimeUnit.SECONDS);
    maxObjectSizeLimit = cfg.getLong("receive", "maxObjectSizeLimit", 0);
    maxObjectSizeLimitFormatted = cfg.getString("receive", null, "maxObjectSizeLimit");

    packConfig = new PackConfig();
    packConfig.setDeltaCompress(false);//from  w  ww  . java  2s . c om
    packConfig.setThreads(1);
    packConfig.fromConfig(cfg);
}

From source file:com.sap.poc.jgit.storage.jdbc.pgm.JdbcDaemon.java

License:Eclipse Distribution License

@Override
protected void run() throws Exception {
    final PackConfig packConfig = new PackConfig();

    if (configFile != null) {
        if (!configFile.exists())
            throw die(MessageFormat.format(CLIText.get().configFileNotFound, configFile.getAbsolutePath()));

        final FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED);
        cfg.load();/*from   w w w. jav  a  2  s . co  m*/
        packConfig.fromConfig(cfg);
    }

    int threads = packConfig.getThreads();
    if (threads <= 0)
        threads = Runtime.getRuntime().availableProcessors();
    if (1 < threads)
        packConfig.setExecutor(Executors.newFixedThreadPool(threads));

    final org.eclipse.jgit.transport.Daemon d;

    d = new org.eclipse.jgit.transport.Daemon(
            host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(port));

    final JdbcDatabase db = new JdbcDatabaseBuilder().setURI(uri).build();

    final RepositoryResolver<DaemonClient> resolver = new RepositoryResolver<DaemonClient>() {
        @Override
        public Repository open(DaemonClient req, String name) throws RepositoryNotFoundException {
            try {
                return new JdbcRepositoryBuilder().setDatabase(db).setRepositoryName(name).build();
            } catch (DhtException e) {
                throw new RepositoryNotFoundException(name, e);
            }
        }
    };

    d.setPackConfig(packConfig);
    d.setRepositoryResolver(resolver);
    if (0 <= timeout)
        d.setTimeout(timeout);

    for (final String n : enable)
        service(d, n).setEnabled(true);
    for (final String n : disable)
        service(d, n).setEnabled(false);

    for (final String n : canOverride)
        service(d, n).setOverridable(true);
    for (final String n : forbidOverride)
        service(d, n).setOverridable(false);

    d.start();
    out.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress()));
}

From source file:net.antoniy.gidder.beta.ssh.Upload.java

License:Apache License

@Override
protected void runImpl() throws IOException {
    if (!hasPermission()) {
        err.write(MSG_REPOSITORY_PERMISSIONS.getBytes());
        err.flush();//from   w w w. j  a v  a 2s  .com
        onExit(CODE_OK, MSG_REPOSITORY_PERMISSIONS);
        return;
    }

    Config config = new Config();
    //      int timeout = Integer.parseInt(config.getString("transfer", null,
    //            "timeout"));
    int timeout = 10;

    PackConfig packConfig = new PackConfig();
    packConfig.setDeltaCompress(false);
    packConfig.setThreads(1);
    packConfig.fromConfig(config);

    final UploadPack up = new UploadPack(repo);
    up.setPackConfig(packConfig);
    up.setTimeout(timeout);
    up.upload(in, out, err);
}