Skip to content
jimklo edited this page Feb 14, 2012 · 8 revisions

Barista

Barista is a Java View Server for CouchDB. Below you will find a quick overview on how to get started. Go to here for more detailed information on designing and installing Java Views.

Prerequisites

  • Java 1.6
  • Maven

Basic Configuration

View Server Installation

  1. clone the GitHub repository
git clone git://github.com/jimklo/Barista.git
  1. build and package the jars
cd Barista
mvn package
  1. Configure CouchDB local.ini
[couchdb]
; Default setting is 5 secs, increase if your specific Map Reduce implementation requires more than 5 seconds to respond
os_process_timeout = 10000 
[query_servers]
; add 'java' as a supported language for Map and Reduce.
java=/usr/bin/java -cp /path/to/barista/viewserver/target/viewserver-jar-with-dependencies.jar com.sri.learningregistry.couchdb.viewserver.ViewServer
  1. Restart CouchDB
curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/_restart'

View Installation

  1. Views should implement com.sri.learningregistry.couchdb.viewserver.interfaces.MapDoc for map function implementation and com.sri.learningregistry.couchdb.viewserver.interfaces.Reduce for reduce function implementation. Sample views are included in the ./views project.
  2. Package views into jar file(s).
cd ./views
mvn package
  1. Add insert all jars as an attachment to single document, be sure to note the revision number of the last jar file.
curl -s -H "Content-Type: application/octect-stream" -X PUT 'http://localhost:5984/java/classpath/views.jar' --data-binary @views/target/views-0.0.1-SNAPSHOT-jar-with-dependencies.jar
  1. Add a design document that defines the view.
curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/java' -d "{\"_id\":\"_design/java\",\"language\":\"java\",\"views\":{\"xmlvalidate\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.XMLSchemaValidationView\\\"}\"},\"simple\":{\"map\":\"{\\\"classpath\\\":[\\\"http://127.0.0.1:5984/java/classpath/views.jar\\\"],\\\"rev\\\":\\\"${REV_NEW_JAR}\\\",\\\"classname\\\":\\\"com.sri.learningregistry.couchdb.views.SampleView\\\"}\"}}}"
  1. Access the view to build.
curl -X GET 'http://localhost:5984/java/_design/java/_view/simple'
Clone this wiki locally