Package org.eclipse.jgit.transport
Class Daemon
- java.lang.Object
-
- org.eclipse.jgit.transport.Daemon
-
public class Daemon extends java.lang.ObjectBasic daemon for the anonymousgit://transport protocol.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDaemon.Acceptor
-
Field Summary
Fields Modifier and Type Field Description private Daemon.AcceptoracceptThreadprivate static intBACKLOGstatic intDEFAULT_PORT9418: IANA assigned port number for Git.private java.net.InetSocketAddressmyAddressprivate PackConfigpackConfigprivate java.lang.ThreadGroupprocessors(package private) ReceivePackFactory<DaemonClient>receivePackFactoryprivate RepositoryResolver<DaemonClient>repositoryResolverprivate DaemonService[]servicesprivate inttimeout(package private) UploadPackFactory<DaemonClient>uploadPackFactory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearThread()java.net.InetSocketAddressgetAddress()Get the address connections are received on.PackConfiggetPackConfig()Get configuration controlling packing, may be null.ReceivePackFactory<DaemonClient>getReceivePackFactory()Get the factory used to construct per-request ReceivePack.DaemonServicegetService(java.lang.String name)Lookup a supported service so it can be reconfigured.intgetTimeout()Get timeout (in seconds) before aborting an IO operation.booleanisRunning()Whether this daemon is receiving connections.(package private) DaemonServicematchService(java.lang.String cmd)(package private) RepositoryopenRepository(DaemonClient client, java.lang.String name)voidsetPackConfig(PackConfig pc)Set the configuration used by the pack generator.voidsetReceivePackFactory(ReceivePackFactory<DaemonClient> factory)Set the factory to construct and configure per-request ReceivePack.voidsetRepositoryResolver(RepositoryResolver<DaemonClient> resolver)Set the resolver used to locate a repository by name.voidsetTimeout(int seconds)Set the timeout before willing to abort an IO call.voidsetUploadPackFactory(UploadPackFactory<DaemonClient> factory)Set the factory to construct and configure per-request UploadPack.voidstart()Start this daemon on a background thread.(package private) voidstartClient(java.net.Socket s)voidstop()Stop this daemon.voidstopAndWait()Stops this daemon and waits until it's acceptor thread has finished.
-
-
-
Field Detail
-
DEFAULT_PORT
public static final int DEFAULT_PORT
9418: IANA assigned port number for Git.- See Also:
- Constant Field Values
-
BACKLOG
private static final int BACKLOG
- See Also:
- Constant Field Values
-
myAddress
private java.net.InetSocketAddress myAddress
-
services
private final DaemonService[] services
-
processors
private final java.lang.ThreadGroup processors
-
acceptThread
private Daemon.Acceptor acceptThread
-
timeout
private int timeout
-
packConfig
private PackConfig packConfig
-
repositoryResolver
private volatile RepositoryResolver<DaemonClient> repositoryResolver
-
uploadPackFactory
volatile UploadPackFactory<DaemonClient> uploadPackFactory
-
receivePackFactory
volatile ReceivePackFactory<DaemonClient> receivePackFactory
-
-
Constructor Detail
-
Daemon
public Daemon()
Configure a daemon to listen on any available network port.
-
Daemon
public Daemon(java.net.InetSocketAddress addr)
Configure a new daemon for the specified network address.- Parameters:
addr- address to listen for connections on. If null, any available port will be chosen on all network interfaces.
-
-
Method Detail
-
getAddress
public java.net.InetSocketAddress getAddress()
Get the address connections are received on.- Returns:
- the address connections are received on.
-
getService
public DaemonService getService(java.lang.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()
Get timeout (in seconds) before aborting an IO operation.- 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.
-
getPackConfig
public PackConfig getPackConfig()
Get configuration controlling packing, may be null.- Returns:
- configuration controlling packing, may be null.
-
setPackConfig
public void setPackConfig(PackConfig pc)
Set the configuration used by the pack generator.- Parameters:
pc- configuration controlling packing parameters. If null the source repository's settings will be used.
-
setRepositoryResolver
public void setRepositoryResolver(RepositoryResolver<DaemonClient> resolver)
Set the resolver used to locate a repository by name.- Parameters:
resolver- the resolver instance.
-
setUploadPackFactory
public void setUploadPackFactory(UploadPackFactory<DaemonClient> factory)
Set the factory to construct and configure per-request UploadPack.- Parameters:
factory- the factory. If null upload-pack is disabled.
-
getReceivePackFactory
public ReceivePackFactory<DaemonClient> getReceivePackFactory()
Get the factory used to construct per-request ReceivePack.- Returns:
- the factory.
- Since:
- 4.3
-
setReceivePackFactory
public void setReceivePackFactory(ReceivePackFactory<DaemonClient> factory)
Set the factory to construct and configure per-request ReceivePack.- Parameters:
factory- the factory. If null receive-pack is disabled.
-
start
public void start() throws java.io.IOExceptionStart this daemon on a background thread.- Throws:
java.io.IOException- the server socket could not be opened.java.lang.IllegalStateException- the daemon is already running.
-
clearThread
private void clearThread()
-
isRunning
public boolean isRunning()
Whether this daemon is receiving connections.- Returns:
trueif this daemon is receiving connections.
-
stop
public void stop()
Stop this daemon.
-
stopAndWait
public void stopAndWait() throws java.lang.InterruptedExceptionStops this daemon and waits until it's acceptor thread has finished.- Throws:
java.lang.InterruptedException- if waiting for the acceptor thread is interrupted- Since:
- 4.9
-
startClient
void startClient(java.net.Socket s)
-
matchService
DaemonService matchService(java.lang.String cmd)
-
openRepository
Repository openRepository(DaemonClient client, java.lang.String name) throws ServiceMayNotContinueException
- Throws:
ServiceMayNotContinueException
-
-