Context Server Installation

From MobiComp

Jump to: navigation, search

The following instructions assume that the Context Server is to be installed on a linux or OS/X platform. The server and associated database can be installed under any user account but these instructions assume the existence of a user called mobicomp.

Contents

Obtain the source code

Checkout a copy of the ContextServer and main src trees (for further details, see MobiComp_Repository):

  svn checkout http://www.piranesi.dyndns.org/svn/MobiComp/ContextServer/trunk ContextServer
  svn checkout http://www.piranesi.dyndns.org/svn/MobiComp/src/trunk src

If not already installed on the server host, you will also need to download and install the PostgreSQL DBMS, the Apache web server and Tomcat servlet engine (we currently use v8.1.3, v2.2.3 and v5.0.28 respectively). The system will probably work with other servlet engines, but only the Apache/Tomcat combination has been tested. It may also be possible to use other DBMS, but only those with an effective rule/trigger mechanism that allows simple queries on a view to be replaced by a sequence of operations on another table, see the create rule statements in the file sql/context.sql.

Create the PostgreSQL context database

Login to the 'postgres' account and create the mobicomp user:

$ createuser mobicomp

Start psql and set a suitable password for the mobicomp user:

$ psql postgres
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

postgres=# alter user mobicomp with password 'asdfghjkl';

Now create the database:

$ createdb --owner=mobicomp mobicomp --password

(enter the mobicomp postgres password when prompted).

Then add the following line to the IPv4 section of /usr/local/pgsql/data/pg_hba.conf (assuming postgres is installed in the default location /usr/local/pgsql):

host    context     all         0.0.0.0/32            password  passwd

Now, logout from the postgres account and, as the mobicomp user, cd to the ContextServer/sql directory and use psql to import and run the context.sql and spatial.sql scripts to create the tables and populate the database:

$ psql context
Welcome to psql 8.1.3, the PostgreSQL interactive terminal.
...
context=# \i context.sql
...
context=# \i spatial.sql
...

Build the servlet

Edit ContextServer/web/WEB-INF/web.xml and change the postgres connection username and password to match those used above.

Run the following command in the ContextServer directory to build the context.war file to be used by tomcat:

$ ant dist

Configure Tomcat

Install tomcat according to the instructions provided. Then user the manager application to install the context.war application archive created above.

Configure Apache

Edit httpd.conf to enable apache to act as a proxy for the tomcat server, passing servlet requests to tomcat. There are several ways to get apache and tomcat working together, but this is the simplest. Locate the Proxy Server directives and modify as follows:

#
# Proxy Server directives. Uncomment the following lines to
# enable the proxy server:
#
<IfModule mod_proxy.c>
ProxyRequests Off

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>

ProxyPass /Context http://localhost:8080/Context
ProxyPassReverse /Context http://localhost:8080/Context

#
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
#
ProxyVia Off
#
# To enable a cache of proxied content, uncomment the following lines.
# See http://httpd.apache.org/docs/2.2/mod/mod_cache.html for more details.
#
#<IfModule mod_disk_cache.c>
#   CacheEnable disk /
#   CacheRoot "/var/cache/mod_proxy"
#</IfModule>
#

</IfModule>
# End of proxy directives.

Adding Trackers, Listeners and Aggregators

The server has been extended to allow tracker and listener components to be loaded at runtime.

The current distribution includes a prototype LocationListener (in fact, an aggregator). When loaded into the server, this component listens for location.point and location.gps ContextElements. On receiving a put event for either of these elements, it uses the getNearestLocation and getObjectURL methods of ContextServiceDB, which implements the SpatialStoreIF interface, to find a placename and/or a URL associated with the location.

If the location corresponds to a named place in the database, getNearestLocation returns the placename and a location.placename element is put into the store. If the location has an associated URL, getObjectURL returns the URL. This is used to create a beacon element which is then put into the store.

TODO: Document the database setup behind the LocationListener.