The Caboteria / Tech Web / TechNotes > ProgrammingNotes > JavaNotes / PrevaylerNotes (19 Jul 2006, TobyCabot)
Prevayler http://www.prevayler.org/ is an interesting tool that allows you to manage a tree of Java objects persistently. It's basically a combination of Java serialization and the Command pattern. All changes to the "database" must be in the form of Command objects that can be serialized and then called to perform their changes.

Prevayler is controversial because of their hype-filled site, and their claims about how much faster they are than a relational database. In the end, it turns out that prevayler is designed for working with small datasets that can fit in memory. It's not as scalable as a relational database, nor is it as "open" since people can't hook up to it and send arbitrary SQL commands. It's nice solution for cases where an RDBMS is overkill for working with a small data set.

Prevayler's javadoc blows. Why don't open source hackers document their code?

Startup

Prevayler (see PrevaylerImpl constructor) first tries to recover the dataset from a snapshot (see the snapshot manager) and then recovers transactions from the journal. It does this by adding itself (an inner class) as a subscriber to the publisher. The publisher calls the journal which reads and replays any transactions that are in the journal since the checkpoint.

Transaction

Single-node case

Snapshots

You need to manually tell prevayler to snapshot itself by calling Prevayler.takeSnapshot().

Critical Regions

Lots of them.

The process of "subscribing" a TransactionListener brings it up to date with the transaction journal. During that time transactions are blocked and vice versa (see CentralPublisher.publish()).

Transactions are applied to the database one at a time (see PrevaylerImpl.subscriber().receive()).

Misc

http://java.sun.com/developer/technicalArticles/ALT/serialization/ - since Prevayler rests on Java serialization it's a good idea to learn as much as you can about it.

Edit | Attach | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback