Example of Spring Boot Data Rest app showing JSON usage from JUG meetup on 22nd Apr 2015
Instructions to follow during the DEMO:
Singlenode:
- Start xd-singlenode and xd-shell
- Show xd-shell ‘help' and ‘module list’ and ’stream list’
- stream create --name timeToLog --definition "time | log"
- stream list
- stream deploy --name timeToLog
- Show logs of container and XD UI
- stream undeploy --name timeToLog
- Show logs of container and XD UI
- stream create --name httpToFile --definition "http | file —dir=/data/xd" —deploy http post --target http://localhost:9000 --data "Hello JUGЭ http post --target http://localhost:9000 --data "Hello from XD stream"
- Show files created
Distributed:
- Start Zookeper (./zkServer.sh start)
- Start ./hsqldb-server
- Start ./xd-admin
- Start ./xd-container
- Start ./xd-container
- Show XD UI with all streams came from Zookeeper
- Show Zookeeper data: ./zkCli.sh ls /xd ls /xd/modules/source ls /xd/streams ls /xd/deployments/streams
- Deploy timeToLog stream and show Redis exceptions
- Start Redis distributed with Spring XD (./redis-server) stream deploy timeToLog
- Show modules deployed to diff containers
- Stop one module and show recovery
Taps:
- Show counter usage as tap: stream create --name timeToLogTap --definition "tap:stream:timeToLog > counter --name=simpleCounter" —deploy stream deploy timeToLog counter list counter display simpleCounter
- Show XD UI and zookeeper (ls /xd/taps)
Hadoop integration:
- Start HDFS (sbin/start-dfs.sh)
- Show Hadoop UI (http://localhost:50070/dfshealth.html)
- Show HDFS content: ./hdfs dfs -ls /xd
- Show HDFS console from XD shell hadoop config fs --namenode hdfs://localhost:8020 hadoop fs ls /xd
- Deploy twitterSearchToHDFS stream: create stream --name twitterToHdfs —definition "twittersearch --query='java' | hdfs --partitionPath=payload.lang --rollover=1M --idleTimeout=10000" stream deploy twitterToHdfs hadoop fs ls /xd stream undeploy twitterToHdfs hadoop fs rm -r /xd/twitterToHdfs
Final example (works only on xd-singlenode because of some BUG with headers population in distributed mode, however anyway required header-enricher custom module to be installed):
- module delete processor:tweet-transformer
- module upload --file /Users/oleg/dev/Projects/JavaDayKiev2015/SpringXDCustomTweetsTransformer/target/tweets-transformer-1.0-SNAPSHOT.jar --name tweet-transformer --type processor
- stream create --name tweetsIngestion --definition "twittersearch --query=java --outputType=application/json | filter --expression=#jsonPath(payload,'$.lang').equals('en') | header-enricher --headers='{"Content-Type":"''application/json;charset=UTF-8''"}' | http-client --url='''http://localhost:8080/tweets''' --httpMethod=POST | null"
- stream create --name debugForTweetsIngestion --definition "tap:stream:tweetsIngestion > tweet-transformer --extractField=id | log" --deploy
- stream create --name tweetsIngestionCount --definition "tap:stream:tweetsIngestion > field-value-counter --fieldName=lang --name=countByLanguage" --deploy
- stream create --name tweetsToHdfs --definition "tap:stream:tweetsIngestion > hdfs --partitionPath=payload.lang --rollover=1M --idleTimeout=10000" --deploy
- stream deploy tweetsIngestion