RegisterSign In

API Documentation: Class 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(BlockId block_id)
void putServersForBlock(BlockId block_id, List<BlockServerElement> servers, int ttl_hint)
void removeServersWithBlock(BlockId block_id)
PathInfo getPathInfo(String path_name)
void putPathInfo(String path_name, PathInfo path_info)

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(BlockId 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(BlockId 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(BlockId 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.

PathInfo getPathInfo(String path_name)

Returns the PathInfo stored with the given path_name if it's stored in this cache, or 'null' otherwise.

void putPathInfo(String path_name, PathInfo path_info)

Stored the PathInfo in the cache. If 'path_info' is null then the entry is cleared in the cache.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.