CFEngine API

org.recommender.server
Class DBList

java.lang.Object
  |
  +--org.recommender.server.DBList

public class DBList
extends java.lang.Object

Implements a queue of ratings to be written to the database. 1 Accessor method to modify the queue (add ratings) shall be called by client threads, 2 Accessor method to get the content of the queue shall be called by DBManager thread, Thread safe property is guaranted by using Object monitors to provide synchronization.

Author:
Olivier Godde

Constructor Summary
DBList()
           
 
Method Summary
static void flush()
          Flushes the list of queries, forcing execution of all the pending database requests.
static java.lang.String getItemFieldName()
          Accessor, return itemFieldName.
static java.util.LinkedList getQueries()
          Accessor function, to be called by DBManager Thread.
static java.lang.String getRatingFieldName()
          Accessor, return ratingFieldName.
static java.lang.String getRatingTableName()
          Accessor, return ratingTableName.
static java.lang.String getUserFieldName()
          Accessor, return userFieldName.
static void init(java.lang.String ratingTable, java.lang.String userField, java.lang.String itemField, java.lang.String ratingField)
          Initialize the table this DBList will contact with.
static void insertOrReplaceRating(ItemRating rating)
          Insert clients' ratings into the table.
static void removeRating(int userID, int itemID)
          Remove clients' ratings from the table.
static void updateRating(ItemRating rating)
          Update clients' ratings in the table.
static void wakeUpFlushingThread()
          Wakes up a Thread that executed a "flush" operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBList

public DBList()
Method Detail

init

public static void init(java.lang.String ratingTable,
                        java.lang.String userField,
                        java.lang.String itemField,
                        java.lang.String ratingField)
Initialize the table this DBList will contact with. Called by DBManager thread.

Parameters:
ratingTable -
userField -
itemField -
ratingField -

insertOrReplaceRating

public static void insertOrReplaceRating(ItemRating rating)
Insert clients' ratings into the table. Synchronize so that two clients do not access the list at the same time. When the size of the list increases to 50, notify the waiting DBManager thread to add rating into database.


removeRating

public static void removeRating(int userID,
                                int itemID)
Remove clients' ratings from the table. Synchronize so that two clients do not access the list at the same time.


updateRating

public static void updateRating(ItemRating rating)
Update clients' ratings in the table. Synchronize so that two clients do not access the list at the same time.


flush

public static void flush()
Flushes the list of queries, forcing execution of all the pending database requests.


wakeUpFlushingThread

public static void wakeUpFlushingThread()
Wakes up a Thread that executed a "flush" operation.


getQueries

public static java.util.LinkedList getQueries()
Accessor function, to be called by DBManager Thread. The Thread enters the monitor for the DBList and calls wait whenever there is less than 50 ratings waiting and it's been less than 30 seconds since the last time it ran. Otherwise, it enters the monitor again to get a copy of the List and returns this copy.

Returns:
returnList

getRatingTableName

public static java.lang.String getRatingTableName()
Accessor, return ratingTableName.

Returns:
ratingTableName

getUserFieldName

public static java.lang.String getUserFieldName()
Accessor, return userFieldName.

Returns:
userFiledName

getItemFieldName

public static java.lang.String getItemFieldName()
Accessor, return itemFieldName.

Returns:
itemFieldName

getRatingFieldName

public static java.lang.String getRatingFieldName()
Accessor, return ratingFieldName.

Returns:
ratingFieldName

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu