Traffic Monitor¶
Introduction¶
Traffic Monitor is a Java Tomcat application that monitors caches, provides health state information to Traffic Router, and collects statistics for use in tools such as Traffic Ops and Traffic Stats. The health state provided by Traffic Monitor is used by Traffic Router to control which caches are available on the CDN.
Software Requirements¶
To work on Traffic Monitor you need a *nix (MacOS and Linux are most commonly used) environment that has the following installed:
- Eclipse >= Kepler SR2 (or another Java IDE)
- Maven >= 3.3.1
- JDK >= 6.0
Traffic Monitor Project Tree Overview¶
traffic_control/traffic_monitor/
- base directory for Traffic Monitoretc/
- Miscellaneous simulator utilitiessrc/main
- Main source directory for the Traffic Monitorbin/
- Configuration toolsconf/
- Configuration filesjava/
- Java source code for Traffic Monitoropt/tomcat/conf
- Contains Tomcat configuration file(s) pulled in during an RPM buildresources/
- Resources pulled in during an RPM buildscripts/
- Scripts used by the RPM build processwebapp/
- Java webapp resources
src/test
- Test source directory for Traffic Monitorjava/
- JUnit based unit tests for Traffic Monitorresources/conf
- Configuration files used by unit testsresources/db
- Files downloaded by unit testsresources/var
- Files generated by unit tests
Java Formatting Conventions¶
None at this time. The codebase will eventually be formatted per Java standards.
Installing The Developer Environment¶
To install the Traffic Monitor Developer environment:
- Clone the traffic_control repository using Git.
- Change directories into
traffic_control/traffic_monitor
. - Edit the following parameters in src/test/resources/conf/traffic_monitor_config.js:
Parameter | Value |
---|---|
tm.hostname |
FQDN of the Traffic Ops instance (do not include http://). |
tm.username |
Admin username for Traffic Ops |
tm.password |
Password for admin user |
cdnName |
Name of the CDN this Traffic Monitor will monitor |
Import the existing git repo into Eclipse:
- File -> Import -> Git -> Projects from Git; Next
- Existing local repository; Next
- Add -> browse to find
traffic_control
; Add - Select
traffic_control
; Next - Ensure “Import existing projects” is selected, expand
traffic_control
, selecttraffic_monitor
; Next - Ensure
traffic_monitor
is checked; Finish - Ensure
traffic_monitor
has been opened by Eclipse after importing
Run
mvn clean verify
from thetraffic_monitor
directoryStart the embedded Jetty instance from within Eclipse
In the package explorer, expand
traffic_monitor
Expand
src/test/java
Expand the package
com.comcast.cdn.traffic_control.traffic_monitor
Open and run
Start.java
Note
If an error is displayed in the Console, run
mvn clean verify
from thetraffic_monitor
directoryWith a web browser, navigate to http://localhost:8080
Test Cases¶
Unit tests can be executed using Maven by running mvn test
at the root of the traffic_monitor
project.