Changeset 24501
- Timestamp:
- 2011-08-26T23:32:25+12:00 (12 years ago)
- Location:
- gs3-extensions/solr/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/bin/script/solr_passes.pl
r24483 r24501 58 58 sub open_java_solr 59 59 { 60 my ($collect, $ds_idx,$full_builddir,$indexdir,$removeold) = @_; 61 62 # if removeold set, then delete the curring $full_builddir 63 if ($removeold) { 64 my $full_indexdir = &util::filename_cat($full_builddir,$indexdir); 65 &util::rm_r($full_indexdir); 66 } 60 my ($core,$full_builddir,$indexdir) = @_; 67 61 68 62 # If the Solr/Jetty server is not already running, the following starts 69 63 # it up, and only returns when the server is "reading and listening" 70 64 71 my $solr_server = new solrserver( );65 my $solr_server = new solrserver($full_builddir); 72 66 $solr_server->start(); 73 67 $self->{'solr_server'} = $solr_server; 74 68 75 69 # Now start up the solr-post command 76 &solrutil::open_post_pipe($co llect,$ds_idx);70 &solrutil::open_post_pipe($core); 77 71 } 78 72 … … 187 181 my $argc = scalar(@argv); 188 182 189 my $removeold = 0;190 183 my @filtered_argv = (); 191 184 … … 196 189 my $option = $1; 197 190 198 # -removeold causes the existing index to be overwritten199 if ($option eq "removeold") {200 print STDERR "\n-removeold set (new index will be created)\n";201 $removeold = 1;202 }203 191 # -verbosity <num> 204 elsif ($option eq "verbosity") {192 if ($option eq "verbosity") { 205 193 $i++; 206 194 if ($i<$argc) … … 223 211 my $filtered_argc = scalar(@filtered_argv); 224 212 225 if ($filtered_argc < 5) {226 print STDERR "Usage: solr_passes.pl [- removeold|-verbosity num] collect \"text\"|\"index\" {d|s}idxbuild-dir index-name\n";213 if ($filtered_argc < 4) { 214 print STDERR "Usage: solr_passes.pl [-verbosity num] core \"text\"|\"index\" build-dir index-name\n"; 227 215 exit 1; 228 216 } 229 217 230 my $co llect= $filtered_argv[0];218 my $core = $filtered_argv[0]; 231 219 my $mode = $filtered_argv[1]; 232 my $ds_idx = $filtered_argv[2]; 233 my $full_builddir = $filtered_argv[3]; 234 my $indexdir = $filtered_argv[4]; 220 my $full_builddir = $filtered_argv[2]; 221 my $indexdir = $filtered_argv[3]; 235 222 236 223 # We only need the Solr handle opened if we are indexing the 237 224 # documents, not if we are just storing the text 238 225 if ($mode eq "index") { 239 open_java_solr($co llect, $ds_idx, $full_builddir, $indexdir, $removeold);226 open_java_solr($core, $full_builddir, $indexdir); 240 227 } 241 228 -
gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
r24497 r24501 112 112 else 113 113 { 114 my $collection = $self->{'collection'}; 114 my $site = $self->{'site'}; 115 my $collect = $self->{'collection'}; 116 my $core_prefix = (defined $site) ? "$site-$collect" : $collect; 117 my $core = $core_prefix; # unused in this call to solr_passes 115 118 116 119 print STDERR "Executable: $solr_passes_exe\n"; 117 120 print STDERR "Sections: $solr_passes_sections\n"; 118 121 print STDERR "Build Dir: $build_dir\n"; 119 print STDERR "Cmd: $solr_passes_exe $co llection text dummy\"$build_dir\" \"dummy\" $osextra\n";120 if (!open($handle, "| $solr_passes_exe $co llection text dummy\"$build_dir\" \"dummy\" $osextra"))122 print STDERR "Cmd: $solr_passes_exe $core text \"$build_dir\" \"dummy\" $osextra\n"; 123 if (!open($handle, "| $solr_passes_exe $core text \"$build_dir\" \"dummy\" $osextra")) 121 124 { 122 125 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'}; … … 243 246 244 247 my $solr_home = $ENV{'GEXT_SOLR'}; 245 my $in_dirname = &util::filename_cat($solr_home,"etc","conf"); 248 ## my $in_dirname = &util::filename_cat($solr_home,"etc","conf"); 249 my $in_dirname = &util::filename_cat($solr_home,"conf"); 246 250 my $schema_in_filename = &util::filename_cat($in_dirname,"schema.xml.in"); 247 251 … … 281 285 # it up, and only returns when the server is "reading and listening" 282 286 283 my $solr_server = new solrserver( );287 my $solr_server = new solrserver($self->{'build_dir'}); 284 288 $solr_server->start(); 285 289 $self->{'solr_server'} = $solr_server; … … 364 368 # => at most two cores <colname>-Doc and <colname>-Sec 365 369 366 my $collection = $self->{'collection'}; 370 my $site = $self->{'site'}; 371 my $collect = $self->{'collection'}; 372 my $core_prefix = (defined $site) ? "$site-$collect" : $collect; 367 373 368 374 # my $idx = $self->{'index_mapping'}->{$index}; 369 375 my $idx = "idx"; 370 376 371 my $ site = $self->{'site'};377 my $build_dir = $self->{'build_dir'}; 372 378 373 379 foreach my $level (keys %{$self->{'levels'}}) { 374 380 375 381 my ($pindex) = $level =~ /^(.)/; 376 377 my $core = $collection."-".$pindex.$idx; 378 379 # prefix site if exists (e.g. Greenstone 3) 380 $core = "$site-$core" if defined $site; 382 383 my $index_dir = $pindex.$idx; 384 my $core = "$core_prefix-$index_dir"; 385 386 my $force_removeold = ($self->{'incremental'}) ? 0 : 1; 387 if ($force_removeold) { 388 print $outhandle "\n-removeold set (new index will be created)\n"; 389 390 my $full_index_dir = &util::filename_cat($build_dir,$index_dir); 391 &util::rm_r($full_index_dir); 392 &util::mk_dir($full_index_dir); 393 } 381 394 382 395 # if collect==core already in solr.xml (check with STATUS) … … 421 434 my $solr_passes_sections = $llevel; 422 435 423 my $opt_create_index = ($self->{'incremental'}) ? "" : "-removeold";424 425 436 my $osextra = ""; 426 437 if ($ENV{'GSDLOS'} =~ /^windows$/i) { … … 478 489 $handle = *STDOUT; 479 490 } else { 480 my $collection = $self->{'collection'}; 481 my $ds_idx = $self->{'index_mapping'}->{$index}; 482 483 print STDERR "Cmd: $solr_passes_exe $opt_create_index $collection index $ds_idx \"$build_dir\" \"$indexdir\" $osextra\n"; 484 if (!open($handle, "| $solr_passes_exe $opt_create_index $collection index $ds_idx \"$build_dir\" \"$indexdir\" $osextra")) { 491 my $site = $self->{'site'}; 492 my $collect = $self->{'collection'}; 493 my $core_prefix = (defined $site) ? "$site-$collect" : $collect; 494 my $ds_idx = $self->{'index_mapping'}->{$index}; 495 my $core = "$core_prefix-$ds_idx"; 496 497 print STDERR "Cmd: $solr_passes_exe $core index \"$build_dir\" \"$indexdir\" $osextra\n"; 498 if (!open($handle, "| $solr_passes_exe $core index \"$build_dir\" \"$indexdir\" $osextra")) { 485 499 print STDERR "<FatalError name='NoRunSolrPasses'/>\n</Stage>\n" if $self->{'gli'}; 486 500 die "solrbuilder::build_index - couldn't run $solr_passes_exe\n!$\n"; -
gs3-extensions/solr/trunk/src/perllib/solrserver.pm
r24486 r24501 34 34 sub new { 35 35 my $class = shift(@_); 36 my ($build_dir) = @_; 36 37 37 38 my $self = { 'jetty_stop_key' => "greenstone-solr" }; 39 40 $self->{'build_dir'} = $build_dir; 38 41 39 42 my $search_path = &solrutil::get_search_path(); … … 74 77 my $in_preamble = ($output_format eq "xml") ? 1 : 0; 75 78 79 ## print STDERR "**** wgetcmd = \n $cmd\n"; 80 76 81 if (open(WIN,"$cmd |")) { 77 82 … … 213 218 { 214 219 my $self = shift @_; 215 my ($core ) = @_;216 217 my ($ds_idx) = ($core =~ m/^.*-(.* )$/);220 my ($core,$removeold) = @_; 221 222 my ($ds_idx) = ($core =~ m/^.*-(.*?)$/); 218 223 219 224 my $cgi_get_args = "action=CREATE&name=$core"; … … 243 248 chdir($solr_home); 244 249 245 my $solr_etc = &util::filename_cat($solr_home,"etc");250 ## my $solr_etc = &util::filename_cat($solr_home,"etc"); 246 251 247 252 my $server_props = "-DSTOP.PORT=$jetty_stop_port"; 248 253 $server_props .= " -DSTOP.KEY=".$self->{'jetty_stop_key'}; 249 $server_props .= " -Dsolr.solr.home=$solr_ etc";254 $server_props .= " -Dsolr.solr.home=$solr_home"; 250 255 251 256 my $full_server_jar = $self->{'full_server_jar'}; … … 253 258 my $server_java_cmd = "java $server_props -jar \"$full_server_jar\""; 254 259 255 ## print STDERR "**** server cmd start = $server_java_cmd\n";256 260 257 261 my $server_status = "unknown"; … … 261 265 } 262 266 elsif (open(STARTIN,"$server_java_cmd 2>&1 |")) { 267 268 ## print STDERR "**** startup up server with cmd start =\n $server_java_cmd\n"; 263 269 264 270 my $line; -
gs3-extensions/solr/trunk/src/perllib/solrutil.pm
r24483 r24501 63 63 sub open_post_pipe 64 64 { 65 my ($co llect,$ds_idx) = @_;65 my ($core) = @_; 66 66 67 67 my $search_path = get_search_path(); … … 75 75 76 76 # Now run solr-post command 77 my $core = $collect."-".$ds_idx;78 77 my $post_props = "-Durl=http://localhost:$jetty_port/solr/$core/update"; 79 78 $post_props .= " -Ddata=stdin"; … … 82 81 my $post_java_cmd = "java $post_props -jar \"$full_post_jar\""; 83 82 84 ## #print STDERR "**** post cmd = $post_java_cmd\n";83 ## print STDERR "**** post cmd = $post_java_cmd\n"; 85 84 86 85 open (PIPEOUT, "| $post_java_cmd")
Note:
See TracChangeset
for help on using the changeset viewer.