net.i2p.router
Class RouterContext

java.lang.Object
  extended by net.i2p.I2PAppContext
      extended by net.i2p.router.RouterContext

public class RouterContext
extends I2PAppContext

Build off the core I2P context to provide a root for a router instance to coordinate its resources. Router instances themselves should be sure to have their own RouterContext, and rooting off of it will allow multiple routers to operate in the same JVM without conflict (e.g. sessionTags wont get intermingled, nor will their netDbs, jobQueues, or bandwidth limiters).


Field Summary
 
Fields inherited from class net.i2p.I2PAppContext
_clock, _clockInitialized, _globalAppContext, _keyRing, _keyRingInitialized, _overrideProps
 
Constructor Summary
RouterContext(Router router)
           
RouterContext(Router router, Properties envProps)
           
 
Method Summary
 void addPropertyCallback(I2PProperties.I2PPropertyCallback callback)
          Add a callback, which will fire upon changes in the property given in the specific callback.
 FIFOBandwidthLimiter bandwidthLimiter()
          Coordinate this router's bandwidth limits
 Blocklist blocklist()
           
 ClientManagerFacade clientManager()
          How are we coordinating clients for the router?
 ClientMessagePool clientMessagePool()
          Where do we toss messages for the clients (and where do we get client messages to forward on from)?
 CommSystemFacade commSystem()
          How do we pass messages from our outNetMessagePool to another router
 Properties getProperties()
          Access the configuration attributes of this context, listing the properties provided during the context construction, as well as the ones included in System.getProperties.
 String getProperty(String propName)
          Tie in the router's config as properties, as well as whatever the I2PAppContext says.
 int getProperty(String propName, int defaultVal)
          Return an int with an int default
 String getProperty(String propName, String defaultVal)
          Tie in the router's config as properties, as well as whatever the I2PAppContext says.
 void initAll()
           
protected  void initializeClock()
           
protected  void initializeKeyRing()
           
 InNetMessagePool inNetMessagePool()
          Where do we get network messages from (aka where does the comm system dump what it reads)?
 InternalClientManager internalClientManager()
          Use this to connect to the router in the same JVM.
 boolean isRouterContext()
          Use this instead of context instanceof RouterContext
 JobQueue jobQueue()
          The actual driver of the router, where all jobs are enqueued and processed.
 KeyManager keyManager()
          Coordinates the router's ElGamal and DSA keys, as well as any keys given to it by clients as part of a LeaseSet.
 KeyRing keyRing()
          override to support storage in router.config
static List<RouterContext> listContexts()
          Retrieve the list of router contexts currently instantiated in this JVM.
 MessageHistory messageHistory()
          Tracker component for monitoring what messages are wrapped in what containers and how they proceed through the network.
 OutboundMessageRegistry messageRegistry()
          The registry is used by outbound messages to wait for replies.
 MessageStateMonitor messageStateMonitor()
          The monitor keeps track of inbound and outbound messages currently held in memory / queued for processing.
 MessageValidator messageValidator()
          The router keeps track of messages it receives to prevent duplicates, as well as other criteria for "validity".
 NetworkDatabaseFacade netDb()
          Our db cache
 OutNetMessagePool outNetMessagePool()
          Where do we put messages that the router wants to forwards onto the network?
 PeerManagerFacade peerManager()
          Minimal interface for selecting peers for various tasks based on given criteria.
 ProfileManager profileManager()
          Expose a simple API for various router components to take note of particular events that a peer enacts (sends us a message, agrees to participate in a tunnel, etc).
 ProfileOrganizer profileOrganizer()
          Organize the peers we know about into various tiers, profiling their performance and sorting them accordingly.
 Router router()
          what router is this context working for?
 Hash routerHash()
          Convenience method for getting the router hash.
 void setProperty(String propName, String value)
          Modify the configuration attributes of this context, changing one of the properties provided during the context construction.
 Shitlist shitlist()
          who does this peer hate?
 StatisticsManager statPublisher()
          If the router is configured to, gather up some particularly tasty morsels regarding the stats managed and offer to publish them into the routerInfo.
 RouterThrottle throttle()
          Component to coordinate our accepting/rejecting of requests under load
 String toString()
           
 TunnelDispatcher tunnelDispatcher()
          Handle tunnel messages, as well as coordinate the gateways
 TunnelManagerFacade tunnelManager()
          Coordinate this router's tunnels (its pools, participation, backup, etc).
 
Methods inherited from class net.i2p.I2PAppContext
addShutdownTask, aes, clock, deleteTempDir, dsa, elGamalAESEngine, elGamalEngine, getAppDir, getBaseDir, getBooleanProperty, getBooleanPropertyDefaultTrue, getConfigDir, getCurrentContext, getGlobalContext, getLogDir, getPIDDir, getProperty, getPropertyNames, getRouterDir, getShutdownTasks, getTempDir, hmac, hmac256, keyGenerator, logManager, namingService, random, routingKeyGenerator, sessionKeyManager, sha, statManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RouterContext

public RouterContext(Router router)

RouterContext

public RouterContext(Router router,
                     Properties envProps)
Method Detail

setProperty

public void setProperty(String propName,
                        String value)
Modify the configuration attributes of this context, changing one of the properties provided during the context construction.

Parameters:
propName - The name of the property.
value - The new value for the property.

addPropertyCallback

public void addPropertyCallback(I2PProperties.I2PPropertyCallback callback)
Description copied from class: I2PAppContext
Add a callback, which will fire upon changes in the property given in the specific callback. Unimplemented in I2PAppContext: this only makes sense in a router context.

Overrides:
addPropertyCallback in class I2PAppContext
Parameters:
callback - The implementation of the callback.

initAll

public void initAll()

listContexts

public static List<RouterContext> listContexts()
Retrieve the list of router contexts currently instantiated in this JVM. This will always contain only one item (except when a simulation per the MultiRouter is going on), and the list should only be modified when a new context is created or a router is shut down.


router

public Router router()
what router is this context working for?


routerHash

public Hash routerHash()
Convenience method for getting the router hash. Equivalent to context.router().getRouterInfo().getIdentity().getHash()

Returns:
may be null if called very early

clientManager

public ClientManagerFacade clientManager()
How are we coordinating clients for the router?


clientMessagePool

public ClientMessagePool clientMessagePool()
Where do we toss messages for the clients (and where do we get client messages to forward on from)?


inNetMessagePool

public InNetMessagePool inNetMessagePool()
Where do we get network messages from (aka where does the comm system dump what it reads)?


outNetMessagePool

public OutNetMessagePool outNetMessagePool()
Where do we put messages that the router wants to forwards onto the network?


messageHistory

public MessageHistory messageHistory()
Tracker component for monitoring what messages are wrapped in what containers and how they proceed through the network. This is fully for debugging, as when a large portion of the network tracks their messages through this messageHistory and submits their logs, we can correlate them and watch as messages flow from hop to hop.


messageRegistry

public OutboundMessageRegistry messageRegistry()
The registry is used by outbound messages to wait for replies.


messageStateMonitor

public MessageStateMonitor messageStateMonitor()
The monitor keeps track of inbound and outbound messages currently held in memory / queued for processing. We'll use this to throttle the router so we don't overflow.


netDb

public NetworkDatabaseFacade netDb()
Our db cache


jobQueue

public JobQueue jobQueue()
The actual driver of the router, where all jobs are enqueued and processed.


keyManager

public KeyManager keyManager()
Coordinates the router's ElGamal and DSA keys, as well as any keys given to it by clients as part of a LeaseSet.


commSystem

public CommSystemFacade commSystem()
How do we pass messages from our outNetMessagePool to another router


profileOrganizer

public ProfileOrganizer profileOrganizer()
Organize the peers we know about into various tiers, profiling their performance and sorting them accordingly.


peerManager

public PeerManagerFacade peerManager()
Minimal interface for selecting peers for various tasks based on given criteria. This is kept seperate from the profile organizer since this logic is independent of how the peers are organized (or profiled even).


profileManager

public ProfileManager profileManager()
Expose a simple API for various router components to take note of particular events that a peer enacts (sends us a message, agrees to participate in a tunnel, etc).


bandwidthLimiter

public FIFOBandwidthLimiter bandwidthLimiter()
Coordinate this router's bandwidth limits


tunnelManager

public TunnelManagerFacade tunnelManager()
Coordinate this router's tunnels (its pools, participation, backup, etc). Any configuration for the tunnels is rooted from the context's properties


tunnelDispatcher

public TunnelDispatcher tunnelDispatcher()
Handle tunnel messages, as well as coordinate the gateways


statPublisher

public StatisticsManager statPublisher()
If the router is configured to, gather up some particularly tasty morsels regarding the stats managed and offer to publish them into the routerInfo.


shitlist

public Shitlist shitlist()
who does this peer hate?


blocklist

public Blocklist blocklist()

messageValidator

public MessageValidator messageValidator()
The router keeps track of messages it receives to prevent duplicates, as well as other criteria for "validity".


throttle

public RouterThrottle throttle()
Component to coordinate our accepting/rejecting of requests under load


toString

public String toString()
Overrides:
toString in class Object

getProperty

public String getProperty(String propName)
Tie in the router's config as properties, as well as whatever the I2PAppContext says.

Overrides:
getProperty in class I2PAppContext

getProperty

public String getProperty(String propName,
                          String defaultVal)
Tie in the router's config as properties, as well as whatever the I2PAppContext says.

Overrides:
getProperty in class I2PAppContext

getProperty

public int getProperty(String propName,
                       int defaultVal)
Return an int with an int default

Overrides:
getProperty in class I2PAppContext

getProperties

public Properties getProperties()
Description copied from class: I2PAppContext
Access the configuration attributes of this context, listing the properties provided during the context construction, as well as the ones included in System.getProperties.

Overrides:
getProperties in class I2PAppContext
Returns:
new Properties with system and context properties
Since:
0.8.4

initializeClock

protected void initializeClock()
Overrides:
initializeClock in class I2PAppContext

keyRing

public KeyRing keyRing()
override to support storage in router.config

Overrides:
keyRing in class I2PAppContext

initializeKeyRing

protected void initializeKeyRing()
Overrides:
initializeKeyRing in class I2PAppContext

isRouterContext

public boolean isRouterContext()
Use this instead of context instanceof RouterContext

Overrides:
isRouterContext in class I2PAppContext
Returns:
true
Since:
0.7.9

internalClientManager

public InternalClientManager internalClientManager()
Use this to connect to the router in the same JVM.

Overrides:
internalClientManager in class I2PAppContext
Returns:
the client manager
Since:
0.8.3