API Documentation: Class HeapLocalNetworkCache
| Name | HeapLocalNetworkCache |
| Package | com.mckoi.network |
| Implements | com.mckoi.network.LocalNetworkCache |
A LocalNetworkCache implementation that stores nodes on the Java heap, and automatically deletes nodes when a certain threshold of nodes is stored.
Constructors Summary
| HeapLocalNetworkCache(long max_cache_size) | |
| HeapLocalNetworkCache() |
Methods Summary
| void | putNode(DataAddress addr, TreeNode node) | ||
| TreeNode | getNode(DataAddress addr) | ||
| void | deleteNode(DataAddress addr, TreeNode node) | ||
| List<BlockServerElement> | getServersWithBlock(long block_id) | ||
| void | putServersForBlock(long block_id, List<BlockServerElement> servers, int ttl_hint) | ||
| void | removeServersWithBlock(long block_id) |
Constructor Details
HeapLocalNetworkCache(long max_cache_size)
Constructs the heap cache with a maximum size in bytes of all node data that may be stored.
HeapLocalNetworkCache()
Default constructor that creates a heap cache with a maximum size of 32 megabytes.
Method Details
void putNode(DataAddress addr, TreeNode node)
Stores the TreeNode for the given DataAddress in the cache.
TreeNode getNode(DataAddress addr)
Returns the TreeNode value with the given DataAddress if it is stored in this cache, or 'null' otherwise.
void deleteNode(DataAddress addr, TreeNode node)
Removes the tree node referenced by the given DataAddress from the cache, if it is stored within this cache. If the node is not stored in the cache then nothing happens.
List<BlockServerElement> getServersWithBlock(long block_id)
Returns the list of servers in the network the block is stored on if the information is stored in the cache, or 'null' if the information isn't available in the cache. A cached element is valid until its TTL is exceeded. If a request is made for a block that is in the cache but the TTL is exceeded, then this method returns 'null' for that element.
void putServersForBlock(long block_id, List<BlockServerElement> servers, int ttl_hint)
Associates the set of servers with the given block identifier in the cache with a TTL hint (time to live hint). The association is valid in the cache until the current time is greater than the time the association was made plus the TTL value.
Note that the 'servers' object should be considered immutable.
void removeServersWithBlock(long block_id)
Removes a block_id to servers list association. This is intended to be used in the case where we wish to force a status update on cached status information.
