You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2018/09/14 15:55:45 UTC
[trafficcontrol] branch master updated: remove traffic_monitor_java
This is an automated email from the ASF dual-hosted git repository.
rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 4e7a7ab remove traffic_monitor_java
4e7a7ab is described below
commit 4e7a7ab26cce0903ebe54dd0892da45feaf8d3de
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Wed Sep 12 13:50:28 2018 -0600
remove traffic_monitor_java
---
.dependency_license | 1 -
CHANGELOG.md | 1 +
test/astats_sim/Readme.md | 20 -
test/astats_sim/_astats | 172 ---
test/astats_sim/_astats_static | 171 ---
test/astats_sim/ats_sim.js | 425 -------
traffic_monitor_java/.classpath | 36 -
traffic_monitor_java/.gitignore | 4 -
traffic_monitor_java/.pmd | 1262 --------------------
traffic_monitor_java/.project | 29 -
traffic_monitor_java/README.md | 40 -
traffic_monitor_java/build/build_rpm.sh | 81 --
traffic_monitor_java/build/pmd/ruleset.xml | 210 ----
traffic_monitor_java/pom.xml | 518 --------
traffic_monitor_java/src/main/bin/config-doc.sh | 31 -
.../src/main/bin/traffic_monitor_config.pl | 352 ------
.../src/main/conf/log4j.properties | 66 -
.../src/main/conf/traffic_monitor_config.js | 18 -
traffic_monitor_java/src/main/etc/init.d/tomcat | 109 --
.../cdn/traffic_control/traffic_monitor/Index.html | 131 --
.../cdn/traffic_control/traffic_monitor/Index.java | 175 ---
.../traffic_monitor/MonitorApplication.java | 116 --
.../traffic_monitor/MonitorPage.java | 35 -
.../traffic_monitor/MonitorSession.java | 27 -
.../traffic_monitor/StatisticModel.java | 36 -
.../traffic_monitor/config/Cache.java | 213 ----
.../traffic_monitor/config/Config.java | 122 --
.../traffic_monitor/config/ConfigHandler.java | 107 --
.../traffic_monitor/config/MonitorConfig.java | 179 ---
.../traffic_monitor/config/Peer.java | 110 --
.../traffic_monitor/config/RouterConfig.java | 118 --
.../traffic_monitor/data/DataPoint.java | 54 -
.../traffic_monitor/data/DataSummary.java | 81 --
.../traffic_monitor/data/StatisticsLog.java | 282 -----
.../traffic_monitor/health/AbstractState.java | 229 ----
.../traffic_monitor/health/Bandwidth.java | 44 -
.../traffic_monitor/health/CacheState.java | 64 -
.../traffic_monitor/health/CacheStateRegistry.java | 101 --
.../traffic_monitor/health/CacheStateUpdater.java | 143 ---
.../health/CacheStatisticsClient.java | 63 -
.../traffic_monitor/health/CacheWatcher.java | 248 ----
.../health/DeliveryServiceStateRegistry.java | 216 ----
.../traffic_monitor/health/DsState.java | 148 ---
.../traffic_monitor/health/DsStati.java | 175 ---
.../traffic_monitor/health/DsWatcher.java | 97 --
.../traffic_monitor/health/EmbeddedStati.java | 85 --
.../traffic_monitor/health/Event.java | 98 --
.../traffic_monitor/health/HealthDeterminer.java | 380 ------
.../traffic_monitor/health/PeerState.java | 254 ----
.../traffic_monitor/health/PeerWatcher.java | 185 ---
.../traffic_monitor/health/StateRegistry.java | 111 --
.../traffic_monitor/health/TmListener.java | 22 -
.../traffic_monitor/health/TmWatcher.java | 215 ----
.../traffic_monitor/publish/CacheStats.java | 72 --
.../traffic_monitor/publish/ConfigDoc.java | 36 -
.../traffic_monitor/publish/CrConfig.java | 117 --
.../traffic_monitor/publish/CrStates.java | 136 ---
.../traffic_monitor/publish/DsStats.java | 69 --
.../traffic_monitor/publish/EventLog.java | 45 -
.../traffic_monitor/publish/JsonPage.java | 72 --
.../traffic_monitor/publish/PeerStates.java | 79 --
.../traffic_monitor/publish/StatSummary.java | 65 -
.../traffic_monitor/publish/Stats.java | 76 --
.../traffic_monitor/util/Fetcher.java | 284 -----
.../traffic_monitor/util/Network.java | 67 --
.../util/PeriodicResourceUpdater.java | 224 ----
.../traffic_monitor/util/StableBloomFilter.java | 176 ---
.../traffic_monitor/util/Updatable.java | 29 -
.../behaviors/AbstractMultiAjaxBehavior.java | 476 --------
.../behaviors/MultiUpdatingTimerBehavior.java | 138 ---
.../behaviors/UpdatingAttributeAppender.java | 51 -
.../wicket/components/CacheDetailsPage.html | 40 -
.../wicket/components/CacheDetailsPage.java | 37 -
.../wicket/components/CacheListPanel.html | 52 -
.../wicket/components/CacheListPanel.java | 153 ---
.../wicket/components/DsDetailsPage.html | 40 -
.../wicket/components/DsDetailsPage.java | 37 -
.../wicket/components/DsListPanel.html | 60 -
.../wicket/components/DsListPanel.java | 171 ---
.../wicket/components/EventLogPanel.html | 59 -
.../wicket/components/EventLogPanel.java | 92 --
.../wicket/components/StateDetailsPage.java | 75 --
.../wicket/models/CacheDataModel.java | 73 --
.../wicket/models/CacheStateModel.java | 36 -
.../wicket/models/DsStateModel.java | 36 -
.../traffic_monitor/wicket/models/StateModel.java | 48 -
.../src/main/opt/tomcat/conf/server.xml | 45 -
.../src/main/resources/log4j.properties | 31 -
.../src/main/resources/version.prop | 5 -
.../src/main/scripts/postinstall.sh | 18 -
.../src/main/scripts/postremove.sh | 21 -
.../src/main/scripts/preinstall.sh | 32 -
traffic_monitor_java/src/main/scripts/preremove.sh | 18 -
.../src/main/webapp/WEB-INF/web.xml | 52 -
traffic_monitor_java/src/main/webapp/js/main.js | 39 -
traffic_monitor_java/src/main/webapp/style.css | 260 ----
traffic_monitor_java/src/main/webapp/test.html | 95 --
traffic_monitor_java/src/main/webapp/tune-grey.png | Bin 976 -> 0 bytes
traffic_monitor_java/src/main/webapp/tune.png | Bin 1149 -> 0 bytes
.../java/application/MonitorApplicationTest.java | 91 --
.../cdn/traffic_control/traffic_monitor/Start.java | 97 --
.../traffic_monitor/TestHomePage.java | 78 --
.../src/test/java/config/CacheTest.java | 209 ----
.../src/test/java/config/ConfigHandlerTest.java | 102 --
.../src/test/java/config/ConfigTest.java | 136 ---
.../src/test/java/config/MonitorConfigTest.java | 68 --
.../src/test/java/config/RouterConfigTest.java | 168 ---
.../src/test/java/data/DataPointTest.java | 58 -
.../src/test/java/data/StatisticsLogTest.java | 325 -----
.../test/java/health/CacheStateUpdaterTest.java | 297 -----
.../java/health/CacheStatisticsClientTest.java | 66 -
.../src/test/java/health/DeletemeTest.java | 24 -
.../src/test/java/health/HealthDeterminerTest.java | 44 -
.../test/resources/conf/traffic_monitor_config.js | 16 -
.../src/test/resources/db/health-params.json | 39 -
traffic_monitor_java/src/test/resources/keystore | Bin 1481 -> 0 bytes
.../src/test/resources/var/cr-config.json | 134 ---
.../src/test/resources/var/health-params.js | 72 --
118 files changed, 1 insertion(+), 14070 deletions(-)
diff --git a/.dependency_license b/.dependency_license
index 4a13120..8e81704 100644
--- a/.dependency_license
+++ b/.dependency_license
@@ -64,7 +64,6 @@ cron\.d/[^/]*$, Apache
^misc/logos/page_logos/traffic_router_logo\.png, Apache
^misc/logos/page_logos/traffic_stats_logo\.png, Apache
^misc/logos/page_logos/traffic_stats_logo_red\.png, Apache
-^traffic_monitor_java/src/main/webapp/tune(-grey)?\.png, Apache
^traffic_ops/app/public/images/anchor\.gif, Apache
^traffic_ops/app/public/images/bad\.png, Apache
^traffic_ops/app/public/images/blank\.png, Apache
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5022ae..2734bde 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Geolocation-based Client Steering: two new steering target types are available to use for `CLIENT_STEERING` delivery services: `STEERING_GEO_ORDER` and `STEERING_GEO_WEIGHT`. When targets of these types have an Origin with a Coordinate, Traffic Router will order and prioritize them based upon the shortest total distance from client -> edge -> origin. Co-located targets are grouped together and can be weighted or ordered within the same location using `STEERING_GEO_WEIGHT` or `STEERING_ [...]
- Tenancy is now the default behavior in Traffic Ops. All database entries that reference a tenant now have a default of the root tenant. This eliminates the need for the `use_tenancy` global parameter and will allow for code to be simplified as a result. If all user and delivery services reference the root tenant, then there will be no difference from having `use_tenancy` set to 0.
- Traffic Monitor Client Update: Traffic Monitor is updated to use the Traffic Ops v13 client.
+- Removed previously deprecated `traffic_monitor_java`
## [2.2.0] - 2018-06-07
### Added
diff --git a/test/astats_sim/Readme.md b/test/astats_sim/Readme.md
deleted file mode 100644
index 70bc620..0000000
--- a/test/astats_sim/Readme.md
+++ /dev/null
@@ -1,20 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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.
--->
-
-An astats simulator tool written in javascript and perl. Used to test Traffic Monitor.
diff --git a/test/astats_sim/_astats b/test/astats_sim/_astats
deleted file mode 100644
index 7f2c96e..0000000
--- a/test/astats_sim/_astats
+++ /dev/null
@@ -1,172 +0,0 @@
-#!/usr/bin/perl
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-
-
-use strict;
-use warnings;
-
-use DBI;
-use JSON;
-use CGI::Carp qw/fatalsToBrowser/;
-use Data::Dumper;
-use Encode;
-
-my %query_params = &getFormData();
-my $json = JSON->new->utf8;
-my $json_obj;
-
-my $unixtime = time();
-my $server_name = $ENV{'SERVER_NAME'};
-my $cdn_domain_name = "<CDN-DOMAIN_NAME>";
-my $hex_string = $server_name;
-$hex_string =~ s/(.)/sprintf("%d",ord($1))/eg;
-my $int1 = int($hex_string) % 4;
-my $int2 = $hex_string % 40;
-my $int3 = $hex_string % 400;
-my $int4 = $hex_string % 4000;
-my $int5 = $hex_string % 40000;
-my $int6 = $hex_string % 400000;
-my $int7 = $hex_string % 4000000;
-my $int8 = $hex_string % 40000000;
-my $int9 = $hex_string % 40000000;
-my $int10 = $hex_string % 400000000;
-
-my $hit_fresh = int($int10 + $unixtime + $int4);
-my $hit_fresh_process = int($hit_fresh);
-my $hit_revalidated = int(($int10/2) + $unixtime + $int1);
-my $miss_cold = int(($int10/2) + $unixtime + $int3);
-my $miss_not_cacheable = int(($int7/3) + $unixtime + $int1);
-my $miss_changed = int(($unixtime/10000000) + $int1);
-my $miss_client_no_cache = 0;
-my $aborts = int(($unixtime/10000000) + $int2*2);
-my $possible_aborts = 0;
-my $connect_failed = int(($unixtime/1000000) + $int2*4 + $int1*2);
-my $other = int((($unixtime/1000000) + $int3)/100);
-my $unclassified = 0;
-my $write_bytes = int($unixtime*50 + $int4*$int5);
-my $current_client_connections = int($int5*rand());
-my $bytes_used = int($write_bytes/20 + $int2*$int5);
-my $bytes_total = int($bytes_used + $int10);
-my $v1_bytes_used = int($bytes_used);
-my $v1_bytes_total = int($bytes_total);
-my $load_avg_1 = sprintf("%.2f",$unixtime/100000000+(8*rand()));
-my $load_avg_5 = sprintf("%.2f",$load_avg_1 / 2);
-my $load_avg_15 = sprintf("%.2f",$load_avg_1 / 3);
-my $running_procs = int(15*rand($int1));
-my $total_procs = int(2*$running_procs+($int1+2)*2);
-my $last_proc_id = $int5;
-my $proc_loadavg = "$load_avg_1 $load_avg_5 $load_avg_15 $running_procs/$total_procs $last_proc_id";
-my $if_rbytes = int($unixtime*760000000+$bytes_total);
-my $if_rpackets = int($if_rbytes/875);
-my $if_rmcast = int($if_rpackets/$int4);
-my $if_tbytes = int($if_rbytes/1.5);
-my $if_tpackets = int($if_tbytes/1500);
-my $proc_net_dev = $query_params{'inf.name'}. ":$if_rbytes $if_rpackets 0 0 0 0 0 $if_rmcast $if_tbytes $if_tpackets 0 0 0 0 0 0";
-my @ds_bytes;
-my @ds_bytes_in;
-my @ds_200s;
-my @ds_400s;
-my @ds_500s;
-for (my $i=1;$i<10;$i++) {
- my $rand1 = undef;
- $rand1 = rand($int1);
- $ds_bytes[$i] = int($if_tbytes/10 + ($rand1*$rand1));
- $ds_bytes_in[$i] = int($if_rbytes/10 + ($rand1*$rand1));
- $ds_200s[$i] = int($ds_bytes[$i]/9000*0.95);
- $ds_400s[$i] = int($ds_bytes[$i]/9000*0.04);
- $ds_500s[$i] = int($ds_bytes[$i]/9000*0.01);
-}
-$ds_bytes[10] = int($if_tbytes/10 + rand($int1) * rand($int1));
-$ds_bytes_in[10] = int($if_rbytes/10 + rand($int1) * rand($int1));
-$ds_200s[10] = int($ds_bytes[10]/9000*0.95);
-$ds_400s[10] = int($ds_bytes[10]/9000*0.04);
-$ds_500s[10] = int($ds_bytes[10]/9000*0.01);
-
-#proc.net.dev: "bond0:181566812618839 43321349767 0 0 0 0 0 4710035 517574148613675 34658736727 0 0 0 0 0 0"
-
-if (exists $query_params{'application'} ) {
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_fresh"} = $hit_fresh;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_fresh.process"} = $hit_fresh_process;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_revalidated"} = $hit_revalidated;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_cold"} = $miss_cold;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_not_cacheable"} = $miss_not_cacheable;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_changed"} = $miss_changed;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_client_no_cache"} = $miss_client_no_cache;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.aborts"} = $aborts;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.possible_aborts"} = $possible_aborts;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.connect_failed"} = $connect_failed;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.other"} = $other;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.other.unclassified"} = $unclassified;
- $json_obj->{'ats'}->{"proxy.process.net.write_bytes"} = $write_bytes;
- $json_obj->{'ats'}->{"proxy.process.http.current_client_connections"} = $current_client_connections;
- $json_obj->{'ats'}->{"proxy.process.cache.bytes_used"} = $bytes_used;
- $json_obj->{'ats'}->{"proxy.process.cache.bytes_total"} = $bytes_total;
- $json_obj->{'ats'}->{"proxy.process.cache.volume_1.bytes_used"} = $v1_bytes_used;
- $json_obj->{'ats'}->{"proxy.process.cache.volume_1.bytes_total"} = $v1_bytes_total;
- for(my $i=1;$i<10;$i++) {
- my $number = sprintf('%.2d', $i);
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.out_bytes"} = $ds_bytes[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.in_bytes"} = $ds_bytes_in[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_2xx"} = $ds_200s[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_4xx"} = $ds_400s[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_5xx"} = $ds_500s[$i];
- }
- my $number = 10;
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.out_bytes"} = $ds_bytes[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.in_bytes"} = $ds_bytes_in[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_2xx"} = $ds_200s[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_4xx"} = $ds_400s[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_5xx"} = $ds_500s[10];
- $json_obj->{'ats'}->{"server"} = "3.3.0-dev";
-}
-$json_obj->{'system'}->{"inf.name"} = $query_params{"inf.name"};
-$json_obj->{'system'}->{"inf.speed"} = "10000";
-$json_obj->{'system'}->{"proc.net.dev"} = $proc_net_dev;
-$json_obj->{'system'}->{"proc.loadavg"} = $proc_loadavg;
-$json_obj->{'system'}->{"something"} = "here";
-
-
-print "Content-type: text/html\n\n";
-print $json->utf8->encode( $json_obj );
-
-
-sub getFormData {
- my $buffer = "";
- my %hash = ();
- my @params = ();
-
- if ($ENV{'REQUEST_METHOD'} eq 'GET') {
- $buffer = $ENV{'QUERY_STRING'};
- $hash{"four"}="two";
- }
- else {
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
- }
- if ($buffer =~ m/\&/) {
- @params = split(/\&/,$buffer);
- }
- else {
- @params = split(/\;/,$buffer);
- }
- foreach my $p (@params) {
- (my $key, my $value) = split(/\=/,$p);
- $hash{$key}=$value;
- }
- return %hash;
-}
diff --git a/test/astats_sim/_astats_static b/test/astats_sim/_astats_static
deleted file mode 100644
index 61d12b9..0000000
--- a/test/astats_sim/_astats_static
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/perl
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-
-use strict;
-use warnings;
-
-use DBI;
-use JSON;
-use CGI::Carp qw/fatalsToBrowser/;
-use Data::Dumper;
-use Encode;
-
-my %query_params = &getFormData();
-my $json = JSON->new->utf8;
-my $json_obj;
-
-my $unixtime = time();
-my $server_name = $ENV{'SERVER_NAME'};
-my $cdn_domain_name = "<CDN-DOMAIN_NAME>";
-my $hex_string = $server_name;
-$hex_string =~ s/(.)/sprintf("%d",ord($1))/eg;
-my $int1 = int($hex_string) % 4;
-my $int2 = $hex_string % 40;
-my $int3 = $hex_string % 400;
-my $int4 = $hex_string % 4000;
-my $int5 = $hex_string % 40000;
-my $int6 = $hex_string % 400000;
-my $int7 = $hex_string % 4000000;
-my $int8 = $hex_string % 40000000;
-my $int9 = $hex_string % 40000000;
-my $int10 = $hex_string % 400000000;
-
-my $hit_fresh = int($int10 + $unixtime + $int4);
-my $hit_fresh_process = int($hit_fresh);
-my $hit_revalidated = int(($int10/2) + $unixtime + $int1);
-my $miss_cold = int(($int10/2) + $unixtime + $int3);
-my $miss_not_cacheable = int(($int7/3) + $unixtime + $int1);
-my $miss_changed = int(($unixtime/10000000) + $int1);
-my $miss_client_no_cache = 0;
-my $aborts = int(($unixtime/10000000) + $int2*2);
-my $possible_aborts = 0;
-my $connect_failed = int(($unixtime/1000000) + $int2*4 + $int1*2);
-my $other = int((($unixtime/1000000) + $int3)/100);
-my $unclassified = 0;
-my $write_bytes = int($unixtime*50 + $int4*$int5);
-my $current_client_connections = int($int5*rand());
-my $bytes_used = int($write_bytes/20 + $int2*$int5);
-my $bytes_total = int($bytes_used + $int10);
-my $v1_bytes_used = int($bytes_used);
-my $v1_bytes_total = int($bytes_total);
-my $load_avg_1 = sprintf("%.2f",$unixtime/100000000+(8*rand()));
-my $load_avg_5 = sprintf("%.2f",$load_avg_1 / 2);
-my $load_avg_15 = sprintf("%.2f",$load_avg_1 / 3);
-my $running_procs = int(15*rand($int1));
-my $total_procs = int(2*$running_procs+($int1+2)*2);
-my $last_proc_id = $int5;
-my $proc_loadavg = "$load_avg_1 $load_avg_5 $load_avg_15 $running_procs/$total_procs $last_proc_id";
-my $if_rbytes = int($unixtime*760000000+$bytes_total);
-my $if_rpackets = int($if_rbytes/875);
-my $if_rmcast = int($if_rpackets/$int4);
-my $if_tbytes = int($if_rbytes/1.5);
-my $if_tpackets = int($if_tbytes/1500);
-my $proc_net_dev = $query_params{'inf.name'}. ":$if_rbytes $if_rpackets 0 0 0 0 0 $if_rmcast $if_tbytes $if_tpackets 0 0 0 0 0 0";
-my @ds_bytes;
-my @ds_bytes_in;
-my @ds_200s;
-my @ds_400s;
-my @ds_500s;
-for (my $i=1;$i<10;$i++) {
- my $rand1 = undef;
- $rand1 = rand($int1);
- $ds_bytes[$i] = int($if_tbytes/10 + ($rand1*$rand1));
- $ds_bytes_in[$i] = int($if_rbytes/10 + ($rand1*$rand1));
- $ds_200s[$i] = int($ds_bytes[$i]/9000*0.95);
- $ds_400s[$i] = int($ds_bytes[$i]/9000*0.04);
- $ds_500s[$i] = int($ds_bytes[$i]/9000*0.01);
-}
-$ds_bytes[10] = int($if_tbytes/10 + rand($int1) * rand($int1));
-$ds_bytes_in[10] = int($if_rbytes/10 + rand($int1) * rand($int1));
-$ds_200s[10] = int($ds_bytes[10]/9000*0.95);
-$ds_400s[10] = int($ds_bytes[10]/9000*0.04);
-$ds_500s[10] = int($ds_bytes[10]/9000*0.01);
-
-#proc.net.dev: "bond0:181566812618839 43321349767 0 0 0 0 0 4710035 517574148613675 34658736727 0 0 0 0 0 0"
-
-if (exists $query_params{'application'} ) {
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_fresh"} = $hit_fresh;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_fresh.process"} = $hit_fresh_process;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.hit_revalidated"} = $hit_revalidated;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_cold"} = $miss_cold;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_not_cacheable"} = $miss_not_cacheable;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_changed"} = $miss_changed;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.miss_client_no_cache"} = $miss_client_no_cache;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.aborts"} = $aborts;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.possible_aborts"} = $possible_aborts;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.connect_failed"} = $connect_failed;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.errors.other"} = $other;
- $json_obj->{'ats'}->{"proxy.process.http.transaction_counts.other.unclassified"} = $unclassified;
- $json_obj->{'ats'}->{"proxy.process.net.write_bytes"} = $write_bytes;
- $json_obj->{'ats'}->{"proxy.process.http.current_client_connections"} = $current_client_connections;
- $json_obj->{'ats'}->{"proxy.process.cache.bytes_used"} = $bytes_used;
- $json_obj->{'ats'}->{"proxy.process.cache.bytes_total"} = $bytes_total;
- $json_obj->{'ats'}->{"proxy.process.cache.volume_1.bytes_used"} = $v1_bytes_used;
- $json_obj->{'ats'}->{"proxy.process.cache.volume_1.bytes_total"} = $v1_bytes_total;
- for(my $i=1;$i<10;$i++) {
- my $number = sprintf('%.2d', $i);
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.out_bytes"} = $ds_bytes[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.in_bytes"} = $ds_bytes_in[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_2xx"} = $ds_200s[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_4xx"} = $ds_400s[$i];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_5xx"} = $ds_500s[$i];
- }
- my $number = 10;
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.out_bytes"} = $ds_bytes[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.in_bytes"} = $ds_bytes_in[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_2xx"} = $ds_200s[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_4xx"} = $ds_400s[10];
- $json_obj->{'ats'}->{"plugin.remap_stats." . $server_name . ".omg-" . $number . "$cdn_domain_name.status_5xx"} = $ds_500s[10];
- $json_obj->{'ats'}->{"server"} = "3.3.0-dev";
-}
-$json_obj->{'system'}->{"inf.name"} = $query_params{"inf.name"};
-$json_obj->{'system'}->{"inf.speed"} = "10000";
-$json_obj->{'system'}->{"proc.net.dev"} = $proc_net_dev;
-$json_obj->{'system'}->{"proc.loadavg"} = $proc_loadavg;
-$json_obj->{'system'}->{"something"} = "here";
-
-
-print "Content-type: text/html\n\n";
-print $json->utf8->encode( $json_obj );
-
-
-sub getFormData {
- my $buffer = "";
- my %hash = ();
- my @params = ();
-
- if ($ENV{'REQUEST_METHOD'} eq 'GET') {
- $buffer = $ENV{'QUERY_STRING'};
- $hash{"four"}="two";
- }
- else {
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
- }
- if ($buffer =~ m/\&/) {
- @params = split(/\&/,$buffer);
- }
- else {
- @params = split(/\;/,$buffer);
- }
- foreach my $p (@params) {
- (my $key, my $value) = split(/\=/,$p);
- $hash{$key}=$value;
- }
- return %hash;
-}
diff --git a/test/astats_sim/ats_sim.js b/test/astats_sim/ats_sim.js
deleted file mode 100644
index 8bec582..0000000
--- a/test/astats_sim/ats_sim.js
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-var myip = "127.0.0.1";
-var myport = 80;
-var config_url = "https://traffic-ops.com/CRConfig-Snapshots/cdn-name/CRConfig.json";
-var to_user = "";
-var to_password = "";
-var to_login_api = "/api/1.2/user/login";
-var simulator_ua = "ATS Simulator/node.js " + process.version;
-
-// first argument to follow node ats_sim.js
-if (process.argv[2]) {
- config_url = process.argv[2];
-}
-
-// second argument to follow node ats_sim.js
-if (process.argv[3]) {
- myport = process.argv[3];
-}
-
-if (process.argv[4]) {
- to_user = process.argv[4];
-}
-
-if (process.argv[5]) {
- to_password = process.argv[5];
-}
-
-var to_credentials = JSON.stringify({
- "u": to_user,
- "p": to_password,
-});
-
-var errorRateDenominator = 0;
-var debug = 0;
-
-// https://${tmHostname}/CRConfig-Snapshots/${cdnName}/CRConfig.json
-if (debug) console.log("point traffic_monitor::tm.crConfig.json.polling.url to: " + config_url);
-
-var date = new Date();
-var starttime = date.getTime();
-var timeseed = 1383769987010;
-
-console.log("Started " + date);
-
-var protocol = (/^https/.test(config_url) == true ? "https" : "http");
-var client_http = require(protocol);
-var cr_config = '';
-var tld = '';
-var Url = require('url');
-var stats = new Object();
-var to_url = Url.parse(config_url, true);
-
-process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
-auth_get_config();
-
-function auth_get_config() {
- var to_cookie = "";
- var options = {
- protocol: to_url.protocol,
- hostname: to_url.hostname,
- port: to_url.port,
- path: to_login_api,
- method: 'POST',
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- "Content-Length": Buffer.byteLength(to_credentials),
- "User-Agent": simulator_ua
- }
- };
-
- request = client_http.request(options, function(res) {
- var cookie = res.headers["set-cookie"];
-
- if (cookie) {
- cookie.forEach(
- function (cookieMonster) {
- to_cookie += cookieMonster;
- }
- );
- }
-
- if (to_cookie) {
- if (debug) console.log("Cookie: " + to_cookie);
- }
-
- var body = '';
-
- res.on('data', function(chunk) {
- body += chunk;
- });
-
- res.on('end', function() {
- response = JSON.parse(body);
-
- if (res.statusCode == 200) {
- console.log("Successfully authenticated to Traffic Ops");
- get_config(options, to_cookie);
- } else {
- console.log("Authentication response: " + JSON.stringify(response));
- throw new Error("Authentication failed.");
- }
- });
- }).on('error', function(e) {
- console.log("Got error: ", e);
- });
-
- request.write(to_credentials);
- request.end();
-}
-
-function get_config(options, cookie) {
- options.method = "GET";
- options.path = to_url.path;
- options.headers = {
- "Cookie": cookie,
- "User-Agent": simulator_ua
- };
-
- request = client_http.request(options, function(res) {
- var body = '';
-
- res.on('data', function(chunk) {
- body += chunk;
- });
-
- res.on('end', function() {
- cr_config = JSON.parse(body);
- tld = cr_config.config['domain_name'];
- console.log("CDN TLD: " + tld);
-
- for(var cid in cr_config.contentServers) {
- if(cid.indexOf("atsec-sim")!=-1) {
- cr_config.contentServers[cid].queryIp = myip;
- cr_config.contentServers[cid].port = myport;
- }
- }
-
- cr_config
- });
- }).on('error', function(e) {
- console.log("Got error: ", e);
- });
-
- request.end();
-}
-
-var http = require('http');
-
-http.createServer(function (request, response) {
- if (request.url == "/favicon.ico") {
- response.writeHead(404);
- response.end();
- return;
- }
-
- // https://${tmHostname}/CRConfig-Snapshots/${cdnName}/CRConfig.json
- if (request.url.indexOf("/CRConfig.json") != -1) {
- console.log("Delivering CRConfig.json");
- response.end(JSON.stringify(cr_config, null, 4));
- return;
- }
-
- if (errorRateDenominator && rand(errorRateDenominator) == 1) {
- response.writeHead(404);
- response.end();
- return;
- }
-
- var objToJson = { };
- objToJson.cr_config = cr_config;
- var str = JSON.stringify(getData(request));
- response.writeHead(200, {'Content-Type': 'application/json'});
- response.end(str);
-}).listen(myport);
-
-console.log("HTTP Listener started on port " + myport);
-
-var util = require('util');
-var crypto = require('crypto')
-var shasum = crypto.createHash('sha1');
-
-function rand(n) {
- return Math.floor((Math.random() * n) + 1);
-}
-
-Number.prototype.zeroPad = function(numZeros) {
- var n = Math.abs(this);
- var zeros = Math.max(0, numZeros - n.toString().length);
- var zeroString = Math.pow(10,zeros).toString().substr(1);
- if( this < 0 ) {
- zeroString = '-' + zeroString;
- }
-
- return zeroString+n;
-}
-
-function getData(request) {
- var url_parts = Url.parse(request.url, true);
- var query_params = url_parts.query;
-
- if (!request.headers.host) {
- return;
- }
-
- if (debug) console.log(request.url);
- if (debug) console.log(query_params);
- if (debug) console.log(query_params.a);
-
- var ret = {};
- var d = new Date();
- var n = d.getTime();
- var unixtime = d.getTime();
- var basetime = unixtime - timeseed;
- var server_name = request.headers.host.split(':')[0];
- server_name = server_name.split(".")[0];
- var hex_string = server_name;
- var hex = crypto.createHash('sha1').update(server_name).digest('hex');
- hex = parseInt(hex, 16);
- ret.simulator = 1;
- ret.time = unixtime;
- ret.hex = hex;
- var int1 = hex % 4;
- var int2 = hex % 40;
- var int3 = hex % 400;
- var int4 = hex % 4000;
- var int5 = hex % 40000;
- var int6 = hex % 400000;
- var int7 = hex % 4000000;
- var int8 = hex % 40000000;
- var int9 = hex % 40000000;
- var int10 = hex % 400000000;
-
- var hit_fresh = unixtime / 2;
- var hit_fresh_process = hit_fresh;
- var hit_revalidated = (int10 / 2) + unixtime + int1;
- var miss_cold = (int10 / 2) + unixtime + int3;
- var miss_not_cacheable = (int7 / 3) + unixtime + int1;
- var miss_changed = (unixtime / 10000000) + int1;
- var miss_client_no_cache = 0;
- var aborts = (unixtime / 10000000) + int2 * 2;
- var possible_aborts = 0;
- var connect_failed = (unixtime / 1000000) + int2 * 4 + int1 * 2;
- var other = ((unixtime / 1000000) + int3) / 100;
- var unclassified = 0;
- var write_bytes = unixtime + int4 * int5;
- var current_client_connections = Math.round(int5 * Math.random());
- var bytes_used = write_bytes / 20 + int2 * int5;
- var bytes_total = bytes_used + int10;
- var v1_bytes_used = bytes_used;
- var v1_bytes_total = bytes_total;
- var load_avg_1 = (8 * Math.random()).toFixed(2);
- var load_avg_5 = (load_avg_1 / 2).toFixed(2);
- var load_avg_15 = (load_avg_1 / 3).toFixed(2);
- var running_procs = (15 * rand(int1));
- var total_procs = 2 * running_procs + (int1 + 2) * 2;
- var last_proc_id = int5;
- var proc_loadavg = util.format("%d %d %d %d/%d %d", load_avg_1, load_avg_5, load_avg_15, running_procs, total_procs, last_proc_id);
- var if_rbytes = basetime * 500;
- var if_rpackets = if_rbytes / 875;
- var if_rmcast = if_rpackets / int4;
- var if_tbytes = if_rbytes / 3;
- var if_tpackets = if_tbytes / 1500;
- var proc_net_dev = 'bond0';
-
- if (query_params['inf.name']) {
- proc_net_dev = query_params['inf.name'];
- }
-
- proc_net_dev += util.format(":%d %d 0 0 0 0 0 %d %d %d 0 0 0 0 0 0", if_rbytes.toFixed(0), if_rpackets.toFixed(0), if_rmcast.toFixed(0), if_tbytes.toFixed(0), if_tpackets.toFixed(0));
- var ds_bytes = {};
- var ds_bytes_in = {};
- var ds_200s = {};
- var ds_400s = {};
- var ds_500s = {};
-
- for (var i=1; i<=10; i++) {
- var rand1 = rand(int1);
- ds_bytes[i] = if_tbytes / 10;
- ds_bytes_in[i] = if_rbytes / 10;
- var tps = basetime / 10000;
- ds_200s[i] = tps * 0.95;
- ds_400s[i] = tps * 0.04;
- ds_500s[i] = tps * 0.01;
- }
-
- if (query_params.ds && query_params.p && query_params.v && query_params.m) {
- var these_stats = new Object();
- these_stats.delivery_service = query_params.ds;
- these_stats.parameter = query_params.p;
- these_stats.value = parseInt(query_params.v);
- these_stats.multiplier = parseFloat(query_params.m);
- stats[server_name] = these_stats;
- } else if (query_params.stats == 0) {
- delete stats[server_name];
- }
-
- if (debug) console.log(stats);
-
-// #proc.net.dev: "bond0:181566812618839 43321349767 0 0 0 0 0 4710035 517574148613675 34658736727 0 0 0 0 0 0"
-
- ret.ats = {};
- ret.ats["proxy.process.http.transaction_counts.hit_fresh"] = hit_fresh;
- ret.ats["proxy.process.http.transaction_counts.hit_fresh.process"] = hit_fresh_process;
- ret.ats["proxy.process.http.transaction_counts.hit_revalidated"] = hit_revalidated;
- ret.ats["proxy.process.http.transaction_counts.miss_cold"] = miss_cold;
- ret.ats["proxy.process.http.transaction_counts.miss_not_cacheable"] = miss_not_cacheable;
- ret.ats["proxy.process.http.transaction_counts.miss_changed"] = miss_changed;
- ret.ats["proxy.process.http.transaction_counts.miss_client_no_cache"] = miss_client_no_cache;
- ret.ats["proxy.process.http.transaction_counts.errors.aborts"] = aborts;
- ret.ats["proxy.process.http.transaction_counts.errors.possible_aborts"] = possible_aborts;
- ret.ats["proxy.process.http.transaction_counts.errors.connect_failed"] = connect_failed;
- ret.ats["proxy.process.http.transaction_counts.errors.other"] = other;
- ret.ats["proxy.process.http.transaction_counts.other.unclassified"] = unclassified;
- ret.ats["proxy.process.net.write_bytes"] = write_bytes;
- ret.ats["proxy.process.http.current_client_connections"] = current_client_connections;
- ret.ats["proxy.process.cache.bytes_used"] = bytes_used;
- ret.ats["proxy.process.cache.bytes_total"] = bytes_total;
- ret.ats["proxy.process.cache.volume_1.bytes_used"] = v1_bytes_used;
- ret.ats["proxy.process.cache.volume_1.bytes_total"] = v1_bytes_total;
-
- if (cr_config && cr_config.contentServers && server_name in cr_config.contentServers) {
- if (debug) console.log("Attempting to build stats for " + server_name);
-
- for (var delivery_service in cr_config.contentServers[server_name]['deliveryServices']) {
- var data = new Object();
- data['out_bytes'] = ds_bytes[rand(10)].toFixed(0);
- data['in_bytes'] = ds_bytes_in[rand(10)].toFixed(0);
- data['status_2xx'] = ds_200s[rand(10)].toFixed(0);
- data['status_4xx'] = ds_400s[rand(10)].toFixed(0);
- data['status_5xx'] = ds_500s[rand(10)].toFixed(0);
-
- var n = i.zeroPad(2);
- var ds_fqdn = cr_config.contentServers[server_name]['deliveryServices'][delivery_service][0];
-
- if (stats.hasOwnProperty(server_name) && stats[server_name].hasOwnProperty("delivery_service")) {
- var ds_tld = ds_fqdn.substring(ds_fqdn.indexOf(".") + 1);
-
- if (stats[server_name].delivery_service == ds_tld && stats[server_name].parameter in data) {
- var this_request = parseInt(d.getTime());
-
- if (stats[server_name].hasOwnProperty("last_request") && stats[server_name].hasOwnProperty("last_value")) {
- /*
- I'm requiring bignum here to ensure that it's only required when running bandwidth simulations
- if you need to install it:
- npm install bignum
- ..which will install it locally.. to install it globally add -g to the command
- if you have problems loading it due to where you're running ats_sim.js:
- export NODE_PATH=/path/to/the/node_modules
- For example:
- export NODE_PATH=/usr/local/lib/node_modules
- ..and the bignum directory is under /usr/local/lib/node/modules
- See: https://npmjs.org/package/bignum
- ..and: http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
- */
- var bignum = require('bignum');
- var max = bignum(18446744073709551615); // uint64 max
- var seconds_elapsed = Math.ceil((this_request - stats[server_name].last_request) / 1000); // convert to seconds and round up
- var last_value = bignum(stats[server_name].last_value);
- var current_value = bignum(stats[server_name].value * seconds_elapsed * stats[server_name].multiplier).add(last_value);
-
- if (debug) console.log(seconds_elapsed + " second(s) elapsed since the last request");
-
- if (current_value.cmp(max) > 0) {
- if (debug) console.log("Accounting for uint64 rollover; " + current_value.toString() + " > " + max.toString());
- current_value = current_value.sub(max);
- }
-
- if (debug) console.log("Overriding " + ds_tld + "'s " + stats[server_name].parameter + " with " + current_value.toString());
- data[stats[server_name].parameter] = current_value.toString(); // we'll reconvert this to a bignum next time through
- }
-
- stats[server_name].last_value = data[stats[server_name].parameter];
- stats[server_name].last_request = this_request;
- } else {
- if (debug) console.log("Unable to find " + stats[server_name].parameter + " for " + ds_tld);
- }
- }
-
- for (var key in data) {
- ret.ats["plugin.remap_stats." + ds_fqdn + "." + key] = parseInt(data[key]);
- }
- }
- } else {
- if (debug) console.log(server_name + " was not found in cr_config; returning default stats");
-
- for(var i=1; i<=10; i++) {
- var n = i.zeroPad(2);
- ret.ats["plugin.remap_stats." + server_name + ".omg-" + n + tld+ ".out_bytes"] = parseInt(ds_bytes[i].toFixed(0));
- ret.ats["plugin.remap_stats." + server_name + ".omg-" + n + tld+ ".in_bytes"] = parseInt(ds_bytes_in[i].toFixed(0));
- ret.ats["plugin.remap_stats." + server_name + ".omg-" + n + tld+ ".status_2xx"] = parseInt(ds_200s[i].toFixed(0));
- ret.ats["plugin.remap_stats." + server_name + ".omg-" + n + tld+ ".status_4xx"] = parseInt(ds_400s[i].toFixed(0));
- ret.ats["plugin.remap_stats." + server_name + ".omg-" + n + tld+ ".status_5xx"] = parseInt(ds_500s[i].toFixed(0));
- }
- }
-
- ret.ats["server"] = "5.3.2-dev";
-
- ret.system = {};
- ret.system["inf.name"] = query_params["inf.name"];
- ret.system["inf.speed"] = 10000;
- ret.system["proc.net.dev"] = proc_net_dev;
- ret.system["proc.loadavg"] = proc_loadavg;
- ret.system["something"] = "here";
-
- return ret;
-}
diff --git a/traffic_monitor_java/.classpath b/traffic_monitor_java/.classpath
deleted file mode 100644
index 43faee8..0000000
--- a/traffic_monitor_java/.classpath
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java">
- <attributes>
- <attribute name="optional" value="true"/>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
diff --git a/traffic_monitor_java/.gitignore b/traffic_monitor_java/.gitignore
deleted file mode 100644
index 10fed50..0000000
--- a/traffic_monitor_java/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-/target/
-/.settings/
-/bin
-overlays
diff --git a/traffic_monitor_java/.pmd b/traffic_monitor_java/.pmd
deleted file mode 100644
index 5843195..0000000
--- a/traffic_monitor_java/.pmd
+++ /dev/null
@@ -1,1262 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<pmd>
- <useProjectRuleSet>false</useProjectRuleSet>
- <ruleSetFile>.ruleset</ruleSetFile>
- <rules>
- <rule>
- <name>CallSuperFirst</name>
- <ruleset>Android</ruleset>
- </rule>
- <rule>
- <name>CallSuperLast</name>
- <ruleset>Android</ruleset>
- </rule>
- <rule>
- <name>DoNotHardCodeSDCard</name>
- <ruleset>Android</ruleset>
- </rule>
- <rule>
- <name>AvoidBranchingStatementAsLastInLoop</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AvoidDecimalLiteralsInBigDecimalConstructor</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AvoidMultipleUnaryOperators</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AvoidThreadGroup</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AvoidUsingHardCodedIP</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AvoidUsingOctalValues</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>BigIntegerInstantiation</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>BooleanInstantiation</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>BrokenNullCheck</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>CheckResultSet</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>CheckSkipResult</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>ClassCastExceptionWithToArray</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>CollapsibleIfStatements</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>DontCallThreadRun</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>DontUseFloatTypeForLoopIndices</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>DoubleCheckedLocking</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>ExtendsObject</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>ForLoopShouldBeWhileLoop</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>JumbledIncrementer</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>MisplacedNullCheck</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>OverrideBothEqualsAndHashcode</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>ReturnFromFinallyBlock</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>UnconditionalIfStatement</name>
- <ruleset>Basic</ruleset>
- </rule>
- <rule>
- <name>AssignmentInOperand</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidTrailingComma</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>ConsistentReturn</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>EqualComparison</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>GlobalVariable</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>InnaccurateNumericLiteral</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>ScopeForInVariable</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>UnreachableCode</name>
- <ruleset>Basic Ecmascript</ruleset>
- </rule>
- <rule>
- <name>DontNestJsfInJstlIteration</name>
- <ruleset>Basic JSF</ruleset>
- </rule>
- <rule>
- <name>DuplicateJspImports</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>IframeMissingSrcAttribute</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>JspEncoding</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoClassAttribute</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoHtmlComments</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoInlineScript</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoInlineStyleInformation</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoJspForward</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoLongScripts</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>NoScriptlets</name>
- <ruleset>Basic JSP</ruleset>
- </rule>
- <rule>
- <name>MistypedCDATASection</name>
- <ruleset>Basic XML</ruleset>
- </rule>
- <rule>
- <name>ForLoopsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>ForLoopsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>IfElseStmtsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>IfElseStmtsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>IfStmtsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>IfStmtsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>WhileLoopsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>WhileLoopsMustUseBraces</name>
- <ruleset>Braces</ruleset>
- </rule>
- <rule>
- <name>CloneMethodMustImplementCloneable</name>
- <ruleset>Clone Implementation</ruleset>
- </rule>
- <rule>
- <name>CloneThrowsCloneNotSupportedException</name>
- <ruleset>Clone Implementation</ruleset>
- </rule>
- <rule>
- <name>ProperCloneImplementation</name>
- <ruleset>Clone Implementation</ruleset>
- </rule>
- <rule>
- <name>CyclomaticComplexity</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>ExcessiveClassLength</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>ExcessiveMethodLength</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>ExcessiveParameterList</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>ExcessivePublicCount</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>NcssConstructorCount</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>NcssMethodCount</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>NcssTypeCount</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>NPathComplexity</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>TooManyFields</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>TooManyMethods</name>
- <ruleset>Code Size</ruleset>
- </rule>
- <rule>
- <name>CommentContent</name>
- <ruleset>Comments</ruleset>
- </rule>
- <rule>
- <name>CommentRequired</name>
- <ruleset>Comments</ruleset>
- </rule>
- <rule>
- <name>CommentSize</name>
- <ruleset>Comments</ruleset>
- </rule>
- <rule>
- <name>AssignmentInOperand</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AtLeastOneConstructor</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidAccessibilityAlteration</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidFinalLocalVariable</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidLiteralsInIfCondition</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidPrefixingMethodParameters</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidUsingNativeCode</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidUsingShortType</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>AvoidUsingVolatile</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>BooleanInversion</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>CallSuperInConstructor</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>DataflowAnomalyAnalysis</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>DefaultPackage</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>DoNotCallGarbageCollectionExplicitly</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>DontImportSun</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>NullAssignment</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>OneDeclarationPerLine</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>OnlyOneReturn</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>SuspiciousOctalEscape</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryConstructor</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryParentheses</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>UseConcurrentHashMap</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>UseObjectForClearerAPI</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>CouplingBetweenObjects</name>
- <ruleset>Coupling</ruleset>
- </rule>
- <rule>
- <name>ExcessiveImports</name>
- <ruleset>Coupling</ruleset>
- </rule>
- <rule>
- <name>LawOfDemeter</name>
- <ruleset>Coupling</ruleset>
- </rule>
- <rule>
- <name>LooseCoupling</name>
- <ruleset>Coupling</ruleset>
- </rule>
- <rule>
- <name>LoosePackageCoupling</name>
- <ruleset>Coupling</ruleset>
- </rule>
- <rule>
- <name>AbstractClassWithoutAbstractMethod</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AbstractClassWithoutAnyMethod</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AccessorClassGeneration</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AssignmentToNonFinalStatic</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidConstantsInterface</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidDeeplyNestedIfStmts</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidInstanceofChecksInCatchClause</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidProtectedFieldInFinalClass</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidReassigningParameters</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>AvoidSynchronizedAtMethodLevel</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>BadComparison</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>ClassWithOnlyPrivateConstructorsShouldBeFinal</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>CloseResource</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>CompareObjectsWithEquals</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>ConfusingTernary</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>ConstructorCallsOverridableMethod</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>DefaultLabelNotLastInSwitchStmt</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>EmptyMethodInAbstractClassShouldBeAbstract</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>EqualsNull</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>FieldDeclarationsShouldBeAtStartOfClass</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>FinalFieldCouldBeStatic</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>GodClass</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>IdempotentOperations</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>ImmutableField</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>InstantiationToGetClass</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>LogicInversion</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>MissingBreakInSwitch</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>MissingStaticMethodInNonInstantiatableClass</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>NonCaseLabelInSwitchStatement</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>NonStaticInitializer</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>NonThreadSafeSingleton</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>OptimizableToArrayCall</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>PositionLiteralsFirstInComparisons</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>PreserveStackTrace</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>ReturnEmptyArrayRatherThanNull</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SimpleDateFormatNeedsLocale</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SimplifyBooleanExpressions</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SimplifyBooleanReturns</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SimplifyConditional</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SingularField</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SwitchDensity</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>SwitchStmtsShouldHaveDefault</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>TooFewBranchesForASwitchStatement</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UncommentedEmptyConstructor</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UncommentedEmptyMethod</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryLocalBeforeReturn</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UnsynchronizedStaticDateFormatter</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UseCollectionIsEmpty</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UseLocaleWithCaseConversions</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UseNotifyAllInsteadOfNotify</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UseSingleton</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>UseVarargs</name>
- <ruleset>Design</ruleset>
- </rule>
- <rule>
- <name>EmptyCatchBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyCatchBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyFinallyBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyFinallyBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyIfStmt</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyIfStmt</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyInitializer</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyInitializer</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStatementBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStatementBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStatementNotInLoop</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStatementNotInLoop</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStaticInitializer</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyStaticInitializer</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptySwitchStatements</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptySwitchStatements</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptySynchronizedBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptySynchronizedBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyTryBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyTryBlock</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyWhileStmt</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>EmptyWhileStmt</name>
- <ruleset>Empty Code</ruleset>
- </rule>
- <rule>
- <name>AvoidCallingFinalize</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>EmptyFinalizer</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>FinalizeDoesNotCallSuperFinalize</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>FinalizeOnlyCallsSuperFinalize</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>FinalizeOverloaded</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>FinalizeShouldBeProtected</name>
- <ruleset>Finalizer</ruleset>
- </rule>
- <rule>
- <name>DontImportJavaLang</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>DuplicateImports</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>ImportFromSamePackage</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>TooManyStaticImports</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryFullyQualifiedName</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>UnusedImports</name>
- <ruleset>Import Statements</ruleset>
- </rule>
- <rule>
- <name>DoNotCallSystemExit</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>DoNotUseThreads</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>LocalHomeNamingConvention</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>LocalInterfaceSessionNamingConvention</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>MDBAndSessionBeanNamingConvention</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>RemoteInterfaceNamingConvention</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>RemoteSessionInterfaceNamingConvention</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>StaticEJBFieldShouldBeFinal</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>UseProperClassLoader</name>
- <ruleset>J2EE</ruleset>
- </rule>
- <rule>
- <name>GuardDebugLogging</name>
- <ruleset>Jakarta Commons Logging</ruleset>
- </rule>
- <rule>
- <name>ProperLogger</name>
- <ruleset>Jakarta Commons Logging</ruleset>
- </rule>
- <rule>
- <name>UseCorrectExceptionLogging</name>
- <ruleset>Jakarta Commons Logging</ruleset>
- </rule>
- <rule>
- <name>AvoidPrintStackTrace</name>
- <ruleset>Java Logging</ruleset>
- </rule>
- <rule>
- <name>LoggerIsNotStaticFinal</name>
- <ruleset>Java Logging</ruleset>
- </rule>
- <rule>
- <name>MoreThanOneLogger</name>
- <ruleset>Java Logging</ruleset>
- </rule>
- <rule>
- <name>SystemPrintln</name>
- <ruleset>Java Logging</ruleset>
- </rule>
- <rule>
- <name>BeanMembersShouldSerialize</name>
- <ruleset>JavaBeans</ruleset>
- </rule>
- <rule>
- <name>MissingSerialVersionUID</name>
- <ruleset>JavaBeans</ruleset>
- </rule>
- <rule>
- <name>JUnitAssertionsShouldIncludeMessage</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>JUnitSpelling</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>JUnitStaticSuite</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>JUnitTestContainsTooManyAsserts</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>JUnitTestsShouldIncludeAssert</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>SimplifyBooleanAssertion</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>TestClassWithoutTestCases</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryBooleanAssertion</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>UseAssertEqualsInsteadOfAssertTrue</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>UseAssertNullInsteadOfAssertTrue</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>UseAssertSameInsteadOfAssertTrue</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>UseAssertTrueInsteadOfAssertEquals</name>
- <ruleset>JUnit</ruleset>
- </rule>
- <rule>
- <name>AvoidAssertAsIdentifier</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>AvoidEnumAsIdentifier</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>ByteInstantiation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>IntegerInstantiation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>JUnit4SuitesShouldUseSuiteAnnotation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>JUnit4TestShouldUseAfterAnnotation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>JUnit4TestShouldUseBeforeAnnotation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>JUnit4TestShouldUseTestAnnotation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>JUnitUseExpected</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>LongInstantiation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>ReplaceEnumerationWithIterator</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>ReplaceHashtableWithMap</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>ReplaceVectorWithList</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>ShortInstantiation</name>
- <ruleset>Migration</ruleset>
- </rule>
- <rule>
- <name>AbstractNaming</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>AvoidDollarSigns</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>AvoidFieldNameMatchingMethodName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>AvoidFieldNameMatchingTypeName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>BooleanGetMethodName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>ClassNamingConventions</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>GenericsNaming</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>LongVariable</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>MethodNamingConventions</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>MethodWithSameNameAsEnclosingClass</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>MisleadingVariableName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>NoPackage</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>PackageCase</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>ShortClassName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>ShortMethodName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>ShortVariable</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>SuspiciousConstantFieldName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>SuspiciousEqualsMethodName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>SuspiciousHashcodeMethodName</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>VariableNamingConventions</name>
- <ruleset>Naming</ruleset>
- </rule>
- <rule>
- <name>AddEmptyString</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>AvoidArrayLoops</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>AvoidInstantiatingObjectsInLoops</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>LocalVariableCouldBeFinal</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>MethodArgumentCouldBeFinal</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>PrematureDeclaration</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>RedundantFieldInitializer</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>SimplifyStartsWith</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryWrapperObjectCreation</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>UseArrayListInsteadOfVector</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>UseArraysAsList</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>UseStringBufferForStringAppends</name>
- <ruleset>Optimization</ruleset>
- </rule>
- <rule>
- <name>ArrayIsStoredDirectly</name>
- <ruleset>Security Code Guidelines</ruleset>
- </rule>
- <rule>
- <name>MethodReturnsInternalArray</name>
- <ruleset>Security Code Guidelines</ruleset>
- </rule>
- <rule>
- <name>AvoidCatchingGenericException</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidCatchingNPE</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidCatchingThrowable</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidLosingExceptionInformation</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidRethrowingException</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidThrowingNewInstanceOfSameException</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidThrowingNullPointerException</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AvoidThrowingRawExceptionTypes</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>DoNotExtendJavaLangError</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>DoNotThrowExceptionInFinally</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>ExceptionAsFlowControl</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>SignatureDeclareThrowsException</name>
- <ruleset>Strict Exceptions</ruleset>
- </rule>
- <rule>
- <name>AppendCharacterWithChar</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>AvoidDuplicateLiterals</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>AvoidStringBufferField</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>ConsecutiveLiteralAppends</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>InefficientEmptyStringCheck</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>InefficientStringBuffering</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>InsufficientStringBufferDeclaration</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>StringBufferInstantiationWithChar</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>StringInstantiation</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>StringToString</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryCaseChange</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UseEqualsToCompareStrings</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UseIndexOfChar</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UselessStringValueOf</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UseStringBufferLength</name>
- <ruleset>String and StringBuffer</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryBlock</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryConversionTemporary</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryConversionTemporary</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryFinalModifier</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryFinalModifier</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryParentheses</name>
- <ruleset>Controversial</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryReturn</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnnecessaryReturn</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnusedNullCheckInEquals</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnusedNullCheckInEquals</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessOperationOnImmutable</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessOperationOnImmutable</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessOverridingMethod</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessOverridingMethod</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessParentheses</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UselessParentheses</name>
- <ruleset>Unnecessary</ruleset>
- </rule>
- <rule>
- <name>UnusedFormalParameter</name>
- <ruleset>Unused Code</ruleset>
- </rule>
- <rule>
- <name>UnusedLocalVariable</name>
- <ruleset>Unused Code</ruleset>
- </rule>
- <rule>
- <name>UnusedModifier</name>
- <ruleset>Unused Code</ruleset>
- </rule>
- <rule>
- <name>UnusedPrivateField</name>
- <ruleset>Unused Code</ruleset>
- </rule>
- <rule>
- <name>UnusedPrivateMethod</name>
- <ruleset>Unused Code</ruleset>
- </rule>
- <rule>
- <name>AvoidAxisNavigation</name>
- <ruleset>XPath in XSL</ruleset>
- </rule>
- <rule>
- <name>UseConcatOnce</name>
- <ruleset>XPath in XSL</ruleset>
- </rule>
- </rules>
- <includeDerivedFiles>false</includeDerivedFiles>
- <violationsAsErrors>true</violationsAsErrors>
- <fullBuildEnabled>true</fullBuildEnabled>
-</pmd>
diff --git a/traffic_monitor_java/.project b/traffic_monitor_java/.project
deleted file mode 100644
index ac24bb3..0000000
--- a/traffic_monitor_java/.project
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>traffic_monitor</name>
- <comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- </natures>
-</projectDescription>
diff --git a/traffic_monitor_java/README.md b/traffic_monitor_java/README.md
deleted file mode 100644
index b08093e..0000000
--- a/traffic_monitor_java/README.md
+++ /dev/null
@@ -1,40 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you 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
-
-### Why Tests are not in exactly matching packages
-
-The "com.comcast.cdn.traffic_control.traffic_monitor" portion of the package name was omitted from unit
-tests to prevent improper referencing of package private fields and methods of the code under test.
-
-### Running Traffic Monitor locally
-
-The "com.comcast.cdn.traffic_control.traffic_monitor.Start" class allows one to run Traffic Monitor
-locally provided that necessary configuration is in place. By default, the files are specified
-with paths relevant to certain IDEs, but these paths can be changed by specifying different
-properties via System.properties. These properties are:
-
-* traffic_monitor.path.config
-* traffic_monitor.path.db
-
-The first property refers to the location of traffic_monitor_config.js. The second property
-refers to the directory that will be used for certain data files that are downloaded at runtime.
-If you need to specify a different path, use the -D option to the Java command, or modify the
-paths in the Start class directly.
diff --git a/traffic_monitor_java/build/build_rpm.sh b/traffic_monitor_java/build/build_rpm.sh
deleted file mode 100755
index cb14028..0000000
--- a/traffic_monitor_java/build/build_rpm.sh
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/bin/bash
-
-#
-#
-# 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.
-#
-
-#----------------------------------------
-function importFunctions() {
- echo "Verifying the build configuration environment."
- local script=$(readlink -f "$0")
- local scriptdir=$(dirname "$script")
- export TM_DIR=$(dirname "$scriptdir")
- export TC_DIR=$(dirname "$TM_DIR")
- functions_sh="$TC_DIR/build/functions.sh"
- if [[ ! -r $functions_sh ]]; then
- echo "Error: Can't find $functions_sh"
- exit 1
- fi
- . "$functions_sh"
-}
-
-#----------------------------------------
-function buildRpmTrafficMonitor () {
- echo "Building the rpm."
-
- cd "$TM_DIR" || { echo "Could not cd to $TM_DIR: $?"; exit 1; }
- export TRAFFIC_CONTROL_VERSION="$TC_VERSION"
- export GIT_REV_COUNT=$(getRevCount)
- mvn clean package || { echo "RPM BUILD FAILED: $?"; exit 1; }
-
- local rpm=$(find -name \*.rpm)
- if [[ -z $rpm ]]; then
- echo "Could not find rpm file $RPM in $(pwd)"
- exit 1;
- fi
- echo
- echo "========================================================================================"
- echo "RPM BUILD SUCCEEDED, See $DIST/$RPM for the newly built rpm."
- echo "========================================================================================"
- echo
- mkdir -p "$DIST" || { echo "Could not create $DIST: $?"; exit 1; }
-
- cp "$rpm" "$DIST/." || { echo "Could not copy $RPM to $DIST: $?"; exit 1; }
-}
-
-# ---------------------------------------
-function initBuildArea() {
- echo "Initializing the build area."
- mkdir -p "$RPMBUILD"/{SPECS,SOURCES,RPMS,SRPMS,BUILD,BUILDROOT} || { echo "Could not create $RPMBUILD: $?"; exit 1; }
-
- tm_dest=$(createSourceDir traffic_monitor)
-
- export TRAFFIC_CONTROL_VERSION="$TC_VERSION"
- local mvn_cmd="mvn versions:set -DnewVersion=$TRAFFIC_CONTROL_VERSION"
- echo $mvn_cmd
- (cd "$TM_DIR"; $mvn_cmd)
- cp -r "$TM_DIR"/{build,etc,src} "$tm_dest"/. || { echo "Could not copy to $tm_dest: $?"; exit 1; }
- cp "$TM_DIR"/pom.xml "$tm_dest" || { echo "Could not copy to $tm_dest: $?"; exit 1; }
-
- tar -czf "$tm_dest.tgz" -C "$RPMBUILD"/SOURCES $(basename "$tm_dest") || { echo "Could not create tar archive $tm_dest.tgz: $?"; exit 1; }
-
- echo "The build area has been initialized."
-}
-
-# ---------------------------------------
-
-importFunctions
-checkEnvironment
-initBuildArea
-buildRpmTrafficMonitor
diff --git a/traffic_monitor_java/build/pmd/ruleset.xml b/traffic_monitor_java/build/pmd/ruleset.xml
deleted file mode 100644
index 6f5ad95..0000000
--- a/traffic_monitor_java/build/pmd/ruleset.xml
+++ /dev/null
@@ -1,210 +0,0 @@
-<?xml version="1.0"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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.
--->
-
-<ruleset name="Overpass PMD Ruleset" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
- <description>Overpass PMD Ruleset</description>
-
- <exclude-pattern>.*/src/test/.*</exclude-pattern>
-
- <rule ref="rulesets/basic.xml/EmptyCatchBlock" />
- <rule ref="rulesets/basic.xml/EmptyIfStmt" />
- <rule ref="rulesets/basic.xml/EmptyWhileStmt" />
- <rule ref="rulesets/basic.xml/EmptyTryBlock" />
- <rule ref="rulesets/basic.xml/EmptyFinallyBlock" />
- <rule ref="rulesets/basic.xml/EmptySwitchStatements" />
- <rule ref="rulesets/basic.xml/JumbledIncrementer" />
- <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop" />
- <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary" />
- <rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode" />
- <rule ref="rulesets/basic.xml/DoubleCheckedLocking"
- message="Verify that the double-checked variable is declared as volatile.">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock" />
- <rule ref="rulesets/basic.xml/EmptySynchronizedBlock" />
- <rule ref="rulesets/basic.xml/UnnecessaryReturn" />
- <rule ref="rulesets/basic.xml/EmptyStaticInitializer" />
- <rule ref="rulesets/basic.xml/UnconditionalIfStatement" />
- <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop" />
- <rule ref="rulesets/basic.xml/BooleanInstantiation" />
- <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier" />
- <rule ref="rulesets/basic.xml/CollapsibleIfStatements" />
- <rule ref="rulesets/basic.xml/UselessOverridingMethod" />
- <rule ref="rulesets/basic.xml/ClassCastExceptionWithToArray" />
- <rule ref="rulesets/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
- <rule ref="rulesets/basic.xml/UselessOperationOnImmutable" />
- <rule ref="rulesets/basic.xml/MisplacedNullCheck" />
- <rule ref="rulesets/basic.xml/UnusedNullCheckInEquals" />
- <rule ref="rulesets/basic.xml/AvoidThreadGroup" />
- <rule ref="rulesets/basic.xml/BrokenNullCheck" />
- <rule ref="rulesets/basic.xml/BigIntegerInstantiation" />
- <rule ref="rulesets/basic.xml/AvoidUsingOctalValues" />
- <rule ref="rulesets/basic.xml/AvoidUsingHardCodedIP" />
- <rule ref="rulesets/basic.xml/CheckResultSet" />
- <rule ref="rulesets/basic.xml/AvoidMultipleUnaryOperators" />
- <rule ref="rulesets/basic.xml/EmptyInitializer" />
-
- <rule ref="rulesets/braces.xml/IfStmtsMustUseBraces" />
- <rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces" />
- <rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces" />
- <rule ref="rulesets/braces.xml/ForLoopsMustUseBraces" />
-
- <rule ref="rulesets/clone.xml/ProperCloneImplementation" />
- <rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException" />
- <rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable" />
-
- <rule ref="rulesets/codesize.xml/NPathComplexity" />
- <rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
- <rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
- <rule ref="rulesets/codesize.xml/ExcessivePublicCount" />
- <rule ref="rulesets/codesize.xml/TooManyFields" />
- <rule ref="rulesets/codesize.xml/NcssMethodCount" />
- <rule ref="rulesets/codesize.xml/NcssTypeCount" />
- <rule ref="rulesets/codesize.xml/NcssConstructorCount" />
-
- <rule ref="rulesets/controversial.xml/DontImportSun" />
- <rule ref="rulesets/controversial.xml/SuspiciousOctalEscape" />
- <rule ref="rulesets/controversial.xml/AvoidUsingNativeCode" />
- <rule ref="rulesets/controversial.xml/AvoidAccessibilityAlteration" />
- <rule ref="rulesets/controversial.xml/DoNotCallGarbageCollectionExplicitly" />
-
- <rule ref="rulesets/coupling.xml/LooseCoupling" />
-
- <rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts" />
- <rule ref="rulesets/design.xml/AvoidReassigningParameters" >
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/design.xml/SwitchDensity" />
- <rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod" />
- <rule ref="rulesets/design.xml/AccessorClassGeneration" />
- <rule ref="rulesets/design.xml/FinalFieldCouldBeStatic" />
- <rule ref="rulesets/design.xml/CloseResource" />
- <rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt" />
- <rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement" />
- <rule ref="rulesets/design.xml/OptimizableToArrayCall" />
- <rule ref="rulesets/design.xml/BadComparison" />
- <rule ref="rulesets/design.xml/EqualsNull" />
- <rule ref="rulesets/design.xml/InstantiationToGetClass" />
- <rule ref="rulesets/design.xml/IdempotentOperations" />
- <rule ref="rulesets/design.xml/ImmutableField" />
- <rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass" />
- <rule ref="rulesets/design.xml/AssignmentToNonFinalStatic" />
- <rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass" />
- <rule ref="rulesets/design.xml/MissingBreakInSwitch" />
- <rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify" />
- <rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause" />
- <rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod" />
- <rule ref="rulesets/design.xml/SimplifyConditional" />
- <rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons" />
- <rule ref="rulesets/design.xml/NonThreadSafeSingleton" />
- <rule ref="rulesets/design.xml/UnsynchronizedStaticDateFormatter" />
- <rule ref="rulesets/design.xml/PreserveStackTrace" />
- <rule ref="rulesets/design.xml/UseCollectionIsEmpty" />
- <rule ref="rulesets/design.xml/ClassWithOnlyPrivateConstructorsShouldBeFinal" />
- <rule ref="rulesets/design.xml/SingularField" />
- <rule ref="rulesets/design.xml/AbstractClassWithoutAnyMethod" />
-
- <rule ref="rulesets/finalizers.xml/EmptyFinalizer" />
- <rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize" />
- <rule ref="rulesets/finalizers.xml/FinalizeOverloaded" />
- <rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize" />
- <rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected" />
- <rule ref="rulesets/finalizers.xml/AvoidCallingFinalize" />
-
- <rule ref="rulesets/imports.xml/DuplicateImports" />
- <rule ref="rulesets/imports.xml/DontImportJavaLang" />
- <rule ref="rulesets/imports.xml/UnusedImports" />
- <rule ref="rulesets/imports.xml/ImportFromSamePackage" />
- <rule ref="rulesets/imports.xml/TooManyStaticImports" />
-
- <rule ref="rulesets/javabeans.xml/MissingSerialVersionUID" />
-
- <rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal" />
- <rule ref="rulesets/logging-java.xml/SystemPrintln" />
- <rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace" />
-
- <rule ref="rulesets/naming.xml/LongVariable">
- <properties>
- <property name="minimum" value="30" />
- </properties>
- </rule>
- <rule ref="rulesets/naming.xml/ShortMethodName" />
- <rule ref="rulesets/naming.xml/MethodNamingConventions" />
- <rule ref="rulesets/naming.xml/ClassNamingConventions" />
- <rule ref="rulesets/naming.xml/AbstractNaming" />
- <rule ref="rulesets/naming.xml/AvoidDollarSigns" />
- <rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass" />
- <rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName" />
- <rule ref="rulesets/naming.xml/SuspiciousConstantFieldName" />
- <rule ref="rulesets/naming.xml/SuspiciousEqualsMethodName" />
- <rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName" />
- <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName" />-->
- <rule ref="rulesets/naming.xml/NoPackage" />
- <rule ref="rulesets/naming.xml/PackageCase" />
- <rule ref="rulesets/naming.xml/MisleadingVariableName" />
- <rule ref="rulesets/naming.xml/BooleanGetMethodName" />
-
- <rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal" />
- <rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal" />
- <rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector" />
- <rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends" />
- <rule ref="rulesets/optimizations.xml/UseArraysAsList" />
- <rule ref="rulesets/optimizations.xml/AvoidArrayLoops" />
- <rule ref="rulesets/optimizations.xml/UnnecessaryWrapperObjectCreation" />
- <rule ref="rulesets/optimizations.xml/AddEmptyString" />
-
- <rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable" />
- <rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException" />
- <rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl" />
- <rule ref="rulesets/strictexception.xml/AvoidCatchingNPE" />
- <rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes" />
- <rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException" />
- <rule ref="rulesets/strictexception.xml/AvoidRethrowingException" />
- <rule ref="rulesets/strictexception.xml/DoNotExtendJavaLangError" />
- <rule ref="rulesets/strictexception.xml/DoNotThrowExceptionInFinally" />
- <rule ref="rulesets/strictexception.xml/AvoidThrowingNewInstanceOfSameException" />
-
- <rule ref="rulesets/strings.xml/AvoidDuplicateLiterals">
- <properties>
- <property name="threshold" value="4" />
- <property name="skipAnnotations" value="true" />
- </properties>
- </rule>
- <rule ref="rulesets/strings.xml/StringInstantiation" />
- <rule ref="rulesets/strings.xml/StringToString" />
- <rule ref="rulesets/strings.xml/InefficientStringBuffering" />
- <rule ref="rulesets/strings.xml/UnnecessaryCaseChange" />
- <rule ref="rulesets/strings.xml/UseStringBufferLength" />
- <rule ref="rulesets/strings.xml/AppendCharacterWithChar" />
- <rule ref="rulesets/strings.xml/ConsecutiveLiteralAppends" />
- <rule ref="rulesets/strings.xml/UseIndexOfChar" />
- <rule ref="rulesets/strings.xml/UselessStringValueOf" />
- <rule ref="rulesets/strings.xml/StringBufferInstantiationWithChar" />
- <rule ref="rulesets/strings.xml/UseEqualsToCompareStrings" />
-
- <rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
- <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
- <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
- <rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
-
-</ruleset>
diff --git a/traffic_monitor_java/pom.xml b/traffic_monitor_java/pom.xml
deleted file mode 100644
index 1ac2214..0000000
--- a/traffic_monitor_java/pom.xml
+++ /dev/null
@@ -1,518 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.comcast.cdn.traffic_control</groupId>
- <artifactId>traffic_monitor</artifactId>
- <version>2.2.0</version>
- <packaging>war</packaging>
-
- <scm>
- <connection>scm:git:file://</connection>
- <developerConnection>scm:git:file://</developerConnection>
- </scm>
-
- <properties>
- <deploy.dir>/opt/traffic_monitor</deploy.dir>
- <wicket.version>6.0.0</wicket.version>
- <jetty.version>7.6.3.v20120416</jetty.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-core</artifactId>
- <version>${wicket.version}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.6.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.16</version>
- </dependency>
-
- <!-- JETTY DEPENDENCIES FOR TESTING -->
- <dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-all-server</artifactId>
- <version>${jetty.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-datetime</artifactId>
- <version>6.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-examples</artifactId>
- <version>6.0.0</version>
- <type>war</type>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-examples-war</artifactId>
- <version>0.2</version>
- <classifier>test-sources</classifier>
- <exclusions>
- <exclusion>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-atmosphere</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.wicket</groupId>
- <artifactId>wicket-spring</artifactId>
- <version>6.0.0</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.6</version>
- </dependency>
- <dependency>
- <groupId>com.ning</groupId>
- <artifactId>async-http-client</artifactId>
- <version>1.7.17</version>
- </dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-all</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
- <!-- JUNIT DEPENDENCY FOR TESTING -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito</artifactId>
- <version>1.6.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-module-junit4</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <finalName>ROOT</finalName>
- <resources>
- <resource>
- <filtering>false</filtering>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <filtering>true</filtering>
- <directory>src/main/resources</directory>
- <includes>
- <include>**/*.prop</include>
- </includes>
- </resource>
- <resource>
- <filtering>false</filtering>
- <directory>src/main/java</directory>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <filtering>false</filtering>
- <directory>src/test/resources</directory>
- </testResource>
- <testResource>
- <filtering>false</filtering>
- <directory>src/test/java</directory>
- <includes>
- <include>**</include>
- </includes>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- </testResources>
- <plugins>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>2.5</version>
- <executions>
- <execution>
- <id>PMD</id>
- <phase>compile</phase>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <targetJdk>1.6</targetJdk>
- <verbose>true</verbose>
- <failurePriority>2</failurePriority>
- <rulesets>
- <ruleset>build/pmd/ruleset.xml</ruleset>
- </rulesets>
- </configuration>
- </execution>
- </executions>
- <configuration>
- <targetJdk>1.6</targetJdk>
- <verbose>true</verbose>
- <failurePriority>2</failurePriority>
- <rulesets>
- <ruleset>build/pmd/ruleset.xml</ruleset>
- </rulesets>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>buildnumber-maven-plugin</artifactId>
- <version>1.2</version>
- <executions>
- <execution>
- <phase>initialize</phase>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <shortRevisionLength>8</shortRevisionLength>
- <doCheck>false</doCheck>
- <doUpdate>false</doUpdate>
- <timestampFormat>
- {0,date,yyyy-MM-dd}
- </timestampFormat>
- <getRevisionOnlyOnce>false</getRevisionOnlyOnce>
- <format>{0}</format>
- <items>
- <item>scmVersion</item>
- <!-- <item>buildNumber</item> -->
- </items>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>tomcat-maven-plugin</artifactId>
- <version>1.1</version>
- <configuration>
- </configuration>
- </plugin>
- <plugin>
- <inherited>true</inherited>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.5.1</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <encoding>UTF-8</encoding>
- <showWarnings>true</showWarnings>
- <showDeprecation>true</showDeprecation>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>${jetty.version}</version>
- <configuration>
- <connectors>
- <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
- <port>8080</port>
- <maxIdleTime>3600000</maxIdleTime>
- </connector>
- <connector implementation="org.eclipse.jetty.server.ssl.SslSocketConnector">
- <port>8443</port>
- <maxIdleTime>3600000</maxIdleTime>
- <keystore>${project.build.directory}/test-classes/keystore</keystore>
- <password>wicket</password>
- <keyPassword>wicket</keyPassword>
- </connector>
- </connectors>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <version>2.9</version>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.4.1</version>
- <executions>
- <execution>
- <phase>package</phase>
- <id>enforce-environment-variable-is-set</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireEnvironmentVariable>
- <variableName>BUILD_NUMBER</variableName>
- <variableName>RHEL_VERSION</variableName>
- </requireEnvironmentVariable>
- </rules>
- <fail>true</fail>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>rpm-build</id>
- <activation>
- <os>
- <name>linux</name>
- </os>
- </activation>
- <build>
- <finalName>ROOT</finalName>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rpm-maven-plugin</artifactId>
- <version>2.1.4</version>
- <extensions>true</extensions>
- <executions>
- <execution>
- <id>package-rpm</id>
- <goals>
- <goal>attached-rpm</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <group>Applications/Internet</group>
- <release>${env.BUILD_NUMBER}.${env.RHEL_VERSION}</release>
- <needarch>x86_64</needarch>
- <mappings>
- <mapping>
- <directory>${deploy.dir}</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/conf</directory>
- <filemode>700</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/conf</directory>
- <directoryIncluded>false</directoryIncluded>
- <configuration>noreplace</configuration>
- <filemode>600</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <sources>
- <source>
- <filter>true</filter>
- <location>src/main/conf</location>
- </source>
- </sources>
- </mapping>
-
- <mapping>
- <directory>${deploy.dir}/var</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/var/log</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/db</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/bin</directory>
- <filemode>700</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/lib</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/bin</directory>
- <directoryIncluded>false</directoryIncluded>
- <filemode>700</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <sources>
- <source>
- <filter>true</filter>
- <location>src/main/bin</location>
- </source>
- </sources>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/lib</directory>
- <directoryIncluded>false</directoryIncluded>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <artifact>
- <classifiers>
- <classifier />
- </classifiers>
- </artifact>
- <dependency />
- </mapping>
- <mapping>
- <directory>/etc/init.d</directory>
- <directoryIncluded>false</directoryIncluded>
- <filemode>700</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <sources>
- <source>
- <filter>true</filter>
- <location>src/main/etc/init.d</location>
- </source>
- </sources>
- </mapping>
-
- <mapping>
- <directory>/var/run/tomcat</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- <mapping>
- <directory>${deploy.dir}/webapps</directory>
- <directoryIncluded>false</directoryIncluded>
- <filemode>644</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <artifact>
- <classifiers>
- <classifier />
- </classifiers>
- </artifact>
- </mapping>
- <mapping>
- <directory>/opt/tomcat/conf</directory>
- <directoryIncluded>true</directoryIncluded>
- <configuration>true</configuration>
- <filemode>644</filemode>
- <username>root</username>
- <groupname>root</groupname>
- <sources>
- <source>
- <filter>true</filter>
- <location>src/main/opt/tomcat/conf</location>
- </source>
- </sources>
- </mapping>
- <mapping>
- <directory>/var/run/tomcat</directory>
- <filemode>755</filemode>
- <username>root</username>
- <groupname>root</groupname>
- </mapping>
- </mappings>
- <requires>
- <require>jdk</require>
- <require>perl-JSON</require>
- <require>perl-WWW-Curl</require>
- </requires>
-
- <preinstallScriptlet>
- <scriptFile>src/main/scripts/preinstall.sh</scriptFile>
- </preinstallScriptlet>
- <postinstallScriptlet>
- <scriptFile>src/main/scripts/postinstall.sh</scriptFile>
- </postinstallScriptlet>
- <preremoveScriptlet>
- <scriptFile>src/main/scripts/preremove.sh</scriptFile>
- </preremoveScriptlet>
- <postremoveScriptlet>
- <scriptFile>src/main/scripts/postremove.sh</scriptFile>
- </postremoveScriptlet>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <repositories>
- <repository>
- <id>Apache Nexus</id>
- <url>https://repository.apache.org/content/repositories/snapshots/</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
-</project>
diff --git a/traffic_monitor_java/src/main/bin/config-doc.sh b/traffic_monitor_java/src/main/bin/config-doc.sh
deleted file mode 100644
index 06425e1..0000000
--- a/traffic_monitor_java/src/main/bin/config-doc.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-#
-#
-# 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.
-#
-UNZIP=/usr/bin/unzip
-JAVA=/usr/bin/java
-RM=/bin/rm
-TMPDIR=/tmp/monitor-root-war
-WEBAPPSDIR=${deploy.dir}/webapps
-
-${RM} -rf ${TMPDIR}
-
-if [ -e ${WEBAPPSDIR}/ROOT.war ]
- then
- ${UNZIP} -qq -d ${TMPDIR} ${WEBAPPSDIR}/ROOT.war
-fi
-
-${JAVA} -cp ${TMPDIR}/WEB-INF/lib/*:${TMPDIR}/WEB-INF/classes com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig
-
-${RM} -rf ${TMPDIR}
diff --git a/traffic_monitor_java/src/main/bin/traffic_monitor_config.pl b/traffic_monitor_java/src/main/bin/traffic_monitor_config.pl
deleted file mode 100755
index b39a65d..0000000
--- a/traffic_monitor_java/src/main/bin/traffic_monitor_config.pl
+++ /dev/null
@@ -1,352 +0,0 @@
-#!/usr/bin/perl
-#
-#
-# 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.
-#
-
-use strict;
-use warnings;
-use feature qw(switch);
-use JSON;
-use WWW::Curl::Easy;
-
-my $global;
-
-&init();
-&get_traffic_ops_cookie();
-&get_traffic_ops_ort();
-&get_traffic_ops_monitor_cfg();
-&get_default_monitor_cfg();
-&diff_default_traffic_ops_cfg();
-&read_disk_monitor_cfg();
-
-my $update_needed = &check_update_needed();
-if ($update_needed) {
- &write_monitor_cfg();
-}
-else {
- print "DEBUG: Config on disk does not need an update, exiting.\n";
- exit 0;
-}
-
-sub init {
- &init_hostname();
- &init_time();
- &init_cli_params();
-}
-
-sub init_hostname {
- my $fqdn = `/bin/hostname -f`; chomp($fqdn);
- my ($hostname, undef) = split(/\./, $fqdn, 2);
- if (!defined($hostname)) {
- die("FATAL: Unable to determine host name; please ensure this machine properly configured with FQDN.");
- }
- $global->{'host_name'} = $hostname;
- print "DEBUG: Found hostname: " . $hostname . "\n";
-}
-
-sub init_time {
- my $unixtime = time();
- my $date = `/bin/date`; chomp($date);
- $global->{'date'} = $date;
-}
-
-sub get_traffic_ops_ort {
- my $ort_url = $global->{'traffic_ops_host'} . "/ort/" . $global->{'host_name'} . "/ort1";
- my $result = &curl_me($ort_url);
- my $ort_ref = decode_json($result);
- if ( defined ($ort_ref->{'profile'}->{'name'}) ) {
- print "DEBUG: Found profile from traffic_ops: " . $ort_ref->{'profile'}->{'name'} . "\n";
- $global->{'traffic_ops_data'}->{'profile'} = $ort_ref->{'profile'}->{'name'};
- }
- else {
- print "ERROR: No profile found in traffic_ops!\n";
- }
- if ( defined ($ort_ref->{'other'}->{'CDN_name'}) ) {
- print "DEBUG: Found CDN name from traffic_ops: " . $ort_ref->{'other'}->{'CDN_name'} . "\n";
- $global->{'traffic_ops_data'}->{'CDN_name'} = $ort_ref->{'other'}->{'CDN_name'};
- }
- else {
- print "ERROR: No CDN name found in traffic_ops, bailing!\n";
- exit 1;
- }
- if ( defined ($ort_ref->{'config_files'}->{'rascal-config.txt'}->{'location'}) ) {
- print "DEBUG: Found location for rascal-config.txt from traffic_ops: " . $ort_ref->{'config_files'}->{'rascal-config.txt'}->{'location'} . "\n";
- $global->{'location'}->{'traffic_monitor_config'} = $ort_ref->{'config_files'}->{'rascal-config.txt'}->{'location'};
- }
- else {
- print "ERROR: No location for rascal-config.txt found in traffic_ops, bailing!\n";
- exit 1;
- }
-}
-
-sub get_traffic_ops_monitor_cfg {
- my $health_url = $global->{'traffic_ops_host'} . "/health/" . $global->{'traffic_ops_data'}->{'CDN_name'};
- my $result = &curl_me($health_url);
- my $health_ref = decode_json($result);
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'} = $health_ref->{'traffic_monitor_config'};
- if ( !exists($global->{'traffic_ops_data'}->{'traffic_monitor_config'}) ) {
- print "FATAL: Monitor config not found! Bailing!\n";
- exit 1;
- }
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'cdnName'} = $global->{'traffic_ops_data'}->{'CDN_name'};
- my $tm_host = $global->{'traffic_ops_host'};
- $tm_host =~ s/(https?\:\/\/)(.*)/$2/;
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'tm.hostname'} = $tm_host;
-
- my ($tm_username, $tm_password) = split(/:/, $global->{'traffic_ops_login'}, 2);
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'tm.auth.username'} = $tm_username;
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'tm.auth.password'} = $tm_password;
-
- if (exists $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'CDN_name'}) {
- delete $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{'CDN_name'};
- }
-}
-
-sub validate_traffic_ops_monitor_cfg {
- my @missing_params;
- foreach my $param ( keys %{$global->{'disk'}->{'traffic_monitor_config'}} ) {
- if (!exists($global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param}) ) {
- push (@missing_params, $param);
- }
- }
- if (scalar(@missing_params) ) {
- $" = ',';
- print "FATAL: These params are missing from the traffic_ops config: @missing_params \n";
- exit 2;
- }
-}
-
-sub write_monitor_cfg {
- my $monitor_config->{'traffic_monitor_config'} = $global->{'traffic_ops_data'}->{'traffic_monitor_config'};
- my $monitor_config_json = JSON->new->utf8->indent->encode($monitor_config);
- if ($global->{'write_mode'} eq 'prompt' ) {
- print "DEBUG: Proposed traffic_monitor_config: \n$monitor_config_json\n";
- my $select = &get_answer();
- if ($select eq 'Y') {
- &write_monitor_cfg_to_disk($monitor_config_json);
- }
- else {
- print "You elected not to write config to disk, exiting.\n";
- exit 0;
- }
- }
- elsif ($global->{'write_mode'} eq 'auto' ) {
- &write_monitor_cfg_to_disk($monitor_config_json);
- }
-}
-
-sub curl_me {
- my $url = shift;
- my $curl = WWW::Curl::Easy->new;
- my $response_body;
- open(my $fileb, ">", \$response_body);
- $curl->setopt(CURLOPT_VERBOSE, 0);
- if ($url =~ m/https/) {
- $curl->setopt(CURLOPT_SSL_VERIFYHOST, 0);
- $curl->setopt(CURLOPT_SSL_VERIFYPEER, 0);
- $curl->setopt(CURLOPT_USERPWD, $global->{'traffic_ops_login'});
- }
- $curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
- $curl->setopt(CURLOPT_CONNECTTIMEOUT, 5);
- $curl->setopt(CURLOPT_TIMEOUT, 15);
- $curl->setopt(CURLOPT_HEADER,0);
- $curl->setopt(CURLOPT_COOKIE, $global->{'traffic_ops_cookie'});
- $curl->setopt(CURLOPT_URL, $url);
- $curl->setopt(CURLOPT_WRITEDATA, $fileb);
- #$curl->setopt(CURLOPT_HTTPHEADER, @( 'Connection: Keep-Alive', 'Keep-Alive: 300'));
- my $retcode = $curl->perform;
- my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
- if ($response_code != 200) {
- print "FATAL: Got HTTP $response_code response for $url! Cannot continue, bailing!\n";
- exit 1;
- }
- if ($response_body =~ m/html/ || $response_body !~ m/\{/ || $response_body !~ m/\}/ || $response_body !~ m/\:/ ) {
- print "FATAL: $url did not return valid JSON!\n";
- exit 1;
- }
- my $size = length($response_body);
- if ($size == 0) {
- print "FATAL: URL: $url returned empty!! Bailing!\n";
- exit 1;
- }
- return $response_body;
-
-}
-
-sub get_traffic_ops_cookie {
-
- my ( $u, $p ) = split( /:/, $global->{'traffic_ops_login'});
- my $url = $global->{'traffic_ops_host'} . "/login";
- my $curl = WWW::Curl::Easy->new;
- my $response_header;
- open(my $fileb, ">", \$response_header);
- $curl->setopt(CURLOPT_VERBOSE, 0);
- if ($url =~ m/https/) {
- $curl->setopt(CURLOPT_SSL_VERIFYHOST, 0);
- $curl->setopt(CURLOPT_SSL_VERIFYPEER, 0);
- }
- $curl->setopt(CURLOPT_POST, 1);
- $curl->setopt(CURLOPT_POSTFIELDS, "u=$u&p=$p");
- $curl->setopt(CURLOPT_FOLLOWLOCATION, 0);
- $curl->setopt(CURLOPT_CONNECTTIMEOUT, 5);
- $curl->setopt(CURLOPT_TIMEOUT, 15);
- $curl->setopt(CURLOPT_HEADER,0);
- $curl->setopt(CURLOPT_URL, $url);
- $curl->setopt(CURLOPT_WRITEHEADER, $fileb);
- my $retcode = $curl->perform;
- my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
- if ($response_code != 302) {
- print "FATAL: Got HTTP $response_code response for $url! Cannot continue, bailing!\n";
- exit 1;
- }
- my $size = length($response_header);
- if ($size == 0) {
- print "FATAL: URL: $url returned empty!! Bailing!\n";
- exit 1;
- }
- (my @lines) = split (/\n/, $response_header);
- (my @cookies) = grep /Set-Cookie/, @lines;
- foreach my $cookie (@cookies) {
- if ($cookie =~ m/Set-Cookie/ && !defined($global->{'traffic_ops_cookie'}) ) {
- (my $dum, $global->{'traffic_ops_cookie'}) = split(/ /, $cookie);
- $global->{'traffic_ops_cookie'} =~ s/\;//g;
- last;
- }
- }
- if ( !defined($global->{'traffic_ops_cookie'}) ) {
- print "FATAL: Didn't get cookie from traffic_ops! Bailing!\n";
- exit 1;
- }
-}
-
-sub get_default_monitor_cfg {
- my $default_cfg = `/opt/traffic_monitor/bin/config-doc.sh`;
- my $cfg_json = decode_json($default_cfg);
- $global->{'default'}->{'traffic_monitor_config'} = $cfg_json;
-}
-
-sub diff_default_traffic_ops_cfg {
- foreach my $param ( sort keys %{$global->{'traffic_ops_data'}->{'traffic_monitor_config'}} ) {
- if (!exists $global->{'default'}->{'traffic_monitor_config'}->{$param}) {
- print "WARN: Param found in traffic_ops, but not used in Monitor: '$param'\n";
- delete ($global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param});
- }
- }
- foreach my $param ( sort keys %{$global->{'default'}->{'traffic_monitor_config'}} ) {
- my $data = $global->{'default'}->{'traffic_monitor_config'}->{$param};
- if (!exists ($global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param})) {
- if (exists $data->{'defaultValue'}) {
- printf ("WARN: Param not in traffic_ops: %-40s description: %-120s Using default value of: %-40s \n", $param, $data->{'description'}, $data->{'defaultValue'});
- $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param} = $data->{'defaultValue'};
- }
- else {
- print "FATAL: $param has no default value, and is not in config from traffic_opsonkeys.\n";
- }
- }
- }
-}
-
-sub check_update_needed {
- my $update_needed = 0;
- foreach my $param ( sort keys %{$global->{'traffic_ops_data'}->{'traffic_monitor_config'}} ) {
- if (!exists ( $global->{'disk'}->{'traffic_monitor_config'}->{$param} ) ) {
- print "DEBUG: $param needed in config, but does not exist in config on disk.\n";
- $update_needed++;
- next;
- }
- else {
- if ( $global->{'disk'}->{'traffic_monitor_config'}->{$param} ne $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param} ) {
- print "DEBUG: $param value on disk (" . $global->{'disk'}->{'traffic_monitor_config'}->{$param} . ") does not match value needed in config (" . $global->{'traffic_ops_data'}->{'traffic_monitor_config'}->{$param} . ").\n";
- $update_needed++;
- }
- }
- }
- return $update_needed;
-}
-
-sub read_disk_monitor_cfg {
- my $disk_fname = $global->{'location'}->{'traffic_monitor_config'} . "/traffic_monitor_config.js";
-
- if (! -f $disk_fname) {
- print "WARN: $disk_fname does not exist\n";
- $global->{'disk'}->{'traffic_monitor_config'} = undef;
- return();
- }
-
- open my $fh, '<', $disk_fname || die("FATAL: Can't open $disk_fname: $!");
- local $/ = undef;
- my $disk_cfg = <$fh>;
- close ($fh);
- my $disk_cfg_json = decode_json($disk_cfg);
- $global->{'disk'}->{'traffic_monitor_config'} = $disk_cfg_json->{'traffic_monitor_config'};
-}
-
-sub usage {
- print "====-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-====\n";
- print "Usage: perl traffic_monitor_config.pl <Traffic Operations Host> <Traffic Operations Login> <Write Mode>\n";
- print "\t<Traffic Operations Host> => format like:\n";
- print "\t\thttps://tm-host.company.net\n";
- print "\n";
- print "\t<Traffic Operations Login> => format like:\n";
- print "\t\tadmin:password\n";
- print "\n";
- print "\t<Write Mode> => choose:\n";
- print "\t\t[auto] Automatic -- Write new config changes to disk, if needed.\n";
- print "\t\t[prompt] Prompt -- Prompt before writing config changes to disk, if needed.\n";
- print "====-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-====\n";
- exit 1;
-}
-
-sub init_cli_params {
- if ( $#ARGV != 2 ) {
- &usage();
- }
- if ( $ARGV[0] !~ m/^https?\:\/\// ) {
- &usage();
- }
- if ( $ARGV[1] !~ m/\:/ ) {
- &usage();
- }
- if ( $ARGV[2] ne 'auto' && $ARGV[2] ne 'prompt' ) {
- &usage();
- }
- else {
- $global->{'traffic_ops_host'} = $ARGV[0];
- print "DEBUG: traffic_ops selected: " . $global->{'traffic_ops_host'} . "\n";
- $global->{'traffic_ops_login'} = $ARGV[1];
- print "DEBUG: traffic_ops login: " . $global->{'traffic_ops_login'} . "\n";
- $global->{'write_mode'} = $ARGV[2];
- print "DEBUG: Config write mode: " . $global->{'write_mode'} . "\n";
- }
-}
-
-sub write_monitor_cfg_to_disk {
- my $monitor_config_json = shift;
- open my $fh, '>', $global->{'location'}->{'traffic_monitor_config'} . "/traffic_monitor_config.js" || die "Can't open " . $global->{'location'}->{'traffic_monitor_config'} . "\n";
- print "DEBUG: Writing " . $global->{'location'}->{'traffic_monitor_config'} . "/traffic_monitor_config.js\n";
- print $fh $monitor_config_json;
- close $fh;
-}
-
-sub get_answer {
- my $select;
- while (!defined($select) || ($select ne 'Y' && $select ne 'n')) {
- print "----------------------------------------------\n";
- print "----OK to write this config to disk? (Y/n) [n]";
- $select = <STDIN>;
- chomp($select);
- print "----------------------------------------------\n";
- }
- return $select;
-}
diff --git a/traffic_monitor_java/src/main/conf/log4j.properties b/traffic_monitor_java/src/main/conf/log4j.properties
deleted file mode 100644
index 17c0cc4..0000000
--- a/traffic_monitor_java/src/main/conf/log4j.properties
+++ /dev/null
@@ -1,66 +0,0 @@
-#
-#
-# 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.
-#
-
-# ACCESS is set to be a Syslog Appender
-log4j.appender.ACCESS=org.apache.log4j.net.SyslogAppender
-log4j.appender.ACCESS.syslogHost=127.0.0.1:5140
-
-# ACCESS uses PatternLayout.
-log4j.appender.ACCESS.layout=org.apache.log4j.PatternLayout
-log4j.appender.ACCESS.layout.ConversionPattern=%m%n
-log4j.appender.ACCESS.threshold=INFO
-
-# A1 is set to be a RollingFileAppender.
-#log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 is set to be a RollingFileAppender.
-log4j.appender.A1=org.apache.log4j.RollingFileAppender
-log4j.appender.A1.file=${deploy.dir}/var/log/traffic_monitor.log
-log4j.appender.A1.maxFileSize=75MB
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5p %d{yyyy-MM-dd'T'HH:mm:ss.SSS} [%t] %c - %m%n
-log4j.appender.A1.threshold=ALL
-
-# Set root logger level to DEBUG and its only appender to A1.
-# Valid levels are: ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, NONE
-log4j.rootLogger=WARN, A1
-
-# Set application logger levels
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor=INFO
-
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.config=INFO
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.health=WARN
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.publish=INFO
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.util=INFO
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.wicket=INFO
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors=INFO
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.wicket.components=INFO
-
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.access=INFO, ACCESS
-log4j.additivity.com.comcast.cdn.traffic_control.traffic_monitor.access=false
-
-log4j.appender.EVENT=org.apache.log4j.RollingFileAppender
-log4j.appender.EVENT.File=/opt/traffic_monitor/var/log/event.log
-log4j.appender.EVENT.MaxFileSize=200MB
-log4j.appender.EVENT.MaxBackupIndex=10
-
-log4j.appender.EVENT.layout=org.apache.log4j.PatternLayout
-log4j.appender.EVENT.layout.ConversionPattern=%m%n
-log4j.appender.EVENT.threshold=INFO
-
-log4j.logger.com.comcast.cdn.traffic_control.traffic_monitor.event=INFO, EVENT
-log4j.additivity.com.comcast.cdn.traffic_control.traffic_monitor.event=false
\ No newline at end of file
diff --git a/traffic_monitor_java/src/main/conf/traffic_monitor_config.js b/traffic_monitor_java/src/main/conf/traffic_monitor_config.js
deleted file mode 100644
index 0fa20af..0000000
--- a/traffic_monitor_java/src/main/conf/traffic_monitor_config.js
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "traffic_monitor_config": {
- "health.polling.interval": "5000",
- "tm.polling.interval": "10000",
- "tm.hostname": "",
- "tm.healthParams.polling.url": "https://${tmHostname}/health/${cdnName}",
- "hack.ttl": "30",
- "cdnName": "",
- "peers.polling.url": "http://${hostname}/publish/CrStates?raw",
- "health.timepad": "20",
- "health.event-count": "200",
- "tm.dataServer.polling.url": "https://${tmHostname}/dataserver/orderby/id",
- "tm.auth.url": "https://${tmHostname}/login",
- "tm.auth.username": "",
- "tm.auth.password": "",
- "tm.crConfig.json.polling.url": "https://${tmHostname}/CRConfig-Snapshots/${cdnName}/CRConfig.json"
- }
-}
diff --git a/traffic_monitor_java/src/main/etc/init.d/tomcat b/traffic_monitor_java/src/main/etc/init.d/tomcat
deleted file mode 100644
index 5083fba..0000000
--- a/traffic_monitor_java/src/main/etc/init.d/tomcat
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/sh
-#
-# tomcat This shell script takes care of starting and stopping Tomcat
-#
-# chkconfig: 345 80 20
-#
-### BEGIN INIT INFO
-# Provides: tomcat
-# Required-Start: $network $syslog
-# Required-Stop: $network $syslog
-# Default-Start:
-# Default-Stop:
-# Description: start and stop tomcat
-# Short-Description: start and stop tomcat
-### END INIT INFO
-#
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-
-. /etc/rc.d/init.d/functions
-
-export NAME=tomcat
-export TOMCAT_HOME=/opt/$NAME
-export CATALINA_PID=/var/run/tomcat/$NAME.pid
-export CATALINA_OPTS="-Xms512m -Xmx4096m -Dlog4j.configuration=file://${deploy.dir}/conf/log4j.properties"
-export TOMCAT_LOCK=/var/lock/subsys/$NAME
-
-
-start() {
- runuser -s /bin/bash root -c "$TOMCAT_HOME/bin/startup.sh"
- RETVAL=$?
- echo -n "Starting $NAME"
- if [ $RETVAL = 0 ]; then
- touch $TOMCAT_LOCK
- echo_success
- else
- echo_failure
- fi
- echo
-}
-
-
-stop() {
- $TOMCAT_HOME/bin/shutdown.sh
- RETVAL=$?
- echo -n "Stopping $NAME"
- if [ $RETVAL = 0 ]; then
- rm -f $TOMCAT_LOCK
- echo_success
- else
- echo_failure
- fi
- echo
-}
-
-
-case "$1" in
- start)
- start
- ;;
- stop)
- if [ -s "$CATALINA_PID" ]; then
- stop
- else
- echo "It seems like tomcat is not running. You may try force-stop"
- echo -n "Stopping $NAME"
- echo_warning
- echo
- fi
- ;;
- force-stop)
- stop
- ;;
- restart)
- $0 stop
-# for i in {1..18}
-# do
-# echo -n .
-# sleep 1
-# done
-# echo .
- $0 start
- ;;
- status)
- status -p $CATALINA_PID $NAME
- ;;
- version)
- $TOMCAT_HOME/bin/catalina.sh version
- ;;
- *)
- echo "Usage: $0 {start|stop|force-stop|restart|status|version}"
- exit 1
-esac
-exit 0
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.html b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.html
deleted file mode 100644
index 95a85c9..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.html
+++ /dev/null
@@ -1,131 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you 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.
--->
-
-<html>
-<head>
-
-<title>Traffic Monitor</title>
-<link href="style.css" rel="stylesheet" />
-
-<script type="text/javascript">
-$(".hider").live("click",function(){
- var me = $(this);
- var targetname = me.attr("data-target");
- var target = $("."+targetname);
- if(target.is(':visible')) {
- $(".show",me).show();
- $(".hide",me).hide();
- target.slideUp();
- } else {
- $(".show",me).hide();
- $(".hide",me).show();
- target.slideDown();
- }
- return false;
-});
-
-$(function() {
- $(".top-bar-hidden").hide();
-});
-
-$(".tab a").live("click",function(){
- var me = $(this).parents(".tab");
- me.addClass("selected");
- var targetname = me.attr("data-target");
- var target = $("#"+targetname);
- target.show();
- var siblings = me.siblings(".tab");
- siblings.each(function( index ) {
- var s = $(this);
- s.removeClass("selected");
- var t = s.attr("data-target");
- $("#"+t).hide();
- });
- return false;
-});
-</script>
-</head>
-
-<body>
- <div id="container">
- <div id="header">
- <div class="top-bar">
- <div class="status-bar">
- <ul>
- <li>Caches: count=<span wicket:id="servers_count"></span>
- available=<span wicket:id="servers_available"></span>
- down=<span wicket:id="servers_down"></span>
- </li>
- <li>Bandwidth: <span wicket:id="totalBandwidth"></span>/<span wicket:id="totalBandwidthAvailable"></span> </li>
- <li>Source: <span wicket:id="source"></span></li>
- <li style="float: right;"><span wicket:id="version"></span></li>
- </ul>
- <br clear="all" />
- </div>
- </div>
- </div>
-
-
- <div id="contents">
-
- <div>
- <h3>Published Docs:</h3>
- <ul>
- <li><a href="/publish/EventLog">EventLog</a></li>
- <li><a href="/publish/CacheStats?hc=1">CacheStats</a></li>
- <li><a href="/publish/DsStats?hc=1">DsStats</a></li>
- <li><a href="/publish/CrStates">CrStates</a> (as published to Traffic Routers)</li>
- <li><a href="/publish/CrConfig?json">CrConfig</a> (json)</li>
- <li><a href="/publish/PeerStates">PeerStates</a></li>
- <li><a href="/publish/Stats">Stats</a></li>
- <li><a href="/publish/StatSummary">StatSummary</a></li>
- <li><a href="/publish/ConfigDoc">ConfigDoc</a></li>
- </ul>
- </div>
-
- <!-- <div wicket:id="server-tabs"></div> -->
- <div class="main-tab-panel" style="float: left;">
- <ul style="float: left;">
- <li class="selected tab" data-target="tab-page-1"><a href="#" >Cache States</a></li>
- <li class="tab" data-target="tab-page-2"><a href="#" >DeliveryService States</a></li>
- <li class="tab" data-target="tab-page-3"><a href="#">Event Log</a></li>
- </ul>
- </div>
- <div id="tab-page-1">
- <div wicket:id="serverList"></div>
- </div>
- <div id="tab-page-2" class="hidden">
- <div wicket:id="dsList"></div>
- </div>
- <div id="tab-page-3" class="hidden">
- <div wicket:id="eventLog"></div>
- </div>
-
- <div >
- <span style="margin-left: 25px"> Number of updates:</span> <span
- id="num_updates">0</span> <br /> <span style="margin-left: 25px">
- Last Val:</span> <span id="last_val">0</span>
- <div>
- <a href="/">Refresh Server List</a>
- </div>
- </div>
- </div>
- </div>
-</body>
-</html>
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.java
deleted file mode 100644
index c3212c0..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/Index.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheStateRegistry;
-import org.apache.log4j.Logger;
-import org.apache.wicket.Component;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.behavior.Behavior;
-import org.apache.wicket.markup.html.IHeaderContributor;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.util.time.Duration;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.publish.Stats;
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.behaviors.MultiUpdatingTimerBehavior;
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel;
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel;
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.EventLogPanel;
-
-public class Index extends MonitorPage implements IHeaderContributor {
- private static final Logger LOGGER = Logger.getLogger(Index.class);
- private static final long serialVersionUID = 1L;
-
- final public static NumberFormat NUMBER_FORMAT = new DecimalFormat("#,###.00");
-
- public Index() {
- final Behavior updater = new MultiUpdatingTimerBehavior(Duration.seconds(1));
-
- final Label servers_count = new Label("servers_count", getServerListSizeModel());
- servers_count.setOutputMarkupId(true);
- add(servers_count);
-
- final Label servers_down = new Label("servers_down", getServersDownModel());
-
- servers_down.add(updater);
- add(servers_down);
-
- final Label totalBandwidth = new Label("totalBandwidth",getCachesTotalBandwidthModel());
- totalBandwidth.add(updater);
- add(totalBandwidth);
-
- final Label totalBandwidthAvailable = new Label("totalBandwidthAvailable", getCachesTotalMaxBandwidthModel());
- totalBandwidthAvailable.add(updater);
- add(totalBandwidthAvailable);
-
- add(new Label("version", new Model<String>(getVersionStr())));
-
- final Label source = new Label("source", getSourceModel());
- source.add(updater);
- add(source);
-
- final Component[] updateList = new Component[] {servers_count};
-
- final Label servers_available = new Label("servers_available",getServersAvailableModel());
-
- servers_available.add(updater);
- add(servers_available);
-
- add(new CacheListPanel("serverList", updater, updateList));
- add(new EventLogPanel("eventLog"));
-
- add(new DsListPanel("dsList", updater, updateList));
- }
-
- private Model<Integer> getServerListSizeModel() {
- return new Model<Integer>() {
- @Override
- public Integer getObject() {
- return CacheStateRegistry.getInstance().size();
- }
- };
- }
-
- private Model<String> getServersDownModel() {
- return new Model<String>("") {
-
- @Override
- public String getObject() {
- return Integer.toString(CacheStateRegistry.getInstance().getCachesDownCount());
- }
- };
- }
-
- private Model<String> getCachesTotalBandwidthModel() {
- return new Model<String>("") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getObject( ) {
- return NUMBER_FORMAT.format(CacheStateRegistry.getInstance().getCachesBandwidthInKbps());
- }
- };
- }
-
- private Model<String> getCachesTotalMaxBandwidthModel() {
- return new Model<String>("") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getObject( ) {
- return NUMBER_FORMAT.format(CacheStateRegistry.getInstance().getCachesMaxBandwidthInKbps());
- }
- };
- }
-
- private Model<String> getSourceModel() {
- return new Model<String>(""){
- private static final long serialVersionUID = 1L;
-
- @Override
- public String getObject( ) {
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- if(config == null) { return "[no config]"; }
- final String host = config.getEffectiveProps().get("tm.hostname");
- final String cdnName = config.getEffectiveProps().get("cdnName");
- return host+"/"+cdnName;
- }
- };
- }
-
- private String getVersionStr() {
- try {
- final JSONObject stats = Stats.getVersionInfo().getJSONObject("stats");
- final String name = stats.getString("name");
- final String version = stats.getString("version");
- final String revision = stats.getString("git-revision").replace("${buildNumber}","");
- String dateStr;
-
- try {
- dateStr = " (" + (new SimpleDateFormat("yyyy-MM-dd").format(new Date(stats.getLong("buildTimestamp")))) + ")";
- } catch (JSONException e) {
- dateStr = "(dev build)";
- }
-
- return name + "-" + version + "-" + revision + dateStr;
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
-
- return "";
- }
-
- private Model<String> getServersAvailableModel() {
- return new Model<String>("") {
-
- @Override
- public String getObject() {
- return Integer.toString(CacheStateRegistry.getInstance().getCachesAvailableCount());
- }
- };
- }
-}
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorApplication.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorApplication.java
deleted file mode 100644
index edd65a2..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorApplication.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.Application;
-import org.apache.wicket.Page;
-import org.apache.wicket.Session;
-import org.apache.wicket.protocol.http.WebApplication;
-import org.apache.wicket.request.Request;
-import org.apache.wicket.request.Response;
-import org.apache.wicket.util.time.Duration;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.RouterConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.DsWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.PeerWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.TmWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.publish.CrStates;
-
-public class MonitorApplication extends WebApplication {
- private static final Logger LOGGER = Logger.getLogger(MonitorApplication.class);
- private CacheWatcher cw;
- private TmWatcher tmw;
- private PeerWatcher pw;
- private DsWatcher dsw;
- private static long startTime;
-
- public static MonitorApplication get() {
- return (MonitorApplication) Application.get();
- }
-
- /**
- * @see org.apache.wicket.Application#getHomePage()
- */
- @Override
- public Class<? extends Page> getHomePage() {
- return Index.class;
- }
-
- /**
- * @see org.apache.wicket.Application#init()
- */
- @Override
- public void init() {
- super.init();
-
- if (!ConfigHandler.getInstance().configFileExists()) {
- LOGGER.fatal("Cannot find configuration file: " + ConfigHandler.getInstance().getConfigFile());
- // This will only stop Tomcat if the security manager allows it
- // https://tomcat.apache.org/tomcat-6.0-doc/security-manager-howto.html
- System.exit(1);
- }
-
- getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
-
- // This allows us to override the Host header sent via URLConnection
- System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
-
- final HealthDeterminer hd = new HealthDeterminer();
- tmw = new TmWatcher(hd);
- cw = new CacheWatcher();
- cw.init(hd);
- dsw = new DsWatcher();
- dsw.init(hd);
- pw = new PeerWatcher();
- pw.init();
- tmw.addTmListener(RouterConfig.getTmListener(hd));
- tmw.init();
-
- CrStates.init(cw, pw, hd);
-
- mountPackage("/publish", CrStates.class);
- startTime = System.currentTimeMillis();
- }
-
- @Override
- public Session newSession(final Request request, final Response response) {
- return new MonitorSession(request);
- }
-
- public void onDestroy() {
- final boolean forceDown = ConfigHandler.getInstance().getConfig().shouldForceSystemExit();
- ConfigHandler.getInstance().destroy();
- LOGGER.warn("MonitorApplication: shutting down ");
- tmw.destroy();
-
- if (forceDown) {
- LOGGER.warn("MonitorApplication: System.exit");
- System.exit(0);
- }
-
- cw.destroy();
- dsw.destroy();
- pw.destroy();
- }
-
- public static long getUptime() {
- return System.currentTimeMillis() - startTime;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorPage.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorPage.java
deleted file mode 100644
index 5eb78de..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorPage.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor;
-
-import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.head.JavaScriptHeaderItem;
-import org.apache.wicket.markup.html.WebPage;
-
-public class MonitorPage extends WebPage {
- private static final long serialVersionUID = 1L;
-
- public MonitorSession getMonitorSession() {
- return (MonitorSession) getSession();
- }
-
- @Override
- public void renderHead(final IHeaderResponse response) {
- super.renderHead(response);
-
- response.render(JavaScriptHeaderItem.forUrl("/js/main.js"));
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorSession.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorSession.java
deleted file mode 100644
index 4222f82..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/MonitorSession.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor;
-
-import org.apache.wicket.protocol.http.WebSession;
-import org.apache.wicket.request.Request;
-
-public class MonitorSession extends WebSession {
- private static final long serialVersionUID = 1L;
-
- public MonitorSession(final Request request) {
- super(request);
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/StatisticModel.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/StatisticModel.java
deleted file mode 100644
index 9e0b46e..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/StatisticModel.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor;
-
-
-import org.apache.wicket.model.Model;
-
-public class StatisticModel extends Model<String> implements java.io.Serializable {
- final private String key;
-
- public StatisticModel(final String key) {
- this.key = key;
- }
-
- public String getKey() {
- return key;
- }
-
- @Override
- public String getObject( ) {
- return "";
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Cache.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Cache.java
deleted file mode 100644
index 8372277..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Cache.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import org.apache.wicket.ajax.json.JSONArray;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.Bandwidth;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class Cache implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- protected String hostname;
- private CacheState state;
- final private JSONObject json;
-
- public Bandwidth previousTx;
-
- public Cache(final String id, final JSONObject o) throws JSONException {
- json = o;
- hostname = id;
- json.getString("ip");
- json.optString("ip6");
- json.getString("status");
- json.getString("locationId");
- json.getString("profile");
- json.getString("fqdn");
- json.getString("type");
- json.getInt("port");
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public void setHostname(final String hostname) {
- this.hostname = hostname;
- }
-
- public String toString() {
- return "Cache Server: " + hostname;
- }
-
- public String getIpAddress() {
- return json.optString("ip");
- }
-
- public String getInterfaceName() {
- return json.optString("interfaceName");
- }
-
- public String getStatus() {
- return json.optString("status");
- }
-
- public String getLocation() {
- return json.optString("locationId");
- }
-
- public void setState(final CacheState state, final HealthDeterminer healthDeterminer) {
- healthDeterminer.setIsAvailable(this, state);
- this.state = state;
- }
-
- public void setError(final CacheState state, final String e, final HealthDeterminer myHealthDeterminer) {
- myHealthDeterminer.setIsAvailable(this, e, state);
- this.state = state;
- }
-
- public CacheState getState() {
- return state;
- }
-
- public boolean isAvailableKnown() {
- return state != null && state.hasValue("isAvailable");
- }
-
- public boolean isAvailable() {
- return !isAvailableKnown() || Boolean.parseBoolean(state.getLastValue("isAvailable"));
- }
-
- public String getQueryIp() {
- final String ip = json.optString("queryIp");
-
- if (ip != null && !ip.equals("")) {
- return ip;
- }
-
- return getIp();
- }
-
- public int getQueryPort() {
- if (json.has("queryPort")) {
- return json.optInt("queryPort");
- }
-
- return json.optInt("port");
- }
-
- public String getIp() {
- return getIpAddress();
- }
-
- public String getType() {
- return json.optString("type");
- }
-
- public String getIp6() {
- return json.optString("ip6");
- }
-
- HealthDeterminer healthDeterminer;
-
- public void setControls(final HealthDeterminer healthDeterminer) {
- this.healthDeterminer = healthDeterminer;
- }
-
- public JSONObject getControls() {
- if (healthDeterminer == null) {
- return null;
- }
-
- return healthDeterminer.getControls(this);
- }
-
- public void setCacheState(final CacheState cacheState) {
- state = cacheState;
- }
-
- public long getHistoryTime() {
- return getControls().optInt("history.time");
- }
-
- public String getProfile() {
- return json.optString("profile");
- }
-
- public String getFqdn() {
- return json.optString("fqdn");
- }
-
- public JSONObject getDeliveryServices() {
- return json.optJSONObject("deliveryServices");
- }
-
- public boolean hasDeliveryServices() {
- return json.has("deliveryServices");
- }
-
- public List<String> getDeliveryServiceIds() {
- return Arrays.asList(JSONObject.getNames(getDeliveryServices()));
- }
-
- public List<String> getFqdns(final String deliveryServiceId) throws JSONException {
- final ArrayList<String> fqdns = new ArrayList<String>();
-
- final JSONObject deliveryServices = getDeliveryServices();
-
- if (!deliveryServices.has(deliveryServiceId)) {
- fqdns.add(deliveryServices.getString(deliveryServiceId));
- return fqdns;
- }
-
- final JSONArray ja = deliveryServices.optJSONArray(deliveryServiceId);
-
- if (ja != null) {
- for (int i = 0; i < ja.length(); i++) {
- fqdns.add(ja.getString(i));
- }
-
- return fqdns;
- }
-
- fqdns.add(deliveryServices.optString(deliveryServiceId));
-
- return fqdns;
- }
-
- public String getStatisticsUrl() {
- final JSONObject controls = getControls();
-
- if (controls == null) {
- return null;
- }
-
- final String statisticsUrl = controls.optString("health.polling.url");
-
- if (statisticsUrl == null) {
- return null;
- }
-
- return statisticsUrl.replace("${hostname}", getFqdn()).replace("${interface_name}", getInterfaceName());
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Config.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Config.java
deleted file mode 100644
index 0e1d099..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Config.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-public class Config implements java.io.Serializable {
- private static final Logger LOGGER = Logger.getLogger(Config.class);
- private static final long serialVersionUID = 1L;
-
- private JSONObject baseProps = new JSONObject();
- private JSONObject props = new JSONObject();
- private final JSONObject propDoc = new JSONObject();
-
- public Config() {
-
- }
-
- public Config(final JSONObject properties) {
- baseProps = properties;
- props = new JSONObject(baseProps, JSONObject.getNames(baseProps));
- }
-
- public void update(final JSONObject overlayJson) throws JSONException {
- if (overlayJson == null) {
- LOGGER.warn("Skipping NULL overlay");
- props = baseProps;
- return;
- }
-
- LOGGER.info("update, adding: " + overlayJson.toString(2));
- final JSONObject properties = new JSONObject(baseProps, JSONObject.getNames(baseProps));
-
- Iterator<String> names = overlayJson.keys();
- while (names.hasNext()) {
- String name = names.next();
- properties.put(name, overlayJson.get(name));
- }
-
- props = properties;
- }
-
- public JSONObject getConfigDoc() {
- return propDoc;
- }
-
- @SuppressWarnings("unchecked")
- public Map<String,String> getEffectiveProps() {
- final Iterator<String> keys = props.keys();
- final Map<String, String> effectiveProperties = new HashMap<String, String>();
-
- while (keys.hasNext()) {
- String key = keys.next();
- effectiveProperties.put(key, props.optString(key));
- }
-
- return effectiveProperties;
- }
-
- public String getString(final String key, final String defaultValue, final String description) {
- String value = props.has(key) ? props.optString(key) : defaultValue;
- updatePropertiesDoc(key, defaultValue, value, description, "propString");
- return value;
- }
-
- public Long getLong(final String key, final long defaultValue, final String description) {
- long value = props.has(key) ? props.optLong(key) : defaultValue;
- updatePropertiesDoc(key, defaultValue, value, description, "Long");
- return value;
- }
-
- public int getInt(final String key, final int defaultValue, final String description) {
- int value = props.has(key) ? props.optInt(key) : defaultValue;
- updatePropertiesDoc(key, defaultValue, value, description, "integer");
- return value;
- }
-
- public boolean getBool(final String key, final boolean defaultValue, final String description) {
- boolean value = props.has(key) ? props.optBoolean(key) : defaultValue;
- updatePropertiesDoc(key, defaultValue, value, description, "boolean");
- return value;
- }
-
- private void updatePropertiesDoc(final String key, final Object defaultValue, final Object value, final String description, final String type) {
- if (!propDoc.has(key)) {
- try {
- String docDefaultValue = (defaultValue != null) ? String.valueOf(defaultValue) : "";
- JSONObject json = new JSONObject().put("defaultValue", docDefaultValue).put("description", description).put("type", type);
- propDoc.put(key, json);
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- }
-
- try {
- String s = String.valueOf(String.valueOf(value));
- s = (key.toLowerCase().contains("password")) ? "**********" : s;
- propDoc.getJSONObject(key).put("value", s);
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/ConfigHandler.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/ConfigHandler.java
deleted file mode 100644
index f825bbd..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/ConfigHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONObject;
-
-public class ConfigHandler {
- private static final Logger LOGGER = Logger.getLogger(ConfigHandler.class);
- private static final String CONFIG_FILEPATH = "/opt/traffic_monitor/conf/traffic_monitor_config.js";
- private static final String DB_FILEPATH = "/opt/traffic_monitor/db";
- public static final String CONFIG_PROPERTY = "traffic_monitor.path.config";
- public static final String DB_PROPERTY = "traffic_monitor.path.db";
-
- private final Object lok = new Object();
- private MonitorConfig config = null;
- private boolean shutdown;
- private final File configFile = new File(getFilePath(CONFIG_PROPERTY, CONFIG_FILEPATH));
- private final String dbPath = getFilePath(DB_PROPERTY, DB_FILEPATH);
-
- // Recommended Singleton Pattern implementation
- // https://community.oracle.com/docs/DOC-918906
-
- private ConfigHandler() { }
-
- public static ConfigHandler getInstance() {
- return ConfigHandlerHolder.CONFIG_HANDLER;
- }
-
- private static class ConfigHandlerHolder {
- private static final ConfigHandler CONFIG_HANDLER = new ConfigHandler();
- }
-
- public void destroy() {
- shutdown = true;
- }
-
- public MonitorConfig getConfig() {
- if (shutdown) {
- return null;
- }
-
- synchronized (lok) {
- if (config != null) {
- return config;
- }
-
- if (!configFileExists()) {
- config = new MonitorConfig();
- return config;
- }
-
- try {
- final JSONObject jsonConfig = new JSONObject(IOUtils.toString(new FileReader(configFile)));
- config = new MonitorConfig(jsonConfig.getJSONObject("traffic_monitor_config"));
- } catch (FileNotFoundException e) {
- LOGGER.error("Failed to find traffic monitor configuration file " + configFile.toString());
- } catch (Exception e) {
- LOGGER.warn(e, e);
- }
-
- if (config == null) {
- config = new MonitorConfig();
- }
- }
-
- return config;
- }
-
- public File getDbFile(final String filename) {
- return new File(dbPath, filename);
- }
-
- public File getConfigFile() {
- return configFile;
- }
-
- public boolean configFileExists() {
- return configFile.exists();
- }
-
- private String getFilePath(final String property, final String staticFilePath) {
- if (property != null && System.getProperty(property) != null) {
- return System.getProperty(property);
- }
-
- return staticFilePath;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/MonitorConfig.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/MonitorConfig.java
deleted file mode 100644
index a8d2def..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/MonitorConfig.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-public class MonitorConfig extends Config {
-
- private static final long serialVersionUID = 1L;
-
- private boolean hasForcedPropCalls = false;
-
- // This is used by src/main/bin/config-doc.sh which is used by src/main/bin/traffic_monitor_config.pl which must be run after rpm install of traffic monitor
- @SuppressWarnings("PMD")
- public static void main(final String[] args) throws JSONException {
- final JSONObject doc = ConfigHandler.getInstance().getConfig().getConfigDoc();
- System.out.println(doc.toString(2));
- }
-
- public MonitorConfig() {
- }
-
- public MonitorConfig(final JSONObject jsonObject) throws JSONException {
- super(jsonObject);
- }
-
- public String getCrConfigUrl() {
- return getPropertyString("tm.crConfig.json.polling.url", "https://${tmHostname}/CRConfig-Snapshots/${cdnName}/CRConfig.json", "Url for the cr-config (json)");
- }
-
- public String getHeathUrl() {
- return getPropertyString("tm.healthParams.polling.url", "https://${tmHostname}/health/${cdnName}", "The url for the heath params (json)");
- }
-
- public String getAuthUrl() {
- return getPropertyString("tm.auth.url", "https://${tmHostname}/login", "The url for the authentication form");
- }
-
- public String getAuthUsername() {
- return getPropertyString("tm.auth.username", null, "The username for the authentication form");
- }
-
- public String getAuthPassword() {
- return getPropertyString("tm.auth.password", null, "The password for the authentication form");
- }
-
- public Long getTmFrequency() {
- return getLong("tm.polling.interval", 10000, "The polling frequency for getting updates from TM");
- }
-
- public int getEventLogCount() {
- return getInt("health.event-count", 200, "The number of historical events that will be kept");
- }
-
- public int getHealthPollingInterval() {
- return getInt("health.polling.interval", 5000, "The polling frequency for getting the states from caches");
- }
-
- public long getHealthDsInterval() {
- return getInt("health.ds.interval", 1000, "The polling frequency for calculating the deliveryService states");
- }
-
- public long getDsCacheLeniency() {
- return getInt("health.ds.leniency", 30000, "The amount of time before the deliveryService disregards the last update from a non-responsive cache");
- }
-
- public boolean shouldForceSystemExit() {
- return getBool("hack.forceSystemExit", false, "Call System.exit on shutdown");
- }
-
- public String getPeerUrl() {
- return getString("peers.polling.url", "http://${hostname}/publish/CrStates?raw", "The url for current, unfiltered states from peer monitors");
- }
-
- public long getPeerPollingInterval() {
- return getInt("peers.polling.interval", 5000, "Polling frequency for getting states from peer monitors");
- }
-
- public int getPeerThreadPool() {
- return getInt("peers.threadPool", 1, "The number of threads given to the pool for querying peers");
- }
-
- public int getConnectionTimeout() {
- return getInt("default.connection.timeout", 2000, "Default connection time for all queries (cache, peers, TM)");
- }
-
- public int getCacheTimePad() {
- return getInt("health.timepad", 10, "A delay between each separate cache query");
- }
-
- @SuppressWarnings("PMD")
- public boolean getPeerOptimistic() {
- return getBool("hack.peerOptimistic", true, "The assumption of a caches availability when unknown by peers");
- }
-
- @SuppressWarnings("PMD")
- public boolean getPublishDsStates() {
- return getBool("hack.publishDsStates", true, "If true, the delivery service states will be included in the CrStates.json");
- }
-
- public String getAccessControlAllowOrigin() {
- return getString("default.accessControlAllowOrigin", "*",
- "The value for the header: Access-Control-Allow-Origin for published jsons... should be narrowed down to TMs");
- }
-
- public int getStartupMinCycles() {
- return getInt("health.startupMinCycles", 2, "The number of query cycles that must be completed before this Traffic Monitor will start reporting");
- }
-
- public String getPropertyString(final String key, final String defaultValue, final String description) {
- return completePropString(getString(key, defaultValue, description));
- }
-
- protected String completePropString(final String pattern) {
- if (pattern == null) {
- return null;
- }
-
- String propertyString = pattern;
- final String tmHostname = getString("tm.hostname", null, "TM hostname");
-
- if (tmHostname != null && !tmHostname.isEmpty()) {
- propertyString = pattern.replace("${tmHostname}", tmHostname);
- }
-
- final String cdnName = getString("cdnName", null, "Cluster/CDN name");
-
- if (cdnName != null && !cdnName.isEmpty()) {
- propertyString = propertyString.replace("${cdnName}", cdnName);
- }
-
- return propertyString;
- }
-
- @Override
- public JSONObject getConfigDoc() {
- if (!hasForcedPropCalls) {
- hasForcedPropCalls = true;
-
- // Populate default values in the properties document that is used by the ConfigDoc api endpoint
- getCrConfigUrl();
- getHeathUrl();
- getAuthUrl();
- getAuthUsername();
- getAuthPassword();
- getTmFrequency();
- getEventLogCount();
- getHealthPollingInterval();
- getHealthDsInterval();
- getDsCacheLeniency();
- shouldForceSystemExit();
- getPeerUrl();
- getPeerPollingInterval();
- getPeerThreadPool();
- getConnectionTimeout();
- getCacheTimePad();
- getPeerOptimistic();
- getPublishDsStates();
- getAccessControlAllowOrigin();
- getStartupMinCycles();
- }
-
- return super.getConfigDoc();
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Peer.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Peer.java
deleted file mode 100644
index 898e2c8..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/Peer.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.PeerState;
-
-public class Peer implements Serializable {
- private static final long serialVersionUID = 1L;
- final private String hostname;
- final private Map<String, String> headerMap = new HashMap<String, String>();
- final private String fqdn;
- final private String ip;
- final private String status;
- final private String location;
- final private int port;
-
- private PeerState state;
- private String error;
-
- public Peer(final String hostname, final JSONObject json) throws JSONException {
- this.hostname = hostname;
-
- fqdn = json.optString("fqdn");
- port = (json.optInt("port") == 0) ? 80 : json.optInt("port");
-
- if (fqdn != null && !fqdn.isEmpty()) {
- headerMap.put("Host", fqdn + ":" + getPortString());
- }
-
- ip = json.optString("ip");
- status = json.optString("status");
- location = json.optString("location");
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public String getId() {
- return getHostname();
- }
-
- public PeerState getState() {
- return state;
- }
-
- public void setState(final PeerState state) {
- this.state = state;
- }
-
- public String getError() {
- return error;
- }
-
- public void setError(final String error) {
- this.error = error;
- }
-
- public String getFqdn() {
- return fqdn;
- }
-
- public String getIpAddress() {
- return ip;
- }
-
- public String getStatus() {
- return status;
- }
-
- public String getLocation() {
- return location;
- }
-
- final public int getPort() {
- return port;
- }
-
- final public String getPortString() {
- return String.valueOf(getPort());
- }
-
- public String toString() {
- return getHostname();
- }
-
- public Map<String, String> getHeaderMap() {
- return headerMap;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/RouterConfig.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/RouterConfig.java
deleted file mode 100644
index 344e4bd..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/config/RouterConfig.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.config;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheStateRegistry;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.PeerState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.TmListener;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Network;
-
-public class RouterConfig {
- private static final Logger LOGGER = Logger.getLogger(RouterConfig.class);
-
- private static RouterConfig crConfig;
-
- final private List<Cache> cacheList = new ArrayList<Cache>();
- final private Map<String, Peer> peerMap = new HashMap<String, Peer>();
- final private JSONObject dsList;
-
- public RouterConfig(final JSONObject crConfigJson, final HealthDeterminer healthDeterminer) throws JSONException {
- final JSONObject cachesJson = crConfigJson.optJSONObject("contentServers");
-
- LOGGER.info("Processing new CrConfig");
-
- for (String id : JSONObject.getNames(cachesJson)) {
- try {
- final Cache cache = new Cache(id, cachesJson.getJSONObject(id));
- healthDeterminer.setControls(cache);
- cache.setCacheState(CacheStateRegistry.getInstance().get(cache.getHostname()));
- cacheList.add(cache);
- } catch (JSONException e) {
- LOGGER.warn("Failed processing json for cache " + id + ":", e);
- }
- }
-
- if (crConfigJson.has("monitors")) {
- final JSONObject peers = crConfigJson.optJSONObject("monitors");
-
- for (String id : JSONObject.getNames(peers)) {
- final Peer peer = new Peer(id, peers.optJSONObject(id));
-
- if (Network.isIpAddressLocal(peer.getIpAddress())) {
- LOGGER.debug("Skipping monitor " + id + "; IP address " + peer.getIpAddress() + " is local");
- continue;
- }
-
- if (Network.isLocalName(peer.getFqdn())) {
- LOGGER.debug("Skipping monitor " + id + "; fqdn " + peer.getFqdn() + " is the local fully qualified name");
- continue;
- }
-
- if (Network.isLocalName(id)) {
- LOGGER.debug("Skipping monitor " + id + "; short name " + id + " is the local hostname");
- continue;
- }
-
- if ("ONLINE".equals(peer.getStatus())) {
- peerMap.put(peer.getId(), peer);
- }
- }
-
- PeerState.removeAllBut(peerMap.keySet());
- }
-
- dsList = crConfigJson.optJSONObject("deliveryServices");
- }
-
- public List<Cache> getCacheList() {
- return cacheList;
- }
-
- public Map<String, Peer> getPeerMap() {
- return peerMap;
- }
-
- public JSONObject getDsList() {
- return dsList;
- }
-
- public static TmListener getTmListener(final HealthDeterminer healthDeterminer) {
- return new TmListener() {
- @Override
- public void handleCrConfig(final JSONObject crConfigJson) {
- try {
- crConfig = new RouterConfig(crConfigJson, healthDeterminer);
- } catch (Exception e) {
- LOGGER.warn("Failed Processing CrConfig json",e);
- }
- }
- };
- }
-
- public static RouterConfig getCrConfig() {
- return crConfig;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataPoint.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataPoint.java
deleted file mode 100644
index 9ac465d..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataPoint.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.data;
-
-public class DataPoint implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- private long index;
- private final String value;
- private int span;
-
- public DataPoint(final String value, final long index) {
- this.value = value;
- this.index = index;
- this.span = 1;
- }
-
- public String getValue() {
- return value;
- }
-
- public boolean matches(final String other) {
- return (other != null) ? other.equals(value) : value == null;
- }
-
- public long getIndex() {
- return index;
- }
-
- public void setIndex(final int index) {
- this.index = index;
- }
-
- public void update(final long index) {
- this.index = index;
- span++;
- }
-
- public int getSpan() {
- return span;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataSummary.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataSummary.java
deleted file mode 100644
index 820b19f..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/DataSummary.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.data;
-
-public class DataSummary implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- private long startTime;
- private long endTime;
- private double average;
- private double high;
- private double low;
- private double start;
- private double end;
- private int dpCount;
- public DataSummary() {
- }
- public void accumulate(final DataPoint dp, final long t) {
- final double v = Double.parseDouble(dp.getValue());
- if(dpCount == 0) {
- startTime = t;
- endTime = t;
- high = v;
- low = v;
- start = v;
- end = v;
- average = v;
- } else {
- if(t > endTime) {
- endTime = t;
- } else if(t < startTime) {
- startTime = t;
- }
- if(v > high) {
- high = v;
- } else if(v < low) {
- low = v;
- }
- // a = a' + (v-a')/(c'+1)
- end = v;
- average = average + (v-average)/(dpCount+1);
- }
- dpCount++;
- }
- public long getStartTime() {
- return startTime;
- }
- public long getEndTime() {
- return endTime;
- }
- public double getAverage() {
- return average;
- }
- public double getHigh() {
- return high;
- }
- public double getLow() {
- return low;
- }
- public int getDpCount() {
- return dpCount;
- }
- public double getStart() {
- return start;
- }
- public double getEnd() {
- return end;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/StatisticsLog.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/StatisticsLog.java
deleted file mode 100644
index 5645532..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/data/StatisticsLog.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.data;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import org.apache.log4j.Logger;
-
-import java.util.Arrays;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class StatisticsLog {
- private static final Logger LOGGER = Logger.getLogger(StatisticsLog.class);
- private final Map<String,Deque<DataPoint>> data = new HashMap<String,Deque<DataPoint>>();
- protected final Set<String> hiddenKeys = new HashSet<String>();
- private final List<Long> times = new LinkedList<Long>();
- private final List<Long> indexes = new LinkedList<Long>();
- private int index;
-
- public Deque<DataPoint> get(final String key) {
- return data.get(key);
- }
-
- public void putDataPoint(final String key, final String value) {
- Deque<DataPoint> statistics = data.get(key);
-
- if (statistics == null) {
- statistics = new LinkedList<DataPoint>();
- synchronized(data) {
- data.put(key, statistics);
- }
- }
-
- DataPoint dataPoint = getLastDataPoint(key);
-
- if (dataPoint != null && dataPoint.matches(value)) {
- dataPoint.update(index);
- return;
- }
-
- dataPoint = new DataPoint(value, index);
- statistics.addLast(dataPoint);
- }
-
- private DataPoint getLastDataPoint(final String key) {
- if (!hasValue(key)) {
- return null;
- }
-
- return data.get(key).getLast();
- }
-
- public Set<String> getKeys() {
- return data.keySet();
- }
-
- public boolean hasValue(final String key) {
- return data.containsKey(key) && (!data.get(key).isEmpty());
- }
-
- public String getLastValue(final String key) {
- final DataPoint dataPoint = getLastDataPoint(key);
- return (dataPoint != null) ? dataPoint.getValue() : null;
- }
-
- public String getValue(final String key, final long targetIndex) {
- if (!hasValue(key)) {
- return null;
- }
-
- Iterator<DataPoint> dataPoints = get(key).descendingIterator();
-
- while (dataPoints.hasNext()) {
- final DataPoint dataPoint = dataPoints.next();
- if (targetIndex > dataPoint.getIndex()) {
- return null;
- }
-
- if (targetIndex <= (dataPoint.getIndex() - dataPoint.getSpan())) {
- continue;
- }
-
- return dataPoint.getValue();
- }
-
- return null;
- }
-
- public boolean getBool(final String key) {
- try {
- return Boolean.parseBoolean(getLastValue(key));
- } catch (Exception e) {
- return true;
- }
- }
-
- public long getLong(final String key) {
- try {
- return Long.parseLong(getLastValue(key));
- } catch (Exception e) {
- return 0;
- }
- }
-
- public double getDouble(final String key) {
- try {
- return Double.parseDouble(getLastValue(key));
- } catch (Exception e) {
- return 0;
- }
- }
-
- private Set<String> filterKeys(final String[] statList, final boolean wildcard) {
- Set<String> statisticsKeys;
-
- if (statList == null) {
- return getKeys();
- }
-
- if (!wildcard) {
- return new HashSet<String>(Arrays.asList(statList));
- }
-
- statisticsKeys = new HashSet<String>();
-
- for (String key : getKeys()) {
- for (String stat : statList) {
- if (key.toLowerCase().contains(stat.toLowerCase())) {
- statisticsKeys.add(key);
- break;
- }
- }
- }
-
- return statisticsKeys;
- }
-
- public Map<String, Deque<DataPoint>> filter(final int maxItems, final String[] statList, final boolean wildcard, final boolean allowHidden) {
- final Map<String, Deque<DataPoint>> filteredStatistics = new HashMap<String,Deque<DataPoint>>();
-
- synchronized(data) {
- Set<String> statisticsKeys = filterKeys(statList, wildcard);
-
- for (String key : statisticsKeys) {
-
- if (!data.containsKey(key) || (!allowHidden && hiddenKeys.contains(key))) {
- continue;
- }
-
- final LinkedList<DataPoint> statistics = (LinkedList<DataPoint>) data.get(key);
-
- if (maxItems == 0 || statistics.size() <= 1) {
- filteredStatistics.put(key, statistics);
- } else {
- /*
- * If fromIndex == toIndex, List.subList() will return an empty list.
- * The only way they will be equal is if the list is empty or
- * has a single item, which is handled above.
- */
-
- final int toIndex = statistics.size();
- final int fromIndex = Math.max(0, toIndex - maxItems);
-
- filteredStatistics.put(key, new LinkedList<DataPoint>(statistics.subList(fromIndex, toIndex)));
- }
- }
- }
-
- return filteredStatistics;
- }
-
- public void addHiddenStats(Set<String> keys) {
- hiddenKeys.addAll(keys);
- }
-
- public long getTime(final DataPoint dataPoint) {
- return getTime(dataPoint.getIndex());
- }
-
- public long getTime(final long targetIndex) {
- synchronized(times) {
- for (long index : indexes) {
- if (index == targetIndex) {
- return times.get(indexes.indexOf(index));
- }
- }
- }
-
- return 0;
- }
-
- public void prepareForUpdate(final String stateId, final long historyTime) {
-
- synchronized(times) {
- addNullDataForIndex(index);
- index++;
- final long time = System.currentTimeMillis();
- final long removeTime = time - historyTime;
- int removeCount = 0;
-
- times.add(time);
- indexes.add(new Long(index));
-
- while (times.get(0) < removeTime) {
- removeCount++;
- times.remove(0);
- }
-
- if (removeCount == 0) {
- return;
- }
-
- for (int i = 0; i < removeCount; i++) {
- indexes.remove(0);
- }
-
- removeOldest(stateId);
- }
- }
-
- private void addNullDataForIndex(final long index) {
- synchronized (data) {
- for(String key : data.keySet()) {
- DataPoint lastDataPoint = getLastDataPoint(key);
- if (lastDataPoint == null || lastDataPoint.getIndex() != index) {
- putDataPoint(key, null);
- }
- }
- }
- }
-
- private void removeOldest(final String stateId) {
- final long oldestIndex = indexes.get(0);
-
- for(String key : data.keySet()) {
- final Deque<DataPoint> dataPoints = get(key);
-
- if (dataPoints.isEmpty()) {
- LOGGER.warn("list empty for " + key + " - " + stateId);
- continue;
- }
-
-
- while (dataPoints.getFirst().getIndex() < oldestIndex) {
- if (dataPoints.size() == 1) {
- LOGGER.warn(String.format("%s - %s: index %d < baseIndex %d", key, stateId, dataPoints.getFirst().getIndex(), oldestIndex));
- break;
- }
-
- dataPoints.remove();
-
- if (dataPoints.isEmpty()) {
- LOGGER.warn(String.format("list empty for %s - %s", key, stateId));
- }
- }
-
- }
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/AbstractState.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/AbstractState.java
deleted file mode 100644
index 47fb607..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/AbstractState.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.data.StatisticsLog;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.Event.EventType;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONArray;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.util.string.Strings;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.data.DataPoint;
-import com.comcast.cdn.traffic_control.traffic_monitor.data.DataSummary;
-
-abstract public class AbstractState {
- private static final Logger LOGGER = Logger.getLogger(AbstractState.class);
- public static final String IS_AVAILABLE_STR = "isAvailable";
- public static final String IS_HEALTHY_STR = "isHealthy";
- private long historyTime = 5*60*1000;
-
- final String id;
- protected final StatisticsLog statisticsLog = new StatisticsLog();
- private Event lastEvent = null;
-
- protected AbstractState(final String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- protected void putDataPoints(final Map<String, String> statistics) {
- if (statistics == null) {
- return;
- }
-
- synchronized(this) {
- for(String key : statistics.keySet()) {
- putDataPoint(key, statistics.get(key));
- }
- }
- }
-
- public void putDataPoint(final String key, final String v) {
- statisticsLog.putDataPoint(key, v);
- }
-
- public Set<String> getStatisticsKeys() {
- return statisticsLog.getKeys();
- }
-
- protected Map<String, Deque<DataPoint>> getStats(final int hc, final String[] statList, final boolean wildcard, final boolean hidden) {
- return statisticsLog.filter(hc, statList, wildcard, hidden);
- }
-
- protected Deque<DataPoint> getDataPoints(final String key) {
- return statisticsLog.get(key);
- }
-
- public boolean hasValue(final String key) {
- return statisticsLog.hasValue(key);
- }
-
- public String getLastValue(final String key) {
- return statisticsLog.getLastValue(key);
- }
-
- public String getValue(final String key, final long targetIndex) {
- return statisticsLog.getValue(key, targetIndex);
- }
-
- public boolean getBool(final String key) {
- return statisticsLog.getBool(key);
- }
-
- public long getLong(final String key) {
- return statisticsLog.getLong(key);
- }
-
- public double getDouble(final String key) {
- return statisticsLog.getDouble(key);
- }
-
- public boolean isAvailable() {
- return getBool(IS_AVAILABLE_STR);
- }
-
- public Map<String, DataSummary> getSummary(final long startTime, final long endTime, final String[] stats2, final boolean wildcard, final boolean hidden) {
- final Map<String, Deque<DataPoint>> map = getStats(0, stats2, wildcard, hidden);
- final Map<String, DataSummary> retMap = new HashMap<String, DataSummary>();
- final long checkPeriod = 5000;
- for(String key : map.keySet()) {
- final Deque<DataPoint> dpList = map.get(key);
- final DataSummary ds = new DataSummary();
- retMap.put(key, ds);
- for(DataPoint dp : dpList) {
- final int span = dp.getSpan();
- final long lastTime = statisticsLog.getTime(dp);
- for(int i = 0; i < span; i++) {
- final long t = lastTime - (checkPeriod * (span - (i+1)));
- if(startTime != 0 && t < startTime) { continue; }
- if(endTime != -1 && t > endTime) { break; }
- try {
- ds.accumulate(dp, t);
- } catch(Exception e) {
- LOGGER.debug(e);
- }
- }
- }
- }
- return retMap;
- }
-
- protected void prepareStatisticsForUpdate() {
- statisticsLog.prepareForUpdate(id, historyTime);
- }
-
- public void setHistoryTime(final long t) {
- if (t > 0) {
- historyTime = t;
- }
- }
-
- public String getStatusString() {
- final List<String> errors = new ArrayList<String>();
- final String error = getLastValue("error-string");
- final StringBuilder status = new StringBuilder();
-
- status.append(getLastValue("status"));
-
- if (error != null) {
- errors.add(error);
- } else {
- errors.add(isAvailable() ? "available" : "unavailable");
- }
-
- if (getBool("clearData")) {
- errors.add("monitoring disabled");
- }
-
- if (!errors.isEmpty()) {
- status.append(" - ");
- status.append(Strings.join(", ", errors));
- }
-
- return status.toString();
- }
-
- public boolean isError() {
- return getLastValue("error-string") != null;
- }
-
- public void setAvailable(final EventType type, final boolean isAvailable, final String error) {
- final boolean isHealthy = (error == null);
- boolean logChange = true;
-
- if (!isHealthy) {
- LOGGER.debug(String.format("Error on '%s': %s", id, error));
- }
-
- if (lastEvent != null && getBool(IS_HEALTHY_STR) == isHealthy && getBool(IS_AVAILABLE_STR) == isAvailable) {
- logChange = false;
- }
-
- putDataPoint(IS_AVAILABLE_STR, String.valueOf(isAvailable));
- putDataPoint(IS_HEALTHY_STR, String.valueOf(isHealthy));
-
- if (logChange) {
- lastEvent = Event.logStateChange(this.getId(), type, isAvailable, getStatusString());
- }
- }
-
- public JSONObject getStatsJson(final int hc, final String[] statList, final boolean wildcard, final boolean hidden) throws JSONException {
- final Map<String, Deque<DataPoint>> map = getStats(hc, statList, wildcard, hidden);
- final JSONObject ret = new JSONObject();
- for(String key : map.keySet()) {
- final JSONArray a = new JSONArray();
- ret.put(key, a);
- for(DataPoint dp : map.get(key)) {
- if (dp == null)
- continue;
-
- final JSONObject o = new JSONObject();
- /* Technically, this belongs in DataPoint, however, other logic
- * relies on a null DataPoint value. Because the JSON library
- * discards a key with a null value, let's handle it here. -jse
- */
- final String value = (dp.getValue() == null) ? "false" : dp.getValue();
- o.put("value", value);
- o.put("span", dp.getSpan());
- o.put("time", statisticsLog.getTime(dp));
- o.put("index", dp.getIndex());
- a.put(o);
- }
- }
- return ret;
- }
-
- public void addHiddenStats(Set<String> keys) {
- statisticsLog.addHiddenStats(keys);
- }
-
- public long getTime(final long index) {
- return statisticsLog.getTime(index);
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Bandwidth.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Bandwidth.java
deleted file mode 100644
index 0aea900..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Bandwidth.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-public class Bandwidth {
- public static final int BITS_IN_BYTE = 8;
- public static final int BITS_IN_KBPS = 1000;
-// public static final int MS_IN_SEC = 1000;
- public final long timeInMS;
- public final long bits;
-
- public Bandwidth(final String bytes) {
- timeInMS = System.currentTimeMillis();
- bits = Long.parseLong(bytes) * BITS_IN_BYTE;
- }
- public Bandwidth(final long bytes) {
- timeInMS = System.currentTimeMillis();
- bits = bytes * BITS_IN_BYTE;
- }
-
- public double calculateKbps(final Bandwidth current) {
- double result = 0.0;
- // as long as the numbers are not too large, dividing both num and denom by 1000 is a waste of time
- final double tDelta = ((current.timeInMS - timeInMS));// / MS_IN_SEC);
- if (tDelta > 0.0) {
- final double bitDiff = (current.bits - bits);
- result = bitDiff / tDelta;
- }
- return Math.max(0.0, result);
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheState.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheState.java
deleted file mode 100644
index 4d10f4a..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheState.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.ADMIN_DOWN;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.OFFLINE;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.REPORTED;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.STANDBY;
-
-public class CacheState extends AbstractState {
- transient private Cache cache;
- public static final String STATUS = "status";
- public static final String ERROR_STRING = "error-string";
-
- public CacheState(final String id) {
- super(id);
- }
-
- public void setCache(final Cache cache) {
- this.cache = cache;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- public void setError(final String error) {
- putDataPoint(STATUS, cache.getStatus());
- putDataPoint(ERROR_STRING, error);
- final Event.EventType type = Event.EventType.CACHE_STATE_CHANGE;
- type.setType(cache.getType());
- setAvailable(type, getIsAvailable(false), error);
- }
-
- public boolean getIsAvailable(final boolean isHealthy) {
- final AdminStatus status;
- try {
- status = AdminStatus.valueOf(cache.getStatus());
- } catch (IllegalArgumentException e) {
- return false;
- }
-
- return getIsAvailable(status, isHealthy);
- }
-
- public boolean getIsAvailable(AdminStatus status, final boolean isHealthy) {
- return (status == REPORTED) ? isHealthy : (status != ADMIN_DOWN && status != OFFLINE && status != STANDBY);
- }
-}
\ No newline at end of file
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateRegistry.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateRegistry.java
deleted file mode 100644
index dd63356..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateRegistry.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.ADMIN_DOWN;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.OFFLINE;
-
-public class CacheStateRegistry extends StateRegistry<CacheState> {
- // Recommended Singleton Pattern implementation
- // https://community.oracle.com/docs/DOC-918906
-
- private CacheStateRegistry() { }
-
- public static CacheStateRegistry getInstance() {
- return CacheStateRegistryHolder.REGISTRY;
- }
-
- private static class CacheStateRegistryHolder {
- private static final CacheStateRegistry REGISTRY = new CacheStateRegistry();
- }
-
- public CacheState update(final Cache cache) {
- CacheState cacheState = getOrCreate(cache.getHostname());
- cacheState.setCache(cache);
- return cacheState;
- }
-
- public int getCachesDownCount() {
- int count = 0;
- for (AbstractState state : states.values()) {
- if (state.isError()) {
- count++;
- }
- }
- return count;
- }
-
- public int getCachesAvailableCount() {
- int count = 0;
- for (AbstractState state : states.values()) {
- if (state.isAvailable()) {
- count++;
- }
- }
- return count;
- }
-
- public long getCachesBandwidthInKbps() {
- return getSumOfLongStatistic("kbps");
- }
-
- public long getCachesMaxBandwidthInKbps() {
- return getSumOfLongStatistic("maxKbps");
- }
-
- public String getStatusString(final String hostname) {
- AbstractState cacheState = states.get(hostname);
- if (cacheState == null || cacheState.isAvailable()) {
- return " ";
- }
-
- final String status = cacheState.getLastValue(HealthDeterminer.STATUS);
-
- if (status == null) {
- return "error";
- }
-
- HealthDeterminer.AdminStatus adminStatus = HealthDeterminer.AdminStatus.valueOf(status);
-
- if (adminStatus == ADMIN_DOWN || adminStatus == OFFLINE) {
- return "warning";
- }
-
- return "error";
- }
-
- @Override
- protected CacheState createState(final String id) {
- return new CacheState(id);
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateUpdater.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateUpdater.java
deleted file mode 100644
index 5ed444e..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStateUpdater.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.models.CacheDataModel;
-import com.ning.http.client.AsyncCompletionHandler;
-import com.ning.http.client.Response;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.Future;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class CacheStateUpdater extends AsyncCompletionHandler<Object> {
- final private static Logger LOGGER = Logger.getLogger(CacheStateUpdater.class);
- final private CacheState state;
- final private CacheDataModel errorCount;
- private long time;
- private long requestTimeout;
- private HealthDeterminer myHealthDeterminer;
- private AtomicInteger failCount;
- private Future<Object> future;
-
- public CacheStateUpdater(final CacheState cacheState, final CacheDataModel errorCount) {
- this.state = cacheState;
- this.errorCount = errorCount;
- }
-
- public CacheStateUpdater update(final HealthDeterminer myHealthDeterminer, AtomicInteger failCount, long requestTimeout) {
- this.myHealthDeterminer = myHealthDeterminer;
- this.time = System.currentTimeMillis();
- this.failCount = failCount;
- this.requestTimeout = requestTimeout;
- return this;
- }
-
- @Override
- public Integer onCompleted(final Response response) throws JSONException, IOException {
- final int code = response.getStatusCode();
- state.putDataPoint("queryTime", String.valueOf(System.currentTimeMillis() - time));
-
- if (code != 200) {
- state.setError(code + " - " + response.getStatusText());
- return code;
- }
-
- final Map<String, String> statisticsMap = new HashMap<String, String>();
-
- final JSONObject json = new JSONObject(response.getResponseBody());
- JSONObject ats = json.has("global") ? json.optJSONObject("global") : json.optJSONObject("ats");
-
- statisticsMap.putAll(jsonToPrefixedMap(ats, "ats."));
- statisticsMap.putAll(jsonToPrefixedMap(json.optJSONObject("system"), "system."));
-
- state.putDataPoints(statisticsMap);
- state.putDataPoint("stateUrl", state.getCache().getStatisticsUrl());
-
- synchronized (state.getCache()) {
- state.getCache().setState(state, myHealthDeterminer);
- }
-
- return code;
- }
-
- @Override
- public void onThrowable(final Throwable t) {
- if (!(t instanceof CancellationException)) {
- LOGGER.warn(t + " : " + state.getCache().getStatisticsUrl());
- failCount.incrementAndGet();
- } else {
- LOGGER.warn("Request to " + state.getCache().getStatisticsUrl() + " failed to complete in time");
- }
-
- state.putDataPoint("queryTime", String.valueOf(System.currentTimeMillis() - time));
-
- try {
- errorCount.inc();
- state.setError(t.toString());
- } catch (Exception e2) {
- LOGGER.warn(e2, e2);
- }
- }
-
- private Map<String, String> jsonToPrefixedMap(JSONObject json, final String prefix) {
- Map<String, String> map = new HashMap<String, String>();
-
- Iterator<?> keys = json.keys();
-
- while (keys.hasNext()) {
- final String key = (String) keys.next();
- map.put(prefix + key, String.valueOf(json.opt(key)));
- }
-
- return map;
- }
-
- public void setFuture(final Future<Object> future) {
- this.future = future;
- }
-
- public boolean completeFetchStatistics(final AtomicInteger cancelCount) {
- if (future == null || future.isDone() || future.isCancelled()) {
- return true;
- }
-
- if (System.currentTimeMillis() > requestTimeout) {
- try {
- future.cancel(true);
- cancelCount.incrementAndGet();
- } catch (Exception e) {
- LOGGER.warn("Error on cancel: " + e);
- }
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStatisticsClient.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStatisticsClient.java
deleted file mode 100644
index 206226d..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheStatisticsClient.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.ning.http.client.AsyncHttpClient;
-import com.ning.http.client.AsyncHttpClientConfig;
-import com.ning.http.client.ProxyServer;
-import com.ning.http.client.Request;
-import org.apache.log4j.Logger;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Future;
-
-public class CacheStatisticsClient {
- private static final Logger LOGGER = Logger.getLogger(CacheStatisticsClient.class);
- private final AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
-
- public void fetchCacheStatistics(final Cache cache, final CacheStateUpdater cacheStateUpdater) {
- int port = cache.getQueryPort() != 0 ? cache.getQueryPort() : 80;
- final ProxyServer proxyServer = new ProxyServer(cache.getQueryIp(), port);
-
- Request request = asyncHttpClient
- .prepareGet(cache.getStatisticsUrl())
- .setProxyServer(proxyServer)
- .build();
-
- try {
- final Future<Object> future = asyncHttpClient.executeRequest(request, cacheStateUpdater);
- cacheStateUpdater.setFuture(future);
- } catch (IOException e) {
- LOGGER.warn("Failed to fetch cache statistics from " + request.getUrl(),e);
- }
- }
-
-
- public void shutdown() {
- while (!asyncHttpClient.isClosed()) {
- LOGGER.warn("closing");
- asyncHttpClient.close();
- }
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheWatcher.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheWatcher.java
deleted file mode 100644
index 8228728..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/CacheWatcher.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.models.CacheDataModel;
-import org.apache.log4j.Logger;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.RouterConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.OFFLINE;
-import static com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer.AdminStatus.ONLINE;
-
-public class CacheWatcher {
- private static final Logger LOGGER = Logger.getLogger(CacheWatcher.class);
-
- private HealthDeterminer myHealthDeterminer;
-
- private static final List<CacheDataModel> list = new ArrayList<CacheDataModel>();
- private static final CacheDataModel itercount = new CacheDataModel("Iteration Count");
- private static final CacheDataModel fetchCount = new CacheDataModel("Fetch Count");
- private static final CacheDataModel errorCount = new CacheDataModel("Error Count");
- private static final CacheDataModel queryInterval = new CacheDataModel("Last Query Interval");
- private static final CacheDataModel queryIntervalActual = new CacheDataModel("Query Interval Actual");
- private static final CacheDataModel queryIntervalTarget = new CacheDataModel("Query Interval Target");
- private static final CacheDataModel queryIntervalDelta = new CacheDataModel("Query Interval Delta");
- private static final CacheDataModel freeMem = new CacheDataModel("Free Memory (MB)");
- private static final CacheDataModel totalMem = new CacheDataModel("Total Memory (MB)");
- private static final CacheDataModel maxMemory = new CacheDataModel("Max Memory (MB)");
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- private final List<CacheStateUpdater> cacheStateUpdaters = new ArrayList<CacheStateUpdater>();
- boolean isActive = true;
-
- private FetchService mainThread;
-
- private final CacheStateRegistry cacheStateRegistry = CacheStateRegistry.getInstance();
- private final CacheStatisticsClient cacheStatisticsClient = new CacheStatisticsClient();
-
- public static List<CacheDataModel> getProps() {
- return list;
- }
-
- public CacheWatcher init(final HealthDeterminer hd) {
- myHealthDeterminer = hd;
- list.add(itercount);
- list.add(fetchCount);
- list.add(errorCount);
- list.add(queryInterval);
- list.add(queryIntervalActual);
- list.add(queryIntervalTarget);
- list.add(queryIntervalDelta);
- list.add(totalMem);
- list.add(freeMem);
- list.add(maxMemory);
-
- mainThread = new FetchService();
- mainThread.start();
- return this;
- }
-
- class FetchService extends Thread {
- public FetchService() {
- }
-
- final Runtime runtime = Runtime.getRuntime();
-
- private List<CacheState> checkCaches(final RouterConfig crConfig, final AtomicInteger failCount) {
- maxMemory.set(runtime.maxMemory() / (1024 * 1024));
- totalMem.set(runtime.totalMemory() / (1024 * 1024));
- freeMem.set(runtime.freeMemory() / (1024 * 1024));
-
- final List<CacheState> cacheStates = new ArrayList<CacheState>();
-
- for (Cache cache : crConfig.getCacheList()) {
-
- if (!isActive) {
- // destroy was called, do stop fetching
- return cacheStates;
- }
-
- if (!myHealthDeterminer.shouldMonitor(cache)) {
- continue;
- }
-
- final CacheState state = cacheStateRegistry.update(cache);
-
- cacheStates.add(state);
-
- if (!shouldFetchStats(cache)) {
- cache.setState(state, myHealthDeterminer);
- continue;
- }
-
- state.prepareStatisticsForUpdate();
-
- fetchCount.inc();
- state.putDataPoint("_queryUrl_", cache.getStatisticsUrl());
- state.setHistoryTime(cache.getHistoryTime());
-
- final long requestTimeout = System.currentTimeMillis() + myHealthDeterminer.getConnectionTimeout(cache, 2000);
-
- final CacheStateUpdater cacheStateUpdater = new CacheStateUpdater(state, errorCount).update(myHealthDeterminer, failCount, requestTimeout);
- cacheStateUpdaters.add(cacheStateUpdater);
- cacheStatisticsClient.fetchCacheStatistics(cache, cacheStateUpdater);
-
- cacheTimePad();
- }
-
- return cacheStates;
- }
-
- private void cacheTimePad() {
- if (config == null) {
- return;
- }
-
- final int t = config.getCacheTimePad();
-
- if (t == 0) {
- return;
- }
-
- try {
- Thread.sleep(t);
- } catch (InterruptedException e) {
- // Ignore
- }
- }
-
- public void run() {
- while (true) {
- if (!isActive) {
- LOGGER.warn("Not active");
- return;
- }
-
- try {
- final long time = System.currentTimeMillis();
- final RouterConfig crConfig = RouterConfig.getCrConfig();
-
- if (crConfig == null && config != null) {
- try {
- Thread.sleep(config.getHealthPollingInterval());
- } catch (InterruptedException e) {
- // Ignore
- }
-
- LOGGER.warn("No router config available, skipping health check");
- continue;
- }
-
- final AtomicInteger failCount = new AtomicInteger(0);
- final List<CacheState> states = checkCaches(crConfig, failCount);
-
- boolean waitForFinish = true;
- final AtomicInteger cancelCount = new AtomicInteger(0);
-
- while (waitForFinish) {
- waitForFinish = false;
-
- for (CacheStateUpdater updater : cacheStateUpdaters) {
- waitForFinish |= !updater.completeFetchStatistics(cancelCount);
- }
- }
-
- cacheStateUpdaters.clear();
- cacheStateRegistry.removeAllBut(states);
- final long completedTime = System.currentTimeMillis();
-
- try {
- Thread.sleep(Math.max(config.getHealthPollingInterval() - (completedTime - time), 0));
- } catch (InterruptedException e) {
- // Ignore
- }
-
- itercount.inc();
-
- final long mytime = System.currentTimeMillis() - time;
-
- queryInterval.set(mytime);
- queryIntervalTarget.set(config.getHealthPollingInterval());
- queryIntervalActual.set(completedTime - time);
- queryIntervalDelta.set((completedTime - time) - config.getHealthPollingInterval());
-
- LOGGER.debug("Check time of " + states.size() + " caches elapsed: " + mytime + " msec, (Active time was " + (completedTime - time) + ") msec, " + cancelCount.get() + " checks were cancelled, " + failCount.get() + " failed");
- } catch (Exception e) {
- LOGGER.warn(e, e);
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) {
- // Ignore
- }
- }
- }
- }
- }
-
-
- public void destroy() {
- LOGGER.warn("CacheWatcher: shutting down ");
-
- isActive = false;
- final long time = System.currentTimeMillis();
-
- mainThread.interrupt();
- cacheStatisticsClient.shutdown();
-
- while (mainThread.isAlive()) {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- // Ignore
- }
- }
- LOGGER.warn("Stopped: Termination time: " + (System.currentTimeMillis() - time));
- }
-
- public long getCycleCount() {
- return itercount.getRawValue();
- }
-
- public boolean shouldFetchStats(final Cache cache) {
- HealthDeterminer.AdminStatus adminStatus = HealthDeterminer.AdminStatus.valueOf(cache.getStatus());
- return (adminStatus != OFFLINE && adminStatus != ONLINE);
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DeliveryServiceStateRegistry.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DeliveryServiceStateRegistry.java
deleted file mode 100644
index c73906c..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DeliveryServiceStateRegistry.java
+++ /dev/null
@@ -1,216 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.data.DataPoint;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-
-public class DeliveryServiceStateRegistry extends StateRegistry<DsState> {
- private static final Logger LOGGER = Logger.getLogger(DeliveryServiceStateRegistry.class);
-
- // Recommended Singleton Pattern implementation
- // https://community.oracle.com/docs/DOC-918906
-
- private DeliveryServiceStateRegistry() { }
-
- public static DeliveryServiceStateRegistry getInstance() {
- return DeliveryServiceStateRegistryHolder.REGISTRY;
- }
-
- private static class DeliveryServiceStateRegistryHolder {
- private static final DeliveryServiceStateRegistry REGISTRY = new DeliveryServiceStateRegistry();
- }
-
- public void completeUpdateAll(final HealthDeterminer myHealthDeterminer, final JSONObject dsList, final long lenientTime) {
- for (CacheState cacheState : CacheStateRegistry.getInstance().getAll()) {
- if (cacheState.getCache() != null && cacheState.getCache().hasDeliveryServices()) {
- updateStates(cacheState, lenientTime);
- }
- }
-
- final Collection<String> toRemove = new ArrayList<String>();
- toRemove.addAll(states.keySet());
-
- if (dsList != null) {
- for (String dsId : JSONObject.getNames(dsList)) {
- toRemove.remove(dsId);
- try {
- final DsState dss = (DsState) getOrCreate(dsId);
- dss.completeRound(myHealthDeterminer.getDsControls(dss.getId()));
- } catch (Exception e) {
- LOGGER.warn(e, e);
- }
- }
- }
-
- for(String id : toRemove) {
- states.remove(id);
- }
- }
-
- private void updateStates(final CacheState cacheState, final long lenientTime) {
- final Cache cache = cacheState.getCache();
-
- for(String deliveryServiceId : cache.getDeliveryServiceIds()) {
- try {
- final List<String> fqdns = cache.getFqdns(deliveryServiceId);
- final DsState deliveryServiceState = (DsState) getOrCreate(deliveryServiceId);
-
- // Don't count the cache as reporting unless there were no errors and stats were read
- boolean error = false;
- boolean foundStats = false;
-
- for(String fqdn : fqdns) {
- final String propBase = "ats.plugin.remap_stats."+fqdn;
- final DsStati stati = createStati(propBase, cacheState, lenientTime, deliveryServiceId);
-
- deliveryServiceState.accumulate(stati, cache.getLocation(), cacheState);
-
- if (stati != null) {
- foundStats = true;
-
- if (stati.error) {
- error = true;
- }
- }
- }
-
- // Update cache counters
- deliveryServiceState.addCacheConfigured();
-
- if (cacheState.isAvailable()) {
- deliveryServiceState.addCacheAvailable();
- }
-
- if (foundStats && !error) {
- deliveryServiceState.addCacheReporting();
- }
- } catch(Exception e) {
- LOGGER.warn(e,e);
- }
- }
- }
-
- public void startUpdateAll() {
- synchronized(states) {
- for(AbstractState ds :states.values()) {
- ds.prepareStatisticsForUpdate();
- }
- }
- }
-
- @Override
- protected DsState createState(final String deliveryServiceId) {
- return new DsState(deliveryServiceId);
- }
-
- private DsStati createStati(final String propBase, final CacheState cacheState, final long leniency, final String dsId) {
- DsStati dsStati;
-
- synchronized (cacheState) {
- final Deque<DataPoint> dataPoints = cacheState.getDataPoints(propBase + ".out_bytes");
-
- if (dataPoints == null) {
- return null;
- }
-
- long lastIndex = dataPoints.getLast().getIndex();
- lastIndex = getLastGoodIndex(dataPoints, lastIndex);
-
- if (lastIndex < 0) {
- return null;
- }
-
- final long time = cacheState.getTime(lastIndex);
-
- if (time < leniency) {
- return null;
- }
-
- dsStati = new DsStati(propBase, cacheState, lastIndex, dsId);
-
- final long prevIndex = getLastGoodIndex(dataPoints, lastIndex-1);
-
- if (prevIndex >= 0) {
- final DsStati priorDsStati = new DsStati(propBase, cacheState, prevIndex, dsId);
-
- if (!dsStati.calculateKbps(priorDsStati)) {
- if (LOGGER.isInfoEnabled()) {
- printDps(dataPoints, propBase);
- }
- }
- }
- }
-
- return dsStati;
- }
-
- public long getLastGoodIndex(final Deque<DataPoint> dataPoints, final long targetIndex) {
- if (targetIndex < 0) {
- return -1;
- }
-
- Iterator<DataPoint> dataPointIterator = dataPoints.descendingIterator();
-
- while (dataPointIterator.hasNext()) {
- DataPoint dataPoint = dataPointIterator.next();
- if (dataPoint.getValue() == null) {
- continue;
- }
-
- final long index = dataPoint.getIndex();
- final long span = dataPoint.getSpan();
-
- if (targetIndex <= (index-span)) {
- continue;
- }
-
- if (targetIndex < index) {
- return targetIndex;
- }
-
- return index;
- }
-
- return -1;
- }
-
- public boolean printDps(final Deque<DataPoint> dataPoints, final String id) {
- LOGGER.warn(id + ":");
-
- Iterator<DataPoint> dataPointIterator = dataPoints.descendingIterator();
- while (dataPointIterator.hasNext()) {
- DataPoint dataPoint = dataPointIterator.next();
- LOGGER.warn(String.format("\tindex: %d, span: %d, value: %s", dataPoint.getIndex(), dataPoint.getSpan(), dataPoint.getValue()));
- }
-
- return false;
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsState.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsState.java
deleted file mode 100644
index 51057b5..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsState.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.wicket.ajax.json.JSONArray;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.EmbeddedStati.StatType;
-
-public class DsState extends AbstractState {
- private static final long serialVersionUID = 1L;
- final private Map<StatType, Map<String, EmbeddedStati>> aggregateStats = new HashMap<StatType, Map<String, EmbeddedStati>>();
- final public static String DISABLED_LOCATIONS = "disabledLocations";
-
- private DsStati currentDsStati;
- private int cachesConfigured = 0;
- private int cachesAvailable = 0;
- private int cachesReporting = 0;
-
- public DsState(final String id) {
- super(id);
- }
-
- public void accumulate(final DsStati stati, final String location, final CacheState state) {
- if (stati == null) {
- return;
- }
-
- if (currentDsStati == null) {
- currentDsStati = stati;
- } else {
- currentDsStati.accumulate(stati);
- }
-
- aggregateStats(StatType.LOCATION, location, stati);
- aggregateStats(StatType.CACHE, state.id, stati);
- aggregateStats(StatType.TYPE, state.getCache().getType(), stati);
- }
-
- private void aggregateStats(final StatType statType, final String statKey, final DsStati dsStat) {
- if (!aggregateStats.containsKey(statType)) {
- aggregateStats.put(statType, new HashMap<String, EmbeddedStati>());
- }
-
- final Map<String, EmbeddedStati> aggregate = aggregateStats.get(statType);
-
- if (!aggregate.containsKey(statKey)) {
- aggregate.put(statKey, new EmbeddedStati(statType, statKey));
- }
-
- aggregate.get(statKey).accumulate(dsStat);
- }
-
- public boolean completeRound(final JSONObject dsControls) {
- if (currentDsStati != null && currentDsStati.out_bytes != 0) {
- putDataPoints(currentDsStati.getStati("total"));
- currentDsStati = null;
- }
-
- putDataPoint("caches-configured", String.valueOf(cachesConfigured));
- putDataPoint("caches-available", String.valueOf(cachesAvailable));
- putDataPoint("caches-reporting", String.valueOf(cachesReporting));
-
- cachesConfigured = 0;
- cachesAvailable = 0;
- cachesReporting = 0;
-
- HealthDeterminer.setIsAvailable(this, dsControls);
-
- for (Map<String, EmbeddedStati> aggregate : aggregateStats.values()) {
- processDataPoints(aggregate.values(), dsControls);
- }
-
- return true;
- }
-
- private void processDataPoints(final Collection<EmbeddedStati> stats, final JSONObject dsControls) {
- final Map<StatType, StringBuilder> disabled = new HashMap<StatType, StringBuilder>();
-
- for (EmbeddedStati stat : stats) {
- final Map<String, String> points = stat.completeRound();
-
- if (points == null) {
- continue;
- }
-
- putDataPoints(points);
-
- if (stat.isHidden()) {
- addHiddenStats(points.keySet());
- }
-
- if (stat.getStatType() == StatType.LOCATION) {
- if (!disabled.containsKey(stat.getStatType())) {
- disabled.put(stat.getStatType(), new StringBuilder());
- }
-
- if (!HealthDeterminer.setIsLocationAvailable(this, stat, dsControls)) {
- disabled.get(stat.getStatType()).append("\"").append(stat.getId()).append("\", ");
- }
- }
- }
-
- for (StatType statType : disabled.keySet()) {
- final StringBuilder sb = disabled.get(statType);
-
- if (statType == StatType.LOCATION && sb != null) {
- final String s = sb.toString();
- putDataPoint(DISABLED_LOCATIONS, s);
- }
- }
- }
-
- public JSONArray getDisabledLocations() throws JSONException {
- return new JSONArray("["+this.getLastValue(DISABLED_LOCATIONS)+"]");
- }
-
- public void addCacheConfigured() {
- this.cachesConfigured++;
- }
-
- public void addCacheAvailable() {
- this.cachesAvailable++;
- }
-
- public void addCacheReporting() {
- this.cachesReporting++;
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsStati.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsStati.java
deleted file mode 100644
index 016ab5e..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsStati.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import org.apache.log4j.Logger;
-
-import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-public class DsStati implements java.io.Serializable {
- private static final Logger LOGGER = Logger.getLogger(DsStati.class);
- private static final long serialVersionUID = 1L;
- long csIndex = 0;
- long in_bytes;
- long out_bytes;
- long status_2xx;
- long status_3xx;
- long status_4xx;
- long status_5xx;
- boolean error = false;
-
- double kbps;
- double tps_2xx;
- double tps_3xx;
- double tps_4xx;
- double tps_5xx;
- double tps_total;
-
- String dsId;
- String csId;
-
- public static final int BITS_IN_BYTE = 8;
- public static final int MS_IN_SEC = 1000;
- public final long time;
-
- public DsStati(final String propBase, final CacheState cacheState, final long index, final String dsId) {
- this.csIndex = index;
- this.time = cacheState.getTime(index);
- String v = cacheState.getValue(propBase + ".in_bytes", index);
- this.in_bytes = toLong(v);
- final String k = propBase + ".out_bytes";
- v = cacheState.getValue(k, index);
- this.out_bytes = toLong(v);
- v = cacheState.getValue(propBase + ".status_2xx", index);
- this.status_2xx = toLong(v);
- this.status_3xx = toLong(cacheState.getValue(propBase + ".status_3xx", index));
- this.status_4xx = toLong(cacheState.getValue(propBase + ".status_4xx", index));
- this.status_5xx = toLong(cacheState.getValue(propBase + ".status_5xx", index));
- this.dsId = dsId;
- this.csId = cacheState.getId();
- }
-
- public DsStati(final DsStati stati) {
- this.error = stati.error;
- this.time = stati.time;
- this.in_bytes = stati.in_bytes;
- this.out_bytes = stati.out_bytes;
- this.status_2xx = stati.status_2xx;
- this.status_3xx = stati.status_3xx;
- this.status_4xx = stati.status_4xx;
- this.status_5xx = stati.status_5xx;
-
- this.kbps = stati.kbps;
- this.tps_2xx = stati.tps_2xx;
- this.tps_3xx = stati.tps_3xx;
- this.tps_4xx = stati.tps_4xx;
- this.tps_5xx = stati.tps_5xx;
- this.tps_total = stati.tps_total;
- }
-
- private static long toLong(final String str) {
- if (str == null) {
- return 0;
- }
- return (long) Double.parseDouble(str);
- }
-
- void accumulate(final DsStati ds) {
- this.in_bytes += ds.in_bytes;
- this.out_bytes += ds.out_bytes;
- this.status_2xx += ds.status_2xx;
- this.status_3xx += ds.status_3xx;
- this.status_4xx += ds.status_4xx;
- this.status_5xx += ds.status_5xx;
-
- this.kbps += ds.kbps;
- this.tps_2xx += ds.tps_2xx;
- this.tps_3xx += ds.tps_3xx;
- this.tps_4xx += ds.tps_4xx;
- this.tps_5xx += ds.tps_5xx;
- this.tps_total += ds.tps_total;
- }
-
- public boolean calculateKbps(final DsStati prior) {
- if (prior == null) {
- LOGGER.warn("why is prior null");
- return false;
- }
- if (prior.time == 0) {
- LOGGER.warn("why is prior.time==0");
- }
- if ((out_bytes == 0 || prior.out_bytes == 0) && out_bytes != prior.out_bytes) {
- LOGGER.warn(dsId + ": throwing out " + csId + ": out_bytes==0");
- if (prior.out_bytes != 0) {
- LOGGER.warn("\t prior.out_bytes=" + prior.out_bytes);
- }
- return false;
- }
- final long deltaTimeMs = time - prior.time; // / MS_IN_SEC
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(String.format("time delta: %d, index: %d -> %d", deltaTimeMs, prior.csIndex, this.csIndex));
- }
- if (deltaTimeMs == 0) {
- LOGGER.warn("time delta 0");
- return false;
- }
- final long delta = (out_bytes - prior.out_bytes);
- // as long as the numbers are not too large, dividing both num and denom by 1000 is a waste of time
- // rates.kbps = (delta / BITS_IN_KBPS) * BITS_IN_BYTE / deltaTime;
- kbps = ((double) delta / (double) deltaTimeMs) * BITS_IN_BYTE;
- if (kbps < 0.0) {
- LOGGER.warn(dsId + ": throwing out " + csId + ": kbps=" + kbps);
- kbps = 0.0;
- return false;
- }
-
- final double deltaTime = (double) deltaTimeMs / (double) MS_IN_SEC;
-
- tps_2xx = ((double) status_2xx - (double) prior.status_2xx) / deltaTime;
- tps_3xx = ((double) status_3xx - (double) prior.status_3xx) / deltaTime;
- tps_4xx = ((double) status_4xx - (double) prior.status_4xx) / deltaTime;
- tps_5xx = ((double) status_5xx - (double) prior.status_5xx) / deltaTime;
- tps_total = tps_2xx + tps_3xx + tps_4xx + tps_5xx;
-
- return true;
- }
-
- Map<String, String> getStati(final String base) {
- final Map<String, String> r = new HashMap<String, String>();
- r.put(base + ".in_bytes", String.valueOf(in_bytes));
- r.put(base + ".out_bytes", String.valueOf(out_bytes));
- r.put(base + ".status_2xx", String.valueOf(status_2xx));
- r.put(base + ".status_3xx", String.valueOf(status_3xx));
- r.put(base + ".status_4xx", String.valueOf(status_4xx));
- r.put(base + ".status_5xx", String.valueOf(status_5xx));
-
- DecimalFormat df = new DecimalFormat("0.00");
- r.put(base + ".kbps", df.format(kbps));
- r.put(base + ".tps_2xx", df.format(tps_2xx));
- r.put(base + ".tps_3xx", df.format(tps_3xx));
- r.put(base + ".tps_4xx", df.format(tps_4xx));
- r.put(base + ".tps_5xx", df.format(tps_5xx));
- r.put(base + ".tps_total", df.format(tps_total));
- return r;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsWatcher.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsWatcher.java
deleted file mode 100644
index c1e8482..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/DsWatcher.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import org.apache.log4j.Logger;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.RouterConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-
-public class DsWatcher {
- private static final Logger LOGGER = Logger.getLogger(DsWatcher.class);
-
- private HealthDeterminer myHealthDeterminer;
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- boolean isActive = true;
- private FetchService mainThread;
- private final DeliveryServiceStateRegistry deliveryServiceStateRegistry = DeliveryServiceStateRegistry.getInstance();
-
- public DsWatcher init(final HealthDeterminer hd) {
- myHealthDeterminer = hd;
- mainThread = new FetchService();
- mainThread.start();
- return this;
- }
-
- class FetchService extends Thread {
- public FetchService() {
- }
-
- public void run() { // run the service
- while(true) {
- if(!isActive) { return; }
- try {
- final long time = System.currentTimeMillis();
- final RouterConfig crConfig = RouterConfig.getCrConfig();
- if(crConfig == null) {
- try {
- Thread.sleep(config.getHealthPollingInterval());
- } catch (InterruptedException e) { }
- continue;
- }
-
- deliveryServiceStateRegistry.startUpdateAll();
-
- if (crConfig.getDsList() == null) {
- LOGGER.warn("No Delivery Services present in CR Config");
- }
-
- deliveryServiceStateRegistry.completeUpdateAll(myHealthDeterminer, crConfig.getDsList(), time-config.getDsCacheLeniency());
- try {
- Thread.sleep(Math.max(config.getHealthDsInterval()-(System.currentTimeMillis()-time),0));
- } catch (InterruptedException e) { }
- final long mytime = System.currentTimeMillis()-time;
- LOGGER.debug("Pool time elapsed: "+mytime);
- } catch (Exception e) {
- LOGGER.warn(e,e);
- try {
- Thread.sleep(100);
- } catch (InterruptedException ex) { }
- }
- }
- }
-
- }
-
- public void destroy() {
- LOGGER.warn("DsWatcher: shutting down ");
- isActive = false;
- final long time = System.currentTimeMillis();
- mainThread.interrupt();
- while(mainThread.isAlive()) {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- }
- LOGGER.warn("Stopped: Termination time: "+(System.currentTimeMillis() - time));
- }
-
-}
-
-
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/EmbeddedStati.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/EmbeddedStati.java
deleted file mode 100644
index 22ad81d..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/EmbeddedStati.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class EmbeddedStati implements java.io.Serializable {
- private static final long serialVersionUID = 1L;
- private DsStati currentDtati;
- private final String id;
- private StatType statType;
-
- public enum StatType {
- LOCATION,
- CACHE,
- TYPE
- };
-
- public EmbeddedStati(final StatType statType, final String id, final String delimiter) {
- final StringBuilder statId = new StringBuilder();
-
- statId.append(statType.toString().toLowerCase());
- statId.append(delimiter);
- statId.append(id);
-
- this.id = statId.toString();
- this.statType = statType;
- }
-
- public EmbeddedStati(final StatType statType, final String id) {
- this(statType, id, ".");
- }
-
- public void accumulate(final DsStati stati) {
- if (currentDtati == null) {
- currentDtati = new DsStati(stati);
- } else {
- currentDtati.accumulate(stati);
- }
- }
-
- public Map<String, String> completeRound() {
- if (currentDtati == null) {
- return null;
- }
-
- final Map<String, String> r = new HashMap<String, String>();
-
- r.putAll(currentDtati.getStati(this.getId()));
- currentDtati = null;
-
- return r;
- }
-
- public String getId() {
- return id;
- }
-
- public boolean isHidden() {
- return (statType == StatType.CACHE) ? true : false;
- }
-
- public StatType getStatType() {
- return statType;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Event.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Event.java
deleted file mode 100644
index 0b9155d..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/Event.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-
-public class Event extends JSONObject implements Serializable {
- private static final Logger EVENT_LOGGER = Logger.getLogger("com.comcast.cdn.traffic_control.traffic_monitor.event");
- private static final Logger LOGGER = Logger.getLogger(Event.class);
- private static final long serialVersionUID = 1L;
- static List<JSONObject> rollingLog = new LinkedList<JSONObject>();
- static int logIndex = 0;
-
- public enum EventType {
- CACHE_STATE_CHANGE,
- PEER_STATE_CHANGE("Peer"),
- DELIVERY_SERVICE_STATE_CHANGE("Delivery Service");
-
- private String type;
-
- EventType(final String type) {
- this.type = type;
- }
-
- EventType() {
- }
-
- @Override
- public String toString() {
- return (type != null) ? type : "UNKNOWN";
- }
-
- public void setType(final String type) {
- this.type = type;
- }
- }
-
- public static Event logStateChange(final String name, final EventType type, final boolean isAvailable, final String message) {
- final long currentTimeMillis = System.currentTimeMillis();
- final String timeString = String.format("%d.%03d", currentTimeMillis / 1000, currentTimeMillis % 1000);
-
- EVENT_LOGGER.info(String.format("%s host=\"%s\", type=%s, available=%s, msg=\"%s\"", timeString , name, type, String.valueOf(isAvailable), message));
-
- final Event ret = new Event(name, type, isAvailable, message);
- final int eventLogCount = ConfigHandler.getInstance().getConfig().getEventLogCount();
-
- synchronized (rollingLog) {
- rollingLog.add(0, ret);
- while(rollingLog.size() > eventLogCount) {
- rollingLog.remove(rollingLog.size()-1);
- }
- }
- return ret;
- }
-
- public static List<JSONObject> getEventLog() {
- synchronized (rollingLog) {
- return new ArrayList<JSONObject>(rollingLog);
- }
- }
-
- public Event(final String name, final EventType type, final boolean isAvailable, final String error) {
- try {
- this.put("hostname", name); // left this to preserve behavior for any dependent uses
- this.put("name", name);
- this.put("type", type.toString());
- this.put("time", System.currentTimeMillis());
- this.put("index", logIndex++);
- this.put("isAvailable", isAvailable);
- this.put("description", error);
-
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/HealthDeterminer.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/HealthDeterminer.java
deleted file mode 100644
index 072380e..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/HealthDeterminer.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.io.File;
-import java.io.FileReader;
-import java.text.DecimalFormat;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.Event.EventType;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Updatable;
-
-public class HealthDeterminer {
- private static final Logger LOGGER = Logger.getLogger(HealthDeterminer.class);
-
- public static final String IS_AVAILABLE_KEY = "isAvailable";
- public static final String STATUS = "status";
- public static final String ERROR_STRING = "error-string";
- public static final String NO_ERROR_FOUND = "No error found";
-
- private JSONObject profiles;
- private JSONObject deliveryServices;
-
- public enum AdminStatus {
- ONLINE, OFFLINE, REPORTED, ADMIN_DOWN, STANDBY
- }
-
- public Updatable getUpdateHandler() {
- return new Updatable() {
-
- @Override
- public boolean update(final File newDB) {
- LOGGER.debug("enter: "+newDB);
- try {
- final String str = IOUtils.toString(new FileReader(newDB));
- final JSONObject o = new JSONObject(str);
- return update(o);
- } catch (Exception e) {
- LOGGER.warn("error on update: "+newDB, e);
- return false;
- }
- }
- public boolean update(final JSONObject o) throws JSONException {
- profiles = o.getJSONObject("profiles");
- deliveryServices = o.optJSONObject("deliveryServices");
- LOGGER.warn(o.toString(2));
- return true;
- }
- };
- }
- public boolean shouldMonitor(final Cache cache) {
- final String profile = cache.getProfile();
- final String type = cache.getType();
- if(profiles == null) { return false; }
- final JSONObject set = profiles.optJSONObject(type);
- if(set == null) { return false; }
- if(!set.has(profile)) { return false; }
-// final JSONObject controls = set.optJSONObject(profile);
- cache.setControls(this);
- return true;
- }
- public boolean shouldMonitor(final JSONObject o) throws JSONException {
- final String profile = o.getString("profile");
- final String type = o.getString("type");
- final JSONObject set = profiles.optJSONObject(type);
- if(set == null || !set.has(profile)) { return false; }
- return true;
- }
- public void setControls(final Cache c) {
- final String profile = c.getProfile();
- final String type = c.getType();
- if(profiles == null) { return; }
- final JSONObject set = profiles.optJSONObject(type);
- if(set == null) { return; }
- if(!set.has(profile)) { return; }
-// final JSONObject controls = set.optJSONObject(profile);
- c.setControls(this);
- }
- public JSONObject getControls(final Cache c) {
- final String profile = c.getProfile();
- final String type = c.getType();
- if(profiles == null) { return null; }
- final JSONObject set = profiles.optJSONObject(type);
- if(set == null) { return null; }
- if(!set.has(profile)) { return null; }
- return set.optJSONObject(profile);
- }
-
- public String getIp(final Cache c) {
- final CacheState state = c.getState();
- if(state != null) {
- final String ip = state.getLastValue("resolved-ip");
- if(ip != null) { return ip; }
- }
- return c.getIpAddress();
- }
-
- public static boolean getIsAvailable(final Cache c, final boolean isHealthy) {
- final String status = c.getStatus();
- try {
- switch(AdminStatus.valueOf(status)) {
- case ONLINE: return true;
- case ADMIN_DOWN: return false;
- case OFFLINE: return false;
- case REPORTED: return isHealthy;
- case STANDBY: return false;
- default: return true;
- }
- } catch(IllegalArgumentException e) {
- return false;
- }
- }
- public static boolean getIsAvailable(final String status, final boolean isHealthy) {
- try {
- switch(AdminStatus.valueOf(status)) {
- case ONLINE: return true;
- case ADMIN_DOWN: return false;
- case OFFLINE: return false;
- case REPORTED: return isHealthy;
- case STANDBY: return false;
- default: return true;
- }
- } catch(IllegalArgumentException e) {
- return false;
- }
- }
- public void setIsAvailable(final Cache cache, final CacheState state) {
- // first check ONLINEness
- final String status = cache.getStatus();
- final String error = getErrorString(cache, state);
- state.putDataPoint(STATUS, status);
- state.putDataPoint(ERROR_STRING, error);
- final boolean isHealthy = (error == null);
- final EventType type = EventType.CACHE_STATE_CHANGE;
- type.setType(cache.getType());
- state.setAvailable(type, getIsAvailable(cache, isHealthy), error);
- }
-
- public void setIsAvailable(final Cache cache, final String e, final CacheState state) {
- final String status = cache.getStatus();
- state.putDataPoint(STATUS, status);
- state.putDataPoint(ERROR_STRING, e);
- final EventType type = EventType.CACHE_STATE_CHANGE;
- type.setType(cache.getType());
- state.setAvailable(type, getIsAvailable(cache, false), e);
- }
-
- private boolean shouldClearData(final String status) {
- try {
- switch(AdminStatus.valueOf(status)) {
- case ONLINE: return true;
- case ADMIN_DOWN: return false;
- case OFFLINE: return true;
- case REPORTED: return false;
- default: return false;
- }
- } catch(IllegalArgumentException e) {
- return true;
- }
-
- }
- String getErrorString(final Cache cache, final CacheState state) {
- if(shouldClearData(cache.getStatus())) {
- state.putDataPoint("clearData", "true");
- return null;
- }
-
- // this is where all the intelligence goes
- final String loadStr = state.getLastValue("system.proc.loadavg");
- final String loadavg = loadStr.split(" ")[0];
- state.putDataPoint("loadavg", loadavg);
-
- final String str = state.getLastValue("system.proc.net.dev");
- String tx_bytes= "0";
- // String rx_bytes= "0";
- if(str == null) {
- LOGGER.warn("system.proc.net.dev missing on: "+cache.getHostname());
- } else {
- for(String line : str.split("\\n")) {
- line = line.replace(":", " ").trim();
- final String[] parts = line.split("\\s+");
- if(parts.length < 11) { continue; }
- if(parts[0].equals(cache.getInterfaceName())) {
- tx_bytes=parts[9];
- // rx_bytes=parts[1];
- }
- }
- }
- final Bandwidth currentTx = new Bandwidth(tx_bytes);
-
- final long speed = state.getLong("system.inf.speed");
- final long maxBW = speed * Bandwidth.BITS_IN_KBPS;
- // if (BandwidthHALF_DUPLEX.equalsIgnoreCase(mode)) {
- // maxBW = (maxBW / 2);
- // }
-
- final double kbps = calculateCurrentBandwidth(cache.previousTx, currentTx);
- cache.previousTx = currentTx;
- final double availBandwidthKbps = (double) maxBW - kbps;
- final double availBandwidthMbps = availBandwidthKbps / 1000.0;
-
- DecimalFormat df = new DecimalFormat("0.00");
- state.putDataPoint("kbps", df.format(kbps));
- state.putDataPoint("bandwidth", df.format(kbps));
- state.putDataPoint("maxKbps", Long.toString(maxBW));
- state.putDataPoint("availableBandwidthInKbps", df.format(availBandwidthKbps));
- state.putDataPoint("availableBandwidthInMbps", df.format(availBandwidthMbps));
-
- return mapControlsToError(cache.getControls(), state, "");
- }
- private static String mapControlsToError(final JSONObject controls, final AbstractState state, final String propBase) {
- if(controls == null) { return null; }
- final String[] keys = JSONObject.getNames(controls);
- for(String key : keys) {
- try {
- if(!key.startsWith("health.threshold.")) { continue; }
- String value = controls.optString(key);
- key = key.replace("health.threshold.", "");
- key = propBase+key;
- boolean greater = false;
- if(value.startsWith(">")) {
- value = value.replace(">", "");
- greater = true;
- }
- double cv = 0.0;
- try {
- cv = Double.parseDouble(value);
- } catch (Exception e) {cv = 0;}
- final String vstr = state.getLastValue(key);
- if(vstr == null) {
- continue;
- }
- // try {
- final double v = Double.parseDouble(vstr);
- // } catch (Exception e) {
- // return 0;
- // }
- // final double v = state.getDouble(key);
- if(!greater) {
- if(v > cv) {
- return String.format("%s too high (%f > %f)", key, v, cv);
- }
- } else {
- if(v < cv) {
- return String.format("%s too low (%f < %f)", key, v, cv);
- }
- }
- } catch(Exception e) {
- LOGGER.warn(e,e);
- }
- }
- // health.threshold.availableBandwidthInMbps: ">200"
- // health.polling.url: "http://${hostname}/_astats?application=&inf.name=${interface_name}"
- // health.threshold.queryTime: "500"
- // history.count: "30"
- // health.threshold.loadavg: "8.0"
- return null;
- }
- double calculateCurrentBandwidth(final Bandwidth prev, final Bandwidth curr) {
- double currBW = 0.0;
- if (prev != null) {
- currBW = prev.calculateKbps(curr);
- }
- return currBW;
- }
-
-
- public JSONObject getJSONStats(final Cache cache, final boolean peerOptimistic, final boolean raw) throws JSONException {
- final JSONObject statsJson = new JSONObject();
- final boolean isAvailableKnown = cache.isAvailableKnown();
- final boolean isAvailable = cache.isAvailable();
-
- if (!raw && peerOptimistic && PeerState.isCacheAvailableOnAnyPeer(cache)) {
- statsJson.put(IS_AVAILABLE_KEY, getIsAvailable(cache, true)); // ensure status overrides peer
- return statsJson;
- }
-
- if (isAvailableKnown) {
- statsJson.put(IS_AVAILABLE_KEY, isAvailable);
- } else {
- statsJson.put(IS_AVAILABLE_KEY, "unknown");
- }
-
- if (raw) {
-
- String error = null;
- String status = cache.getStatus();
-
- if (cache.getState() != null) {
- error = cache.getState().getLastValue(ERROR_STRING);
- status = cache.getState().getLastValue(STATUS);
- }
-
- if (error == null) {
- error = NO_ERROR_FOUND;
- }
-
- statsJson.put(ERROR_STRING, error);
- statsJson.put(STATUS, status);
- }
-
- return statsJson;
- }
-
- public int getConnectionTimeout(final Cache cache, final int d) {
- final JSONObject jo = cache.getControls();
- if(jo == null) { return d; }
- final int r = jo.optInt("health.connection.timeout");
- if(r == 0) { return d; }
- return r;
- }
- public JSONObject getDsControls(final String id) {
- if(deliveryServices == null) {
- return null;
- }
- return deliveryServices.optJSONObject(id);
- }
- public static void setIsAvailable(final DsState dsState, final JSONObject dsControls) {
- final EventType type = EventType.DELIVERY_SERVICE_STATE_CHANGE;
-
- if (dsControls == null) {
- dsState.putDataPoint(STATUS, "ONLINE");
- dsState.setAvailable(type, getIsAvailable("ONLINE", true), null);
- return;
- }
-
- // first check ONLINEness
- final String status = dsControls.optString(STATUS);
- final String error = getErrorString(dsControls, dsState);
- dsState.putDataPoint(STATUS, status);
- dsState.putDataPoint(ERROR_STRING, error);
- final boolean isHealthy = (error == null);
- dsState.setAvailable(EventType.DELIVERY_SERVICE_STATE_CHANGE, getIsAvailable(status, isHealthy), error);
- }
- private static String getErrorString(final JSONObject dsControls, final DsState dsState) {
- return mapControlsToError(dsControls, dsState, "");
- }
- public static boolean setIsLocationAvailable(final DsState dsState, final EmbeddedStati loc, final JSONObject dsControls) {
- boolean isAvailable = true;
- String error = null;
- if(dsControls != null) {
- final JSONObject locControlSet = dsControls.optJSONObject("locations");
- if(locControlSet != null) {
- final JSONObject locControls = locControlSet.optJSONObject(loc.getId());
- if(locControls != null) {
- error = getErrorString(locControls, loc, dsState);
- }
- }
- }
- if(error!=null) {
- isAvailable = false;
- }
- dsState.putDataPoint("location."+loc.getId()+"."+ERROR_STRING, error );
- dsState.putDataPoint("location."+loc.getId()+"."+IS_AVAILABLE_KEY, String.valueOf(isAvailable));
- return isAvailable;
- }
- private static String getErrorString(final JSONObject locControls,
- final EmbeddedStati loc, final DsState dsState) {
- return mapControlsToError(locControls, dsState, "location."+loc.getId()+".");
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerState.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerState.java
deleted file mode 100644
index 32a0988..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerState.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Peer;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.Event.EventType;
-
-public class PeerState extends AbstractState {
- private static final Logger LOGGER = Logger.getLogger(PeerState.class);
- private static final long serialVersionUID = 1L;
- private static Map<String, PeerState> states = new HashMap<String, PeerState>();
- private static Map<String, Boolean> overrideMap = new HashMap<String, Boolean>();
- private Peer peer;
- private boolean reachable = false;
-
- PeerState(final String id) {
- super(id);
- }
-
- public static List<PeerState> getPeerStates() {
- synchronized(states) {
- return new ArrayList<PeerState>(states.values());
- }
- }
-
- public static PeerState getOrCreate(final Peer peer) {
- return getOrCreate(peer.getHostname(), peer);
- }
-
- public static PeerState getOrCreate(final String host, final Peer peer) {
- synchronized(states) {
- PeerState ps = states.get(host);
-
- if (ps == null) {
- ps = new PeerState(host);
- states.put(host, ps);
- }
-
- ps.setPeer(peer);
- peer.setState(ps);
-
- return ps;
- }
- }
-
- public static PeerState getState(final String host) {
- synchronized(states) {
- return states.get(host);
- }
- }
-
- private void setPeer(final Peer peer) {
- this.peer = peer;
- }
-
- public Peer getPeer() {
- return peer;
- }
-
- public static boolean has(final String host) {
- if (states.get(host) == null) {
- return false;
- }
-
- return true;
- }
-
- public static void removeAllBut(final Set<String> peerSet) {
- synchronized(states) {
- for (String key : new ArrayList<String>(states.keySet())) {
- if (!peerSet.contains(key)) {
- states.remove(key);
- }
- }
- }
- }
-
- public static String get(final String stateId, final String key) {
- return getState(stateId).getLastValue(key);
- }
-
- public static int getPeerCount() {
- return states.size();
- }
-
- public static boolean hasPeers() {
- if (states.isEmpty()) {
- return false;
- } else {
- return true;
- }
- }
-
- public static int getOnlinePeerCount() {
- int onlineCount = 0;
-
- for (PeerState peerState : PeerState.getPeerStates()) {
- if (!peerState.isReachable()) {
- continue;
- } else {
- onlineCount++;
- }
- }
-
- return onlineCount;
- }
-
- public static boolean hasOnlinePeers() {
- if (getOnlinePeerCount() > 0) {
- return true;
- } else {
- return false;
- }
- }
-
- public static boolean isCacheAvailableOnAnyPeer(final Cache c) {
- final List<Peer> onlineList = getCacheAvailableOnPeers(c);
-
- if (onlineList != null && !onlineList.isEmpty()) {
- return true;
- } else {
- return false;
- }
- }
-
- public static List<Peer> getCacheAvailableOnPeers(final Cache c) {
- final List<Peer> onlineList = new ArrayList<Peer>();
-
- if (PeerState.hasPeers()) {
- for (PeerState peerState : PeerState.getPeerStates()) {
- if (!peerState.isReachable()) {
- continue;
- }
-
- final Peer peer = peerState.getPeer();
- final String pAvailability = peerState.getLastValue(c.getHostname());
-
- if (pAvailability == null || pAvailability.equals("unknown")) {
- continue;
- }
-
- final boolean pIsAvailable = Boolean.parseBoolean(pAvailability);
-
- if (pIsAvailable == true) {
- LOGGER.debug(String.format("ERROR: %s - isAvailable set to %s from: %s", c.getHostname(), String.valueOf(pIsAvailable), peer.getId()));
- onlineList.add(peer);
- }
- }
- }
-
- return onlineList;
- }
-
- public static void logOverride(final Cache c) {
- final Boolean state = overrideMap.get(c.getFqdn());
- final EventType type = EventType.CACHE_STATE_CHANGE;
- type.setType(c.getType());
-
- if (PeerState.hasOnlinePeers()) {
- final List<Peer> onlineList = PeerState.getCacheAvailableOnPeers(c);
-
- if (!onlineList.isEmpty()) {
- if (state == null || !state.booleanValue()) {
- final StringBuffer msg = new StringBuffer("Health protocol override condition detected; healthy on (at least) ");
- msg.append(Arrays.toString(onlineList.toArray()).replaceAll("\\[|\\]", ""));
- Event.logStateChange(c.getHostname(), type, true, msg.toString());
- overrideMap.put(c.getFqdn(), true);
- }
- } else if (onlineList.isEmpty()) {
- if (state == null || state.booleanValue()) {
- final StringBuffer msg = new StringBuffer("Health protocol override condition irrelevant; not online on any peers");
-
- if (c.isAvailableKnown() && c.isAvailable()) {
- msg.append("; healthy locally");
- } else if (c.isAvailableKnown() && !c.isAvailable()) {
- msg.append("; unhealthy locally");
- } else {
- msg.append("; local state unknown");
- }
-
- Event.logStateChange(c.getHostname(), type, c.isAvailable(), msg.toString());
- overrideMap.put(c.getFqdn(), false);
- }
- }
- } else if (state != null && state.booleanValue()) {
- final StringBuffer msg = new StringBuffer("Health protocol override condition irrelevant; no peers online");
- Event.logStateChange(c.getHostname(), type, c.isAvailable(), msg.toString());
- overrideMap.put(c.getFqdn(), false);
- }
- }
-
- public static void clearOverride(final Cache c) {
- if (overrideMap.containsKey(c.getFqdn())) {
- final Boolean state = overrideMap.get(c.getFqdn());
-
- if (state.booleanValue()) {
- final EventType type = EventType.CACHE_STATE_CHANGE;
- type.setType(c.getType());
- Event.logStateChange(c.getHostname(), type, true, "Health protocol override condition cleared; healthy locally");
- }
-
- overrideMap.remove(c.getFqdn());
- }
- }
-
- public boolean isReachable() {
- return reachable;
- }
-
- public void setReachable(final boolean reachable) {
- setReachable(reachable, null);
- }
-
- public void setReachable(final boolean reachable, final String reason) {
- if (isReachable() != reachable) {
- final StringBuilder sb = new StringBuilder();
-
- if (reason == null && reachable) {
- sb.append("Peer is reachable");
- } else if (reason == null && !reachable) {
- sb.append("Peer is unreachable");
- } else if (reason != null) {
- sb.append(reason);
- }
-
- Event.logStateChange(peer.getHostname(), EventType.PEER_STATE_CHANGE, reachable, sb.toString());
- }
-
- this.reachable = reachable;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerWatcher.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerWatcher.java
deleted file mode 100644
index 2380eb7..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/PeerWatcher.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONObject;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.RouterConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Peer;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Fetcher;
-
-public class PeerWatcher {
- private static final Logger LOGGER = Logger.getLogger(PeerWatcher.class);
- private FetchService mainThread;
- private boolean isActive = true;
-
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
-
- public PeerWatcher init() {
- mainThread = new FetchService();
- mainThread.start();
- return this;
- }
-
- class FetchService extends Thread {
- public FetchService() {
- }
-
- final Runtime runtime = Runtime.getRuntime();
-
- public void run() { // run the service
- ExecutorService pool = null;
-
- while (true) {
- if(!isActive ) {
- return;
- }
-
- final long time = System.currentTimeMillis();
- final RouterConfig crConfig = RouterConfig.getCrConfig();
-
- if (crConfig == null) {
- try {
- Thread.sleep(config.getPeerPollingInterval());
- } catch (Exception e) { }
- continue;
- }
-
- final Map<String, Peer> peerMap = crConfig.getPeerMap();
-
- try {
- final int poolSize = config.getPeerThreadPool();
- pool = Executors.newFixedThreadPool(poolSize);
- checkPeers(pool, peerMap);
- } catch(Exception e) {
- LOGGER.warn(e,e);
- if(!isActive) { return; }
- }
-
- try {
- pool.shutdown();
- Thread.sleep(config.getPeerPollingInterval());
- } catch (Exception e) { }
-
- try {
- while(!pool.awaitTermination(1, TimeUnit.SECONDS)) {
- LOGGER.warn("Pool did not terminate");
- }
- } catch (Exception e) { }
-
- final long mytime = System.currentTimeMillis()-time;
- }
- }
-
- }
-
- private void checkPeers(final ExecutorService pool, final Map<String, Peer> peerMap) {
- Map<String, Peer> myMap = null;
- synchronized(PeerWatcher.this) {
- myMap = peerMap;
- }
-
- final String urlPattern = config.getPeerUrl(); // http://${hostname}/publish/CrStates?raw
-
- if (myMap == null || myMap.isEmpty()) {
- return;
- }
-
- for (String key : myMap.keySet()) {
- if (!isActive) {
- return;
- }
-
- final Peer peer = myMap.get(key);
- final PeerState peerState = PeerState.getOrCreate(peer);
-
- pool.execute(getHandler(peerState, urlPattern));
- }
- }
-
- private Runnable getHandler(final PeerState peerState, final String urlPattern) {
- return new Runnable(){
- @Override
- public void run() {
- if (!isActive) {
- return;
- }
-
- final Peer peer = peerState.getPeer();
- final String url = urlPattern.replace("${hostname}", peer.getIpAddress()).
- replace("${port}", peer.getPortString());
- final String prettyUrl = urlPattern.replace("${hostname}", peer.getFqdn()).
- replace("${port}", peer.getPortString());
-
- try {
- final String result = Fetcher.fetchContent(url, peer.getHeaderMap(), config.getConnectionTimeout());
- final JSONObject jr = new JSONObject(result);
- final JSONObject cacheStates = jr.getJSONObject("caches");
-
- peerState.setReachable(true);
- peerState.prepareStatisticsForUpdate();
-
- for (String id : JSONObject.getNames(cacheStates)) {
- final JSONObject cache = cacheStates.getJSONObject(id);
- peerState.putDataPoint(id, cache.optString(AbstractState.IS_AVAILABLE_STR));
- }
- } catch (Exception e) {
- peerState.setReachable(false, e.getMessage());
- LOGGER.warn(e + " to " + prettyUrl);
- }
-
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- final RouterConfig crConfig = RouterConfig.getCrConfig();
-
- if (crConfig != null && config.getPeerOptimistic()) {
- for (Cache cache : crConfig.getCacheList()) {
- if (!cache.isAvailable()) {
- PeerState.logOverride(cache);
- } else {
- PeerState.clearOverride(cache);
- }
- }
- }
- }
- };
- }
-
- public void destroy() {
- LOGGER.warn("PeerWatcher: shutting down ");
- isActive = false;
- final long time = System.currentTimeMillis();
-
- mainThread.interrupt();
-
- while (mainThread.isAlive()) {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
- }
-
- LOGGER.warn("Stopped: Termination time: "+(System.currentTimeMillis() - time));
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/StateRegistry.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/StateRegistry.java
deleted file mode 100644
index 9206bdd..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/StateRegistry.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- */
-
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class StateRegistry<T extends AbstractState> {
- protected final Map<String, T> states = new ConcurrentHashMap<String, T>();
-
- public T get(final String id) {
- synchronized(states) {
- return states.get(id);
- }
- }
-
- public Collection<T> getAll() {
- synchronized (states) {
- return states.values();
- }
- }
-
- public T getOrCreate(final String id) {
- synchronized (states) {
- T abstractState = states.get(id);
-
- if (abstractState != null) {
- return abstractState;
- }
-
- return put(createState(id));
- }
- }
-
- public T put(T abstractState) {
- states.put(abstractState.getId(), abstractState);
- return abstractState;
- }
-
- public int size() {
- synchronized (states) {
- return states.size();
- }
- }
-
- public boolean has(final String id) {
- return states.containsKey(id);
- }
-
- public String get(final String stateId, final String key) {
- if (!has(stateId)) {
- return "";
- }
-
- return get(stateId).getLastValue(key);
- }
-
- public long getSumOfLongStatistic(final String key) {
- long sum = 0;
- for(AbstractState state : states.values()) {
- sum += state.getDouble(key);
- }
- return sum;
- }
-
- public void removeAllBut(final List<T> states) {
- final Set<String> stateIds = new HashSet<String>();
-
- for (T state : states) {
- stateIds.add(state.getId());
- }
-
- removeAllBut(stateIds);
- }
-
- protected T createState(final String id) {
- return null;
- }
-
- public void removeAllBut(Set<String> stateIds) {
- synchronized (states) {
- for (String key : states.keySet()) {
- if (!stateIds.contains(key)) {
- states.remove(key);
- }
- }
- }
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmListener.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmListener.java
deleted file mode 100644
index d74cd01..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import org.apache.wicket.ajax.json.JSONObject;
-
-public interface TmListener {
- void handleCrConfig(JSONObject o);
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmWatcher.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmWatcher.java
deleted file mode 100644
index 57819d4..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/health/TmWatcher.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.health;
-
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.model.Model;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.publish.CrConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Fetcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.PeriodicResourceUpdater;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Updatable;
-
-public class TmWatcher {
- private static final Logger LOGGER = Logger.getLogger(TmWatcher.class);
- static TmWatcher instance;
- List<TmListener> tmlisteners = new ArrayList<TmListener>();
- private final HealthDeterminer hd;
- private final static String CFG_KEY_SUFFIX = "-config";
-
- public TmWatcher(final HealthDeterminer hd) {
- this.hd = hd;
- }
-
-
- public void addTmListener(final TmListener tl) {
- synchronized(tmlisteners) {
- tmlisteners.add(tl);
- }
- }
-// public Updatable getDataServerHandler() {
-// return new Updatable() {
-// @Override
-// public boolean update(final File newDB) {
-// LOGGER.debug("enter: "+newDB);
-// try {
-// final String str = IOUtils.toString(new FileReader(newDB));
-// final JSONArray o = new JSONArray(str);
-// // LOGGER.warn(o.toString(2));
-// LOGGER.debug("array size: "+o.length());
-// synchronized(tmlisteners) {
-// for(TmListener l : tmlisteners) {
-// try {
-// l.handleServerList(o);
-// } catch(Exception e) {
-// LOGGER.error(e.toString(), e);
-// }
-// }
-// }
-// } catch (Exception e) {
-// LOGGER.warn("error on update: "+newDB, e);
-// return false;
-// }
-// return true;
-// }
-// @Override
-// public boolean update(final JSONObject jsonObject) throws JSONException {
-// return false;
-// }
-// };
-// }
- public Updatable getConfigHandler(final MonitorConfig config, final Updatable updateHandler) {
- return new Updatable() {
- @Override
- public boolean update(final File newDB) {
- LOGGER.debug("enter: "+newDB);
- try {
- final String str = IOUtils.toString(new FileReader(newDB));
- final JSONObject o = new JSONObject(str);
- String cfgKey = null;
-
- @SuppressWarnings("unchecked")
- final Iterator<String> it = o.keys();
- while (it.hasNext()) {
- final String key = it.next();
- LOGGER.info("KEY -> " + key);
-
- if (key.endsWith(CFG_KEY_SUFFIX)) {
- cfgKey = key;
- break;
- }
- }
-
- if (cfgKey != null) {
- config.update(o.getJSONObject(cfgKey));
- updateHandler.update(o);
- return true;
- } else {
- LOGGER.fatal("Unable to find configuration key in health JSON; must end with " + CFG_KEY_SUFFIX);
- return false;
- }
- } catch (Exception e) {
- LOGGER.warn("error on update: "+newDB, e);
- return false;
- }
- }
- @Override
- public boolean update(final JSONObject jsonObject) throws JSONException {
- return false;
- }
-
- };
- }
-
- private Updatable getCrConfigUpdateHandler() {
- return new Updatable() {
- @Override
- public boolean update(final File newDB) {
- try {
- final String jsonStr = FileUtils.readFileToString(newDB);
- final JSONObject jo = new JSONObject(jsonStr);
- for(TmListener l : tmlisteners) {
- try {
- l.handleCrConfig(jo);
- } catch(Exception e) {
- LOGGER.error(e.toString(), e);
- }
- }
- return true;
- } catch (IOException e) {
- LOGGER.warn(e,e);
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- return false;
- }
- @Override
- public boolean update(final JSONObject jsonObject) throws JSONException {
- return false;
- }
- };
- }
-
- public static TmWatcher getInstance() {
- return instance;
- }
-
- public void refresh() {
- tmUpdater.forceUpdate();
- }
-
- PeriodicResourceUpdater tmUpdater;
- public void init() {
- synchronized(LOGGER) {
- if(instance == null) {
- instance = this;
- }
- }
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- tmUpdater = new PeriodicResourceUpdater(
- new Model<Long>() {
- private static final long serialVersionUID = 1L;
- @Override
- public Long getObject( ) {
- return config.getTmFrequency();
- }
- }) {
- @Override
- protected File fetchFile(final String url) throws IOException {
- return Fetcher.downloadTM(url, config.getAuthUrl(), config.getAuthUsername(), config.getAuthPassword(), config.getConnectionTimeout());
- }
- };
- tmUpdater.add(this.getConfigHandler(config, hd.getUpdateHandler()), new Model<String>() {
- private static final long serialVersionUID = 1L;
- @Override
- public String getObject( ) {
- return config.getHeathUrl();
- }
- }, "health-params.js");
-
- this.addTmListener(CrConfig.getCrConfigListener());
- tmUpdater.add(getCrConfigUpdateHandler(), new Model<String>() {
- private static final long serialVersionUID = 1L;
- @Override
- public String getObject( ) {
- return config.getCrConfigUrl();
- }
- }, "cr-config.json");
-
- tmUpdater.init();
-
- }
-
-
-
- public void destroy() {
- tmUpdater.destroy();
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CacheStats.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CacheStats.java
deleted file mode 100644
index 74fac99..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CacheStats.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.Date;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheStateRegistry;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheState;
-
-public class CacheStats extends JsonPage {
- private static final long serialVersionUID = 1L;
- private final CacheStateRegistry cacheStateRegistry = CacheStateRegistry.getInstance();
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- String[] stats = null;
- final String str = pp.get("stats").toString();
- final int hc = pp.get("hc").toInt(0);
-
- if (str != null) {
- stats = str.split(",");
- }
-
- final String type = pp.get("type").toString();
- final boolean wildcard = pp.get("wildcard").toBoolean(false);
- final boolean hidden = pp.get("hidden").toBoolean(false);
- final String host = pp.get(0).toString();
- final JSONObject o = new JSONObject();
- o.put("date", new Date().toString());
- o.put("pp", pp);
- final JSONObject servers = new JSONObject();
-
- if (host != null && !host.equals("")) {
- if (cacheStateRegistry.has(host)) {
- servers.put(host, cacheStateRegistry.get(host).getStatsJson(hc, stats, wildcard, hidden));
- } else {
- o.put("error", "Hostname not found: " + host);
- }
- } else {
- for (CacheState cacheState : cacheStateRegistry.getAll()) {
- if (type == null || type.equals(cacheState.getCache().getType())) {
- servers.put(cacheState.getId(), cacheState.getStatsJson(hc, stats, wildcard, hidden));
- }
- }
- }
-
- o.put("caches", servers);
-
- return o;
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/ConfigDoc.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/ConfigDoc.java
deleted file mode 100644
index 7462b31..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/ConfigDoc.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-
-public class ConfigDoc extends JsonPage {
- private static final long serialVersionUID = 1L;
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- return ConfigHandler.getInstance().getConfig().getConfigDoc();
- }
-
-}
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrConfig.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrConfig.java
deleted file mode 100644
index f59ca34..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrConfig.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.markup.MarkupType;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.TmListener;
-import com.comcast.cdn.traffic_control.traffic_monitor.util.Updatable;
-
-public class CrConfig extends WebPage {
- private static final Logger LOGGER = Logger.getLogger(CrConfig.class);
- private static final long serialVersionUID = 1L;
-
- public CrConfig() {
- // String jsonData = "{\"jsonKey\":\"jsonValue\"}";
- // IResource jsonResource = new ByteArrayResource("text/plain", jsonData.getBytes());
- // IRequestHandler requestHandler = new ResourceRequestHandler(jsonResource, null);
- // requestHandler.respond(getRequestCycle());
- }
-
- /**
- * The default markup is html. We want it to be xml.
- */
- @Override
- public final MarkupType getMarkupType() {
- return new MarkupType("xml", "text/xml");
- }
- /**
- * Send out the xml!!!!
- */
- @Override
- public final void renderPage() {
- final PageParameters pageParameters = this.getPageParameters();
- if(pageParameters != null && pageParameters.getPosition("json") != -1) {
- getResponse().write(crConfigJsonStr);
- return;
- }
- getResponse().write(crConfigStr);
- }
- private static void setCrConfigJsonStr(final String string) {
- crConfigJsonStr = string;
- }
-
- static private String crConfigStr = "";
- static private String crConfigJsonStr = "";
- static private JSONObject crConfigJson = null;
-
- public static String getCrConfigStr() {
- return crConfigStr;
- }
-
- public static void setCrConfigStr(final String crConfigStr) {
- CrConfig.crConfigStr = crConfigStr;
- }
-
- public static JSONObject getCrConfigJson() {
- return crConfigJson;
- }
-
- public static void setCrConfigJson(final JSONObject crConfigJson) {
- CrConfig.crConfigJson = crConfigJson;
- }
-
- public static class UpdateHandler implements Updatable {
- @Override
- public boolean update(final File newDB) {
- try {
- CrConfig.crConfigStr = FileUtils.readFileToString(newDB);
- return true;
- } catch (IOException e) {
- LOGGER.warn(e,e);
- }
- return false;
- }
- @Override
- public boolean update(final JSONObject jsonObject) throws JSONException {
- return false;
- }
- }
-
- public static TmListener getCrConfigListener() {
- return new TmListener() {
- @Override
- public void handleCrConfig(final JSONObject o) {
- try {
- setCrConfigJsonStr(o.toString(2));
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- }
- };
- }
-
-}
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrStates.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrStates.java
deleted file mode 100644
index 8bac0ae..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/CrStates.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.Cache;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.RouterConfig;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.AbstractState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.DeliveryServiceStateRegistry;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.DsState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.HealthDeterminer;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.PeerWatcher;
-
-public class CrStates extends JsonPage {
- private static final Logger LOGGER = Logger.getLogger(CrStates.class);
- private static final long serialVersionUID = 1L;
- private static CacheWatcher myCacheWatcher;
- private static PeerWatcher myPeerWatcher;
- private static HealthDeterminer myHealthDeterminer;
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- if (myPeerWatcher == null) {
- return null;
- }
-
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- final RouterConfig crConfig = RouterConfig.getCrConfig();
-
- if (crConfig == null || myCacheWatcher.getCycleCount() < config.getStartupMinCycles()) {
- return null;
- }
-
- final boolean raw = (pp.getPosition("raw") != -1);
- final String cacheType = pp.get("cacheType").toString();
- final JSONObject o = new JSONObject();
- o.put("caches", getCrStates(crConfig, raw, cacheType));
-
- if (ConfigHandler.getInstance().getConfig().getPublishDsStates()) {
- o.put("deliveryServices", getDsStates(crConfig));
- }
-
- return o;
- }
-
- private JSONObject getCrStates(final RouterConfig crConfig, final boolean raw, final String cacheType) {
- if (crConfig == null) {
- return null;
- }
-
- try {
- final JSONObject servers = new JSONObject();
- final List<Cache> caches = crConfig.getCacheList();
-
- for (Cache c : caches) {
- synchronized(c) {
- if (c.getControls() == null || (cacheType != null && !cacheType.equals(c.getType()))) {
- continue;
- }
-
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- servers.put(c.getHostname(), myHealthDeterminer.getJSONStats(c, config.getPeerOptimistic(), raw));
- }
- }
-
- if (servers.length() == 0) {
- LOGGER.warn("no caches returned! ");
- }
-
- return servers;
- } catch (JSONException e) {
- LOGGER.warn(e, e);
- }
-
- return null;
- }
-
- private JSONObject getDsStates(final RouterConfig crConfig) {
- if (crConfig == null) {
- return null;
- }
-
- try {
- final JSONObject ret = new JSONObject();
-
- for (DsState dsState : DeliveryServiceStateRegistry.getInstance().getAll()) {
- final JSONObject dsJo = new JSONObject();
-
- if (!dsState.hasValue(AbstractState.IS_AVAILABLE_STR)) {
- continue;
- }
-
- dsJo.put(AbstractState.IS_AVAILABLE_STR, dsState.isAvailable());
- dsJo.put(DsState.DISABLED_LOCATIONS, dsState.getDisabledLocations());
- ret.put(dsState.getId(), dsJo);
- }
-
- return ret;
- } catch (JSONException e) {
- LOGGER.warn(e, e);
- }
-
- return null;
- }
-
- public static void init(final CacheWatcher cw, final PeerWatcher pw, final HealthDeterminer hd) {
- myCacheWatcher = cw;
- myPeerWatcher = pw;
- myHealthDeterminer = hd;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/DsStats.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/DsStats.java
deleted file mode 100644
index 8506185..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/DsStats.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.Date;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.AbstractState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.DeliveryServiceStateRegistry;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-public class DsStats extends JsonPage {
- private static final long serialVersionUID = 1L;
- private final DeliveryServiceStateRegistry deliveryServiceStateRegistry = DeliveryServiceStateRegistry.getInstance();
-
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- String str = pp.get("hc").toString();
- int hc = 0;
- try {
- hc = Integer.parseInt(str);
- } catch(Exception e) {hc = 0;}
- String[] stats = null;
- str = pp.get("stats").toString();
- if(str != null) {
- stats = str.split(",");
- }
- final boolean wildcard = pp.get("wildcard").toBoolean(false);
- final boolean hidden = pp.get("hidden").toBoolean(false);
- final String deliveryService = pp.get(0).toString();
- final JSONObject o = new JSONObject();
- o.put("date", new Date().toString());
- o.put("pp", pp);
- final JSONObject servers = new JSONObject();
- if(deliveryService != null && !deliveryService.equals("")) {
- if(deliveryServiceStateRegistry.has(deliveryService)) {
- servers.put(deliveryService, deliveryServiceStateRegistry.get(deliveryService).getStatsJson(hc, stats, wildcard, hidden));
- } else {
- o.put("error", "Delivery service not found: "+deliveryService);
- }
- } else {
- for(AbstractState s : deliveryServiceStateRegistry.getAll()) {
- servers.put(s.getId(),s.getStatsJson(hc, stats, wildcard, hidden));
- }
- }
- o.put("deliveryService", servers);
- return o;
- }
-
-}
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/EventLog.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/EventLog.java
deleted file mode 100644
index 1bb3f6e..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/EventLog.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.List;
-
-import org.apache.wicket.ajax.json.JSONArray;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.Event;
-
-public class EventLog extends JsonPage {
- private static final long serialVersionUID = 1L;
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- final JSONObject o = new JSONObject();
- final List<JSONObject> list = Event.getEventLog();
- final JSONArray events = new JSONArray(list);
- o.put("events", events);
- return o;
- }
-
-}
-
-
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/JsonPage.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/JsonPage.java
deleted file mode 100644
index 4f6b0f6..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/JsonPage.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.markup.MarkupType;
-import org.apache.wicket.markup.html.WebPage;
-import org.apache.wicket.request.http.WebResponse;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-import com.comcast.cdn.traffic_control.traffic_monitor.config.MonitorConfig;
-
-public class JsonPage extends WebPage {
- private static final Logger LOGGER = Logger.getLogger(JsonPage.class);
- private static final long serialVersionUID = 1L;
-
- /**
- * The default markup is html. We want it to be json.
- */
- @Override
- public final MarkupType getMarkupType() {
- return new MarkupType("json", "application/json");
- }
-
- /**
- * Send out the json!!!!
- */
- @Override
- public final void renderPage() {
- final MonitorConfig config = ConfigHandler.getInstance().getConfig();
- final WebResponse response = (WebResponse)super.getResponse();
- response.setHeader("Access-Control-Allow-Origin", config.getAccessControlAllowOrigin() );
- try {
- final JSONObject jo = getJson(getPageParameters());
- if(jo == null) {
- response.sendError(503, "Not ready");
- return;
- }
- response.write(jo.toString(2));
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- }
- protected static long getParam(final PageParameters pp, final String key, final long d) {
- try {
- return Long.parseLong(pp.get(key).toString());
- } catch(Exception e) {
- return d;
- }
- }
-
-
- protected JSONObject getJson(final PageParameters pp) throws JSONException {
- return new JSONObject();
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/PeerStates.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/PeerStates.java
deleted file mode 100644
index eaca64c..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/PeerStates.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.Date;
-import java.util.List;
-
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.PeerState;
-
-public class PeerStates extends JsonPage {
- private static final long serialVersionUID = 1L;
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- String str = pp.get("hc").toString();
- int hc = 0;
-
- try {
- hc = Integer.parseInt(str);
- } catch(Exception e) {
- hc = 0;
- }
-
- String[] stats = null;
- str = pp.get("stats").toString();
-
- if (str != null) {
- stats = str.split(",");
- }
-
- final boolean wildcard = pp.get("wildcard").toBoolean(false);
- final boolean hidden = pp.get("hidden").toBoolean(false);
-
- final String host = pp.get(0).toString();
- final JSONObject o = new JSONObject();
- o.put("date", new Date().toString());
- o.put("pp", pp);
- final JSONObject servers = new JSONObject();
- final List<PeerState> peers = PeerState.getPeerStates();
-
- if (host != null && !host.equals("")) {
- if (PeerState.has(host)) {
- servers.put(host,PeerState.getState(host).getStatsJson(hc, stats, wildcard, hidden));
- } else {
- o.put("error", "Hostname not found: "+host);
- }
- } else {
- for (PeerState p : peers) {
- servers.put(p.getId(),p.getStatsJson(hc, stats, wildcard, hidden));
- }
- }
-
- o.put("peers", servers);
- return o;
- }
-}
-
-
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/StatSummary.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/StatSummary.java
deleted file mode 100644
index 652d95f..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/StatSummary.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.util.Date;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheState;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheStateRegistry;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-public class StatSummary extends JsonPage {
- private static final long serialVersionUID = 1L;
- private final CacheStateRegistry cacheStateRegistry = CacheStateRegistry.getInstance();
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- final long startTime = getParam(pp, "startTime", 0);
- final long endTime = getParam(pp, "endTime", -1);
- String[] stats = null;
- final String str = pp.get("stats").toString();
- if(str != null) {
- stats = str.split(",");
- }
- final boolean wildcard = pp.get("wildcard").toBoolean(false);
- final boolean hidden = pp.get("hidden").toBoolean(false);
- final String host = pp.get("cache").toString();
- final JSONObject o = new JSONObject();
- o.put("date", new Date().toString());
- o.put("pp", pp);
- final JSONObject servers = new JSONObject();
- if(host != null && !host.equals("")) {
- if(cacheStateRegistry.has(host)) {
- servers.put(host,cacheStateRegistry.get(host).getSummary(startTime, endTime, stats, wildcard, hidden));
- } else {
- o.put("error", "Hostname not found: "+host);
- }
- } else {
- for (CacheState cacheState : cacheStateRegistry.getAll()) {
- servers.put(cacheState.getId(),cacheState.getSummary(startTime, endTime, stats, wildcard, hidden));
- }
- }
-
- o.put("caches", servers);
- return o;
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/Stats.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/Stats.java
deleted file mode 100644
index f85941b..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/publish/Stats.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.publish;
-
-import java.io.InputStream;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.log4j.Logger;
-import org.apache.wicket.ajax.json.JSONException;
-import org.apache.wicket.ajax.json.JSONObject;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.MonitorApplication;
-import com.comcast.cdn.traffic_control.traffic_monitor.health.CacheWatcher;
-import com.comcast.cdn.traffic_control.traffic_monitor.wicket.models.CacheDataModel;
-
-public class Stats extends JsonPage {
- private static final Logger LOGGER = Logger.getLogger(Stats.class);
- private static final long serialVersionUID = 1L;
-
- /**
- * Send out the json!!!!
- */
- @Override
- public JSONObject getJson(final PageParameters pp) throws JSONException {
- return getVersionInfo();
- }
-
- static Properties props;
- public static JSONObject getVersionInfo() {
- synchronized(LOGGER) {
- final JSONObject o = new JSONObject();
- try {
- final InputStream stream = Stats.class.getResourceAsStream("/version.prop");
- if(props == null) {
- props = new Properties();
- try {
- props.load(stream);
- stream.close();
- } catch (Exception e) {
- LOGGER.warn(e,e);
- props = null;
- }
- }
- props.put("uptime", Long.toString(MonitorApplication.getUptime()));
-
- final List<CacheDataModel> cwProps = CacheWatcher.getProps();
- for(CacheDataModel m : cwProps) {
- props.put(m.getKey(), m.getValue());
- }
- o.put("stats", props);
-
- } catch (JSONException e) {
- LOGGER.warn(e,e);
- }
- return o;
- }
- }
-}
-
-
-
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Fetcher.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Fetcher.java
deleted file mode 100644
index ee38261..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Fetcher.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpCookie;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLEncoder;
-import java.security.SecureRandom;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Map;
-
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-
-public class Fetcher {
- private static final Logger LOGGER = Logger.getLogger(Fetcher.class);
- private static final String GET_STR = "GET";
- private static final String UTF8_STR = "UTF-8";
-
- static {
- try {
- final SSLContext ctx = SSLContext.getInstance("TLS");
- ctx.init(new KeyManager[0], new TrustManager[] {new DefaultTrustManager()}, new SecureRandom());
- SSLContext.setDefault(ctx);
- } catch (Exception e) {
- LOGGER.warn(e,e);
- }
- }
-
- private static class DefaultTrustManager implements X509TrustManager {
- @Override
- public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) throws CertificateException {}
- @Override
- public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) throws CertificateException {}
- @Override
- public X509Certificate[] getAcceptedIssuers() { return null; }
- }
-
- public static String fetchContent(final String link, final int timeout) throws IOException {
- return fetchContent(new URL(link).openConnection(), timeout);
- }
-
- public static String fetchContent(final String link, final Map<String, String> headerMap, final int timeout) throws IOException {
- final URL url = new URL(link);
- final URLConnection conn = url.openConnection();
-
- for (String key : headerMap.keySet()) {
- conn.setRequestProperty(key, headerMap.get(key));
- }
-
- return fetchContent(conn, timeout);
- }
-
- public static String fetchContent(final String stateUrl, final String ipStr, final int port, final int timeout) throws IOException {
- final URLConnection conn = new URL(stateUrl).openConnection(
- new Proxy(Proxy.Type.HTTP, new InetSocketAddress(ipStr, port)));
- if(timeout!=0) {
- conn.setConnectTimeout(timeout);
- conn.setReadTimeout(timeout);
- }
- conn.connect();
-
- return IOUtils.toString(new InputStreamReader(conn.getInputStream(), UTF8_STR));
- }
-
- public static String fetchContent(final URLConnection conn, final int timeout) throws IOException {
- conn.setAllowUserInteraction(true);
- if(timeout!=0) {
- conn.setConnectTimeout(timeout);
- conn.setReadTimeout(timeout);
- }
- conn.connect();
- return IOUtils.toString(new InputStreamReader(conn.getInputStream(), UTF8_STR));
- }
-
- public static String fetchDataFromServer(final String url) throws IOException {
- LOGGER.warn("__ENTERING fetchDataFromServer()");
-
- final URL u = new URL(url);
- final HttpsURLConnection http = (HttpsURLConnection)u.openConnection();
- http.setRequestMethod(GET_STR);
- return fetchContent(http, 0);
- }
-
- protected static String tmpPrefix = "loc";
- protected static String tmpSuffix = ".dat";
- public static File downloadFile(final String url) throws IOException {
- InputStream in = null;
- OutputStream out = null;
- try {
- LOGGER.info("downloadFile: " + url);
- final URL u = new URL(url);
- final URLConnection urlc = u.openConnection();
- if(urlc instanceof HttpsURLConnection) {
- final HttpsURLConnection http = (HttpsURLConnection)urlc;
- http.setInstanceFollowRedirects(false);
- http.setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(final String arg0, final SSLSession arg1) {
- return true;
- }
- });
- http.setRequestMethod(GET_STR);
- http.setAllowUserInteraction(true);
- }
- in = urlc.getInputStream();//new GZIPInputStream(dbURL.openStream());
- // if(sourceCompressed) { in = new GZIPInputStream(in); }
-
- final File outputFile = File.createTempFile(tmpPrefix, tmpSuffix);
- out = new FileOutputStream(outputFile);
-
- IOUtils.copy(in, out);
- return outputFile;
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- }
- public static String fetchSecureContent(final String url, final int timeout) throws IOException {
- LOGGER.info("fetchSecureContent: " + url);
- final URL u = new URL(url);
- final URLConnection conn = u.openConnection();
- if(timeout!=0) {
- conn.setConnectTimeout(timeout);
- conn.setReadTimeout(timeout);
- }
- if(conn instanceof HttpsURLConnection) {
- final HttpsURLConnection http = (HttpsURLConnection)conn;
- http.setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(final String arg0, final SSLSession arg1) {
- return true;
- }
- });
- http.setRequestMethod(GET_STR);
- http.setAllowUserInteraction(true);
- }
- return IOUtils.toString(conn.getInputStream());
- }
-
- private static HttpCookie tmCookie;
-
- private static HttpCookie getTmCookie(final String url, final String username, final String password, final int timeout) throws IOException {
- if (tmCookie != null && !tmCookie.hasExpired()) {
- return tmCookie;
- }
-
- final String charset = UTF8_STR;
- final String query = String.format("u=%s&p=%s",
- URLEncoder.encode(username, charset),
- URLEncoder.encode(password, charset));
- final URLConnection connection = new URL(url).openConnection();
-
- if (!(connection instanceof HttpsURLConnection)) {
- return null;
- }
-
- final HttpsURLConnection http = (HttpsURLConnection) connection;
-
- http.setInstanceFollowRedirects(false);
-
- http.setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(final String arg0, final SSLSession arg1) {
- return true;
- }
- });
-
- http.setRequestMethod("POST");
- http.setAllowUserInteraction(true);
-
- if (timeout != 0) {
- http.setConnectTimeout(timeout);
- http.setReadTimeout(timeout);
- }
-
- http.setDoOutput(true); // Triggers POST.
- http.setRequestProperty("Accept-Charset", charset);
- http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
-
- OutputStream output = null;
-
- try {
- output = http.getOutputStream();
- output.write(query.getBytes(charset));
- } finally {
- if (output != null) {
- try {
- output.close();
- } catch (IOException e) {
- LOGGER.debug(e,e);
- }
- }
- }
-
- LOGGER.info("fetching cookie: " + url);
- connection.connect();
-
- tmCookie = HttpCookie.parse(http.getHeaderField("Set-Cookie")).get(0);
- LOGGER.debug("cookie: "+ tmCookie);
-
- return tmCookie;
- }
- public static File downloadTM(final String url, final String authUrl, final String username, final String password) throws IOException {
- return downloadTM(url, authUrl, username, password, 0);
- }
- public static File downloadTM(final String url, final String authUrl, final String username, final String password, final int timeout) throws IOException {
- InputStream in = null;
- OutputStream out = null;
-
- try {
- final URL u = new URL(url);
- final URLConnection urlc = u.openConnection();
-
- if (timeout != 0) {
- urlc.setConnectTimeout(timeout);
- urlc.setReadTimeout(timeout);
- }
-
- if (urlc instanceof HttpsURLConnection) {
- final String cookie = getTmCookie(authUrl, username, password, timeout).toString();
-
- final HttpsURLConnection http = (HttpsURLConnection)urlc;
- http.setInstanceFollowRedirects(false);
- http.setHostnameVerifier(new HostnameVerifier() {
- @Override
- public boolean verify(final String arg0, final SSLSession arg1) {
- return true;
- }
- });
- http.setRequestMethod(GET_STR);
- http.setAllowUserInteraction(true);
- http.addRequestProperty("Cookie", cookie);
- }
-
- in = urlc.getInputStream();
-
- final File outputFile = File.createTempFile(tmpPrefix, tmpSuffix);
- out = new FileOutputStream(outputFile);
-
- IOUtils.copy(in, out);
- return outputFile;
- } finally {
- IOUtils.closeQuietly(in);
- IOUtils.closeQuietly(out);
- }
- }
-
- public static void clearTmCookie() {
- tmCookie = null;
- }
-
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Network.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Network.java
deleted file mode 100644
index 0456c0a..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/Network.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.util;
-
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-import org.apache.log4j.Logger;
-
-public class Network {
- private static final Logger LOGGER = Logger.getLogger(Network.class);
-
- public static final boolean isIpAddressLocal(final String ip) {
- try {
- final InetAddress address = InetAddress.getByName(ip);
- final Enumeration<NetworkInterface> ifaceList = NetworkInterface.getNetworkInterfaces();
-
- while (ifaceList.hasMoreElements()) {
- final NetworkInterface iface = ifaceList.nextElement();
- final Enumeration<InetAddress> addressList = iface.getInetAddresses();
-
- while (addressList.hasMoreElements()) {
- final InetAddress thisAddress = addressList.nextElement();
-
- if (address.equals(thisAddress)) {
- LOGGER.debug(address + " found on " + iface.getName() + "; returning true");
- return true;
- }
- }
- }
- } catch (UnknownHostException ex) {
- LOGGER.fatal(ex, ex);
- } catch (SocketException ex) {
- LOGGER.fatal(ex, ex);
- }
-
- return false;
- }
-
- public static boolean isLocalName(final String name) {
- try {
- if (name.equals(InetAddress.getLocalHost().getHostName())) {
- return true;
- }
- } catch (UnknownHostException ex) {
- LOGGER.fatal(ex, ex);
- }
-
- return false;
- }
-}
diff --git a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/PeriodicResourceUpdater.java b/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/PeriodicResourceUpdater.java
deleted file mode 100644
index bfd9265..0000000
--- a/traffic_monitor_java/src/main/java/com/comcast/cdn/traffic_control/traffic_monitor/util/PeriodicResourceUpdater.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *
- * 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.
- */
-
-package com.comcast.cdn.traffic_control.traffic_monitor.util;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileLock;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-
-import com.comcast.cdn.traffic_control.traffic_monitor.config.ConfigHandler;
-
-/**
- *
- * @author jlaue
- *
- */
-public class PeriodicResourceUpdater {
- private static final Logger LOGGER = Logger.getLogger(PeriodicResourceUpdater.class);
- private boolean isActive = true;
- private boolean running = false;
-
- protected IModel<Long> pollingInterval;
- protected IModel<String> host;
-
-// static protected ScheduledExecutorService executorService;
-// protected ScheduledFuture<?> scheduledService;
-
- public PeriodicResourceUpdater(final IModel<Long> interval) {
- pollingInterval = interval;
- }
-
- private final List<UpdateModel> umList = new ArrayList<UpdateModel>();
- private static class UpdateModel {
- protected List<Model<String>> urlList = new LinkedList<Model<String>>();
- protected String databaseLocation;
- private Updatable listener;
- private boolean hasBeenLoaded = false;
-
- private void putCurrent() {
- final File existingDB = ConfigHandler.getInstance().getDbFile(databaseLocation);
-
- if (existingDB.exists()) {
- LOGGER.warn("loading: " + existingDB.getAbsolutePath());
- listener.update(existingDB);
- }
-
- hasBeenLoaded = true;
- }
- }
-
- public void add(final Updatable listener, final Model<String> url, final String location) {
- final UpdateModel um = new UpdateModel();
- um.listener = listener;
- um.urlList.add(url);
- um.databaseLocation = location;
- add(um);
- }
-
- public void add(final Updatable listener, final String[] urla, final String location) {
- final UpdateModel um = new UpdateModel();
- um.listener = listener;
- for(String url : urla) {
- um.urlList.add(new Model<String>(url));
- }
- um.databaseLocation = location;
- add(um);
- }
-
- private void add(final UpdateModel um) {
- um.putCurrent();
- synchronized(umList) {
- umList.add(um);
- }
- }
-
-// static {
-// executorService = java.util.concurrent.Executors.newSingleThreadScheduledExecutor();
-// }
-
- public void destroy() {
-// executorService.shutdownNow();
- isActive = false;
- mainThread.interrupt();
- while (running) {
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) { }
- }
- }
-
- final private Runnable updater = new Runnable() {
- @Override
- public void run() {
- running = true;
- while(isActive) {
- try {
- synchronized(umList) {
- for(UpdateModel um : umList) {
- if(!isActive) {
- running = false;
- return;
- }
- updateDatabase(um);
- }
- }
- } catch(Exception e) {
- LOGGER.warn("error", e);
- }
- try {
- Thread.sleep(getPollingInterval());
- } catch (InterruptedException e) { }
- }
... 4921 lines suppressed ...