- Timestamp:
- 2015-12-10T12:19:20+13:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/tdb/trunk/perllib/DBDrivers/70HyphenFormat.pm
r30341 r30347 32 32 # 33 33 ############################################################################### 34 35 # Note: This driver may be a candidate for further splitting, maybe into a 36 # PipedExecutableDriver and a 70HyphenFormatDriver... but for now all piped 37 # drivers are 70 hyphen format ones, so, yeah. 34 38 35 39 package DBDrivers::70HyphenFormat; … … 59 63 $self->{'read_executable'} = 'error'; 60 64 $self->{'write_executable'} = 'error'; 65 $self->{'forced_affinity'} = -1; # Set to processor number for forced affinity 61 66 bless($self, $class); 62 67 return $self; … … 68 73 69 74 70 ## @function close_infodb_handle(filehandle)71 #72 sub close_infodb_handle73 {74 my $self = shift(@_);75 my $infodb_handle = shift(@_);76 $self->debugPrintFunctionHeader();77 close($infodb_handle);78 }79 ## close_infodb_handle(filehandle) => void ##80 81 82 75 ## @function close_infodb_write_handle(filehandle) 83 76 # … … 85 78 { 86 79 my $self = shift(@_); 87 $self->close_infodb_handle(@_); 80 $self->debugPrintFunctionHeader(@_); 81 my $handle = shift(@_); 82 my $force_close = shift(@_); # Undefined most of the time 83 my $continue_close = $self->removeConnectionIfPersistent($handle, $force_close); 84 if ($continue_close) { 85 close($handle); 86 } 87 return; 88 88 } 89 89 ## close_infodb_write_handle(filehandle) => void ## … … 142 142 { 143 143 my $self = shift(@_); 144 $self->debugPrintFunctionHeader(@_); 144 145 my $infodb_handle = shift(@_); 145 146 my $infodb_key = shift(@_); 146 147 147 # A minus at the end of a key (after the ]) signifies 'delete' 148 print $infodb_handle "[$infodb_key]-\n"; 149 148 print $infodb_handle '[' . $infodb_key . ']-' . "\n"; 150 149 # The 70 minus signs are also needed, to help make the parsing by db2txt simple 151 150 print $infodb_handle '-' x 70, "\n"; … … 160 159 my $self = shift(@_); 161 160 $self->debugPrintFunctionHeader(@_); 162 my $infodb_file_handle = $self->openWriteHandle(@_); 161 my $path = shift(@_); 162 my $append = shift(@_); 163 my $infodb_file_handle = $self->retrieveConnectionIfPersistent($path, $append);; 164 # No available existing connection 165 if (!defined $infodb_file_handle || !$infodb_file_handle) { 166 $infodb_file_handle = $self->openWriteHandle($path, $append, @_); 167 $self->registerConnectionIfPersistent($infodb_file_handle, $path, $append); 168 } 163 169 return $infodb_file_handle; 164 170 } … … 181 187 } 182 188 my $infodb_file_handle = undef; 183 my $cmd = '"' . $exe . '" ' . $default_args; 189 my $cmd = ''; 190 if ($self->{'forced_affinity'} >= 0) 191 { 192 $cmd = 'taskset -c ' . $self->{'forced_affinity'} . ' '; 193 } 194 $cmd .= '"' . $exe . '" ' . $default_args; 184 195 foreach my $open_arg (@_) { 196 # Special - append is typically missing a hyphen 197 if ($open_arg eq 'append') { 198 $open_arg = '-append'; 199 } 185 200 $cmd .= ' ' . $open_arg; 186 201 } … … 199 214 200 215 ## @function openReadHandle(string, string) => filehandle 216 # 201 217 sub openReadHandle 202 218 { … … 207 223 208 224 225 ## @function openWriteHandle(*) => filehandle 226 # 209 227 sub openWriteHandle 210 228 { … … 212 230 return $self->openPipedHandle(RWMODE_WRITE, $self->{'write_executable'}, @_); 213 231 } 232 ## openWriteHandle(*) => filehandle ## 233 214 234 215 235 ## @function read_infodb_entry(string, string) => hashmap … … 232 252 my $infodb_file_path = shift(@_); 233 253 my $infodb_map = shift(@_); 254 $self->debugPrintFunctionHeader($infodb_file_path, $infodb_map); 234 255 my $infodb_file_handle = $self->openReadHandle($infodb_file_path); 235 256 my $infodb_line = ""; … … 250 271 } 251 272 } 252 $self->close_infodb_ handle($infodb_file_handle);273 $self->close_infodb_write_handle($infodb_file_handle); 253 274 } 254 275 ## read_infodb_file(string, hashmap) => void ## … … 291 312 } 292 313 } 293 $self->close_infodb_ handle($infodb_file_handle);314 $self->close_infodb_write_handle($infodb_file_handle); 294 315 } 295 316 ## read_infodb_keys(string, hashmap) => void ## … … 354 375 print $infodb_file_handle "[$infodb_key]\n"; 355 376 print $infodb_file_handle "$serialized_infodb_map\n"; 356 $self->close_infodb_ handle($infodb_file_handle);377 $self->close_infodb_write_handle($infodb_file_handle); 357 378 $status = 0; # as in exit status of cmd OK 358 379 }
Note:
See TracChangeset
for help on using the changeset viewer.