API Documentation: Interface LocalNetworkCache

Name LocalNetworkCache
Package com.mckoi.network

A local cache of network topology information and node data. Implementations may include persistent storage of information by the local services available in the client instance, or weak caches with short lived (in time and/or by session) storage, such as on the Java heap.

The node cache heavily exploits the property that a node address is globally unique by value and with respect to all nodes valid now and in the future. Implementations must also support caching of block to server maps as provided by the manager server, with a time-to-live component.

Methods Summary

TreeNode getNode(DataAddress address)
void putNode(DataAddress address, TreeNode node)
void deleteNode(DataAddress address, TreeNode node)
List<BlockServerElement> getServersWithBlock(long block_id)
void putServersForBlock(long block_id, List<BlockServerElement> servers, int ttl_hint)
void removeServersWithBlock(long block_id)

Method Details

TreeNode getNode(DataAddress address)

Returns the TreeNode value with the given DataAddress if it is stored in this cache, or 'null' otherwise.

void putNode(DataAddress address, TreeNode node)

Stores the TreeNode for the given DataAddress in the cache.

void deleteNode(DataAddress address, 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.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Sun Microsystems, Inc.
Mckoi is Copyright © 2000 - 2012 Diehl and Associates, Inc. All rights reserved.