Changeset 24483 for gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
- Timestamp:
- 2011-08-26T00:22:29+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
r24456 r24483 117 117 print STDERR "Sections: $solr_passes_sections\n"; 118 118 print STDERR "Build Dir: $build_dir\n"; 119 print STDERR "Cmd: $solr_passes_exe $collection text $solr_passes_sections\"$build_dir\" \"dummy\" $osextra\n";120 if (!open($handle, "| $solr_passes_exe $collection text $solr_passes_sections\"$build_dir\" \"dummy\" $osextra"))119 print STDERR "Cmd: $solr_passes_exe $collection text dummy \"$build_dir\" \"dummy\" $osextra\n"; 120 if (!open($handle, "| $solr_passes_exe $collection text dummy \"$build_dir\" \"dummy\" $osextra")) 121 121 { 122 122 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'}; … … 272 272 273 273 274 sub solr_core_admin275 {276 my $self = shift (@_);277 my ($url) = @_;278 279 my $cmd = "wget -O - \"$url\" 2>&1";280 281 my $preamble_output = "";282 my $xml_output = "";283 my $error_output = undef;284 285 my $in_preamble = 1;286 287 if (open(WIN,"$cmd |")) {288 289 my $line;290 while (defined ($line=<WIN>)) {291 292 if ($line =~ m/ERROR \d+:/) {293 chomp $line;294 $error_output = $line;295 last;296 }297 elsif ($in_preamble) {298 if ($line =~ m/<.*>/) {299 $in_preamble = 0;300 }301 else {302 $preamble_output .= $line;303 }304 }305 306 if (!$in_preamble) {307 $xml_output .= $line;308 }309 }310 close(WIN);311 312 }313 else {314 $error_output = "Error: failed to run $cmd\n";315 $error_output .= " $!\n";316 }317 318 my $output = { 'preamble' => $preamble_output,319 'output' => $xml_output,320 'error' => $error_output };321 322 return $output;323 }324 325 274 sub pre_build_indexes 326 275 { … … 415 364 # => at most two cores <colname>-Doc and <colname>-Sec 416 365 417 my $jetty_server_port = $ENV{'SOLR_JETTY_PORT'};418 my $base_url = "http://localhost:$jetty_server_port/solr/admin/cores";419 420 366 my $collection = $self->{'collection'}; 421 367 … … 427 373 my ($pindex) = $level =~ /^(.)/; 428 374 429 my $llevel = $mgppbuilder::level_map{$level}; 430 my $core = $collection."-".lc($llevel); 431 432 433 # if collect==core not already in solr.xml (check with STATUS) 434 # => use CREATE API to add to solr.xml 375 ## my $llevel = $mgppbuilder::level_map{$level}; 376 ## my $core = $collection."-".lc($llevel); 377 378 my $core = $collection."-".$pindex.$idx; 379 380 # if collect==core already in solr.xml (check with STATUS) 381 # => use RELOAD call to refresh fields now expressed in schema.xml 435 382 # 436 383 # else 437 # => use RELOAD call to refresh fields now expressed in schema.xml 438 439 440 my $check_core_url = "$base_url?action=STATUS&core=$core"; 441 my $output = $self->solr_core_admin($check_core_url); 442 443 if (defined $output->{'error'}) { 444 445 my $preamble = $output->{'preamble'}; 446 my $error = $output->{'error'}; 447 448 print STDERR "----\n"; 449 print STDERR "Error: Failed to get XML response from:\n"; 450 print STDERR " $check_core_url\n"; 451 print STDERR "Output was:\n"; 452 print STDERR $preamble if ($preamble ne ""); 453 print STDERR "$error\n"; 454 print STDERR "----\n"; 455 456 next; 457 } 458 459 # If the collection doesn't exist yet, then there will be 460 # an empty element of the form: 461 # <lst name="collect-doc"/> 462 # where 'collect' is the actual name of the collection, 463 # such as demo 464 465 my $xml_output = $output->{'output'}; 466 467 my $empty_element="<lst\\s+name=\"$core\"\\s*\\/>"; 468 469 my $check_core_exists = !($xml_output =~ m/$empty_element/s); 470 471 if ($check_core_exists) { 472 473 my $reload_core_url = "$base_url?action=RELOAD&core=$core"; 474 384 # => use CREATE API to add to solr.xml 385 386 my $check_core_exists = $solr_server->admin_ping_core($core); 387 388 if ($check_core_exists) { 475 389 print $outhandle "Reloading Solr core: $core\n"; 476 $s elf->solr_core_admin($reload_core_url);390 $solr_server->admin_reload_core($core); 477 391 } 478 392 else { 479 480 my $collect_home = $ENV{'GSDLCOLLECTDIR'};481 my $etc_dirname = &util::filename_cat($collect_home,"etc");482 483 my $build_dir = $self->{'build_dir'};484 my $idx_dirname = &util::filename_cat($build_dir,$pindex.$idx);485 486 my $create_core_url = "$base_url?action=CREATE&name=$core";487 $create_core_url .= "&instanceDir=$etc_dirname";488 $create_core_url .= "&dataDir=$idx_dirname";489 490 393 print $outhandle "Creating Solr core: $core\n"; 491 $s elf->solr_core_admin($create_core_url);394 $solr_server->admin_create_core($core); 492 395 } 493 396 } … … 574 477 } else { 575 478 my $collection = $self->{'collection'}; 576 577 print STDERR "Cmd: $solr_passes_exe $opt_create_index $collection index $solr_passes_sections \"$build_dir\" \"$indexdir\" $osextra\n"; 578 if (!open($handle, "| $solr_passes_exe $opt_create_index $collection index $solr_passes_sections \"$build_dir\" \"$indexdir\" $osextra")) { 479 my $ds_idx = $self->{'index_mapping'}->{$index}; 480 481 print STDERR "Cmd: $solr_passes_exe $opt_create_index $collection index $ds_idx \"$build_dir\" \"$indexdir\" $osextra\n"; 482 if (!open($handle, "| $solr_passes_exe $opt_create_index $collection index $ds_idx \"$build_dir\" \"$indexdir\" $osextra")) { 579 483 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'}; 580 484 die "solrbuilder::build_index - couldn't run $solr_passes_exe\n!$\n";
Note:
See TracChangeset
for help on using the changeset viewer.