RegisterSign In

API Documentation: Class SimpleDatabase

Package: com.mckoi.sdb
implements com.mckoi.network.ConsensusProcessor

An implementation of a ConsensusProcessor for the Simple Database data model. This class manages a simple database which implements a directory of file and table objects.

Simple Database provides concurrency control models for the file and table objects it supports. Files may not be concurrently modified (a concurrent modification to a file will generate an exception and rollback at commit time). Tables may be concurrently modified provided the change does not clash (for example, multiple transactions commit a row delete on the same row).

The concurrency control for the meta structures (the file and table name directory) will causes a commit fault if concurrent transactions try to create or delete an object with the same name.

This data model does not implement features you'd expect from a full file system such as file meta-data (file creation time, access lists for security, etc). There is no notion of a directory tree with sub-directories, however file names can be of any length so an ad-hoc directory hierarchy can be created by the name string.

Constructors Summary

SimpleDatabase()

Methods Summary

String getName()
String getDescription()
String getStats(ConsensusDDBConnection connection, DataAddress snapshot)
void initialize(ConsensusDDBConnection connection)
DataAddress commit(ConsensusDDBConnection connection, DataAddress proposal) throws CommitFaultException

Constructor Details

SimpleDatabase()

Method Details

String getName()

The name of this processor, displayed in the adminsitration user interface.

String getDescription()

A description of this processor appropriate for display in the help section of the user interface.

String getStats(ConsensusDDBConnection connection, DataAddress snapshot)

Returns the size and number of files stored in the most recent snapshot.

void initialize(ConsensusDDBConnection connection)

This function creates an initial data model state on a completely blank database. This is only ever called once during the lifespan of a particular state, and the given connection will always be a blank untouched database.

This function is intended to setup the state of a database to a beginning state.

DataAddress commit(ConsensusDDBConnection connection, DataAddress proposal)

Attempts to commit a proposed change and create an updated database state. The given ConsensusDDBConnection object provides access to the latest version of the database as well as historical information about previous states. The proposal is represented as a DataAddress object which is the root node of a data tree that will contain the details of the changes proposed.

If a proposed commit is rejected, this function throws a CommitFaultException and no change is made. If the proposal is accepted, the returned DataAddress is the new root node of this path instance.

Note that this method should be efficiently implemented because it is not possible to perform this function on a single path instance in multiple processes. The reason for this is because the current database state must be deterministic.

The text on this page is licensed under the Creative Commons Attribution 3.0 License. Java is a registered trademark of Oracle and/or its affiliates.
Mckoi is Copyright © 2000 - 2020 Diehl and Associates, Inc. All rights reserved.