CRUD application template for Cassandra for Developers training.
This exercise is meant to practice usage of Datastax' Cassandra Driver for Java, especially it's mapper module. User is is meant to fill in all FixMe gaps with working code.
- installed and working Cassandra DB, cqlsh
- sbt
- curl
- Load schema from the
create-schema.cqlfile:cql -f create-schema.cql. It will create asongbrowserkeyspace with all necessary contents. - Optionally (but recommended), load sample data into the tables by using
cql -f insert-data.cql.
Next, run application as-is, without any changes in the source code:
Run sbt run inside cassandra-crud-rest directory.
Run sbt -Dhttp.port=XYZ run inside cassandra-crud-rest directory.
Run sbt test inside inside cassandra-crud-rest directory. Make sure you do not have any application listening on port 9000 (including other Cassandra instances).
Try querying following endpoints to see how the application behaves (remember to use appropriate port!). Word beginning with colon (:) should be substituted with a value. Use internet browser as a client:
http://localhost:9000/albums/:artist- returns all albums for a given artist,http://localhost:9000/albums/search/:title- returns all albums which title contains given phrase,http://localhost:9000/songs/:artist- returns all songs for a given artist,http://localhost:9000/songs/paginate/:artist- returns all songs for a given artist as a paginable list, 1st page only,http://localhost:9000/songs/paginate/:artist?page=N- returns all songs for a given artist as a paginable list, Nth page only,http://localhost:9000/songs/:release_year/:album_title- returns all songs from the given album (by title and release year).
http://localhost:9000/albumfor adding a new album (or updating existing one, remember INSERT / UPDATE operations in Cassandra),http://localhost:9000/songfor adding or updating a song.
- Ensure you know how the application works.
- Fill in
CassandraSupportclass to add missing Mappers. - Fill in
getXYZandsaveXYZmethods in all classes in DAO classes. - Take a look at sample tests suite (AlbumsDAOTest).
- Fill in gaps in
SongsByAlbumDAOTestandSongsByArtistDAOTest.
You can verify your results using the tests. For debugging consider using cqlsh or DevCenter tool.