Modules‎ > ‎

Persistency

Student Learning Objectives

The learning objectives for this module include:
  • To understand the basic paradigms for persistency (serialization, RDBMS, non-RDBMS, etc.) and their trade-offs (object-relational mismatch, etc.)
  • To gain facility with the BerkeleyDB persistency framework for fast, thread-safe storage and retrieval of Java objects. 
  • To put it all together with your prior work on REST and web application design to produce a simple but fully functional distributed system. 

Resources

Readings

Helpful introductory readings about persistency and BerkeleyDB include:

Software

Screencast


Slides

Experiential Learning

Assignment A06: BerkeleyDB code katas

Code katas are exercises in programming that help you to refine your skills.  This assignment will help you achieve the student learning objectives by actively working with an example system using BerkeleyDB: the berkeleydb-contactdb.  

To start, download the .zip distribution of berkeleydb-contactdb to your local system.  Edit the build.xml file so that the project name is no longer berkeleydb-contactdb, but rather berkeleydb-contactdb-<username>, where <username> is your uhunix account name.  Run "ant -f verify.build.xml" on your local copy of the system to make sure that it compiles and passes all quality assurance tests.  Next, bring up Eclipse, import the project, then select the project name and use the "refactor" menu item to change the Eclipse project name from berkeleydb-contactdb to berkeleydb-contactdb-<username>.

Now modify your local copy in the following ways.  I am guesstimating that it will require 6 hours of work to complete these Katas.  After publishing your blog entries, we will find out the accuracy of this prediction!

Kata 1: Timestamp as secondary index

The example system provides a single key for retrieval of a Contact: it's unique ID. For this Kata, you will first implement a secondary key for Contacts that consists of a timestamp represented as a long value. For example, (new Date()).getValue() returns the current time as a long value.  This timestamp could mean a variety of things in practice, such as the time the contact was created, or the contact's birthday, etc., but we won't worry about that for now. 

Write unit tests to make sure that your secondary index works correctly, and that in particular you can retrieve a set of Contacts whose timestamps fall within a specified range.  

Once you have implemented the secondary index, extend the ContactClient system with two new commands:
  • get-timestamp: returns the Contact with the given timestamp, if such a Contact exists.
  • get-range: returns the set of Contacts with timestamps between two specified values. 
Note that all of the sensor data in the Solar Decathlon system will have timestamps associated with them, and a frequent operation on the database will be to retrieve the sensor data instances during a given time period, so this kata will help you understand how to do that. 

Kata 2: Wicket, REST, and BerkeleyDB: A match made in heaven

This is the Kata you've all been waiting for!   Create a client-server system for managing contacts that:
  1. Provides a Wicket client.  The wicket client should consist of a single page, and allow the user to store a contact given its info, and retrieve a contact given its unique ID. The Wicket client code should invoke an underlying Restlet-based module to send a request to a ContactDB server to put or get data.
  2. Provides a Restlet and BerkeleyDB server.  The server should accept and process requests using Restlet, and use BerkeleyDB to persist the Contacts.
After you have finished this Kata, you will have achieved familiarity with examples of the three fundamental technologies for building distributed, web-based services:  user interface (Wicket), communication (Restlet), and persistent storage (BerkeleyDB). Congratulations!

Submission instructions

By noon on the date indicated on the schedule page, publish a technical article using your blog in which you describe your introduction to BerkeleyDB and your experience with each of these Katas.  Your technical article should follow the guidelines in the Professional Persona module.

You must take special care to not let this technical article devolve into a "homework submission report".  Think about how to present the information in such a way that it is of general interest.

For each Kata, describe what you did, indicate whether or not you finished it, how long it took you to do it, and what issues you ran into while doing it.  

Provide a link to a distribution zip file for your local copy (using "ant -f dist.build.xml") so that it can be downloaded and reviewed. If you have followed the instructions correctly, your zip file will be created with a name that includes your UH account name. (Do not simply rename the file to include your UH account name--go back and re-read the instructions so that the project itself, not only the file name, is changed.)

Comments