Class Daemon


  • public class Daemon
    extends Object
    Basic daemon for the anonymous git:// transport protocol.
    • Constructor Detail

      • Daemon

        public Daemon​(InetSocketAddress addr,
                      Executor acceptThreadPool,
                      ExecutorService executorService,
                      org.eclipse.jgit.internal.ketch.KetchLeaderCache leaders)
        Configures a new daemon for the specified network address. The daemon will not attempt to bind to an address or accept connections until a call to start().
        Parameters:
        addr - address to listen for connections on. If null, any available port will be chosen on all network interfaces.
        acceptThreadPool - source of threads for waiting for inbound socket connections. Every time the daemon is started or restarted, a new task will be submitted to this pool. When the daemon is stopped, the task completes.
    • Method Detail

      • getAddress

        public InetSocketAddress getAddress()
        Returns:
        the address connections are received on.
      • getService

        public DaemonService getService​(String name)
        Lookup a supported service so it can be reconfigured.
        Parameters:
        name - name of the service; e.g. "receive-pack"/"git-receive-pack" or "upload-pack"/"git-upload-pack".
        Returns:
        the service; null if this daemon implementation doesn't support the requested service type.
      • getTimeout

        public int getTimeout()
        Returns:
        timeout (in seconds) before aborting an IO operation.
      • setTimeout

        public void setTimeout​(int seconds)
        Set the timeout before willing to abort an IO call.
        Parameters:
        seconds - number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with the connected client.
      • setRepositoryResolver

        public void setRepositoryResolver​(org.eclipse.jgit.transport.resolver.RepositoryResolver<DaemonClient> resolver)
        Sets the resolver that locates repositories by name.
        Parameters:
        resolver - the resolver instance.
      • setUploadPackFactory

        public void setUploadPackFactory​(org.eclipse.jgit.transport.resolver.UploadPackFactory<DaemonClient> factory)
        Sets the factory that constructs and configures the per-request UploadPack.
        Parameters:
        factory - the factory. If null upload-pack is disabled.
      • start

        public void start()
                   throws IOException
        Starts this daemon listening for connections on a thread supplied by the executor service given to the constructor. The daemon can be stopped by a call to stop() or by shutting down the ExecutorService.
        Throws:
        IOException - the server socket could not be opened.
        IllegalStateException - the daemon is already running.
      • isRunning

        public boolean isRunning()
        Returns:
        true if this daemon is receiving connections.
      • stop

        public void stop()
        Stops this daemon. It is safe to call this method on a daemon which is already stopped, in which case the call has no effect.