This is a datastructure which manages (3+Clients) "sub-netDbs" on behalf of an I2P router, each representing it's own view of the network. Normally, these sub-netDb's are identified by the hash of the primary session belonging to the client who "owns" a particular sub-netDb.
There is one "Special" netDb which has a non-hash name. This is used for the operation of router itself and not clients, in particular when acting as a floodfill:
- Main NetDB: This is the netDb we use if or when we become a floodfill, and for direct interaction with other routers on the network, such as when we are communicating with a floodfill.
It is possible that it may be advantageous some day to have other netDb's for specific use cases, but that is not the purpose of this class at this time.
And there are an unlimited number of "Client" netDbs. These sub-netDbs are intended to contain only the information required to operate them, and as such most of them are very small, containing only a few LeaseSets belonging to clients. Each one corresponds to a Destination which can receive information from the netDb, and can be indexed either by it's hash or by it's base32 address. This index is known as the 'dbid' or database id.
Users of this class should strive to always access their sub-netDbs via the explicit DBID of the destination recipient, or using the DBID of the special netDb when it's appropriate to route the netDb entry to one of the special tables.
Field Summary
Modifier and TypeFieldDescriptionprivate final RouterContextThe router context the segments live in.private final LogLogger for this class.private final FloodfillNetworkDatabaseFacadeThe facade holding the main database.static final HashDatabase id of the special main netDb, deliberately null so it is never confused with a client's hash-keyed id.Constructor Summary
ConstructorsConstructorDescriptionNew segmentor with the given RouterContext, containing a default, main netDb and prepared to add client netDbs.Method Summary
Modifier and TypeMethodDescriptionclientNetDB(Hash id) The client netDb for the given id.private NetworkDatabaseFacadegetSubNetDB(Hash id) Retrieves the FloodfillNetworkDatabaseFacade object for the specified ID.The main netDb, the one we will use if we are a floodfill.voidshutdown()If we are floodfill, turn it off and tell everybody for the _mainDbid.voidstartup()Start up the _mainDbid.
Field Details
_log
Logger for this class._context
The router context the segments live in.MAIN_DBID
Database id of the special main netDb, deliberately null so it is never confused with a client's hash-keyed id._mainDbid
The facade holding the main database.
Constructor Details
FloodfillNetworkDatabaseSegmentor
New segmentor with the given RouterContext, containing a default, main netDb and prepared to add client netDbs.- Parameters:
context- the router context supplying the log manager and the client netDb facades this segmentor creates and queries
Method Details
getSubNetDB
Retrieves the FloodfillNetworkDatabaseFacade object for the specified ID. If the ID is null, the main database is returned.- Parameters:
id- the ID of the FloodfillNetworkDatabaseFacade object to retrieve- Returns:
- the FloodfillNetworkDatabaseFacade object corresponding to the ID or null if it does not exist.
shutdown
public void shutdown()If we are floodfill, turn it off and tell everybody for the _mainDbid.- Specified by:
shutdownin classSegmentedNetworkDatabaseFacade
startup
public void startup()Start up the _mainDbid.- Specified by:
startupin classSegmentedNetworkDatabaseFacade
mainNetDB
The main netDb, the one we will use if we are a floodfill.- Specified by:
mainNetDBin classSegmentedNetworkDatabaseFacade- Returns:
- may be null
clientNetDB
The client netDb for the given id. Will return the "main" netDb if the dbid is null.- Specified by:
clientNetDBin classSegmentedNetworkDatabaseFacade- Parameters:
id- the destination hash naming which client sub-database to use- Returns:
- non-null, the main netDb if the client netDb does not exist