Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

CloudI Java Tutorial

Build Status

This repository contains the example source code for the tutorial at The source code provides local real-time recommendations for the electronic books available at Project Gutenberg.

While the source code is meant to show information related to Java development with the Java CloudI API, additional source code dependencies are used:

  • Apache Log4j to allow Apache Mahout to use the CloudI log file through stdout/stderr (which keeps all the service log output in the cloudi.log file)
  • Apache Commons DBCP for the Apache Mahout database connection pool
  • Apache Mahout for the recommendations in Java
  • Gson for JSON serialization in Java
  • Jcommander for command-line parsing in Java of CloudI service configuration arguments
  • PostgreSQL Driver for Java database usage along with PostgreSQL and Apache Mahout


Use maven and JDK 1.7 or 1.8 (Java 7 or 8) to build:

mvn clean package


Refer to the Java Tutorial for detailed steps.


Update an item's rating:

curl -X POST -d '{"message_name": "recommendation_update", "user_id": 1, "item_id": 1, "rating": 5.0}' http://localhost:8080/tutorial/java/service/recommendation/update

Get the current list of recommendations:

curl -X POST -d '{"message_name": "recommendation_list", "user_id": 1}' http://localhost:8080/tutorial/java/service/recommendation/list

Get the current list of items with the user's current ratings:

curl -X POST -d '{"message_name": "item_list", "user_id": 1, "language": "en", "subject": "Philosophy"}' http://localhost:8080/tutorial/java/service/item/list

Get the current list of languages that items are available in:

curl -X POST -d '{"message_name": "language_list"}' http://localhost:8080/tutorial/java/service/language/list

Get the current list of subjects that items are available in:

curl -X POST -d '{"message_name": "subject_list"}' http://localhost:8080/tutorial/java/service/subject/list

Refresh the list of items with the books available at

curl -X POST -d '{"message_name": "item_refresh"}' http://localhost:8080/tutorial/java/service/item/refresh

Update the recommendations model (public services often do this daily or weekly, but this can be done more frequently):

curl -X POST -d '{"message_name": "recommendation_refresh"}' http://localhost:8080/tutorial/java/service/recommendation/refresh