Changeset 24447
- Timestamp:
- 2011-08-22T14:17:35+12:00 (12 years ago)
- Location:
- gs3-extensions/solr/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/solr/trunk/src/bin/script/solr_passes.pl
r24446 r24447 35 35 # into that needed by the solr server. 36 36 37 my $jetty_stop_key="greenstone-solr";38 37 39 38 BEGIN { … … 47 46 use util; 48 47 49 50 48 # Not quite OO, but close enough for now 51 49 # 52 50 my $self = { 'full_server_jar' => undef, 53 ## 'full_post_jar' = undef, 54 ## 'full_index_propfile' = undef, 55 'jetty_explicitly_started' => undef 56 }; 51 'jetty_explicitly_started' => undef, 52 'jetty_stop_key' => "greenstone-solr" 53 }; 57 54 58 55 … … 81 78 my ($search_path) = @_; 82 79 83 my $solr_home = $ENV{'GEXT_SOLR'}; 84 my $jetty_stop_port = $ENV{'JETTY_STOP_PORT'}; 80 my $solr_home = $ENV{'GEXT_SOLR'}; 81 my $jetty_stop_port = $ENV{'JETTY_STOP_PORT'}; 82 my $jetty_server_port = $ENV{'SOLR_JETTY_PORT'}; 85 83 86 84 chdir($solr_home); … … 89 87 90 88 my $server_props = "-DSTOP.PORT=$jetty_stop_port"; 91 $server_props .= " -DSTOP.KEY= $jetty_stop_key";89 $server_props .= " -DSTOP.KEY=".$self->{'jetty_stop_key'}; 92 90 $server_props .= " -Dsolr.solr.home=$solr_etc"; 93 91 … … 97 95 98 96 my $server_java_cmd = "java $server_props -jar \"$full_server_jar\""; 99 # if ($ENV{'GSDLOS'} eq "windows") { 100 # $server_java_cmd = "start $server_java_cmd"; 101 # } 102 # else { 103 # $server_java_cmd .= " &"; 104 # } 105 97 98 ## print STDERR "**** server cmd = $server_java_cmd\n"; 106 99 107 100 if (open(SIN,"$server_java_cmd 2>&1 |")) { 108 101 102 my $server_status = "unknown"; 103 109 104 my $line; 110 105 while (defined($line=<SIN>)) { … … 113 108 # which signifies that the server has started up and is 114 109 # "ready and listening" 110 111 ## print STDERR "**** $line"; 112 113 if (($line =~ m/^(WARN|ERROR|SEVERE):/) 114 || ($line =~ m/^[0-9 :-]*(WARN|ERROR|SEVERE)::/)) { 115 print $line; 116 } 117 118 119 if ($line =~ m/WARN::failed SocketConnector/) { 120 if ($line =~ m/Address already in use/) { 121 $server_status = "already-running"; 122 } 123 else { 124 $server_status = "failed-to-start"; 125 } 126 last; 127 } 128 129 if ($line =~ m/INFO::Started SocketConnector/) { 130 $server_status = "explicitly-started"; 131 last; 132 } 133 } 134 135 if ($server_status eq "explicitly-started") { 136 $self->{'jetty_explicitly_started'} = 1; 137 print STDERR "Jetty server ready and listening for connections\n"; 138 } 139 elsif ($server_status eq "already-running") { 140 print STDERR "Using existing server detected on port $jetty_server_port\n"; 141 } 142 else { 143 print STDERR "Failed to start Solr/Jetty web server on $jetty_server_port\n"; 144 exit -1; 145 } 115 146 116 last if ($line =~ m/INFO::Started SocketConnector/);117 }118 119 print STDERR "Jetty server ready and listening for connections\n";120 121 147 # now we know the server is ready to accept connections, fork a 122 148 # child process that continues to listen to the output and … … 140 166 else { 141 167 print STDERR "Error: failed to start solr-jetty-server\n"; 142 print STDERR "!$\n"; 168 print STDERR "!$\n\n"; 169 print STDERR "Command attempted was:\n"; 170 print STDERR " $server_java_cmd\n"; 171 print STDERR "run from directory:\n"; 172 print STDERR " $solr_home\n"; 173 print STDERR "----\n"; 174 143 175 exit -1; 144 176 } … … 147 179 # *and* we are the parent process of the fork() 148 180 149 $self->{'jetty_explicitly_started'} = 1;150 151 181 } 152 182 … … 158 188 my $jetty_stop_port = $ENV{'JETTY_STOP_PORT'}; 159 189 160 my $server_props = "-DSTOP.PORT=$jetty_stop_port -DSTOP.KEY=$jetty_stop_key"; 190 my $server_props = "-DSTOP.PORT=$jetty_stop_port"; 191 $server_props .= " -DSTOP.KEY=".$self->{'jetty_stop_key'}; 161 192 my $server_java_cmd = "java $server_props -jar \"$full_server_jar\" --stop"; 162 193 … … 170 201 else { 171 202 wait(); # let the child process finish 203 print STDERR "Jetty server shutdown\n"; 172 204 } 173 205 } … … 185 217 } 186 218 187 # No longer used, as solr now run as two cores per collection (-Doc and -Sec)188 #189 # # Set up an 'index.properties' file in $full_builddir, with the line190 # # index=$indexdir191 # $full_index_propfile = &util::filename_cat($full_builddir,"index.properties");192 193 # if (open(IPOUT,">$full_index_propfile")) {194 # print IPOUT "index=$indexdir\n";195 # close(IPOUT);196 # }197 # else {198 # print STDERR "Failed to create $full_index_propfile\n";199 # print STDERR "!$\n";200 # exit -2;201 # }202 203 204 205 219 my $search_path = []; 206 220 … … 215 229 start_solr_server($search_path); 216 230 217 218 231 # Now run the solr-post command 219 232 220 233 chdir($ENV{'GEXT_SOLR'}); 221 222 234 223 235 my $post_jar = &util::filename_cat("lib","java","solr-post.jar"); 224 236 my $full_post_jar = locate_file($search_path,$post_jar); 225 ## $self->{'full_post_jar'} = $full_post_jar;226 237 227 238 my $jetty_server_port = $ENV{'SOLR_JETTY_PORT'}; … … 234 245 my $post_java_cmd = "java $post_props -jar \"$full_post_jar\""; 235 246 236 print STDERR "**** post cmd = $post_java_cmd\n";247 ### print STDERR "**** post cmd = $post_java_cmd\n"; 237 248 238 249 open (PIPEOUT, "| $post_java_cmd") … … 250 261 stop_solr_server(); 251 262 } 252 253 # No longer used 254 # # $full_index_propfile is set up as a global variable so it can be shared 255 # # between open_java_solr() and here 256 # &util::rm($full_index_propfile); 257 } 258 259 260 261 263 } 264 265 266 #---- 262 267 263 268 sub save_xml_doc … … 418 423 } 419 424 else { 420 print STDERR "Streaming input onto solr server!\n";425 print STDERR "Streaming document input onto Solr server!\n"; 421 426 pass_on_xml_stream(); 422 427 } -
gs3-extensions/solr/trunk/src/perllib/solrbuilder.pm
r24446 r24447 320 320 # to figure out what the metadata_field_mapping is 321 321 322 ## my $db_level = "section"; #always323 324 322 # set up the document processr 325 323 $self->{'buildproc'}->set_output_handle (undef); 326 324 $self->{'buildproc'}->set_mode ('index_field_mapping'); 327 ## $self->{'buildproc'}->set_index ($index);328 ## $self->{'buildproc'}->set_indexing_text (0);329 #$self->{'buildproc'}->set_indexfieldmap ($self->{'indexfieldmap'});330 ## $self->{'buildproc'}->set_levels ($levels);331 ## $self->{'buildproc'}->set_db_level ($db_level);332 325 $self->{'buildproc'}->reset(); 333 326 … … 338 331 &plugin::end($self->{'pluginfo'}); 339 332 340 ## close ($handle) unless $self->{'debug'};341 342 ## $self->print_stats();343 344 # just make "delete" stop ???345 333 } 346 334 … … 373 361 374 362 } 375 376 # Essentially the same as the lucenebuilder.pm version, only using solr_passes377 # => refactor and make better use of inheritence378 379 sub build_indexesXXXX {380 my $self = shift (@_);381 my ($indexname) = @_;382 my $outhandle = $self->{'outhandle'};383 384 $self->pre_build_indexes($indexname);385 386 my $indexes = [];387 if (defined $indexname && $indexname =~ /\w/) {388 push @$indexes, $indexname;389 } else {390 $indexes = $self->{'collect_cfg'}->{'indexes'};391 }392 393 # have we got para index?394 foreach my $level (keys %{$self->{'levels'}}) {395 if ($level =~ /paragraph/) {396 print $outhandle "Warning: Paragraph level indexing not supported by Solr\n";397 last;398 }399 }400 # create the mapping between the index descriptions401 # and their directory names (includes subcolls and langs)402 $self->{'index_mapping'} = $self->create_index_mapping ($indexes);403 404 # build each of the indexes405 foreach my $index (@$indexes) {406 if ($self->want_built($index)) {407 408 my $idx = $self->{'index_mapping'}->{$index};409 foreach my $level (keys %{$self->{'levels'}}) {410 next if $level =~ /paragraph/; # we don't do para indexing411 my ($pindex) = $level =~ /^(.)/;412 # should probably check that new name with level413 # is unique ... but currently (with doc sec and para)414 # each has unique first letter.415 $self->{'index_mapping'}->{$index} = $pindex.$idx;416 417 my $llevel = $mgppbuilder::level_map{$level};418 print $outhandle "\n*** building index $index at level $llevel in subdirectory " .419 "$self->{'index_mapping'}->{$index}\n" if ($self->{'verbosity'} >= 1);420 print STDERR "<Stage name='Index' source='$index' level=$llevel>\n" if $self->{'gli'};421 422 $self->build_index($index,$llevel);423 }424 $self->{'index_mapping'}->{$index} = $idx;425 426 } else {427 print $outhandle "\n*** ignoring index $index\n" if ($self->{'verbosity'} >= 1);428 }429 }430 }431 432 363 433 364 # Essentially the same as the lucenebuilder.pm version, only using solr_passes … … 546 477 print $handle "<update>\n"; 547 478 548 open(TOUT,">/tmp/solr.out"); binmode(TOUT,":utf8");549 print TOUT "<update>\n";550 close(TOUT);551 552 479 &plugin::read ($self->{'pluginfo'}, $self->{'source_dir'}, 553 480 "", {}, {}, $self->{'buildproc'}, $self->{'maxdocs'}, 0, $self->{'gli'}); … … 556 483 print $handle "</update>\n"; 557 484 558 open(TOUT,">>/tmp/solr.out"); binmode(TOUT,":utf8");559 print TOUT "</update>\n";560 close(TOUT);561 562 485 close ($handle) unless $self->{'debug'}; 563 486 … … 568 491 569 492 } 570 571 493 572 494 -
gs3-extensions/solr/trunk/src/perllib/solrbuildproc.pm
r24446 r24447 556 556 $text .= $end_doc if ($sec_tag_name eq ""); 557 557 558 559 558 ## $text .= "<commit/>\n"; 560 559 561 560 print $solrhandle $text; 562 561 563 open(TOUT,">>/tmp/solr.out"); binmode(TOUT,":utf8");564 print TOUT $text;565 close(TOUT);566 562 } 567 563
Note:
See TracChangeset
for help on using the changeset viewer.