You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by AleiHanami <gi...@git.apache.org> on 2017/05/10 15:05:56 UTC

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

GitHub user AleiHanami opened a pull request:

    https://github.com/apache/storm/pull/2108

    STORM-2508:storm-solr enhancement: update solrj to 5.5, support custom SolrClientFactory and commit operation

    I have a case that the SolrCloud in my organization is protected by SSL + Basic Auth, so I need to provide customized SolrClient instance to SolrUpdateBolt. Likewise, the RestJsonSchemaBuilder cannot access Schema API without auth.
    In addition, for "near real-time search", soft commit is preferred, so it is better to expose an interface for user to customize commit operation.
    I think those features will also be useful for other people who needs to use custom SolrClient implementation and control the detail of commit operation. So, finally, I plan an enhancement for storm-solr:
    1. update solrj and related dependencies to 5.5;
    2. improve SolrConfig to support custom SolrClientFactory and CommitCallBack;
    3. provide a SchemaBuilder implementation which use custom SolrClient to request Schema API.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/AleiHanami/storm client-enhance

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/storm/pull/2108.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2108
    
----
commit e338fc6d024cb8cebd823908b24f8c65d5704537
Author: AleiHanami <ra...@gmail.com>
Date:   2017-05-10T14:58:41Z

    STORM-2508
    
    storm-solr enhancement: update solrj to 5.5, support custom SolrClientFactory and commit operation

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132811072
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    + *
    + * @see <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a>
    + * @author alei
    + */
    +public class SolrClientSchemaBuilder implements SchemaBuilder {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SolrClientSchemaBuilder.class);
    +
    +    private Schema schema;
    +
    +    public SolrClientSchemaBuilder(String collection, SolrClientFactory factory) throws IOException, SolrServerException {
    +        SchemaRequest request = new SchemaRequest();
    +        SchemaResponse response = request.process(factory.getSolrClient(), collection);
    +        SchemaRepresentation representation = response.getSchemaRepresentation();
    +        schema = convert(representation);
    +    }
    +
    +    @Override
    +    public Schema getSchema() {
    +        return schema;
    +    }
    +
    +    private Schema convert(final SchemaRepresentation representation) {
    +        Schema converted = new Schema();
    +        converted.setUniqueKey(representation.getUniqueKey());
    +        converted.setName(representation.getName());
    +        converted.setVersion(String.valueOf(representation.getVersion()));
    +        List<FieldType> fieldTypeList = new ArrayList<>(representation.getFieldTypes().size());
    +        for (FieldTypeDefinition type : representation.getFieldTypes()) {
    +            FieldType fieldType = new FieldType();
    +            fieldType.setClazz(type.getAttributes().get("class").toString());
    +            if (type.getAttributes().get("multiValued") != null) {
    +                fieldType.setMultiValued(Boolean.valueOf(type.getAttributes().get("multiValued").toString()));
    +            }
    +            fieldType.setName(type.getAttributes().get("name").toString());
    +            fieldTypeList.add(fieldType);
    +        }
    +        converted.setFieldTypes(fieldTypeList);
    +        List<org.apache.storm.solr.schema.Field> fieldList =
    +                new ArrayList<>(representation.getFields().size());
    +        for (Map<String, Object> field : representation.getFields()) {
    +            org.apache.storm.solr.schema.Field schemaField = new org.apache.storm.solr.schema.Field();
    +            schemaField.setName(field.get("name").toString());
    --- End diff --
    
    Nit: An explicit cast to String might be nicer here, so you get an exception in case this isn't a String for some reason.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132810794
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/client/DefaultSolrClientFactory.java ---
    @@ -0,0 +1,30 @@
    +/*
    + * DefaultCloudSolrClientFactory.java
    --- End diff --
    
    Please replace this license header with the Apache header (copy it from one of the other files)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/storm/pull/2108


---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132811153
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/config/CommitCallback.java ---
    @@ -0,0 +1,23 @@
    +/*
    + * OnCommit.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.config;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +
    +import java.io.IOException;
    +import java.io.Serializable;
    +
    +/**
    + * This callback interface is invoked on {@link SolrCommitStrategy} triggers or tick. Typically fire
    + * a "commit" request to solr, you can customize commit details by implementing this interface.
    + * @author alei
    + */
    +public interface CommitCallback extends Serializable {
    +
    +    void process(SolrClient solrClient, String collection) throws SolrServerException, IOException;
    --- End diff --
    
    Nit: Shouldn't this be named "commit"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132810804
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/client/DefaultSolrClientFactory.java ---
    @@ -0,0 +1,30 @@
    +/*
    + * DefaultCloudSolrClientFactory.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.client;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +
    +/**
    + * default implementation of {@link SolrClientFactory}, which takes a zookeeper host
    + * and produce {@link org.apache.solr.client.solrj.impl.CloudSolrClient} with the host.
    + *
    + * @author alei
    --- End diff --
    
    Please remove the author.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132810900
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    --- End diff --
    
    Is there any reason to prefer the REST schema builder over this one? Otherwise maybe we should remove the other one?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by sachingsachin <gi...@git.apache.org>.
Github user sachingsachin commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132823455
  
    --- Diff: external/storm-solr/pom.xml ---
    @@ -67,13 +67,13 @@
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-core</artifactId>
    -            <version>5.2.1</version>
    +            <version>5.5.0</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-test-framework</artifactId>
    -            <version>5.2.1</version>
    +            <version>5.5.0</version>
    --- End diff --
    
    To avoiding adding version everywhere, this should be made a property


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132811049
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    + *
    + * @see <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a>
    + * @author alei
    + */
    +public class SolrClientSchemaBuilder implements SchemaBuilder {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SolrClientSchemaBuilder.class);
    +
    +    private Schema schema;
    +
    +    public SolrClientSchemaBuilder(String collection, SolrClientFactory factory) throws IOException, SolrServerException {
    +        SchemaRequest request = new SchemaRequest();
    +        SchemaResponse response = request.process(factory.getSolrClient(), collection);
    +        SchemaRepresentation representation = response.getSchemaRepresentation();
    +        schema = convert(representation);
    +    }
    +
    +    @Override
    +    public Schema getSchema() {
    +        return schema;
    +    }
    +
    +    private Schema convert(final SchemaRepresentation representation) {
    +        Schema converted = new Schema();
    +        converted.setUniqueKey(representation.getUniqueKey());
    +        converted.setName(representation.getName());
    +        converted.setVersion(String.valueOf(representation.getVersion()));
    +        List<FieldType> fieldTypeList = new ArrayList<>(representation.getFieldTypes().size());
    +        for (FieldTypeDefinition type : representation.getFieldTypes()) {
    +            FieldType fieldType = new FieldType();
    +            fieldType.setClazz(type.getAttributes().get("class").toString());
    +            if (type.getAttributes().get("multiValued") != null) {
    +                fieldType.setMultiValued(Boolean.valueOf(type.getAttributes().get("multiValued").toString()));
    --- End diff --
    
    Is this attribute already a boolean? If so I don't think there's a reason to toString and then Boolean.valueOf it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132810994
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    + *
    + * @see <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a>
    + * @author alei
    + */
    +public class SolrClientSchemaBuilder implements SchemaBuilder {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SolrClientSchemaBuilder.class);
    +
    +    private Schema schema;
    +
    +    public SolrClientSchemaBuilder(String collection, SolrClientFactory factory) throws IOException, SolrServerException {
    +        SchemaRequest request = new SchemaRequest();
    +        SchemaResponse response = request.process(factory.getSolrClient(), collection);
    +        SchemaRepresentation representation = response.getSchemaRepresentation();
    +        schema = convert(representation);
    +    }
    +
    +    @Override
    +    public Schema getSchema() {
    +        return schema;
    +    }
    +
    +    private Schema convert(final SchemaRepresentation representation) {
    +        Schema converted = new Schema();
    +        converted.setUniqueKey(representation.getUniqueKey());
    +        converted.setName(representation.getName());
    +        converted.setVersion(String.valueOf(representation.getVersion()));
    --- End diff --
    
    Nit: If this is a float, shouldn't we keep it that way in Schema?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by srdo <gi...@git.apache.org>.
Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132811101
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    + *
    + * @see <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a>
    + * @author alei
    + */
    +public class SolrClientSchemaBuilder implements SchemaBuilder {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SolrClientSchemaBuilder.class);
    +
    +    private Schema schema;
    +
    +    public SolrClientSchemaBuilder(String collection, SolrClientFactory factory) throws IOException, SolrServerException {
    +        SchemaRequest request = new SchemaRequest();
    +        SchemaResponse response = request.process(factory.getSolrClient(), collection);
    +        SchemaRepresentation representation = response.getSchemaRepresentation();
    +        schema = convert(representation);
    +    }
    +
    +    @Override
    +    public Schema getSchema() {
    +        return schema;
    +    }
    +
    +    private Schema convert(final SchemaRepresentation representation) {
    --- End diff --
    
    Nit: It might be good to add a unit test for this, to verify that this conversion does the right thing. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Posted by sachingsachin <gi...@git.apache.org>.
Github user sachingsachin commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132823446
  
    --- Diff: external/storm-solr/pom.xml ---
    @@ -46,13 +46,13 @@
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-solrj</artifactId>
    -            <version>5.2.1</version>
    +            <version>5.5.0</version>
    --- End diff --
    
    5.5.0 version is affected by a security problem and is also more than 1.5 years old.
    http://lucene.apache.org/solr/news.html
    Please consider moving to Solr 6.5.1 or 6.6.0


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---