edu.cmu.aura.service.db
Class Database

java.lang.Object
  |
  +--edu.cmu.aura.service.db.Database
All Implemented Interfaces:
DataSink, PrimitiveService, java.rmi.Remote

public class Database
extends java.lang.Object
implements PrimitiveService, DataSink

Database provides a simple Database oriented implementation of PrimitiveService. It is currently designed for functionality over performance and scalability.


Field Summary
 
Fields inherited from interface edu.cmu.aura.service.PrimitiveService
ALL_ATTRIBS, ANY_CHANGE, DEFAULT_EXEC_INTERVAL, DEFAULT_SERVICE, DEFAULT_SERVICE_NAME, NO_REQS, NO_TIME_LIMIT, RELATION_ATTRIB, SELECT_ALL
 
Constructor Summary
Database(java.lang.String name)
          Create a new Database.
 
Method Summary
 void addTable(edu.cmu.aura.service.db.Table table)
          Add a table to this Database.
 void delete(java.lang.String serviceName, java.util.ArrayList keyVal)
          Delete an entry from the service database.
 void display()
          Display the entire Database.
 java.lang.String getName()
          Get the name of this Database.
 int getPort()
          Get the port on which this database is accepting incoming requests.
 edu.cmu.aura.service.db.Table getTableByName(java.lang.String name)
          Get a specified table.
 void insert(java.lang.String serviceName, java.util.ArrayList attribs)
          Insert an entry into the service database.
 int postCondTrigger(java.util.ArrayList sAttribs, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, ExpressionNode triggerExpression, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Post a trigger that is to execute when a particular condition is met.
 int postModTrigger(java.util.ArrayList sAttribs, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, java.util.ArrayList triggerAttribs, java.util.ArrayList triggerDeltas, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount.
 int postQuery(java.util.ArrayList selectedAttribs, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit, long execInterval, edu.cmu.aura.service.rpc.RemoteReference queryClient)
          Query a service recurrently.
 QueryResult query(java.util.ArrayList selectedAttributes, java.util.ArrayList serviceNames, ExpressionNode expression, java.util.ArrayList attribReqs, long timeLimit)
          Execute a query against this Database.
 void removeQuery(java.lang.String serviceName, int queryID)
          Remove a recurrent query.
 void removeTrigger(java.lang.String serviceName, int queryID)
          Remove a trigger.
 void start()
          Should be called before the database is accessed.
 void update(java.lang.String serviceName, java.util.ArrayList keyVal, java.util.ArrayList attribs)
          Update an entry's attributes in the service database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database(java.lang.String name)
Create a new Database.

Parameters:
name - the name of this Database.
Method Detail

start

public void start()
Should be called before the database is accessed. Currently this method starts all database updaters.


getName

public java.lang.String getName()
Get the name of this Database.

Returns:
the name of this Database.

getPort

public int getPort()
Get the port on which this database is accepting incoming requests.

Returns:
the port on which this database is accepting incoming requests.

addTable

public void addTable(edu.cmu.aura.service.db.Table table)
Add a table to this Database.


getTableByName

public edu.cmu.aura.service.db.Table getTableByName(java.lang.String name)
Get a specified table.

Parameters:
name - the name of the table to get.
Returns:
the specified table.

display

public void display()
Display the entire Database. This is primarily for debugging.


query

public QueryResult query(java.util.ArrayList selectedAttributes,
                         java.util.ArrayList serviceNames,
                         ExpressionNode expression,
                         java.util.ArrayList attribReqs,
                         long timeLimit)
                  throws ServiceException
Execute a query against this Database.

Specified by:
query in interface PrimitiveService
Parameters:
serviceNames - names of services to retrieve attributes from.
expression - expression selecting which entities or relations in the service should be returned.
attribReqs - requirements on dynamic attributes.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results.
selectedAttributes - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
Returns:
the QueryResult of the query.
ServiceException

postQuery

public int postQuery(java.util.ArrayList selectedAttribs,
                     java.util.ArrayList serviceNames,
                     ExpressionNode expression,
                     java.util.ArrayList attribReqs,
                     long timeLimit,
                     long execInterval,
                     edu.cmu.aura.service.rpc.RemoteReference queryClient)
              throws java.rmi.RemoteException,
                     ServiceException
Query a service recurrently.

Specified by:
postQuery in interface PrimitiveService
Parameters:
selectedAttribs - the attribs to select.
serviceNames - names of services to retrieve attributes from.
expression - expression selecting which entities or relations in the service should be returned.
attribReqs - requirements on dynamic attributes.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results.
execInterval - interval at which to execute the query.
queryClient - the client that should be informed when this query executes.
Returns:
the QueryResult of the query.
java.rmi.RemoteException
ServiceException

postCondTrigger

public int postCondTrigger(java.util.ArrayList sAttribs,
                           java.util.ArrayList serviceNames,
                           ExpressionNode expression,
                           java.util.ArrayList attribReqs,
                           long timeLimit,
                           long execInterval,
                           ExpressionNode triggerExpression,
                           edu.cmu.aura.service.rpc.RemoteReference queryClient)
                    throws java.rmi.RemoteException,
                           ServiceException
Description copied from interface: PrimitiveService
Post a trigger that is to execute when a particular condition is met. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Specified by:
postCondTrigger in interface PrimitiveService
Parameters:
sAttribs - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
serviceNames - names of services to retrieve attributes from. DEFAULT_SERVICE may be used if there is only one service listening on a given port.
expression - expression selecting which entities or relations in the service should be returned. SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. NO_TIME_LIMIT indicates that the client has no hard limit on how long the processing should take; though a client will likely still desire reasonably fast execution.
execInterval - interval at which to check the trigger.
triggerExpression - condition indicating when to fire the trigger.
queryClient - the client that should be informed when this trigger executes.
Returns:
the id of the posted trigger.
java.rmi.RemoteException
ServiceException

postModTrigger

public int postModTrigger(java.util.ArrayList sAttribs,
                          java.util.ArrayList serviceNames,
                          ExpressionNode expression,
                          java.util.ArrayList attribReqs,
                          long timeLimit,
                          long execInterval,
                          java.util.ArrayList triggerAttribs,
                          java.util.ArrayList triggerDeltas,
                          edu.cmu.aura.service.rpc.RemoteReference queryClient)
                   throws java.rmi.RemoteException,
                          ServiceException
Description copied from interface: PrimitiveService
Post a trigger that is to execute when any one of a given set of attributes changes by a specified amount. Note that a trigger may be regarded as a posted query that executes at a particular interval. A client may request that a service check constantly by specifying an execInterval of DEFAULT_EXEC_INTERVAL, but a service is free to decide what interval to check at if it has no easy mechanism for checking constantly.

Specified by:
postModTrigger in interface PrimitiveService
Parameters:
sAttribs - attribsutes to select. ALL_ATTRIBS indicates that all attributes are to be selected.
serviceNames - names of services to retrieve attributes from. DEFAULT_SERVICE may be used if there is only one service listening on a given port.
expression - expression selecting which entities or relations in the service should be returned. SELECT_ALL indicates all entities are to be selected.
attribReqs - requirements on dynamic attributes. NO_REQS indicates there are no requirements in effect.
timeLimit - this is used by clients to inform the service on when they need the results by. This may also be viewed as a suggestion on how hard to work to retrieve the results. NO_TIME_LIMIT indicates that the client has no hard limit on how long the processing should take; though a client will likely still desire reasonably fast execution.
execInterval - interval at which to check the trigger.
triggerAttribs - attributes to watch for changes.
triggerDeltas - amount of change that will cause the trigger to fire for the corresponding attribute.
queryClient - the client that should be informed when this trigger executes.
Returns:
the id of the posted trigger.
java.rmi.RemoteException
ServiceException

removeTrigger

public void removeTrigger(java.lang.String serviceName,
                          int queryID)
                   throws java.rmi.RemoteException,
                          ServiceException
Description copied from interface: PrimitiveService
Remove a trigger.

Specified by:
removeTrigger in interface PrimitiveService
Parameters:
serviceName - name of the service to remove the query from.
queryID - the ID of the query to remove.
java.rmi.RemoteException
ServiceException

removeQuery

public void removeQuery(java.lang.String serviceName,
                        int queryID)
                 throws ServiceException,
                        java.rmi.RemoteException
Remove a recurrent query.

Specified by:
removeQuery in interface PrimitiveService
Parameters:
serviceName - name of the service to remove the query from.
queryID - the ID of the query to remove.
ServiceException
java.rmi.RemoteException

update

public void update(java.lang.String serviceName,
                   java.util.ArrayList keyVal,
                   java.util.ArrayList attribs)
            throws ServiceException,
                   java.rmi.RemoteException
Description copied from interface: DataSink
Update an entry's attributes in the service database. A new entry will be created if one matching the keyVal is not found.

Specified by:
update in interface DataSink
Parameters:
serviceName - name of the service to update
keyVal - key value of the entry to update
attribs - updated attributes
ServiceException
java.rmi.RemoteException

insert

public void insert(java.lang.String serviceName,
                   java.util.ArrayList attribs)
            throws ServiceException
Description copied from interface: DataSink
Insert an entry into the service database. An error will occur if the entry already exists. When no entry exists, this function has the same effect as calling update, but requires one less argument.

Specified by:
insert in interface DataSink
Parameters:
serviceName - name of the service to insert into
attribs - updated attributes
ServiceException

delete

public void delete(java.lang.String serviceName,
                   java.util.ArrayList keyVal)
            throws ServiceException
Description copied from interface: DataSink
Delete an entry from the service database.

Specified by:
delete in interface DataSink
Parameters:
serviceName - name of the service to delete from
keyVal - key value of entry to delete
ServiceException