The purpose of the following entry is to introduce the use of the Oracle Berkley DB via an exercise and describe how it works in combination with Restlet and Wicket.The Berkeley DB library is a building block that provides the complex data management features found in enterprise class databases. These facilities include high throughput, low-latency reads, non-blocking writes, high concurrency, data scalability, in-memory caching, ACID transactions, automatic and catastrophic recovery when the application, system or hardware fails, high availability and replication in an application configurable package. Simply configure the library and use the particular features available to satisfy your particular application needs. Berkeley DB is a reliable solution with over 15 years of production use in products ranging from cell phones to e-commerce. The primary goal of Berkeley DB is to deliver fast, scalable and flexible data management services to your application while remaining transparent to your end-user.Kata 1: Timestamp as secondary index (Completed: True, Time: ~ 1 hour)
Part I: Implementation
The example system we were introduced to by Professor Johnson provides a single key for retrieval of a Contact object. This "primary key" is the object's unique ID. For this Kata, we first implemented a "secondary key" alternative for Contact. The secondary key consists of a timestamp represented as a long value that can either be inputted directly, or generated dynamically.
Once the secondary index was implemented we had to 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.
I should have used the cursor function to iterate through the contacts currently stored in the database, but instead I used a naive for loop. This accomplishes the functionality by going through the range of timestamps specified by the user. This would be very bad, especially if there is significant differences between the times in which the timestamps are created.
For example:
If the user specifies 1 1000 for the range, but there are only 3 secondary keys between this range, the current method is inefficient. When I have time later, I would like to research more on the cursor function.
Part II: Testing
When one creates the timestamps for a contact dynamically upon creation, it can be problematic for JUnit testing. Creating two Contacts, one right after the other, can happen so fast that they will have the same time stamp. It is because of this that the implementor may wish to add the timestamp in just before it's entry into the database.
Kata 2: Wicket, REST, and BerkeleyDB: A match made in heaven (Completed: True, Time: ~ 6 hours)
For this example we created a client-server (i.e. web application) system for managing contacts. We provide a Wicket client front end using Restlet to communicate with BerkleyDB. The Wicket client consist of a single page, and allows the user to store a contact given its information. The functionality to retrieve a contact given its unique ID is also there. The Wicket client code essentially invokes an underlying Restlet-based module to send a request to a ContactDB server to put or get data.
This Kata was highly dependent on the fact that you already knew how to "get" and "put" contacts using Restlet's framework and were very comfortable dealing with Documents and DomRepresentations. I had to cut and paste a few methods from the previous Kata assignment to make everything work smoothly.
The use of sessions to store the data was a neat review and is important to have all transactions on the web application independent of each other no matter what user is on it.
It should be noted that I had to disable the checkstyle check in verify.build.xml as
Missing package-info.java fileis causing the verify to fail and I couldn't readily find a solution. I hope to figure this out for a later blog post.
Here is a link to my distribution



