Changeset 25888
- Timestamp:
- 2012-06-28T18:54:11+12:00 (11 years ago)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/perllib/solrserver.pm
r24643 r25888 204 204 } 205 205 206 206 # Some of the Solr CoreAdmin API calls available. 207 # See http://wiki.apache.org/solr/CoreAdmin 207 208 sub admin_reload_core 208 209 { … … 215 216 } 216 217 218 sub admin_rename_core 219 { 220 my $self = shift @_; 221 my ($oldcore, $newcore) = @_; 222 223 my $cgi_get_args = "action=RENAME&core=$oldcore&other=$newcore"; 224 225 $self->_admin_service($cgi_get_args); 226 } 227 228 sub admin_swap_core 229 { 230 my $self = shift @_; 231 my ($oldcore, $newcore) = @_; 232 233 my $cgi_get_args = "action=SWAP&core=$oldcore&other=$newcore"; 234 235 $self->_admin_service($cgi_get_args); 236 } 237 238 # The ALIAS action is not supported in our version of solr (despite it 239 # being marked as experimental in the documentation for Core Admin) 240 sub admin_alias_core 241 { 242 my $self = shift @_; 243 my ($oldcore, $newcore) = @_; 244 245 my $cgi_get_args = "action=ALIAS&core=$oldcore&other=$newcore"; 246 247 $self->_admin_service($cgi_get_args); 248 } 217 249 218 250 sub admin_create_core 219 251 { 220 252 my $self = shift @_; 221 my ($core, $removeold) = @_;253 my ($core, $data_parent_dir) = @_; # data_parent_dir is optional, can be index_dir. Defaults to builddir if not provided 222 254 223 255 my ($ds_idx) = ($core =~ m/^.*-(.*?)$/); … … 227 259 my $collect_home = $ENV{'GSDLCOLLECTDIR'}; 228 260 my $etc_dirname = &util::filename_cat($collect_home,"etc"); 229 230 my $build_dir = $self->{'build_dir'}; 231 my $idx_dirname = &util::filename_cat($build_dir,$ds_idx); 261 262 if(!defined $data_parent_dir) { 263 $data_parent_dir = $self->{'build_dir'}; 264 } 265 266 my $idx_dirname = &util::filename_cat($data_parent_dir,$ds_idx); # "dataDir" 232 267 233 268 $cgi_get_args .= "&instanceDir=$etc_dirname"; … … 237 272 } 238 273 239 274 # removes (unloads) core from th eext/solr/sorl.xml config file 275 sub admin_unload_core 276 { 277 my $self = shift @_; 278 my ($core) = @_; 279 280 my $cgi_get_args = "action=UNLOAD&core=$core"; # &deleteIndex=true from Solr3.3 281 282 $self->_admin_service($cgi_get_args); 283 } 284 285 sub copy_solrxml_to_web 286 { 287 my $self = shift @_; 288 289 my $ext_solrxml = &util::filename_cat($ENV{'GEXT_SOLR'}, "solr.xml"); 290 my $web_solrxml = &util::filename_cat($ENV{'GSDL3HOME'}, "ext", "solr", "solr.xml"); 291 292 #print STDERR "@@@@ Copying $ext_solrxml to $web_solrxml...\n"; 293 294 &util::cp($ext_solrxml, $web_solrxml); 295 } 240 296 241 297 sub start -
main/trunk/greenstone2/bin/script/activate.pl
r25887 r25888 520 520 $buildtype = "mg"; #mg is the default 521 521 } 522 523 my $solr_server; 524 my @corenames = (); 525 if($buildtype eq "solr") { # start up the jetty server 526 my $solr_ext = $ENV{'GEXT_SOLR'}; # from solr_passes.pl 527 unshift (@INC, "$solr_ext/perllib"); 528 require solrserver; 529 530 # Solr cores are named without taking the collection-group name into account, since solr 531 # is used for GS3 and GS3 doesn't use collection groups but has the site concept instead 532 my ($colname, $colgroup) = &util::get_collection_parts($qualified_collection); 533 534 # See solrbuilder.pm to get the indexing levels (document, section) from the collectcfg file 535 # Used to generate core names from them and remove cores by name 536 foreach my $level ( @{$collectcfg->{'levels'}} ){ 537 my ($pindex) = $level =~ /^(.)/; 538 my $indexname = $pindex."idx"; 539 push(@corenames, "$site-$colname-$indexname"); #"$site-$colname-didx", "$site-$colname-sidx" 540 } 541 542 # If the Solr/Jetty server is not already running, the following starts 543 # it up, and only returns when the server is "reading and listening" 544 $solr_server = new solrserver($build_dir); 545 $solr_server->start(); 546 547 # We'll be moving building to index. For solr collection, there's further 548 # special processing to make a corresponding change to the solr.xml 549 # by removing the temporary building cores and (re)creating the index cores 550 } 522 551 523 552 # Now the logic in GLI's CollectionManager.java (processComplete() … … 572 601 573 602 if($removeold) { 603 604 if ($buildtype eq "solr") { 605 # if solr, remove any cores using the index_dir before deleting this dir 606 foreach my $corename (@corenames) { 607 $solr_server->admin_unload_core($corename); 608 } 609 } 574 610 575 611 if(&util::dir_exists($index_dir)) { … … 596 632 } 597 633 elsif ($keepold) { 634 if ($buildtype eq "solr") { 635 # if solr, remove any cores using the index_dir before deleting this dir 636 foreach my $corename (@corenames) { 637 $solr_server->admin_unload_core($corename); 638 } 639 } 640 598 641 # Copy just the contents of building dir into the index dir, overwriting 599 642 # existing files, but don't replace index with building. … … 602 645 } 603 646 647 if ($buildtype eq "solr") { 648 # Call CREATE action to get the old cores pointing to the index folder 649 foreach my $corename (@corenames) { 650 $solr_server->admin_create_core($corename, $index_dir); 651 } 652 653 # copy the just updated ext/solr/solr.xml to web/ext/solr/solr.xml 654 $solr_server->copy_solrxml_to_web(); 655 } 656 604 657 # 4. Ping the library URL, and if it's a persistent server and running, activate the collection again 605 658 … … 643 696 644 697 &print_msg("\n"); 698 699 if($buildtype eq "solr") { 700 if ($solr_server->explicitly_started()) { 701 $solr_server->stop(); 702 } 703 } 645 704 } 646 705
Note:
See TracChangeset
for help on using the changeset viewer.