You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by omkreddy <gi...@git.apache.org> on 2017/12/18 07:43:21 UTC

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

GitHub user omkreddy opened a pull request:

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

    STORM-2860: Add Kerberos support to Solr bolt

    

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

    $ git pull https://github.com/omkreddy/storm kerberos-solr-bolt

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

    https://github.com/apache/storm/pull/2467.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 #2467
    
----
commit 19d63a173f33327f3ecf27a5256ed866fb7069cb
Author: Manikumar Reddy <ma...@gmail.com>
Date:   2017-12-18T07:05:19Z

    STORM-2860: Add Kerberos support to Solr bolt

----


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by HeartSaVioR <gi...@git.apache.org>.
Github user HeartSaVioR commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    @satishd @hmcl Could you also take a look?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120311
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -88,9 +92,11 @@ private int capacity() {
         @Override
         protected void process(Tuple tuple) {
             try {
    +            LOG.debug("Processing Tuple: {}", tuple);
                 SolrRequest request = solrMapper.toSolrRequest(tuple);
                 solrClient.request(request, solrMapper.getCollection());
                 ack(tuple);
    +            LOG.debug("Acked Tuple: {}", tuple);
    --- End diff --
    
    Same as above


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157942171
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java ---
    @@ -93,6 +93,10 @@ private SolrJsonMapper(Builder builder) {
             jsonUpdateUrl = builder.jsonUpdateUrl;
         }
     
    +    @Override
    +    public void configure() {
    --- End diff --
    
    This may not be needed here once it is defined with default method in `SolrMapper`.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158913106
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -74,6 +75,9 @@ public SolrUpdateBolt(SolrConfig solrConfig, SolrMapper solrMapper, SolrCommitSt
         @Override
         public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
             this.collector = collector;
    +        solrMapper.configure();
    +        if (solrConfig.enableKerberos())
    --- End diff --
    
    This should be moved to above `solrMapper.configure()` so that it does not need to be set in that code path.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120398
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -153,4 +160,15 @@ private void failQueuedTuples(List<Tuple> failedTuples) {
         @Override
         public void declareOutputFields(OutputFieldsDeclarer declarer) { }
     
    +    @Override
    +    public void cleanup() {
    +        if (solrClient != null) {
    +            try {
    +                solrClient.close();
    +            } catch (IOException e) {
    +                LOG.debug("Error while closing solrClient", e);
    --- End diff --
    
    should it be error level?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158812503
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    @HeartSaVioR Yes, thats a reasonable proposal. On 1.x-branch, We can document that we don't support security with RestJsonSchemaBuilder


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159121022
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---
    @@ -0,0 +1,127 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +import org.apache.solr.client.solrj.impl.HttpClientUtil;
    +import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
    +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.config.SolrConfig;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.Field;
    +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.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Class that builds the {@link Schema} object from the schema returned by the SchemaRequest
    + */
    +public class RestJsonSchemaBuilderV2 implements SchemaBuilder {
    +    private static final Logger logger = LoggerFactory.getLogger(RestJsonSchemaBuilderV2.class);
    +    private Schema schema = new Schema();
    +    private SolrConfig solrConfig;
    +    private String collection;
    +
    +    public RestJsonSchemaBuilderV2(SolrConfig solrConfig, String collection) {
    +        this.solrConfig = solrConfig;
    +        this.collection = collection;
    +    }
    +
    +    @Override
    +    public void buildSchema() throws IOException {
    +        SolrClient solrClient = null;
    +        try {
    +            if (solrConfig.enableKerberos())
    +                HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
    +
    +            solrClient = new CloudSolrClient(solrConfig.getZkHostString());
    --- End diff --
    
    The initial code was building the schema from the JSON representation. The other class has been deprecated, which means that JSON is no longer supported. Is there a reason to support both? If so, there should probably be a factory that depending on configuration choice (e.g. Kerberos) would build one or another.
    
    The goal of using JSON was to avoid using all of this programatic setting. 


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158011321
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---
    @@ -0,0 +1,123 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +import org.apache.solr.client.solrj.impl.HttpClientUtil;
    +import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
    +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.config.SolrConfig;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.Field;
    +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.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Class that builds the {@link Schema} object from the schema returned by the SchemaRequest
    + */
    +public class RestJsonSchemaBuilderV2 implements SchemaBuilder {
    +    private static final Logger logger = LoggerFactory.getLogger(RestJsonSchemaBuilderV2.class);
    +    private Schema schema = new Schema();
    +    private SolrConfig solrConfig;
    +    private String collection;
    +
    +    public RestJsonSchemaBuilderV2(SolrConfig solrConfig, String collection) throws IOException {
    +        this.solrConfig = solrConfig;
    +        this.collection = collection;
    +    }
    +
    +    @Override
    +    public void buildSchema() throws IOException {
    +        try {
    +            if (solrConfig.enableKerberos())
    +                HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
    +
    +            SolrClient solrClient = new CloudSolrClient(solrConfig.getZkHostString());
    +            SchemaRequest schemaRequest = new SchemaRequest();
    +            logger.debug("Downloading schema for collection: {}", collection );
    +            SchemaResponse schemaResponse = schemaRequest.process(solrClient, collection);
    +            logger.debug("SchemaResponse Schema: " + schemaResponse);
    --- End diff --
    
    Better to have parameterized log statement.


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by omkreddy <gi...@git.apache.org>.
Github user omkreddy commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    PR for master: https://github.com/apache/storm/pull/2497


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159409508
  
    --- Diff: external/storm-solr/README.md ---
    @@ -171,7 +194,7 @@ Querying  Solr for these patterns, you will see the values that have been indexe
     
     curl -X GET -H "Content-type:application/json" -H "Accept:application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*id_fields_test_val*&wt=json&indent=true
     
    -curl -X GET -H "Content-type: application/json" -H "Accept: application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*id_fields_test_val*&wt=json&indent=true
    +curl -X GET -H "Content-type:application/json" -H "Accept:application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*json_test_val*&wt=json&indent=true
    --- End diff --
    
    yes, looks like a type. same link pasted twice


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158899660
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    @satishd Could you put opinion with my approach, or any new alternatives?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158912237
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    @HeartSaVioR  Suggested approach looks practical to me. If there are requests for this issue to be fixed in 1.x then new interfaces can be introduced without changing existing interfaces and make respective code changes which support both old and new semantics.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157941248
  
    --- Diff: external/storm-solr/README.md ---
    @@ -97,6 +97,29 @@ field separates each value with the token % instead of the default | . To use th
                     .setMultiValueFieldToken("%").build();
     ```
     
    +##Working with Kerberized Solr
    +If your topology is going to interact with kerberized Solr, your bolts/states needs to be authenticated by Solr Server. We can enable
    +authentication by distributing keytabs for solr user on all worker hosts. We can configure the solt bolt to use keytabs by setting
    --- End diff --
    
    nit: configure the solr bolt


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157941502
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -88,11 +92,14 @@ private int capacity() {
         @Override
         protected void process(Tuple tuple) {
             try {
    +            LOG.debug("Processing Tuple: {}", tuple);
                 SolrRequest request = solrMapper.toSolrRequest(tuple);
                 solrClient.request(request, solrMapper.getCollection());
                 ack(tuple);
    +            LOG.debug("Acked Tuple: {}", tuple);
             } catch (Exception e) {
                 fail(tuple, e);
    +            LOG.debug("Failed Tuple: {}", tuple, e);
    --- End diff --
    
    nit: may want to push log statement to `fail` method.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120315
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -88,9 +92,11 @@ private int capacity() {
         @Override
         protected void process(Tuple tuple) {
             try {
    +            LOG.debug("Processing Tuple: {}", tuple);
    --- End diff --
    
    Storm provides these debug log messages when the Config has setDebug(true). Therefore we don't usually add these types of logging.


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by omkreddy <gi...@git.apache.org>.
Github user omkreddy commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    Updated the PR for 1.x. Will raise PR for master


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158739084
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    Looks like major change is RestJsonSchemaBuilder. RestJsonSchemaBuilderV1 builds (fetches) schema in constructor, whereas RestJsonSchemaBuilderV2 builds (fetches) schema in `buildSchema()` which is newly added to interface in SchemaBuilder as well. So the implementation is going to require explicit initialization.
    
    How about separating this into two pull requests which for 1.x-branch is initializing schema in constructor as same as what RestJsonSchemaBuilderV1 is doing (so no need to add `configure()` and `buildSchema()`), and which for master is same as current PR?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158236749
  
    --- Diff: external/storm-solr/pom.xml ---
    @@ -46,19 +46,24 @@
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-solrj</artifactId>
    -            <version>5.2.1</version>
    -            <scope>compile</scope>
    +            <version>5.5.5</version>
    +            <exclusions>
    +                <exclusion>
    +                    <groupId>org.apache.httpcomponents</groupId>
    +                    <artifactId>httpclient</artifactId>
    --- End diff --
    
    solr-solrj 5.5.5 depends on httpclient:jar:4.3.3. This is giving runtime exceptions in Kerberos mode.  So I updated httpclient:jar to 4.5. 


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157942068
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    This can break any existing mappers users may have already created. Better to have default method to address that.


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by HeartSaVioR <gi...@git.apache.org>.
Github user HeartSaVioR commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    @omkreddy 
    Is the patch (for 1.x-branch) "kerberos ready"? Given that we get rid of RestJsonSchemaBuilderV2 here. What brings from this patch by now?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120320
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---
    @@ -128,6 +134,7 @@ private void fail(Tuple tuple, Exception e) {
                 List<Tuple> failedTuples = getQueuedTuples();
                 failQueuedTuples(failedTuples);
             }
    +        LOG.debug("Failed Tuple: {}", tuple, e);
    --- End diff --
    
    Same as above


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158913266
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---
    @@ -0,0 +1,127 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +import org.apache.solr.client.solrj.impl.HttpClientUtil;
    +import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
    +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.config.SolrConfig;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.Field;
    +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.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Class that builds the {@link Schema} object from the schema returned by the SchemaRequest
    + */
    +public class RestJsonSchemaBuilderV2 implements SchemaBuilder {
    +    private static final Logger logger = LoggerFactory.getLogger(RestJsonSchemaBuilderV2.class);
    +    private Schema schema = new Schema();
    +    private SolrConfig solrConfig;
    +    private String collection;
    +
    +    public RestJsonSchemaBuilderV2(SolrConfig solrConfig, String collection) {
    +        this.solrConfig = solrConfig;
    +        this.collection = collection;
    +    }
    +
    +    @Override
    +    public void buildSchema() throws IOException {
    +        SolrClient solrClient = null;
    +        try {
    +            if (solrConfig.enableKerberos())
    --- End diff --
    
    This check can be removed as it should have been already called by `SolrUpdateBolt#prepare()`


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158236702
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    @satishd  Thanks for the review.  Since we are using  java 1.7 compilation for 1.x branch, we can not use default methods. We can do it on mater branch. I don't see any option other than breaking the compatibility here. Let me know your thoughts.
    
    Updated PR with review comments


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r158658318
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---
    @@ -26,6 +26,7 @@
     import java.util.List;
     
     public interface SolrMapper extends Serializable {
    +    void configure();
    --- End diff --
    
    Is there no chance to add it to some kind of configurations (with proper default) and move out of interface? Just to find alternatives which don't break backward compatibility.


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by omkreddy <gi...@git.apache.org>.
Github user omkreddy commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    @HeartSaVioR We can use SolrJsonMapper and still write to kerbered solr cluster. We wont support SolrFieldMapper/RestJsonSchemaBuilderV2 in 1.x.  We can decide t merge or not.
    
    master PR can be  merged.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120430
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java ---
    @@ -70,13 +73,22 @@ public String toString() {
         /**
          * Initiates class containing all the information relating fields with their types.
          * This information is parsed from the schema
    -     * @param schema SolrSchema containing the information about fields and types
    +     * @param schemaBuilder schemaBuilder to build the information about fields and types
          * */
    -    public SolrFieldTypeFinder(Schema schema) {
    -        if (schema == null) {
    -            throw new IllegalArgumentException("Schema object is null");
    +    public SolrFieldTypeFinder(SchemaBuilder schemaBuilder) {
    +        this.schemaBuilder = schemaBuilder;
    +    }
    +
    +    public void initialize() {
    +        if (schemaBuilder == null) {
    +            throw new IllegalArgumentException("schemaBuilder object is null");
    --- End diff --
    
    Should this IllegalArgumentException  validation be done in the constructor to avoid this exception from occurring at runtime?  If it is intended to be done here, perhaps it should be IllegalStateException.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

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


---

[GitHub] storm issue #2467: STORM-2860: Add Kerberos support to Solr bolt

Posted by HeartSaVioR <gi...@git.apache.org>.
Github user HeartSaVioR commented on the issue:

    https://github.com/apache/storm/pull/2467
  
    @satishd @hmcl Friendly reminder: I'll merge this by tomorrow or so if we have no more comments from then.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159409982
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---
    @@ -0,0 +1,127 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +import org.apache.solr.client.solrj.impl.HttpClientUtil;
    +import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
    +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.config.SolrConfig;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.Field;
    +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.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Class that builds the {@link Schema} object from the schema returned by the SchemaRequest
    + */
    +public class RestJsonSchemaBuilderV2 implements SchemaBuilder {
    +    private static final Logger logger = LoggerFactory.getLogger(RestJsonSchemaBuilderV2.class);
    +    private Schema schema = new Schema();
    +    private SolrConfig solrConfig;
    +    private String collection;
    +
    +    public RestJsonSchemaBuilderV2(SolrConfig solrConfig, String collection) {
    +        this.solrConfig = solrConfig;
    +        this.collection = collection;
    +    }
    +
    +    @Override
    +    public void buildSchema() throws IOException {
    +        SolrClient solrClient = null;
    +        try {
    +            if (solrConfig.enableKerberos())
    +                HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());
    +
    +            solrClient = new CloudSolrClient(solrConfig.getZkHostString());
    --- End diff --
    
    RestJsonSchemaBuilderV2.java is also based JSON. it just that instead parsing the url the result, we are using CloudSolrClient to build schema. This internally uses http calls. Functionality wise both are same. 


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157944148
  
    --- Diff: external/storm-solr/pom.xml ---
    @@ -46,19 +46,24 @@
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-solrj</artifactId>
    -            <version>5.2.1</version>
    -            <scope>compile</scope>
    +            <version>5.5.5</version>
    --- End diff --
    
    you may want to have property for org.apache.solr version and use the same in other solr dependencies in this module instead of declaring at each dependency usage.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120269
  
    --- Diff: external/storm-solr/README.md ---
    @@ -97,6 +97,29 @@ field separates each value with the token % instead of the default | . To use th
                     .setMultiValueFieldToken("%").build();
     ```
     
    +##Working with Kerberized Solr
    +If your topology is going to interact with kerberized Solr, your bolts/states need to be authenticated by Solr Server. We can enable
    +authentication by distributing keytabs for solr user on all worker hosts. We can configure the solr bolt to use keytabs by setting
    +SolrConfig.enableKerberos config property.
    +
    +On worker hosts the bolt/trident-state code will use the keytab file with principal provided in the jaas config to authenticate with
    +Solr. You need to specify a Kerberos principal for the client and a corresponding keytab in the JAAS client configuration file.
    +Also make sure the provided principal is configured with required permissions to access solr collections.
    +
    +Here’s an example JAAS config:
    +
    +`SolrJClient {
    +  com.sun.security.auth.module.Krb5LoginModule required
    +  useKeyTab=true
    +  keyTab="/keytabs/foo.keytab"
    --- End diff --
    
    /keytabs/solr.keytab ? Perhaps we could put in here an entry that matches what Ambari typically creates.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120406
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java ---
    @@ -54,4 +65,7 @@ public int getTickTupleInterval() {
             return tickTupleInterval;
         }
     
    +    public boolean enableKerberos() {
    --- End diff --
    
    NIT: IsKerberosEnabled() or isEnableKerberos() ?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159120287
  
    --- Diff: external/storm-solr/README.md ---
    @@ -171,7 +194,7 @@ Querying  Solr for these patterns, you will see the values that have been indexe
     
     curl -X GET -H "Content-type:application/json" -H "Accept:application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*id_fields_test_val*&wt=json&indent=true
     
    -curl -X GET -H "Content-type: application/json" -H "Accept: application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*id_fields_test_val*&wt=json&indent=true
    +curl -X GET -H "Content-type:application/json" -H "Accept:application/json" http://localhost:8983/solr/gettingstarted_shard1_replica2/select?q=*json_test_val*&wt=json&indent=true
    --- End diff --
    
    Was this a bug?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157941206
  
    --- Diff: external/storm-solr/README.md ---
    @@ -97,6 +97,29 @@ field separates each value with the token % instead of the default | . To use th
                     .setMultiValueFieldToken("%").build();
     ```
     
    +##Working with Kerberized Solr
    +If your topology is going to interact with kerberized Solr, your bolts/states needs to be authenticated by Solr Server. We can enable
    --- End diff --
    
    nit: bolts/states need to be 


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r159340988
  
    --- Diff: external/storm-solr/README.md ---
    @@ -97,6 +97,29 @@ field separates each value with the token % instead of the default | . To use th
                     .setMultiValueFieldToken("%").build();
     ```
     
    +##Working with Kerberized Solr
    +If your topology is going to interact with kerberized Solr, your bolts/states need to be authenticated by Solr Server. We can enable
    +authentication by distributing keytabs for solr user on all worker hosts. We can configure the solr bolt to use keytabs by setting
    +SolrConfig.enableKerberos config property.
    +
    +On worker hosts the bolt/trident-state code will use the keytab file with principal provided in the jaas config to authenticate with
    +Solr. You need to specify a Kerberos principal for the client and a corresponding keytab in the JAAS client configuration file.
    +Also make sure the provided principal is configured with required permissions to access solr collections.
    +
    +Here’s an example JAAS config:
    +
    +`SolrJClient {
    +  com.sun.security.auth.module.Krb5LoginModule required
    +  useKeyTab=true
    +  keyTab="/keytabs/foo.keytab"
    --- End diff --
    
    We don't (maybe shouldn't) rely on other project configuration. It looks fine.


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157943956
  
    --- Diff: external/storm-solr/pom.xml ---
    @@ -46,19 +46,24 @@
             <dependency>
                 <groupId>org.apache.solr</groupId>
                 <artifactId>solr-solrj</artifactId>
    -            <version>5.2.1</version>
    -            <scope>compile</scope>
    +            <version>5.5.5</version>
    +            <exclusions>
    +                <exclusion>
    +                    <groupId>org.apache.httpcomponents</groupId>
    +                    <artifactId>httpclient</artifactId>
    --- End diff --
    
    I do not see any httpclient dependency for solr-solrj but org.apache.httpcomponents:httpcore:4.4.1 and org.apache.httpcomponents:httpmime:4.4.1. Am I missing anything here?


---

[GitHub] storm pull request #2467: STORM-2860: Add Kerberos support to Solr bolt

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

    https://github.com/apache/storm/pull/2467#discussion_r157943487
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---
    @@ -0,0 +1,123 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + * <p>
    + * http://www.apache.org/licenses/LICENSE-2.0
    + * <p>
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrClient;
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.impl.CloudSolrClient;
    +import org.apache.solr.client.solrj.impl.HttpClientUtil;
    +import org.apache.solr.client.solrj.impl.Krb5HttpClientConfigurer;
    +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.config.SolrConfig;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.Field;
    +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.LinkedList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * Class that builds the {@link Schema} object from the schema returned by the SchemaRequest
    + */
    +public class RestJsonSchemaBuilderV2 implements SchemaBuilder {
    +    private static final Logger logger = LoggerFactory.getLogger(RestJsonSchemaBuilderV2.class);
    +    private Schema schema = new Schema();
    +    private SolrConfig solrConfig;
    +    private String collection;
    +
    +    public RestJsonSchemaBuilderV2(SolrConfig solrConfig, String collection) throws IOException {
    --- End diff --
    
    This constructor does not really throw any IOException.


---