blob: 4a801bbf67a73e96dcfc0deda6a6614d949eee2b [file] [log] [blame]
..
.. Copyright 2015 Comcast Cable Communications Management, LLC
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
.. http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.
..
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 Monitor
* ``etc/`` - Miscellaneous simulator utilities
* ``src/main`` - Main source directory for the Traffic Monitor
* ``bin/`` - Configuration tools
* ``conf/`` - Configuration files
* ``java/`` - Java source code for Traffic Monitor
* ``opt/tomcat/conf`` - Contains Tomcat configuration file(s) pulled in during an RPM build
* ``resources/`` - Resources pulled in during an RPM build
* ``scripts/`` - Scripts used by the RPM build process
* ``webapp/`` - Java webapp resources
* ``src/test`` - Test source directory for Traffic Monitor
* ``java/`` - JUnit based unit tests for Traffic Monitor
* ``resources/conf`` - Configuration files used by unit tests
* ``resources/db`` - Files downloaded by unit tests
* ``resources/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:
1. Clone the traffic_control repository using Git.
2. Change directories into ``traffic_control/traffic_monitor``.
3. 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 |
+-----------------+------------------------------------------------------------+
4. Import the existing git repo into Eclipse:
a. File -> Import -> Git -> Projects from Git; Next
b. Existing local repository; Next
c. Add -> browse to find ``traffic_control``; Add
d. Select ``traffic_control``; Next
e. Ensure "Import existing projects" is selected, expand ``traffic_control``, select ``traffic_monitor``; Next
f. Ensure ``traffic_monitor`` is checked; Finish
g. Ensure ``traffic_monitor`` has been opened by Eclipse after importing
5. Run ``mvn clean verify`` from the ``traffic_monitor`` directory
6. Start the embedded Jetty instance from within Eclipse
a. In the package explorer, expand ``traffic_monitor``
b. Expand ``src/test/java``
c. Expand the package ``com.comcast.cdn.traffic_control.traffic_monitor``
d. Open and run ``Start.java``
.. Note:: If an error is displayed in the Console, run ``mvn clean verify`` from the ``traffic_monitor`` directory
e. With 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.
API
===
:ref:`reference-tm-api`
.. toctree::
:hidden:
:maxdepth: 1
traffic_monitor/traffic_monitor_api