Example of integrated development of spring boot, spark and Cassandra systems
This article demonstrates an example of using spark as the analysis engine, Cassandra as the data store, and spring boot to develop the driver.
1. Preconditions
Create a keyspace
Create table
Insert test data
2. Spark Cassandra connector installation
Let spark-1.5 1. Cassandra can be used as data storage, and the following jar package dependencies need to be added (for example, place the package in / opt / spark / managed lib / directory, which can be arbitrary):
In the / opt / spark / conf directory, create a new spark env SH file, enter the following
3. Spring boot application development
Add spark Cassandra connector and spark dependencies
In application Configuring spark and Cassandra paths in YML
Special note here spark://master:7077 It is in the form of domain name rather than IP address. You can modify the local hosts file to map the master to the IP address.
Configure sparkcontext and cassandrasqlcontext
Simple call
After startup, it can be executed as a normal spring boot program.
Source address: https://github.com/wiselyman/spring-spark-cassandra.git