Show
Ignore:
Timestamp:
28.06.2012 18:54:11 (7 years ago)
Author:
ak19
Message:

First working version of activate.pl modified for handling solr collections. It needs to update solr cores when moving building to index.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/perllib/solrserver.pm

    r24643 r25888  
    204204} 
    205205 
    206  
     206# Some of the Solr CoreAdmin API calls available.  
     207# See http://wiki.apache.org/solr/CoreAdmin 
    207208sub admin_reload_core 
    208209{ 
     
    215216} 
    216217 
     218sub 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 
     228sub 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) 
     240sub 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} 
    217249 
    218250sub admin_create_core 
    219251{ 
    220252    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 
    222254 
    223255    my ($ds_idx) = ($core =~ m/^.*-(.*?)$/); 
     
    227259    my $collect_home = $ENV{'GSDLCOLLECTDIR'}; 
    228260    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"   
    232267         
    233268    $cgi_get_args .= "&instanceDir=$etc_dirname"; 
     
    237272} 
    238273 
    239  
     274# removes (unloads) core from th eext/solr/sorl.xml config file 
     275sub 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 
     285sub 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} 
    240296 
    241297sub start