-
Notifications
You must be signed in to change notification settings - Fork 0
Home
jimklo edited this page Feb 14, 2012
·
8 revisions
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.
- Java 1.6
- Maven
- clone the GitHub repository
git clone git://github.com/jimklo/Barista.git- build and package the jars
cd Barista
mvn package- 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- Restart CouchDB
curl -H "Content-Type: application/json" -X POST 'http://localhost:5984/_restart'- 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.
- Package views into jar file(s).
cd ./views
mvn package- 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- 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\\\"}\"}}}"- Access the view to build.
curl -X GET 'http://localhost:5984/java/_design/java/_view/simple'