Top Description Inners Fields Constructors Methods
org.eclipse.jgit.transport

public Class Daemon

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.net.InetAddress, .InetSocketAddress, .ServerSocket, .Socket, .SocketAddress, .SocketException, java.util.concurrent.atomic.AtomicBoolean, java.util.Collection, org.eclipse.jgit.annotations.Nullable, org.eclipse.jgit.errors.RepositoryNotFoundException, org.eclipse.jgit.internal.JGitText, org.eclipse.jgit.lib.PersonIdent, .Repository, org.eclipse.jgit.storage.pack.PackConfig, org.eclipse.jgit.transport.resolver.ReceivePackFactory, .RepositoryResolver, .ServiceNotAuthorizedException, .ServiceNotEnabledException, .UploadPackFactory

Basic daemon for the anonymous git:// transport protocol.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private Daemon.Acceptor
private static final int
public static final int
DEFAULT_PORT

9418: IANA assigned port number for Git.

private InetSocketAddress
private PackConfig
private final ThreadGroup
pack-priv volatile ReceivePackFactory<DaemonClient>
private volatile RepositoryResolver<DaemonClient>
private final DaemonService[]
private int
pack-priv volatile UploadPackFactory<DaemonClient>

Constructor Summary

AccessConstructor and Description
public
Daemon()

Configure a daemon to listen on any available network port.

public
Daemon(InetSocketAddress
address to listen for connections on. If null, any available port will be chosen on all network interfaces.
addr
)

Configure a new daemon for the specified network address.

Method Summary

Modifier and TypeMethod and Description
private synchronized void
public synchronized InetSocketAddress

Returns:

the address connections are received on.
getAddress
()

Get the address connections are received on.

public PackConfig

Returns:

configuration controlling packing, may be null.
getPackConfig
()

Get configuration controlling packing, may be null.

public ReceivePackFactory<DaemonClient>

Returns:

the factory.
getReceivePackFactory
()

Get the factory used to construct per-request ReceivePack.

public synchronized DaemonService

Returns:

the service; null if this daemon implementation doesn't support the requested service type.
getService
(String
name of the service; e.g. "receive-pack"/"git-receive-pack" or "upload-pack"/"git-upload-pack".
name
)

Lookup a supported service so it can be reconfigured.

public int

Returns:

timeout (in seconds) before aborting an IO operation.
getTimeout
()

Get timeout (in seconds) before aborting an IO operation.

public synchronized boolean

Returns:

true if this daemon is receiving connections.
isRunning
()

Whether this daemon is receiving connections.

pack-priv synchronized DaemonService
pack-priv Repository
public void
setPackConfig(PackConfig
configuration controlling packing parameters. If null the source repository's settings will be used.
pc
)

Set the configuration used by the pack generator.

public void
setReceivePackFactory(ReceivePackFactory<DaemonClient>
the factory. If null receive-pack is disabled.
factory
)

Set the factory to construct and configure per-request ReceivePack.

public void
setRepositoryResolver(RepositoryResolver<DaemonClient>
the resolver instance.
resolver
)

Set the resolver used to locate a repository by name.

public void
setTimeout(int
number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with the connected client.
seconds
)

Set the timeout before willing to abort an IO call.

public void
setUploadPackFactory(UploadPackFactory<DaemonClient>
the factory. If null upload-pack is disabled.
factory
)

Set the factory to construct and configure per-request UploadPack.

public synchronized void
start()

Start this daemon on a background thread.

pack-priv void
public synchronized void
stop()

Stop this daemon.

public void
stopAndWait()

Stops this daemon and waits until it's acceptor thread has finished.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acceptThreadback to summary
private Daemon.Acceptor acceptThread
BACKLOGback to summary
private static final int BACKLOG
DEFAULT_PORTback to summary
public static final int DEFAULT_PORT

9418: IANA assigned port number for Git.

myAddressback to summary
private InetSocketAddress myAddress
packConfigback to summary
private PackConfig packConfig
processorsback to summary
private final ThreadGroup processors
receivePackFactoryback to summary
pack-priv volatile ReceivePackFactory<DaemonClient> receivePackFactory
repositoryResolverback to summary
private volatile RepositoryResolver<DaemonClient> repositoryResolver
servicesback to summary
private final DaemonService[] services
timeoutback to summary
private int timeout
uploadPackFactoryback to summary
pack-priv volatile UploadPackFactory<DaemonClient> uploadPackFactory

Constructor Detail

Daemonback to summary
public Daemon()

Configure a daemon to listen on any available network port.

Daemonback to summary
public Daemon(InetSocketAddress addr)

Configure a new daemon for the specified network address.

Parameters
addr:InetSocketAddress

address to listen for connections on. If null, any available port will be chosen on all network interfaces.

Annotations
@SuppressWarnings:unchecked

Method Detail

clearThreadback to summary
private synchronized void clearThread()
getAddressback to summary
public synchronized InetSocketAddress getAddress()

Get the address connections are received on.

Returns:InetSocketAddress

the address connections are received on.

getPackConfigback to summary
public PackConfig getPackConfig()

Get configuration controlling packing, may be null.

Returns:PackConfig

configuration controlling packing, may be null.

getReceivePackFactoryback to summary
public ReceivePackFactory<DaemonClient> getReceivePackFactory()

Get the factory used to construct per-request ReceivePack.

Returns:ReceivePackFactory<DaemonClient>

the factory.

Since
4.3
getServiceback to summary
public synchronized DaemonService getService(String name)

Lookup a supported service so it can be reconfigured.

Parameters
name:String

name of the service; e.g. "receive-pack"/"git-receive-pack" or "upload-pack"/"git-upload-pack".

Returns:DaemonService

the service; null if this daemon implementation doesn't support the requested service type.

getTimeoutback to summary
public int getTimeout()

Get timeout (in seconds) before aborting an IO operation.

Returns:int

timeout (in seconds) before aborting an IO operation.

isRunningback to summary
public synchronized boolean isRunning()

Whether this daemon is receiving connections.

Returns:boolean

true if this daemon is receiving connections.

matchServiceback to summary
pack-priv synchronized DaemonService matchService(String cmd)
openRepositoryback to summary
pack-priv Repository openRepository(DaemonClient client, String name) throws ServiceMayNotContinueException
setPackConfigback to summary
public void setPackConfig(PackConfig pc)

Set the configuration used by the pack generator.

Parameters
pc:PackConfig

configuration controlling packing parameters. If null the source repository's settings will be used.

setReceivePackFactoryback to summary
public void setReceivePackFactory(ReceivePackFactory<DaemonClient> factory)

Set the factory to construct and configure per-request ReceivePack.

Parameters
factory:ReceivePackFactory<DaemonClient>

the factory. If null receive-pack is disabled.

Annotations
@SuppressWarnings:unchecked
setRepositoryResolverback to summary
public void setRepositoryResolver(RepositoryResolver<DaemonClient> resolver)

Set the resolver used to locate a repository by name.

Parameters
resolver:RepositoryResolver<DaemonClient>

the resolver instance.

setTimeoutback to summary
public void setTimeout(int seconds)

Set the timeout before willing to abort an IO call.

Parameters
seconds:int

number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with the connected client.

setUploadPackFactoryback to summary
public void setUploadPackFactory(UploadPackFactory<DaemonClient> factory)

Set the factory to construct and configure per-request UploadPack.

Parameters
factory:UploadPackFactory<DaemonClient>

the factory. If null upload-pack is disabled.

Annotations
@SuppressWarnings:unchecked
startback to summary
public synchronized void start() throws IOException

Start this daemon on a background thread.

Exceptions
IOException:
the server socket could not be opened.
IllegalStateException:
the daemon is already running.
startClientback to summary
pack-priv void startClient(Socket s)
stopback to summary
public synchronized void stop()

Stop this daemon.

stopAndWaitback to summary
public void stopAndWait() throws InterruptedException

Stops this daemon and waits until it's acceptor thread has finished.

Exceptions
InterruptedException:
if waiting for the acceptor thread is interrupted
Since
4.9
org.eclipse.jgit.transport back to summary

private Class Daemon.Acceptor

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ServerSocket
private final AtomicBoolean
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
public
Acceptor(ThreadGroup group, String name, ServerSocket socket)

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

public void
private void
Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

listenSocketback to summary
private final ServerSocket listenSocket
runningback to summary
private final AtomicBoolean running

Constructor Detail

Acceptorback to summary
public Acceptor(ThreadGroup group, String name, ServerSocket socket)

Method Detail

isRunningback to summary
public boolean isRunning()
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

Annotations
@Override
shutDownback to summary
public void shutDown()
terminateback to summary
private void terminate()