[
https://issues.apache.org/jira/browse/TC-32?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15768201#comment-15768201
]
ASF GitHub Bot commented on TC-32:
----------------------------------
Github user mitchell852 commented on a diff in the pull request:
https://github.com/apache/incubator-trafficcontrol/pull/141#discussion_r93522293
--- Diff: traffic_ops/app/lib/API/Configs/ApacheTrafficServer.pm ---
@@ -0,0 +1,1959 @@
+package API::Configs::ApacheTrafficServer;
+
+#
+#
+# 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 UI::Utils;
+use Mojo::Base 'Mojolicious::Controller';
+use Date::Manip;
+use NetAddr::IP;
+use Data::Dumper;
+use UI::DeliveryService;
+use JSON;
+use API::DeliveryService::KeysUrlSig qw(URL_SIG_KEYS_BUCKET);
+use URI;
+use File::Basename;
+use File::Path;
+
+#Sub to generate ORT json
+sub ort {
+ my $self = shift;
+ my $id = $self->param('id');
+ my $filename = 'ort';
+ my $scope = 'server';
+
+ ##check user access
+ if ( !&is_oper($self) ) {
+ return $self->forbidden();
+ }
+
+ ##verify that a valid server ID has been used
+ my $server_obj = $self->server_data($id);
+ if ( !defined($server_obj) ) {
+ return $self->not_found();
+ }
+
+ my $data_obj;
+ my $host_name = $server_obj->host_name;
+
+ my %condition = ( 'me.host_name' => $host_name );
+ my $rs_profile = $self->db->resultset('Server')->search( \%condition, {
prefetch => [ 'cdn', 'profile' ] } );
+
+ my $row = $rs_profile->next;
+ if ($row) {
+ my $cdn_name = defined( $row->cdn_id ) ? $row->cdn->name : "";
+
+ $data_obj->{'profile'}->{'name'} = $row->profile->name;
+ $data_obj->{'profile'}->{'id'} = $row->profile->id;
+ $data_obj->{'other'}->{'CDN_name'} = $cdn_name;
+
+ %condition = (
+ 'profile_parameters.profile' =>
$data_obj->{'profile'}->{'id'},
+ -or => [ 'name' => 'location',
'name' => 'scope' ]
+ );
+ my $rs_config = $self->db->resultset('Parameter')->search(
\%condition, { join => 'profile_parameters' } );
+ while ( my $row = $rs_config->next ) {
+ if ( $row->name eq 'location' ) {
+ $data_obj->{'config_files'}->{
$row->config_file }->{'location'} = $row->value;
+ }
+ elsif ( $row->name eq 'scope' ) {
+ $data_obj->{'config_files'}->{
$row->config_file }->{'scope'} = $row->value;
+ }
+ }
+ }
+
+ foreach my $file ( keys %$data_obj->{'config_files'} ) {
+ if ( !defined( $data_obj->{'config_files'}->{$file}->{'scope'}
) ) {
+ $data_obj->{'config_files'}->{$file}->{'scope'} =
$self->get_scope($file);
--- End diff --
$self->get_scope($file)
this makes me wonder, why even bother with all the messiness involved with
creating scope parameters? i kinda think this hard-coded lookup might be
sufficient. or is scope something that could change often and needs to be
configurable at runtime?
> Improve efficiency of ATS config generation
> -------------------------------------------
>
> Key: TC-32
> URL: https://issues.apache.org/jira/browse/TC-32
> Project: Traffic Control
> Issue Type: Improvement
> Components: Traffic Ops API
> Reporter: Derek Gelinas
> Assignee: Derek Gelinas
> Fix For: 1.9.0
>
>
> Currently when generating ATS configuration files, each server calls for its
> individual files from traffic ops. This is a very database-intensive process
> that is not scalable enough. I propose the following changes:
> 1) Generate the configuration files only as many times as needed - many files
> are the same (or can be) for the entire CDN or server profile.
> 2) Once generated, the files can be cached locally. Requests for the files
> by ORT will result in pulling down these cached files rather than many
> hundreds of DB queries each time.
> 3) Migrate the routes for these files to the API. Each call will have
> multiple options - a request made with no options would return the cached
> file, another option would return the current DB data, and a third option
> would update the cached file with the current information in the DB.
> 4) When an update is queued, generate and cache the configuration files, then
> activate the update flag for the relevant servers once the cached file
> generation is completed.
> In this way, triggering updates for the caches will result in an initial
> increase in activity as traffic ops generates the files needed, followed by
> the much lower impact of the files themselves being requested by the caches.
> I believe we can cut down the number of server-specific configuration files
> to only 5 intially, and potentially fewer by having ORT fill in certain
> fields on files like records.config with local data during processing.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)