Skip to content

Commit 6fce851

Browse files
committed
Merge branch 'develop' of https://github.com/WebFuzzing/Dataset into develop
2 parents c8ad065 + 28061fb commit 6fce851

110 files changed

Lines changed: 4445 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ scripts/dockerize/dockerfiles
329329
/jdk_25_maven/cs/rest/jasper/target/
330330
/jdk_25_maven/em/external/rest/jasper/target/
331331
/jdk_25_maven/em/embedded/rest/jasper/target/
332+
/jdk_21_maven/cs/rest/redis-sample/target/
333+
/jdk_21_maven/em/external/rest/redis-sample/target/
334+
/jdk_21_maven/em/embedded/rest/redis-sample/target/
332335
/jdk_11_maven/em/embedded/rest/tracking-system/target/
333336
/jdk_11_maven/em/external/rest/tracking-system/target/
334337
/jdk_17_maven/em/embedded/rest/tiltaksgjennomforing/target/

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ How to setup authentication information, based on the current content of the ini
8585
Auth configuration files can found in the [auth](auth) folder.
8686

8787

88-
### REST: Java/Kotlin (38)
88+
### REST: Java/Kotlin (39)
8989

9090
* **Bibliothek** (MIT), [jdk_17_gradle/cs/rest/bibliothek](jdk_17_gradle/cs/rest/bibliothek), from [https://github.com/PaperMC/bibliothek](https://github.com/PaperMC/bibliothek)
9191

@@ -135,6 +135,8 @@ Auth configuration files can found in the [auth](auth) folder.
135135

136136
* **Quartz Manager** (Apache), [jdk_11_maven/cs/rest-gui/quartz-manager](jdk_11_maven/cs/rest-gui/quartz-manager), from [https://github.com/fabioformosa/quartz-manager](https://github.com/fabioformosa/quartz-manager)
137137

138+
* **Redis Sample** (not-known license), [jdk_21_maven/cs/rest/redis-sample](jdk_21_maven/cs/rest/redis-sample), from [https://github.com/hendisantika/spring-boot-redis-sample](https://github.com/hendisantika/spring-boot-redis-sample)
139+
138140
* **Reservations API** (not-known license), [jdk_11_gradle/cs/rest/reservations-api](jdk_11_gradle/cs/rest/reservations-api), from [https://github.com/cyrilgavala/reservations-api](https://github.com/cyrilgavala/reservations-api)
139141

140142
* **Restcountries** (MPL), [jdk_8_maven/cs/rest/original/restcountries](jdk_8_maven/cs/rest/original/restcountries), from [https://github.com/apilayer/restcountries](https://github.com/apilayer/restcountries)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:21-alpine-jdk
2+
3+
COPY ./dist/redis-sample-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/redis-sample__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-jar redis-sample-sut.jar \
17+
--server.port=8080 --spring.data.redis.host=db --spring.data.redis.port=6379 --spring.data.redis.password=53cret --spring.autoconfigure.exclude=org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfiguration --app.numberOfRatings=5000 --app.ratingStars=5

dockerfiles/redis-sample.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
services:
2+
mitmproxy:
3+
image: mitmproxy/mitmproxy:10.2.4
4+
user: "0:0"
5+
environment:
6+
MITM_LOG_DIR: /custom-logs
7+
MITM_LOG_FILE: ${MITM_LOG_FILE:-minlog.csv}
8+
command: >
9+
mitmdump
10+
--mode reverse:http://sut-redis-sample:8080
11+
--listen-host 0.0.0.0
12+
--listen-port 8080
13+
--set keep_host_header=true
14+
-s /addons/minlog.py
15+
volumes:
16+
- ${HOST_LOG_DIR:-./mitm-logs}:/custom-logs
17+
- ./addons:/addons:ro
18+
ports:
19+
- "${HOST_PORT:-8080}:8080"
20+
depends_on:
21+
- sut-redis-sample
22+
sut-redis-sample:
23+
build:
24+
dockerfile: ./dockerfiles/redis-sample.dockerfile
25+
context: ..
26+
environment:
27+
AUTH_PORT: ${AUTH_PORT:-8081}
28+
ports:
29+
- "${JACOCO_PORT:-6300}:6300"
30+
db:
31+
image: redis:7.4-alpine
32+
command: redis-server --requirepass 53cret

experiments/wb-exp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def __init__(self, name, platform):
201201
Sut("ohsome-api", JDK_17),
202202
Sut("pay-publicapi",JDK_11),
203203
Sut("person-controller",JDK_21),
204+
Sut("redis-sample", JDK_21),
204205
Sut("proxyprint", JDK_8),
205206
Sut("quartz-manager", JDK_11),
206207
Sut("reservations-api", JDK_11),
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
34+
35+
### ds_store
36+
**/.DS_Store
37+
38+
### docker directories
39+
/cassandra/cassandra
40+
/cassandra/redis_data/
41+
/redis_data
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# Redisearch-Digital-Banking-redistemplate
2+
3+
Provides a quick-start example of using Redis with springBoot with Banking structures. Digital Banking uses an API microservices approach to enable high speed requests for account, customer and transaction information. As seen below, this data is useful for a variety of business purposes in the bank.
4+
<a href="" rel="Digital Banking"><img src="images/DigitalBanking.png" alt="" /></a>
5+
6+
### Note: This is the same as Redisearch-Digital-Banking but uses redistemplate instead of any of the crudrepository indexes. redisearch 2.0 indexes will be used. This is not using the crudrepository for the basic redis data.
7+
8+
## Overview
9+
In this tutorial, a java spring boot application is run through a jar file to support typical API calls to a REDIS banking data layer. A redis docker configuration is included.
10+
11+
## Redis Advantages for Digital Banking
12+
* Redis easily handles high write transaction volume
13+
* Redis has no tombstone issues and can upsert posted transactions over pending
14+
* Redis Enterprise scales vertically (large nodes) and horizontally (many nodes)
15+
* Redisearch 2.0 automatically indexes the hash structure created by Spring Java CRUD repository
16+
17+
## Requirements
18+
* Docker installed on your local system, see [Docker Installation Instructions](https://docs.docker.com/engine/installation/).
19+
* Alternatively, can run Redis Enterprise and set the redis host and port in the application.properties file
20+
* When using Docker for Mac or Docker for Windows, the default resources allocated to the linux VM running docker are 2GB RAM and 2 CPU's. Make sure to adjust these resources to meet the resource requirements for the containers you will be running. More information can be found here on adjusting the resources allocated to docker.
21+
22+
[Docker for mac](https://docs.docker.com/docker-for-mac/#advanced)
23+
[Docker for windows](https://docs.docker.com/docker-for-windows/#advanced)
24+
25+
## Links that help!
26+
27+
* [Redis Stack](https://redis.com/blog/introducing-redis-stack/)
28+
* [Redis Search](https://redis.io/docs/stack/search/)
29+
* [Redis Insight](https://redis.io/docs/stack/insight/)
30+
* [Spring Data for Redis github](https://github.com/spring-projects/spring-data-examples/tree/master/redis/repositories)
31+
* [Spring Data for Cassandra](https://www.baeldung.com/spring-data-cassandra-tutorial)
32+
* [Spring Data for Kafka](https://www.baeldung.com/spring-kafka)
33+
* [spring data Reference in domain](https://github.com/spring-projects/spring-data-examples/blob/master/redis/repositories/src/main/java/example/springdata/redis/repositories/Person.java)
34+
* [spring async tips](https://dzone.com/articles/effective-advice-on-spring-async-part-1)
35+
* [swagger-ui with spring](https://www.baeldung.com/spring-rest-openapi-documentation)
36+
*
37+
38+
39+
## Technical Overview
40+
41+
This github java code uses jedis library for redis. The jedis library supports RediSearch, RedisJSON, and RedisTimeSeries. The original github only used spring java without redisearch. That repository is still intact at [this github location](https://github.com/jphaugla/Redis-Digital-Banking). Another subsequent version uses crud repository and search at [this github location](https://github.com/jphaugla/Redisearch-Digital-Banking)
42+
All of the Spring Java indexes have been removed in this version. The crud repository has been removed.
43+
### The spring java code
44+
This is basic spring links
45+
* [Spring Redis](https://docs.spring.io/spring-data/data-redis/docs/current/reference/html/#redis.repositories.indexes)
46+
* *boot*-Contains index creation for each of the four redisearch indexes used in this solution: Account, Customer, Merchant, and Transaction
47+
* *config*-Initial configuration module using autoconfiguration and a threadpool sizing to adjust based on machine size
48+
* *controller*-http API call interfaces
49+
* *data*-code to generate POC type of customer, account, and transaction code
50+
* *domain*-has each of the java objects with their columns. Enables all the getter/setter methods
51+
* *repository*-has repository definitions. With transition to redisearch 2.0, not used as heavily as previously. This is where the redistemplate code is added if crud repository is no longer used. Cassandra transaction repository is also here.
52+
* *service*-asyncservice, topicproducer (kafka) and bankservice doing the interaction with redis
53+
###
54+
The java code demonstrates common API actions with the data layer in REDIS. The java spring Boot framework minimizes the amount of code to build and maintain this solution. Maven is used to build the java code and the code is deployed to the tomcat server.
55+
56+
### Data Structures in use
57+
<a href="" rel="Tables Structures Used"><img src="images/Tables.png" alt="" /></a>
58+
59+
## Using Docker for non-application components
60+
This option uses docker to support all of the non-application components (kafka, cassandra, redis) with the java application running on the local mac.
61+
* Prepare Docker environment-see the Prerequisites section above...
62+
* Pull this github into a directory
63+
```bash
64+
git clone https://github.com/jphaugla/Redisearch-Digital-Banking.git
65+
```
66+
* Refer to the notes for redis Docker images used but don't get too bogged down as docker compose handles everything except for a few admin steps on tomcat.
67+
* [Redis stack docker instructions](https://redis.io/docs/stack/get-started/install/docker/)
68+
* Open terminal and change to the github home where you will see the docker-compose.yml file, then:
69+
```bash
70+
docker-compose -f docker-compose-kafka.yml -f docker-compose.yml -f docker-compose-cassandra.yml up -d
71+
```
72+
## Deploying java application on local mac with Kafka non-application components
73+
* ensure maven and java are deployed on the local machine
74+
* have been running with java 17 or java 18 but other versions should work as well
75+
* have been runing with 3.9.4 and 3.9.5
76+
* Set up the environment and run the java application locally
77+
* edit the [environment file](scripts/setEnv.sh) to use localhost for non-application components
78+
* source this environment file
79+
* run the application
80+
```bash
81+
source scripts/setEnv.sh
82+
java -jar target/redis-0.0.1-SNAPSHOT.jar
83+
```
84+
85+
## Using terraform on azure for all components
86+
<a href="" rel="Deployment"><img src="images/deployment.png" alt="" /></a>
87+
* Use [this github](https://github.com/jphaugla/tfmodule-azure-redis-enterprise) to deploy all of the components (including the application)
88+
* Check the [readme](https://github.com/jphaugla/tfmodule-azure-redis-enterprise/README.md) for the details on deploying this github including the cloning the github and working with Azure. Completely deploy the terraform github for all deployments. This will also deploy [this github](https://github.com/jphaugla/Redisearch-Digital-Banking-redisTemplate) inside the tester node. The later application deployment instructions will be deployed within the tester node using ssh
89+
* maven and java will be installed by the ansible jobs for the tester node
90+
* the ip and dns information is shared in a [temp directory](https://github.com/jphaugla/tfmodule-azure-redis-enterprise/provisioners/temp) within the terraform/ansible repository. Go to the files here to see private (internal) and public (external) kafka node, cassandra node and testinnode IP addresses. The redis internal and external database connection dns names are also available. These dns names will also give an internal and external redis enterprise node IP.
91+
* log into the tester node using the testernode IP and the ssh key defined in test/main.tf and go to github home
92+
```bash
93+
ssh -i <azure key> redislabs@<testerIP>
94+
cd Redisearch-Digital-Banking-redisTemplate
95+
```
96+
* edit the [environment file](scripts/setEnv.sh) using only the internal connection addresses. NOTE: kafka will only connect from local azure IP addresses and not any public IP addresses. Using public and private Kafka addresses is possible but not configured currently
97+
* These steps can all be done from client machine local browser using the kafka node public IP address and port 9021. [http://172.172.133.201:9021/](http://172.172.133.201:9021/) From this home screen, pause the currently running connectors: datagen-pageviews, cassanddra-sink, and redis-sink-json using the Kafka Control Center. This will just remove the noise of a second application running.
98+
* Consider cleaning both the redis (use flushdb) and cassandra databases as well (drop keyspace pageviews)
99+
* Create transaction table in cassandra using provided script
100+
```bash
101+
cd scripts
102+
# edit the CQLSH_HOST variable inside the script for the cassandra host pubic IP address
103+
./createCassandraTrans.sh
104+
```
105+
* start the application after logging in to the testernode
106+
```bash
107+
ssh -i ~/.ssh/<sshkey> redislabs@<testernode public ip>
108+
cd Redisearch-Digital-Banking-redisTemplate
109+
mvn clean package
110+
# edit scripts/setEnv.sh for current nodes - REDIS_HOST, REDIS_PORT, and KAFKA_HOST must all change to match current environment. *IMPORTANT* only use private/internal IP addresses-DO NOT USE *localhost*. Additional note, redis password is different in local docker version and in ansible created version-verify redis password!
111+
source scripts/setEnv.sh
112+
java -jar target/redis-0.0.1-SNAPSHOT.jar
113+
```
114+
* get a second terminal window to the tester node and write a test message to kafka-this will cause the topic to be created. Name can be changed in [application.properties](src/main/resources/application.properites) but default topic name is *transactions*
115+
```bash
116+
ssh -i ~/.ssh/<sshkey> redislabs@<testernode public ip>
117+
cd Redisearch-Digital-Banking-redisTemplate/scripts
118+
# make sure saveTransaction script says doKafka=true
119+
./saveTransaction.sh
120+
```
121+
* verify transactions topic is created using kafka control center
122+
* in control center click on topics and then on the topics page, click messages
123+
* if you run saveTransaction.sh again while looking at the control center topic pane, the message will be visible. If you put offset of 0, both messages will be visible.
124+
* application will create the kafka topic on first usage of the topic.
125+
* Call kafka API to create the RedisSink using provided script. DO THIS FROM your local Mac
126+
```bash
127+
cd Redisearch-Digital-Banking-redisTemplate/scripts
128+
# change localhost to the external/public ip address for the kafka node in the last line.
129+
# Make sure this is the public kafka IP and not the private
130+
# Verify the redis.uri and redis.password. (the redis.uri must be INTERNAL)
131+
./createRedisSink.sh
132+
ssh -i ~/.ssh/<sshkey> redislabs@<testernode public ip>
133+
./saveTransaction.sh
134+
```
135+
verify data flowed in to redis using redis-cli
136+
```bash
137+
redis-cli -h <redis_external_endpoint.txt> -p <redis_port.txt> -a redis123
138+
>keys Trans*
139+
140+
141+
* Call an Api to create the cassandra sink using provided script
142+
```bash
143+
# on local mac
144+
cd Redisearch-Digital-Banking-redisTemplate/scripts
145+
# change localhost to the public ip address for the kafka node in the last line.
146+
# Set the contactPoints to the local IP address for the cassandra node.
147+
./createCassandraSink.sh
148+
ssh -i ~/.ssh/<sshkey> redislabs@<testernode public ip>
149+
./saveTransaction.sh
150+
```
151+
verify data flowed in to cassandra using cqlsh
152+
153+
## process larger record set
154+
verify generateData.sh says doKafkfa=true
155+
```bash
156+
./scripts/generateData.sh
157+
```
158+
Will see large number of records now in cassandra and redis
159+
160+
Shows a benchmark test run of generateData.sh on GCP servers. Although, this test run is using redisearch 1.0 code base. Need to rerun this test.
161+
<a href="" rel="Generate Data Benchmark"><img src="images/Benchmark.png" alt="" /></a>
162+
163+
### Investigate the APIs
164+
#### Use swagger UI
165+
* [open api docs](http://localhost:8080/v3/api-docs)
166+
* [use swagger ui](http://localhost:8080/swagger-ui/index.html)
167+
#### run bash scripts in ./scripts. Adding the redisearch queries behind each script here also...
168+
* addTag.sh - add a tag to a transaction. Tags allow user to mark transactions to be in a buckets such as Travel or Food for budgetary tracking purposes
169+
* deleteCustomer.sh - delete all customers matching a string
170+
* generateData.sh - simple API to generate default customer, accounts, merchants, phone numbers, emails and transactions
171+
* generateLots.sh - for server testing to generate higher load levels. Use with startAppservers.sh. Not for use with docker setup. This is load testing with redis enterprise and client application running in same network in the cloud.
172+
* getByAccount.sh - find transactions for an account between a date range
173+
* getByCreditCard.sh - find transactions for a credit card between a date range
174+
* getByCustID.sh - retrieve transactions for customer
175+
* getByEmail.sh - retrieve customer record using email address
176+
* getByMerchant.sh - find all transactions for an account from one merchant for date range
177+
* getByMerchantCategory.sh - find all transactions for an account from merchant category for date range
178+
* getByNamePhone.sh - get customers by phone and full name.
179+
* getByPhone.sh - get customers by phone only
180+
* getByStateCity.sh - get customers by city and state
181+
* getByZipLastname.sh - get customers by zipcode and lastname.
182+
* getReturns.sh - get returned transactions count by reason code
183+
* getTags.sh - get all tags on an account
184+
* getTaggedAccountTransactions.sh - find transactions for an account with a particular tag
185+
* getTransaction.sh - get one transaction by its transaction ID
186+
* getTransactionStatus.sh - see count of transactions by account status of PENDING, AUTHORIZED, SETTLED
187+
* putCustomer.sh - put a set of json customer records
188+
* saveAccount.sh - save a sample account
189+
* saveCustomer.sh - save a sample customer
190+
* saveTransaction.sh - save a sample Transaction
191+
* startAppservers.sh - start multiple app server instances for load testing
192+
* testPipeline.sh - test pipelining
193+
* updateTransactionStatus.sh - generate new transactions to move all transactions from one transaction Status up to the next transaction status. Parameter is target status. Can choose SETTLED or POSTED. Will move 100,000 transactions per call
194+
* putDispute.sh - put the dispute specified in dispute.sh
195+
* disputeReasonCode.sh - set the dispute reason code
196+
* disputeAccept.sh - accept the dispute
197+
* disputeResolved.sh - charge back the dispute
198+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3.9'
2+
3+
services:
4+
5+
cassandra1:
6+
image: 'cassandra:latest'
7+
environment:
8+
- CASSANDRA_CLUSTER_NAME=test
9+
- CASSANDRA_SEEDS=cassandra1
10+
# this is actually hardcoded with SIMPLE Snitch
11+
- CASSANDRA_DC=datacenter1
12+
- CASSANDRA_ENDPOINT_SNITCH=SimpleSnitch
13+
- CASSANDRA_BROADCAST_ADDRESS=cassandra1
14+
container_name: cassandra1
15+
hostname: cassandra1
16+
ports:
17+
- '9042:9042'
18+
- '9160:9160'
19+
20+
cassandra-load-keyspace:
21+
container_name: cassandra-load-keyspace
22+
image: 'cassandra:latest'
23+
volumes:
24+
- ./cassandra_init:/cassandra_init/
25+
entrypoint: [ "bash", "/cassandra_init/init.sh" ]

0 commit comments

Comments
 (0)