lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Obernberger <joseph.obernber...@gmail.com>
Subject Re: NullPointerException on openStreams
Date Thu, 13 Jul 2017 18:46:28 GMT
Thank you Joel - that was it.

         context = new StreamContext();
context.setSolrClientCache(StaticInfo.getSingleton(props).getClientCache());
         context.workerID = 0;
         context.numWorkers = 1;
context.setModelCache(StaticInfo.getSingleton(props).getModelCache());

Then:
             stream = new 
CloudSolrStream(props.getProperty("hbase.zookeeper.solr.quorum"), 
solrCollectionName, params);
             stream.setStreamContext(context);

Did the trick.  I suspect it will be a problem if multiple programs use 
the name workerID; will do more reading.

-Joe

On 7/13/2017 2:18 PM, Joel Bernstein wrote:
> It's most likely that you're not setting the StreamContext. New versions of
> Solr expect the StreamContext to be set before the stream is opened. The
> SolrClientCache also needs to present in the StreamContext. You can take a
> look at how the StreamHandler does this for an example:
> https://github.com/apache/lucene-solr/blob/master/solr/core/src/java/org/apache/solr/handler/StreamHandler.java#L339
>
> Joel Bernstein
> http://joelsolr.blogspot.com/
>
> On Thu, Jul 13, 2017 at 2:06 PM, Joe Obernberger <
> joseph.obernberger@gmail.com> wrote:
>
>> Hi All - trying to call ClouderSolrStream.open(), but I'm getting this
>> error:
>>
>> java.io.IOException: java.lang.NullPointerException
>>       at org.apache.solr.client.solrj.io.stream.CloudSolrStream.const
>> ructStreams(CloudSolrStream.java:408)
>>       at org.apache.solr.client.solrj.io.stream.CloudSolrStream.open(
>> CloudSolrStream.java:299)
>>
>> I'm passing in a valid zkHost, collection name, and parameters. In fact,
>> if I take the stream expression and past it into the GUI, it works OK.  I'm
>> stumped by what could be null here.
>>
>> My code looks like the following, and I'm getting the error on
>> stream.open().
>>
>>          StringBuilder expression = new StringBuilder();
>>          expression.append("update(models, batchSize=\"50\",");
>> expression.append("train(").append(solrCollectionName).append(",");
>> expression.append("features(").append(solrCollectionName).append(",");
>> expression.append("q=\"*:*\",featureSet=\"FSet_").append(sol
>> rCollectionName).append("\",");
>> expression.append("field=\"Text\",outcome=\"out_i\",positive
>> Label=1,numTerms=").append(numTerms).append("),");
>> expression.append("q=\"*:*\",name=\"").append(docID).append(
>> "\",field=\"Text\",outcome=\"out_i\",maxIterations=\"").
>> append(maxIterations).append("\"))");
>>          logger.info("Have update expression:\n"+expression.toSt
>> ring()+"\n");
>>          params.set("expr", expression.toString());
>>          params.set("qt", "/stream");
>>          params.set("explain", "true");
>>          params.set("q", "*:*");
>>          params.set("fl", "id");
>>          params.set("sort", "id asc");
>>          try {
>>              System.out.println("Open: "+props.getProperty("hbase.zoo
>> keeper.solr.quorum")+"\nCollection: "+solrCollectionName+" \nWith params:
>> "+params);
>>              stream = new CloudSolrStream(props.getPrope
>> rty("hbase.zookeeper.solr.quorum"), solrCollectionName, params);
>>              stream.open();
>>              while (true) {
>>                  Tuple tuple = stream.read();
>>                  logger.info("Tuple Read: "+tuple.fields.toString());
>>                  if (tuple.EOF) {
>>                      break;
>>                  }
>>              }
>>          } catch (IOException ex) {
>>              logger.error("Solr stream error: " + ex);
>>              ex.printStackTrace();
>>          } finally {
>>              if (stream != null) {
>>                  try {
>>                      stream.close();
>>                  } catch (IOException ex) {
>>                      logger.error("Could not close stream: "+ex);
>>                  }
>>              }
>>          }
>>
>> I'm stuck!  Thanks!
>>
>> -Joe
>>
>>
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
>


Mime
View raw message