Changeset 24453 for gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
- Timestamp:
- 2011-08-23T14:23:40+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
r24447 r24453 31 31 32 32 use lucenebuilder; 33 use solrserver; 33 34 use Config; # for getting the perlpath in the recommended way 34 35 … … 271 272 272 273 274 sub solr_core_admin 275 { 276 my $self = shift (@_); 277 my ($url) = @_; 278 279 my $cmd = "wget -q -O - \"$url\""; 280 281 my $status = undef; 282 283 if (open(WIN,"$cmd |")) { 284 285 my $xml_output = ""; 286 my $line; 287 while (defined ($line=<WIN>)) { 288 289 $xml_output .= $line; 290 } 291 close(WIN); 292 293 ## print $xml_output; 294 295 ($status) = ($xml_output =~ m!<int name="status">(\d+)</int>!s); 296 297 } 298 else { 299 print STDERR "Warning: failed to run $cmd\n"; 300 print STDERR " $!\n"; 301 } 302 303 return $status; 304 305 } 306 273 307 sub pre_build_indexes 274 308 { … … 277 311 my $outhandle = $self->{'outhandle'}; 278 312 279 # read in build.cfg if in incremental mode??? 313 # If the Solr/Jetty server is not already running, the following starts 314 # it up, and only returns when the server is "reading and listening" 315 316 my $solr_server = new solrserver(); 317 $solr_server->start(); 318 $self->{'solr_server'} = $solr_server; 280 319 281 320 my $indexes = []; … … 350 389 } 351 390 352 # write out solr 'schema.xml' (and related) file 391 # Write out solr 'schema.xml' (and related) file 392 # 353 393 $self->make_final_field_list(); 354 394 $self->premake_solr_auxiliary_files(); 355 395 356 # if collect==core not already in solr.xml (check with STATUS) 357 # => use CREATE API to add to solr.xml 358 # 359 # else 360 # => use RELOAD call to refresh fields now expressed in schema.xml 396 # Now update the solr-core information in solr.xml 397 # => at most two cores <colname>-Doc and <colname>-Sec 398 399 my $jetty_server_port = $ENV{'SOLR_JETTY_PORT'}; 400 my $base_url = "http://localhost:$jetty_server_port/solr/admin/cores"; 401 402 my $collection = $self->{'collection'}; 403 404 foreach my $level (keys %{$self->{'levels'}}) { 405 406 my $llevel = $mgppbuilder::level_map{$level}; 407 408 my $core = $collection."-".lc($llevel); 409 my $check_core_url = "$base_url?action=STATUS&core=$core"; 410 411 my $check_status = $self->solr_core_admin($check_core_url); 412 413 print STDERR "*** check status = $check_status\n"; 414 415 416 # if collect==core not already in solr.xml (check with STATUS) 417 # => use CREATE API to add to solr.xml 418 # 419 # else 420 # => use RELOAD call to refresh fields now expressed in schema.xml 421 } 361 422 362 423 } … … 499 560 # $self->make_final_field_list() 500 561 # as this has been done in our pre_build_indexes() phase for solr 562 563 564 # Also need to stop the Solr/jetty server if it was explicitly started 565 # in pre_build_indexes() 501 566 567 my $solr_server = $self->{'solr_server'}; 568 569 if ($solr_server->explicitly_started()) { 570 $solr_server->stop(); 571 } 572 573 $self->{'solr_server'} = undef; 574 502 575 } 503 576
Note:
See TracChangeset
for help on using the changeset viewer.