Examples of UpdateRequestProcessorChain


Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  public void doLegacyUpdate(Reader input, Writer output) {
    try {
      SolrCore core = SolrCore.getSolrCore();

      // Old style requests do not choose a custom handler
      UpdateRequestProcessorChain processorFactory = core.getUpdateProcessingChain(null);

      SolrParams params = new MapSolrParams(new HashMap<String, String>());
      SolrQueryRequestBase req = new SolrQueryRequestBase(core, params) {
      };
      SolrQueryResponse rsp = new SolrQueryResponse(); // ignored
      XMLStreamReader parser = inputFactory.createXMLStreamReader(input);
      UpdateRequestProcessor processor = processorFactory.createProcessor(req, rsp);
      XMLLoader loader = (XMLLoader) newLoader(req, processor);
      loader.processUpdate(processor, parser);
      processor.finish();
      output.write("<result status=\"0\"></result>");
    }
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

**/
public abstract class ContentStreamHandlerBase extends RequestHandlerBase {

  public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
    SolrParams params = req.getParams();
    UpdateRequestProcessorChain processorChain =
            req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR));

    UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp);

    try {
      ContentStreamLoader documentLoader = newLoader(req, processor);


View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  /**
   * Load the request processors
   */
   private Map<String,UpdateRequestProcessorChain> loadUpdateProcessorChains() {
    Map<String, UpdateRequestProcessorChain> map = new HashMap<String, UpdateRequestProcessorChain>();
    UpdateRequestProcessorChain def = initPlugins(map,UpdateRequestProcessorChain.class, UpdateRequestProcessorChain.class.getName());
    if(def == null){
      def = map.get(null);
    }
    if (def == null) {
      // construct the default chain
      UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[]{
              new RunUpdateProcessorFactory(),
              new LogUpdateProcessorFactory()
      };
      def = new UpdateRequestProcessorChain(factories, this);
    }
    map.put(null, def);
    map.put("", def);
    return map;
  }
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  /**
   * @return an update processor registered to the given name.  Throw an exception if this chain is undefined
   */   
  public UpdateRequestProcessorChain getUpdateProcessingChain( final String name )
  {
    UpdateRequestProcessorChain chain = updateProcessorChains.get( name );
    if( chain == null ) {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
          "unknown UpdateRequestProcessorChain: "+name );
    }
    return chain;
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  /**
   * Load the request processors
   */
   private Map<String,UpdateRequestProcessorChain> loadUpdateProcessorChains() {
    Map<String, UpdateRequestProcessorChain> map = new HashMap<String, UpdateRequestProcessorChain>();
    UpdateRequestProcessorChain def = initPlugins(map,UpdateRequestProcessorChain.class, UpdateRequestProcessorChain.class.getName());
    if(def == null){
      def = map.get(null);
    }
    if (def == null) {
      // construct the default chain
      UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[]{
              new RunUpdateProcessorFactory(),
              new LogUpdateProcessorFactory()
      };
      def = new UpdateRequestProcessorChain(factories, this);
    }
    map.put(null, def);
    map.put("", def);
    return map;
  }
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  /**
   * @return an update processor registered to the given name.  Throw an exception if this chain is undefined
   */   
  public UpdateRequestProcessorChain getUpdateProcessingChain( final String name )
  {
    UpdateRequestProcessorChain chain = updateProcessorChains.get( name );
    if( chain == null ) {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
          "unknown UpdateRequestProcessorChain: "+name );
    }
    return chain;
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  public void testConfiguration() throws Exception
  {
    SolrCore core = h.getCore();

    // make sure it loaded the factories
    UpdateRequestProcessorChain chained = core.getUpdateProcessingChain( "standard" );
   
    // Make sure it got 3 items and configured the Log chain ok
    assertEquals( 3, chained.chain.length );
    LogUpdateProcessorFactory log = (LogUpdateProcessorFactory)chained.chain[0];
    assertEquals( 100, log.maxNumToLog );
   
   
    UpdateRequestProcessorChain custom = core.getUpdateProcessingChain( null );
    CustomUpdateRequestProcessorFactory link = (CustomUpdateRequestProcessorFactory) custom.chain[0];
   
    assertEquals( custom, core.getUpdateProcessingChain( "" ) );
    assertEquals( custom, core.getUpdateProcessingChain( "custom" ) );
   
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

   */
  private Map<String,UpdateRequestProcessorChain> loadUpdateProcessorChains() {
    final Map<String,UpdateRequestProcessorChain> map = new HashMap<String, UpdateRequestProcessorChain>();
   
    final String parsingErrorText = "Parsing Update Request Processor Chain";
    UpdateRequestProcessorChain def = null;
   
    // This is kinda ugly, but at least it keeps the xpath logic in one place
    // away from the Processors themselves. 
    XPath xpath = solrConfig.getXPath();
    NodeList nodes = (NodeList)solrConfig.evaluate("updateRequestProcessorChain", XPathConstants.NODESET);
    boolean requireName = nodes.getLength() > 1;
    if (nodes !=null ) {
      for (int i=0; i<nodes.getLength(); i++) {
        Node node = nodes.item(i);
        String name       = DOMUtil.getAttr(node,"name", requireName?parsingErrorText:null);
        boolean isDefault = "true".equals( DOMUtil.getAttr(node,"default", null ) );
       
        NodeList links = null;
        try {
          links = (NodeList)xpath.evaluate("processor", node, XPathConstants.NODESET);
        }
        catch (XPathExpressionException e) {
          throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,"Error reading processors",e,false);
        }
        if( links == null || links.getLength() < 1 ) {
          throw new RuntimeException( "updateRequestProcessorChain require at least one processor");
        }
       
        // keep a list of the factories...
        final ArrayList<UpdateRequestProcessorFactory> factories = new ArrayList<UpdateRequestProcessorFactory>(links.getLength());
        // Load and initialize the plugin chain
        AbstractPluginLoader<UpdateRequestProcessorFactory> loader
            = new AbstractPluginLoader<UpdateRequestProcessorFactory>( "processor chain", false, false ) {
          @Override
          protected void init(UpdateRequestProcessorFactory plugin, Node node) throws Exception {
            plugin.init( (node==null)?null:DOMUtil.childNodesToNamedList(node) );
          }
   
          @Override
          protected UpdateRequestProcessorFactory register(String name, UpdateRequestProcessorFactory plugin) throws Exception {
            factories.add( plugin );
            return null;
          }
        };
        loader.load( solrConfig.getResourceLoader(), links );
       
       
        UpdateRequestProcessorChain chain = new UpdateRequestProcessorChain(
            factories.toArray( new UpdateRequestProcessorFactory[factories.size()] ) );
        if( isDefault || nodes.getLength()==1 ) {
          def = chain;
        }
        if( name != null ) {
          map.put(name, chain);
        }
      }
    }
   
    if( def == null ) {
      // construct the default chain
      UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[] {
        new RunUpdateProcessorFactory(),
        new LogUpdateProcessorFactory()
      };
      def = new UpdateRequestProcessorChain( factories );
    }
    map.put( null, def );
    map.put( "", def );
    return map;
  }
View Full Code Here

Examples of org.apache.solr.update.processor.UpdateRequestProcessorChain

  /**
   * @return an update processor registered to the given name.  Throw an exception if this chain is undefined
   */   
  public UpdateRequestProcessorChain getUpdateProcessingChain( final String name )
  {
    UpdateRequestProcessorChain chain = updateProcessorChains.get( name );
    if( chain == null ) {
      throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
          "unknown UpdateRequestProcessorChain: "+name );
    }
    return chain;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.