DHTTestApp is a Tier2 application that is used to demonstrate the functionality of adding, updating, and querying resources/contents using a DHT. You can easily modify this application to perform complex DHT functions. DHTTestAPP & DHT work together where DHTTestAPP utilizes the DHT to store & retrieve (key, value) pairs. DHTTestAPP consist of 2 modules:
- GlobalDhtTestMap – Provides a data structure and functions to maintain a global list of (key, value) pairs in the P2P system. Random keys are taken from this list to issue DHT get and modify queries. This can be modified to replay traces of (key, value) pairs or queries.
- DHTTestApp – Issues DHT put, get, and modify queries after some delay derived from a truncnormal distribution.
API
- Put messages – Use to add a random (key, value) pair into the DHT. A put message (represented as DHTputCAPICall) consists of a random key, random value (string), expiration time (ttl), and whether (key, value) pair can be modified. Then the message is send to the DHT Tier1 application using sendInternalRpcCall() method, which will store (key, value) pair in the DHT. When a successful response is received (key, value) pair is added to the GlobalDhtTestMap.
- Get messages – Pick a random key from the GlobalDhtTestMap and then issue a DHT get(key) query to the DHT Tier1 application using DHTgetCAPICall() method. Tier1 application sends the appropriate value if it exists. If the key's validity has expired delete it from GlobalDhtTestMap otherwise consider get query as success.
- Modify messages – Pick a random key from the GlobalDhtTestMap and then issue a DHT put query to the Tier1 application. DHT entries are modified using a put message that will place an updated version of the (key, value) pair into DHT.