UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.db
Class OskiDB

java.lang.Object
  |
  +--edu.berkeley.guir.lib.db.OskiDB

public class OskiDB
extends Object

Think of this as Cheap-and-Quick-and-Unreliable-DB [tm], no guarantees anywhere. It implements a generic serializable hashtable that things can be stored in. It serves as part of a generic Remote Data Server that ensures that objects retrieved become eventually consistent and written to persistent storage.

Be sure to call updateDB(Object key) whenever a change to an Object in this database is made. Otherwise, there is no way for the system to know that things have been changed.

For example, in the picture below, the Impl is a Remote Data Server. It is essentially a wrapper around the Data that tells the Database (this class) that changes have been made to the Data and that these changes should be sent to persistent storage eventually.

   Tier 1                Tier 2                         Tier 3
   ------    ----------------------------------     --------------

                                                     Data
                                                     ----
    ----                                  ----       |  |
    |  |                                  |  | ----- |  |
    |  |      ----                        |  |       ----
    |  | ---- |  | ---------------------- |  |      
    |  |      |  |          RMI           |  |       ------------
    |  |      ----                        |  | ----- |          |
    |  |                                  |  |       | DATABASE |
    ----                                  ----       |          |
  Interface   Stub                        Impl       |          |
   (Remote)                            (RemoteObj)   ------------

  ------------------                     ------------------------
       CLIENT                                     SERVER
 

This software is distributed under the Berkeley Software License.

 Revisions:  - GUIRLib-v1.0-1.0.0, Dec 05 1998, JH / CBM
               Created class
             - GUIRLib-v1.2-1.0.0, Jun 22 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.3-1.0.0, Aug 11 2000, JH
               Touched for GUIRLib release
             - GUIRLib-v1.4-1.0.0, Aug 31 2000, JH
               Touched for GUIRLib release
 

Since:
JDK 1.2
Version:
GUIRLib-v1.4-1.0.0, Aug 31 2000
Author:
Brad Morrey ( cbmorrey@cs.berkeley.edu ), Jason Hong ( jasonh@cs.berkeley.edu )

Field Summary
static int DEFAULT_FLUSHTIME
          Default to 30 seconds between writes.
static String EXTENSION
          Extension for serialized files.
static String ROOT
          Root name for serialized files.
 
Constructor Summary
OskiDB(String nme)
          Create a new database.
OskiDB(String nme, int newSleepTime)
          Create a new database with the specified sleeptime.
OskiDB(String nme, String tableName, String path)
          Create a database, unserializing one if it exists.
OskiDB(String nme, String tableName, String path, int newFlushTime)
          Create a database, unserializing one if it exists.
 
Method Summary
 boolean containsKey(Object key)
          See if the specified key lies within the database.
 void finalize()
           
 void flushData()
          Flush the data out when called.
 Object get(Object key)
          Get something from the database.
 boolean isDirty()
          Is the data this data server holding dirty (and should be written out)?
static void main(String[] argv)
           
 void put(Object key, Serializable value)
          Put something into the database.
 void setFlushTime(int newFlushTime)
           
 String toString()
          Print out the contents of the database.
 void updateDB()
          Signal that there all objects that have changed and should be written to persistent storage.
 void updateDB(Object key)
          Signal that a specific object is dirty and should be written to persistent storage.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FLUSHTIME

public static final int DEFAULT_FLUSHTIME
Default to 30 seconds between writes.

ROOT

public static final String ROOT
Root name for serialized files.

EXTENSION

public static final String EXTENSION
Extension for serialized files.
Constructor Detail

OskiDB

public OskiDB(String nme,
              String tableName,
              String path)
Create a database, unserializing one if it exists.
Parameters:
nme - is the name of the database.
tableName - is the name of the database to unserialize.
path - is where the files are.

OskiDB

public OskiDB(String nme,
              String tableName,
              String path,
              int newFlushTime)
Create a database, unserializing one if it exists.
Parameters:
nme - is the name of the database.
tableName - is the name of the database to unserialize.
path - is where the files are.
newFlushTime - is how often to flush to disk.

OskiDB

public OskiDB(String nme)
Create a new database.
Parameters:
nme - is the name of the database.

OskiDB

public OskiDB(String nme,
              int newSleepTime)
Create a new database with the specified sleeptime.
Parameters:
nme - is the name of the database.
newSleepTime - is the number of seconds to wait for writes.
Method Detail

finalize

public void finalize()
Overrides:
finalize in class Object

setFlushTime

public void setFlushTime(int newFlushTime)

flushData

public final void flushData()
Flush the data out when called.

isDirty

public final boolean isDirty()
Is the data this data server holding dirty (and should be written out)?

updateDB

public final void updateDB()
Signal that there all objects that have changed and should be written to persistent storage.

updateDB

public final void updateDB(Object key)
Signal that a specific object is dirty and should be written to persistent storage.

get

public Object get(Object key)
Get something from the database.
Parameters:
object - referred to by the key, or null if it does not exist.

put

public void put(Object key,
                Serializable value)
Put something into the database. Automatically marks the value as dirty.

containsKey

public boolean containsKey(Object key)
See if the specified key lies within the database.

toString

public String toString()
Print out the contents of the database.
Overrides:
toString in class Object

main

public static void main(String[] argv)
                 throws Exception

Copyright Information