org.eclipse.jgit.storage.dht.spi
Interface Database

All Known Implementing Classes:
CacheDatabase, MemoryDatabase

public interface Database

A distributed database implementation.

A DHT provider must implement this interface to return table references for each of the named tables. The database and the tables it returns are held as singletons, and thus must be thread-safe. If the underlying implementation needs to use individual "connections" for each operation, it is responsible for setting up a connection pool, borrowing and returning resources within each of the table APIs.

Most APIs on the tables are asynchronous and must perform their computation in the background using a different thread than the caller. Implementations that have only an underlying synchronous API should configure and use an ExecutorService to perform computation in the background on a thread pool.

Tables returned by these methods should be singletons, as the higher level DHT implementation usually invokes these methods each time it needs to use a given table. The suggested implementation approach is:

 class MyDatabase implements Database {
        private final RepositoryIndexTable rep = new MyRepositoryIndex();

        private final RefTable ref = new MyRefTable();

        public RepositoryIndexTable repositoryIndex() {
                return rep;
        }

        public RefTable ref() {
                return ref;
        }
 }
 


Method Summary
 ChunkTable chunk()
           
 WriteBuffer newWriteBuffer()
          Create a new WriteBuffer for the current thread.
 ObjectIndexTable objectIndex()
           
 RefTable ref()
           
 RepositoryTable repository()
           
 RepositoryIndexTable repositoryIndex()
           
 

Method Detail

repositoryIndex

RepositoryIndexTable repositoryIndex()
Returns:
a handle to the table listing known repositories.

repository

RepositoryTable repository()
Returns:
a handle to the table storing repository metadata.

ref

RefTable ref()
Returns:
a handle to the table listing references in a repository.

objectIndex

ObjectIndexTable objectIndex()
Returns:
a handle to the table listing known objects.

chunk

ChunkTable chunk()
Returns:
a handle to the table listing pack data chunks.

newWriteBuffer

WriteBuffer newWriteBuffer()
Create a new WriteBuffer for the current thread.

Unlike other methods on this interface, the returned buffer must be a new object on every invocation. Buffers do not need to be thread-safe.

Returns:
a new buffer to handle pending writes.


Copyright © 2011. All Rights Reserved.