A sample application using the technologies:
- Spring Boot - for running the application and take advantage of framework features.
- gRPC - RPC protocol framework for sending event data to the backend
- Docker - run the application in a container
- NGINX - load balancer
- Neo4J - Graph DB
This sample application collects and process voice call events. The following information is included in the call event:
- Mobile Network Code (MNC)
- Mobile Country Code (MCC)
- Network Name (e.g. T-Mobile / AT&T)
- Network Type (e.g. 2G/3G), or LTE for VoLTE
- Signal DBM
- Signal ASU
- Device Brand
- Device Model
- OS Name
- OS Version
- Latitude
- Longtitude
- All components run in docker
- docker network (Bridge)
- clustering / load balancing
- clustered neo4j graph db via docker-copmose
- submit call event
- get average signal strength (mock data) for a specific cellphone brand (uses cypher to query neo4j)
Notes on NGINX Load Balancing:
- gRPC messages are transported over HTTP/2 either over TLS or not.
- NGINX receives gRPC traffic using HTTP and proxies it using grpc_pass directive.
Following is an extract from:
src/main/nginx/nginx.conf
http {
...
include /etc/nginx/conf.d/*.conf;
}
src/main/nginx/conf.d/default.conf
upstream grpcservers {
server 172.19.3.6:9090;
server 172.19.3.7:9090;
}
server {
listen 80 http2;
location / {
grpc_pass grpc://grpcservers;
}
}
Prerequisite:
Install Java 1.8 SDK, Git, Maven 3, Docker, call-event-proto.
Note: see https://github.com/CNAChino/call-event-proto to install call-event-proto.
Procedure:
-
Get the source code
$ git clone https://github.com/CNAChino/call-event-service.git
-
Compile and package jar file
$ mvn package
OR
$ mvn clean package
Note: This will create the application jar file and the docker image.
To check if the docker image was created, run the following command:
$ docker image ls
To remove the image from your docker local repository, run the following command:
$ docker image rm {docker.image.name.prefix}/{project.artifactId}:{tag}
just replace values ofdocker.image.name.prefix
andproject.artifactId
frompom.xml
.
Fortag
useproject.version
from pom.xml.\
Prerequisite: Start Neo4j Graph DB (Community or Enterprise edition). Then create a neo4j user (disable Force Password Change). Set the Uri, Username and Password in application.properties.
To run the docker image in foreground (add -d to run in background), execute:
docker run --name {name} -it -v {host-local-log-dir}:/app/logs {docker.image.name.prefix}/{project.artifactId}:{tag}
where,
{name}
is the name of container.{network-name}
is the name of docker network.{ip-addr}
is ip address that will be assigned to the container.{host-local-log-dir}
is the path to a file directory in your host operating system for logfiles.{docker.image.name.prefix}
and{project.artifactId}
values are frompom.xml
.{tag}
isproject.version
from pom.xml.
Note: Inside the docker container, the application listens in port 9090 and the working directory is /app
Note: Docker's bridge network applies to containers running on the same docker daemon host.
For clustering containers on multiple docker host, use an overlay network.
Prerequisite:
- Create /apps/nginxlogs, /apps/logs1 and /apps/logs2. Make sure these directories are writable by the application
- Create the bridge network with name ces-brnet and subnet address 172.19.0.0/16
$ docker network create --driver bridge --subnet 172.19.0.0/16 ces-brnet
- Start Neo4j Cluster. This project has src/docker-compose.yml which defines the neo4j db cluster. Execute:
$ docker-compose up
or$ docker-compose up -d
wait for a few minutes then connect to neo4j browser via http://{localhost or your machine IP}:7474
Procedure:
- Run N (2 for this guide) application containers assigning each with an ip address.
$ docker run --name ces1 --network=ces-brnet --ip=172.19.3.6 -itd -v /apps/logs1:/app/logs aureus-prototype/call-event-service:1.0
$ docker run --name ces2 --network=ces-brnet --ip=172.19.3.7 -itd -v /apps/logs2:/app/logs aureus-prototype/call-event-service:1.0
Note: Inside the docker container, the application listens in port 9090 and the working directory is /app
- Build NGINX-LB container
$ cd {path/to/call-event-service}/src/main/nginx
$ docker build -t aureus-prototype/nginx-lb .
- Run NGINX-LB container and assign it with an ip address
$ docker run --network=ces-brnet --ip=172.19.3.5 -v /apps/nginxlogs:/var/log/nginx -itd -p 8080:80 aureus-prototype/nginx-lb
access.log and error.log should be created in your /apps/nginxlogs directory. - To test, run
CallEventClient.java
which is located in src/test/java. Check /apps/nginxlogs, /apps/logs1 and /apps/logs2. Messages should be logged both in apps/logs1 and apps/logs2.