blib/lib/Apache/Hadoop/Config.pm

filter: Statementstmt 6.5% 11 / 167 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 39 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 12.0% 3 / 25 Podpod 0.0% 0 / 9 totaltotal 4.3% 14 / 323 CC 63 SCAR 41.1
CC
63
Cov
4%
new
240.0
_tag
56.0
_calc_min_container_size
42.0
CRAP 60.8
↑ Summary
1 package Apache::Hadoop::Config;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our @ISA = qw();
8 1 our $VERSION = '0.01';
9  
10  
11 # class definition begins
12  
13 0 ▶sub new {
Subroutine new: not called CC=15 SCAR=54.8
Pod undocumented
14 0 my $class = shift;
15 0 my %args = @_;
16 my $self = {
17 namenode => $args{'namenode'} || 'localhost',
18 secondary => $args{'secondary'} || '0.0.0.0',
19 proxynode => $args{'proxynode'} || 'localhost',
20 proxyport => $args{'proxyport'} || 8888,
21 hadoop_install => $args{'hadoop_install'} || '/usr/local/hadoop',
22 hadoop_confdir => $args{'hadoop_confdir'} || '/usr/local/hadoop/etc/hadoop',
23 hdfs_tmp => $args{'hdfs_tmp'} || '/hdfs/tmp',
24 hdfs_name_disks=> $args{'hdfs_name_disks'} ||
25 [ '/hdfs/name1',
26 '/hdfs/name2',
27 ],
28 hdfs_data_disks=> $args{'hdfs_data_disks'} ||
29 [ '/hdfs/data1',
30 '/hdfs/data2',
31 '/hdfs/data3',
32 '/hdfs/data4',
33 ],
34 hadoop_logs => [ '/logs', '/logs/userlog' ],
35 debug => $args{'debug'} || undef,
36  
37 config => $args{'config'} || undef,
38  
39 sysinfo=> {
40 cpu => $args{'cpuinfo'} || undef,
41 mem => $args{'meminfo'} || undef,
42 0 ▶ disk => $args{'diskinfo'} || undef,
Condition0%0/28
$args{'namenode'} || 'localhost'
l!l
00
$args{'secondary'} || '0.0.0.0'
l!l
00
$args{'proxynode'} || 'localhost'
l!l
00
$args{'proxyport'} || 8888
l!l
00
$args{'hadoop_install'} || '/usr/local/hadoop'
l!l
00
$args{'hadoop_confdir'} || '/usr/local/hadoop/etc/hadoop'
l!l
00
$args{'hdfs_tmp'} || '/hdfs/tmp'
l!l
00
$args{'hdfs_name_disks'} || ['/hdfs/name1', '/hdfs/name2']
l!l
00
$args{'hdfs_data_disks'} || ['/hdfs/data1', '/hdfs/data2', '/hdfs/data3', '/hdfs/data4']
l!l
00
$args{'debug'} || undef
l!l
00
$args{'config'} || undef
l!l
00
$args{'cpuinfo'} || undef
l!l
00
$args{'meminfo'} || undef
l!l
00
$args{'diskinfo'} || undef
l!l
00
MC/DC0%0/1
$args{'namenode'} || 'localhost'
$args{'namenode'}
MC/DC0%0/1
$args{'secondary'} || '0.0.0.0'
$args{'secondary'}
MC/DC0%0/1
$args{'proxynode'} || 'localhost'
$args{'proxynode'}
MC/DC0%0/1
$args{'proxyport'} || 8888
$args{'proxyport'}
MC/DC0%0/1
$args{'hadoop_install'} || '/usr/local/hadoop'
$args{'hadoop_install'}
MC/DC0%0/1
$args{'hadoop_confdir'} || '/usr/local/hadoop/etc/hadoop'
$args{'hadoop_confdir'}
MC/DC0%0/1
$args{'hdfs_tmp'} || '/hdfs/tmp'
$args{'hdfs_tmp'}
MC/DC0%0/1
$args{'hdfs_name_disks'} || ['/hdfs/name1', '/hdfs/name2']
$args{'hdfs_name_disks'}
MC/DC0%0/1
$args{'hdfs_data_disks'} || ['/hdfs/data1', '/hdfs/data2', '/hdfs/data3', '/hdfs/data4']
$args{'hdfs_data_disks'}
MC/DC0%0/1
$args{'debug'} || undef
$args{'debug'}
MC/DC0%0/1
$args{'config'} || undef
$args{'config'}
MC/DC0%0/1
$args{'cpuinfo'} || undef
$args{'cpuinfo'}
MC/DC0%0/1
$args{'meminfo'} || undef
$args{'meminfo'}
MC/DC0%0/1
$args{'diskinfo'} || undef
$args{'diskinfo'}
Truth table0%0/2
A
A= $args{'namenode'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'secondary'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'proxynode'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'proxyport'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'hadoop_install'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'hadoop_confdir'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'hdfs_tmp'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'hdfs_name_disks'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'hdfs_data_disks'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'debug'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'config'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'cpuinfo'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'meminfo'}
Aresult
11
00
Truth table0%0/2
A
A= $args{'diskinfo'}
Aresult
11
00
43 },
44 };
45 0 bless $self, $class;
46 0 return $self;
47 }
48  
49 # internal utils
50 0 ▶sub _minimum {
Subroutine _minimum: not called CC=4 SCAR=30.0
51 0 my ($self, @arr) = (@_);
52 0 my $min;
53 0 ▶ for (@arr) { $min = $_ if !$min || $_ < $min; }
Branch: 1 branch
BranchTrueFalseTotal
if not $min or $_ < $min 0 0 0
Condition0%0/3
not $min or $_ < $min
l!l&&r!l&&!r
000
MC/DC0%0/2
not $min or $_ < $min
not $min $_ < $min
Truth table0%0/3
not(A) or B
A= not $minB= $_ < $min
ABresult
1X1
011
000
54 0 return $min;
55 }
56  
57 0 ▶sub _maximum {
Subroutine _maximum: not called CC=4 SCAR=30.0
58 0 my ($self, @arr) = (@_);
59 0 my $max;
60 0 ▶ for (@arr) { $max = $_ if !$max || $_ > $max; }
Branch: 1 branch
BranchTrueFalseTotal
if not $max or $_ > $max 0 0 0
Condition0%0/3
not $max or $_ > $max
l!l&&r!l&&!r
000
MC/DC0%0/2
not $max or $_ > $max
not $max $_ > $max
Truth table0%0/3
not(A) or B
A= not $maxB= $_ > $max
ABresult
1X1
011
000
61 0 return $max;
62 }
63  
64 0 ▶sub _copyconf {
Subroutine _copyconf: not called CC=5 SCAR=34.0
65 0 my ($self, $config) = (@_);
66 0 ▶ unless ( defined $self->{'config'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"config"}) 0 0 0
67 0 $self->{'config'} = $config;
68 0 return;
69 }
70  
71 0 foreach my $file ( keys %{$config} ) {
72 0 foreach my $param ( keys %{$config->{$file}} ) {
73 $self->{'config'}->{$file}->{$param} = $config->{$file}->{$param}
74 0 ▶ unless defined $self->{'config'}->{$file}->{$param};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"config"}{$file}{$param} 0 0 0
75 }
76 }
77 }
78  
79 # get config template
80 0 ▶sub basic_config {
Subroutine basic_config: not called CC=1 SCAR=6.9
Pod undocumented
81 0 my ($self) = (@_);
82 my $config = {
83 'core-site.xml' => {
84 'fs.defaultFS' => 'http://'.$self->{namenode}.':9000',
85 'hadoop.tmp.dir' => $self->{'hdfs_tmp'},
86 },
87 'hdfs-site.xml' => {
88 'dfs.replication' => 1,
89 0 'dfs.namenode.name.dir' => join ( ',', map { 'file://'.$_ } @{$self->{'hdfs_name_disks'}} ),
90 0 'dfs.datanode.data.dir' => join ( ',', map { 'file://'.$_ } @{$self->{'hdfs_data_disks'}} ),
91  
92 # secondary namenode
93 'dfs.namenode.secondary.http-address' => $self->{'secondary'}.':50090',
94 'dfs.namenode.secondary.https-address'=> $self->{'secondary'}.':50091',
95 },
96 'yarn-site.xml' => {
97 'yarn.nodemanager.aux-services' => 'mapreduce_shuffle',
98 'yarn.nodemanager.aux-services.mapreduce.shuffle.class' => 'org.apache.hadoop.mapred.ShuffleHandler',
99 0 'yarn.web-proxy.address' => $self->{'proxynode'}.':'.$self->{'proxyport'},
100 },
101 'mapred-site.xml' => {
102 'mapreduce.framework.name' => 'yarn',
103 }
104 };
105
106 0 $self->_copyconf ( $config );
107 }
108  
109 #
110 # directory management
111 #
112 0 ▶sub _mkdir {
Subroutine _mkdir: not called CC=2 SCAR=17.9
113 0 my ($self, %opts) = (@_);
114 0 ▶ my $mode = $opts{'mode'} || 0750;
Condition0%0/2
$opts{'mode'} || 488
l!l
00
MC/DC0%0/1
$opts{'mode'} || 488
$opts{'mode'}
Truth table0%0/2
A
A= $opts{'mode'}
Aresult
11
00
115 0 my $u = umask (0);
116 0 map { mkdir $_, $mode; chdir $_; } split (/\//, $opts{'directory'});
117 }
118  
119 0 ▶sub create_hdfs_name_disks {
Subroutine create_hdfs_name_disks: not called CC=3 SCAR=24.8
Pod undocumented
120 0 my ($self) = (@_);
121 0 foreach my $dir ( @{$self->{'hdfs_name_disks'}} ) {
122 0 ▶ print "creating ".$dir, "\n" if defined $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"debug"} 0 0 0
123 0 $self->_mkdir( directory => $dir );
124 }
125 }
126  
127 0 ▶sub create_hdfs_data_disks {
Subroutine create_hdfs_data_disks: not called CC=3 SCAR=24.8
Pod undocumented
128 0 my ($self) = (@_);
129 0 foreach my $dir ( @{$self->{'hdfs_data_disks'}} ) {
130 0 ▶ print "creating ".$dir, "\n" if defined $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"debug"} 0 0 0
131 0 $self->_mkdir( directory => $dir );
132 }
133 }
134  
135 0 ▶sub create_hdfs_tmpdir {
Subroutine create_hdfs_tmpdir: not called CC=2 SCAR=17.9
Pod undocumented
136 0 my ($self) = (@_);
137 0 ▶ print "creating ".$self->{'hdfs_tmp'}, "\n" if defined $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"debug"} 0 0 0
138 0 $self->_mkdir( directory => $self->{'hdfs_tmp'}, mode => 01775 );
139 }
140  
141 0 ▶sub create_hadoop_logdir {
Subroutine create_hadoop_logdir: not called CC=3 SCAR=24.8
Pod undocumented
142 # $hadoop_install/tmp 1775
143 0 my ($self) = (@_);
144 0 foreach my $dir ( @{$self->{'hadoop_logs'}} ) {
145 0 ▶ print "creating ".$self->{'hadoop_install'}.$dir, "\n" if defined $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"debug"} 0 0 0
146 0 $self->_mkdir( directory => $self->{'hadoop_install'}.$dir, mode => 01775 );
147 }
148 }
149 # ends
150  
151 #
152 # begin recommended settings
153 #
154  
155 # get cpu core count
156 0 ▶sub _get_cpu_cores {
Subroutine _get_cpu_cores: not called CC=2 SCAR=17.9
157 0 my ($self) = (@_);
158 0 my $cpuinfo = '/proc/cpuinfo';
159 0 ▶ open CPU, $cpuinfo or die "Cannot open $cpuinfo, $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open CPU, $cpuinfo or die "Cannot open $cpuinfo, $!\n" 0 0 0
160 0 $self->{'sysinfo'}->{'cpu'} = scalar (map /^processor/, <CPU>);
161 0 close CPU;
162 }
163  
164 # get memory size
165 0 ▶sub _get_memory_system {
Subroutine _get_memory_system: not called CC=2 SCAR=17.9
166 0 my ($self) = (@_);
167 0 my $meminfo = '/proc/meminfo';
168 0 ▶ open MEM, $meminfo or die "Cannot open $meminfo, $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open MEM, $meminfo or die "Cannot open $meminfo, $!\n" 0 0 0
169 0 $self->{'sysinfo'}->{'mem'} = (split (/\s+/, (grep /^MemTotal/, <MEM>)[0]))[1];
170 0 $self->{'sysinfo'}->{'mem'} = $self->{'sysinfo'}->{'mem'} / (1024.0 * 1024.0);
171 0 close MEM;
172 }
173  
174 # get disk info: not implemented
175 0 ▶sub _get_disk_count {
Subroutine _get_disk_count: not called CC=1 SCAR=6.9
176 0 my ($self) = (@_);
177 0 $self->{'sysinfo'}->{'disk'} = scalar @{$self->{'hdfs_data_disks'}}
178 }
179  
180 # calculate reserved memory
181 0 ▶sub _get_memory_reserved {
Subroutine _get_memory_reserved: not called CC=5 SCAR=34.0
182 0 my ($self) = (@_);
183 0 my ($m, $m1, $m2, $m3);
184  
185 0 ▶ $self->_get_memory_system unless defined $self->{'sysinfo'}->{'mem'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sysinfo"}{"mem"} 0 0 0
186 0 $m = $self->{'sysinfo'}->{'mem'};
187 0 $m1 = int (0.124102 * $m + 1.236659); # approximated by a linear eq through least square
188 0 ▶ $m2 = $m >= 16 ? $m1 - ($m1%2) : $m1;
Branch: 1 branch
BranchTrueFalseTotal
$m >= 16 ? : 0 0 0
189 0 ▶ $m3 = $m >= 64 ? $m2 - ($m2%2) : $m2;
Branch: 1 branch
BranchTrueFalseTotal
$m >= 64 ? : 0 0 0
190 0 ▶ print "reserved_mem (gb): ",$m3,"\n" if $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
191 0 return $m3;
192 }
193  
194 # calculate available memory (total - reserved)
195 0 ▶sub _calc_memory_available {
Subroutine _calc_memory_available: not called CC=3 SCAR=24.8
196 0 my ($self) = (@_);
197 0 ▶ $self->_get_memory_system unless defined $self->{'sysinfo'}->{'mem'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sysinfo"}{"mem"} 0 0 0
198 0 my $mem = $self->{'sysinfo'}->{'mem'} - $self->_get_memory_reserved;
199 0 $mem *= 1024; # mb
200 0 ▶ print "available mem (mb): $mem\n" if $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
201 0 return $mem;
202 }
203  
204 # calculate min container size
205 0 ▶sub _calc_min_container_size {
Subroutine _calc_min_container_size: not called CC=6 SCAR=37.4
206 0 my ($self) = (@_);
207 0 ▶ $self->_get_memory_system unless defined $self->{'sysinfo'}->{'mem'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sysinfo"}{"mem"} 0 0 0
208 0 my $m = $self->{'sysinfo'}->{'mem'};
209 0 ▶ my $m1 = $m < 4 ? 0 : ($m < 8 ? 1 : ($m<24 ? 2 : 3));
Branch: 3 branches
BranchTrueFalseTotal
$m < 4 ? : 0 0 0
$m < 8 ? : 0 0 0
$m < 24 ? : 0 0 0
210 0 my $m2 = 2 ** $m1;
211 0 my $m3 = 0.25 * $m2 * 1024; # mb
212 0 ▶ print "min_container_size (mb): $m3\n" if $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
213 0 return $m3;
214 }
215  
216 0 ▶sub _calc_container_count {
Subroutine _calc_container_count: not called CC=4 SCAR=30.0
217 0 my ($self) = (@_);
218 0 my ($cores, $disks);
219 0 my $ratio = $self->_calc_memory_available / $self->_calc_min_container_size;
220  
221 0 ▶ $self->_get_cpu_cores unless defined $self->{'sysinfo'}->{'cpu'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sysinfo"}{"cpu"} 0 0 0
222 0 $cores = 2 * $self->{'sysinfo'}->{'cpu'};
223  
224 0 ▶ unless (defined $self->{'sysinfo'}->{'disk'}) { $self->_get_disk_count; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"sysinfo"}{"disk"}) 0 0 0
225 0 $disks = 1.8 * $self->{'sysinfo'}->{'disk'};
226  
227 0 ▶ print "cores=$cores disks=$disks ratio=$ratio\n" if $self->{'debug'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
228 0 return int ($self->_minimum($cores, $disks, $ratio));
229 }
230  
231 0 ▶sub _calc_container_memory {
Subroutine _calc_container_memory: not called CC=1 SCAR=6.9
232 0 my ($self) = (@_);
233 0 my $ratio = $self->_calc_memory_available / $self->_calc_container_count;
234 0 my $size = $self->_calc_min_container_size;
235 0 return int($self->_maximum($size, $ratio));
236 }
237  
238 0 ▶sub memory_config {
Subroutine memory_config: not called CC=1 SCAR=6.9
Pod undocumented
239 0 my ($self) = (@_);
240  
241 0 my $con = $self->_calc_container_count;
242 0 my $mpc = $self->_calc_container_memory;
243  
244 0 my $config = {
245 'yarn-site.xml' => {
246 'yarn.nodemanager.resource.memory-mb' => $con * $mpc,
247 'yarn.scheduler.minimum-allocation-mb' => $mpc,
248 'yarn.scheduler.maximum-allocation-mb' => $con * $mpc,
249 },
250 'mapred-site.xml' => {
251 'mapreduce.map.memory.mb' => $mpc,
252 'mapreduce.reduce.memory.mb' => 2 * $mpc,
253 'mapreduce.map.java.opts' => "-Xmx".int(0.8 * $mpc)."m",
254 'mapreduce.reduce.java.opts' => "-Xmx".int(0.8 * 2 * $mpc)."m",
255 },
256 };
257 0 $self->_copyconf ( $config );
258 }
259  
260 0 ▶sub print_config {
Subroutine print_config: not called CC=5 SCAR=34.0
Pod undocumented
261 0 my ($self) = (@_);
262  
263 0 print "min cont size (mb) : ",$self->_calc_min_container_size,"\n";
264 0 print "num of containers : ",$self->_calc_container_count,"\n";
265 0 print "mem per container (mb): ",$self->_calc_container_memory,"\n";
266 0 foreach my $k ( keys %{$self->{'sysinfo'}} ) {
267 print sprintf "%5s : %s\n", $k, $self->{'sysinfo'}->{$k}
268 0 ▶ if defined $self->{'sysinfo'}->{$k};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"sysinfo"}{$k} 0 0 0
269 }
270  
271 0 print "---------------\n";
272 0 foreach my $file ( keys %{$self->{'config'}} ) {
273 0 print $file, "\n";
274 0 my $val = $self->{'config'}->{$file};
275 0 foreach my $key ( keys %$val ) {
276 0 print " ",$key,": ", $val->{$key},"\n";
277 }
278 }
279 0 print "---------------\n";
280 }
281  
282 0 ▶sub _tag {
Subroutine _tag: not called CC=7 SCAR=40.3
283 0 my ($self, %args) = (@_);
284  
285 0 my $header = qq{<?xml version="1.0" encoding="UTF-8"?>
286 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
287 <!--
288 Licensed under the Apache License, Version 2.0 (the "License");
289 you may not use this file except in compliance with the License.
290 You may obtain a copy of the License at
291  
292 http://www.apache.org/licenses/LICENSE-2.0
293  
294 Unless required by applicable law or agreed to in writing, software
295 distributed under the License is distributed on an "AS IS" BASIS,
296 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
297 See the License for the specific language governing permissions and
298 limitations under the License. See accompanying LICENSE file.
299 -->
300  
301 <!-- site-specific property below: -->
302 };
303  
304 0 my $property = qq{ <property>
305 <name>NAME</name>
306 <value>VALUE</value>
307 </property>
308 };
309 # type = header, config, property
310 # (type=config) begin=>1, end=>1
311 # (type==property) name=>s value=>s
312 #
313 0 for ($args{'type'}) {
314 0 ▶ /header/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/header/ and do { return $header } 0 0 0
315 0 return $header;
316 };
317 0 ▶ /config/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/config/ and do { my $str; $str .= "<configuration>\n" if defined $args{"begin"}; $str .= "</configuration>\n" if defined $args{"end"}; return $str } 0 0 0
318 0 my $str;
319 0 ▶ $str .= "<configuration>\n" if defined $args{'begin'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"begin"} 0 0 0
320 0 ▶ $str .= "</configuration>\n" if defined $args{'end'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"end"} 0 0 0
321 0 return $str;
322 };
323 0 ▶ /property/ && do {
Branch: 1 branch
BranchTrueFalseTotal
/property/ and do { my $str = $property; $str =~ s/NAME/$args{"name"}/; $str =~ s/VALUE/$args{"value"}/; return $str } 0 0 0
324 0 my $str = $property;
325 0 $str =~ s/NAME/$args{'name'}/;
326 0 $str =~ s/VALUE/$args{'value'}/;
327 0 return $str;
328 };
329 }
330 }
331
332 0 ▶sub write_config {
Subroutine write_config: not called CC=5 SCAR=34.0
Pod undocumented
333 0 my ($self, %args) = (@_);
334 0 ▶ my $cdir = $args{'confdir'} || $self->{'confdir'};
Condition0%0/3
$args{'confdir'} || $self->{'confdir'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'confdir'} || $self->{'confdir'}
$args{'confdir'} $self->{'confdir'}
Truth table0%0/3
A || B
A= $args{'confdir'}B= $self->{'confdir'}
ABresult
1X1
011
000
335
336 0 foreach my $file ( keys %{$self->{'config'}} ) {
337 0 print "-> writing to $cdir/$file ...\n";
338  
339 # open conf file
340 0 ▶ open CONF, ">".$cdir.'/'.$file or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open CONF, '>' . $cdir . '/' . $file or die $! 0 0 0
341  
342 # xml header
343 0 print CONF $self->_tag (type=>'header');
344 0 print CONF $self->_tag (type=>'config', begin=>1);
345  
346 # properties
347 0 my $prop = $self->{'config'}->{$file};
348 0 foreach my $key ( keys %{$prop} ) {
349 0 print CONF $self->_tag( type=>'property', name=>$key, value=>$prop->{$key} );
350 }
351  
352 # close config
353 0 print CONF $self->_tag (type=>'config', end=>1);
354 0 close CONF;
355 }
356 }
357 #
358 # ends recommended settings
359  
360 1 1;
361 __END__
↑ Summary