Fixing stylecheck problems with storm-solr
Project: http://git-wip-us.apache.org/repos/asf/storm/repo Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/53adebcf Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/53adebcf Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/53adebcf Branch: refs/heads/master Commit: 53adebcfec5dec5e7a59f0a9108da734d3a3f01a Parents: 95602b1 Author: Kishor Patil <[email protected]> Authored: Sun Apr 22 23:24:58 2018 -0400 Committer: Kishor Patil <[email protected]> Committed: Mon Apr 23 02:32:41 2018 -0400 ---------------------------------------------------------------------- external/storm-solr/pom.xml | 2 +- .../apache/storm/solr/bolt/SolrUpdateBolt.java | 30 ++-- .../storm/solr/config/CountBasedCommit.java | 18 +-- .../storm/solr/config/SolrCommitStrategy.java | 18 +-- .../apache/storm/solr/config/SolrConfig.java | 25 ++-- .../storm/solr/mapper/SolrFieldsMapper.java | 137 +++++++++---------- .../storm/solr/mapper/SolrJsonMapper.java | 119 ++++++++-------- .../apache/storm/solr/mapper/SolrMapper.java | 22 ++- .../storm/solr/mapper/SolrMapperException.java | 18 +-- .../org/apache/storm/solr/schema/CopyField.java | 32 ++--- .../org/apache/storm/solr/schema/Field.java | 32 ++--- .../org/apache/storm/solr/schema/FieldType.java | 43 +++--- .../org/apache/storm/solr/schema/Schema.java | 82 +++++------ .../storm/solr/schema/SolrFieldTypeFinder.java | 87 ++++++------ .../schema/builder/RestJsonSchemaBuilder.java | 21 +-- .../schema/builder/RestJsonSchemaBuilderV2.java | 49 +++---- .../solr/schema/builder/SchemaBuilder.java | 20 +-- .../apache/storm/solr/trident/SolrState.java | 24 ++-- .../storm/solr/trident/SolrStateFactory.java | 19 +-- .../apache/storm/solr/trident/SolrUpdater.java | 21 +-- 20 files changed, 350 insertions(+), 469 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/pom.xml ---------------------------------------------------------------------- diff --git a/external/storm-solr/pom.xml b/external/storm-solr/pom.xml index b156f21..b65de8f 100644 --- a/external/storm-solr/pom.xml +++ b/external/storm-solr/pom.xml @@ -125,7 +125,7 @@ <artifactId>maven-checkstyle-plugin</artifactId> <!--Note - the version would be inherited--> <configuration> - <maxAllowedViolations>108</maxAllowedViolations> + <maxAllowedViolations>47</maxAllowedViolations> </configuration> </plugin> </plugins> http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java b/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java index e525d92..f6c7c60 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/bolt/SolrUpdateBolt.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.bolt; @@ -22,7 +16,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; - import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -68,15 +61,16 @@ public class SolrUpdateBolt extends BaseTickTupleAwareRichBolt { this.solrMapper = solrMapper; this.commitStgy = commitStgy; LOG.debug("Created {} with the following configuration: " + - "[SolrConfig = {}], [SolrMapper = {}], [CommitStgy = {}]", - this.getClass().getSimpleName(), solrConfig, solrMapper, commitStgy); + "[SolrConfig = {}], [SolrMapper = {}], [CommitStgy = {}]", + this.getClass().getSimpleName(), solrConfig, solrMapper, commitStgy); } @Override public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) { this.collector = collector; - if (solrConfig.isKerberosEnabled()) + if (solrConfig.isKerberosEnabled()) { HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); + } solrMapper.configure(); this.solrClient = new CloudSolrClient(solrConfig.getZkHostString()); this.toCommitTuples = new ArrayList<>(capacity()); @@ -85,8 +79,8 @@ public class SolrUpdateBolt extends BaseTickTupleAwareRichBolt { private int capacity() { final int defArrListCpcty = 10; return (commitStgy instanceof CountBasedCommit) ? - ((CountBasedCommit)commitStgy).getThreshold() : - defArrListCpcty; + ((CountBasedCommit) commitStgy).getThreshold() : + defArrListCpcty; } @Override http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/config/CountBasedCommit.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/config/CountBasedCommit.java b/external/storm-solr/src/main/java/org/apache/storm/solr/config/CountBasedCommit.java index 6bd1220..1a9c967 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/config/CountBasedCommit.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/config/CountBasedCommit.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.config; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrCommitStrategy.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrCommitStrategy.java b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrCommitStrategy.java index e4abf99..c4a8c3b 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrCommitStrategy.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrCommitStrategy.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.config; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java index ecb3630..bd05e9d 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/config/SolrConfig.java @@ -1,26 +1,19 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.config; -import org.apache.solr.client.solrj.impl.CloudSolrClient; - import java.io.Serializable; +import org.apache.solr.client.solrj.impl.CloudSolrClient; /** * Class containing Solr configuration to be made available to Storm Solr bolts. Any configuration needed in @@ -35,7 +28,7 @@ public class SolrConfig implements Serializable { * @param zkHostString Zookeeper host string as defined in the {@link CloudSolrClient} constructor * */ public SolrConfig(String zkHostString) { - this(zkHostString, 0); + this(zkHostString, 0); } /** @@ -54,7 +47,7 @@ public class SolrConfig implements Serializable { public SolrConfig(String zkHostString, int tickTupleInterval, boolean enableKerberos) { this.zkHostString = zkHostString; this.tickTupleInterval = tickTupleInterval; - this.enableKerberos = enableKerberos; + this.enableKerberos = enableKerberos; } public String getZkHostString() { http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrFieldsMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrFieldsMapper.java b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrFieldsMapper.java index b1d15cc..1ff7aa3 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrFieldsMapper.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrFieldsMapper.java @@ -1,28 +1,19 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.mapper; -import static org.apache.storm.solr.schema.SolrFieldTypeFinder.FieldTypeWrapper; - import java.util.LinkedList; import java.util.List; - import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -36,73 +27,24 @@ import org.apache.storm.tuple.ITuple; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.storm.solr.schema.SolrFieldTypeFinder.FieldTypeWrapper; + public class SolrFieldsMapper implements SolrMapper { private static final Logger log = LoggerFactory.getLogger(SolrFieldsMapper.class); private String collection; private SolrFieldTypeFinder typeFinder; private String multiValueFieldToken; - public static class Builder { - private String collection; - private SolrFieldTypeFinder typeFinder; - private String multiValueFieldToken = "|"; - - /** - * {@link SolrFieldsMapper} builder class. - * @param schemaBuilder Solr {@link Schema} builder class - * @param collection Name of the Solr collection to update using the SolrRequest - */ - public Builder(SchemaBuilder schemaBuilder, String collection) { - setTypeFinder(schemaBuilder); - this.collection = collection; - } - - /** - * {@link SolrFieldsMapper} builder class. - * @param schemaBuilder Solr {@link Schema} builder class - * @param solrClient {@link SolrClient} implementation from where to extract the default Solr collection, if any defined. - */ - public Builder(SchemaBuilder schemaBuilder, SolrClient solrClient) { - setTypeFinder(schemaBuilder); - } - - //TODO Handle the case where there may be no schema - private void setTypeFinder(SchemaBuilder schemaBuilder) { - typeFinder = new SolrFieldTypeFinder(schemaBuilder); - } - - // Sets {@link SolrFieldsMapper} to use the default Solr collection if there is one defined - private void setDefaultCollection(SolrClient solrClient) { - String defaultCollection = null; - if (solrClient instanceof CloudSolrClient) { - defaultCollection = ((CloudSolrClient) solrClient).getDefaultCollection(); - } - this.collection = defaultCollection; - } - - /** - * Sets the token that separates multivalue fields in tuples. The default token is | - * */ - public Builder setMultiValueFieldToken(String multiValueFieldToken) { - this.multiValueFieldToken = multiValueFieldToken; - return this; - } - - public SolrFieldsMapper build() { - return new SolrFieldsMapper(this); - } - } - private SolrFieldsMapper(Builder builder) { this.collection = builder.collection; this.typeFinder = builder.typeFinder; this.multiValueFieldToken = builder.multiValueFieldToken; log.debug("Created {} with the following configuration: [{}] " - + this.getClass().getSimpleName(), this.toString()); + + this.getClass().getSimpleName(), this.toString()); } @Override - public void configure() { + public void configure() { typeFinder.initialize(); } @@ -178,9 +120,60 @@ public class SolrFieldsMapper implements SolrMapper { @Override public String toString() { return "SolrFieldsMapper{" + - "collection='" + collection + '\'' + - ", typeFinder=" + typeFinder + - ", multiValueFieldToken='" + multiValueFieldToken + '\'' + - '}'; + "collection='" + collection + '\'' + + ", typeFinder=" + typeFinder + + ", multiValueFieldToken='" + multiValueFieldToken + '\'' + + '}'; + } + + public static class Builder { + private String collection; + private SolrFieldTypeFinder typeFinder; + private String multiValueFieldToken = "|"; + + /** + * {@link SolrFieldsMapper} builder class. + * @param schemaBuilder Solr {@link Schema} builder class + * @param collection Name of the Solr collection to update using the SolrRequest + */ + public Builder(SchemaBuilder schemaBuilder, String collection) { + setTypeFinder(schemaBuilder); + this.collection = collection; + } + + /** + * {@link SolrFieldsMapper} builder class. + * @param schemaBuilder Solr {@link Schema} builder class + * @param solrClient {@link SolrClient} implementation from where to extract the default Solr collection, if any defined. + */ + public Builder(SchemaBuilder schemaBuilder, SolrClient solrClient) { + setTypeFinder(schemaBuilder); + } + + //TODO Handle the case where there may be no schema + private void setTypeFinder(SchemaBuilder schemaBuilder) { + typeFinder = new SolrFieldTypeFinder(schemaBuilder); + } + + // Sets {@link SolrFieldsMapper} to use the default Solr collection if there is one defined + private void setDefaultCollection(SolrClient solrClient) { + String defaultCollection = null; + if (solrClient instanceof CloudSolrClient) { + defaultCollection = ((CloudSolrClient) solrClient).getDefaultCollection(); + } + this.collection = defaultCollection; + } + + /** + * Sets the token that separates multivalue fields in tuples. The default token is | + * */ + public Builder setMultiValueFieldToken(String multiValueFieldToken) { + this.multiValueFieldToken = multiValueFieldToken; + return this; + } + + public SolrFieldsMapper build() { + return new SolrFieldsMapper(this); + } } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java index 14a0a39..2334a0e 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrJsonMapper.java @@ -1,26 +1,19 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.mapper; -import java.util.List; - import com.google.gson.Gson; +import java.util.List; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -39,56 +32,8 @@ public class SolrJsonMapper implements SolrMapper { private final String jsonTupleField; private final String collection; - public static class Builder { - private String jsonUpdateUrl = "/update/json/docs"; - private final String jsonTupleField; - private final String collection; - - /** - * {@link SolrJsonMapper} builder class. - * @param collection Name of the Solr collection to update using the SolrRequest - * @param jsonTupleField Name of the tuple field that contains the JSON object used to update the Solr index - */ - public Builder(String collection, String jsonTupleField) { - this.collection = collection; - this.jsonTupleField = jsonTupleField; - } - - /** - * {@link SolrJsonMapper} builder class. - * @param solrClient {@link SolrClient} implementation from where to extract the default Solr collection, if any defined. - * @param jsonTupleField Name of the tuple field that contains the JSON object used to update the Solr index - */ - public Builder(SolrClient solrClient, String jsonTupleField) { - String defaultCollection = null; - if (solrClient instanceof CloudSolrClient) { - defaultCollection = ((CloudSolrClient) solrClient).getDefaultCollection(); - } - this.collection = defaultCollection; - this.jsonTupleField = jsonTupleField; - } - - /** - * Sets the URL endpoint where to send {@link SolrRequest} requests in JSON format. This URL is defined - * by Solr and for the most part you will not have to call this method to to override this value. - * Currently the default value is /update/json/docs. - * This method is available to support future evolutions of the Solr API. - * - * @param jsonUpdateUrl URL endpoint to where send {@link SolrRequest} - * @return {@link Builder object} used to build instances of {@link SolrJsonMapper} - */ - public Builder setJsonUpdateUrl(String jsonUpdateUrl) { - this.jsonUpdateUrl = jsonUpdateUrl; - return this; - } - - public SolrJsonMapper build() { - return new SolrJsonMapper(this); - } - } - private SolrJsonMapper(Builder builder) { - jsonTupleField = builder.jsonTupleField ; + jsonTupleField = builder.jsonTupleField; collection = builder.collection; jsonUpdateUrl = builder.jsonUpdateUrl; } @@ -157,4 +102,52 @@ public class SolrJsonMapper implements SolrMapper { } return json; } + + public static class Builder { + private final String jsonTupleField; + private final String collection; + private String jsonUpdateUrl = "/update/json/docs"; + + /** + * {@link SolrJsonMapper} builder class. + * @param collection Name of the Solr collection to update using the SolrRequest + * @param jsonTupleField Name of the tuple field that contains the JSON object used to update the Solr index + */ + public Builder(String collection, String jsonTupleField) { + this.collection = collection; + this.jsonTupleField = jsonTupleField; + } + + /** + * {@link SolrJsonMapper} builder class. + * @param solrClient {@link SolrClient} implementation from where to extract the default Solr collection, if any defined. + * @param jsonTupleField Name of the tuple field that contains the JSON object used to update the Solr index + */ + public Builder(SolrClient solrClient, String jsonTupleField) { + String defaultCollection = null; + if (solrClient instanceof CloudSolrClient) { + defaultCollection = ((CloudSolrClient) solrClient).getDefaultCollection(); + } + this.collection = defaultCollection; + this.jsonTupleField = jsonTupleField; + } + + /** + * Sets the URL endpoint where to send {@link SolrRequest} requests in JSON format. This URL is defined + * by Solr and for the most part you will not have to call this method to to override this value. + * Currently the default value is /update/json/docs. + * This method is available to support future evolutions of the Solr API. + * + * @param jsonUpdateUrl URL endpoint to where send {@link SolrRequest} + * @return {@link Builder object} used to build instances of {@link SolrJsonMapper} + */ + public Builder setJsonUpdateUrl(String jsonUpdateUrl) { + this.jsonUpdateUrl = jsonUpdateUrl; + return this; + } + + public SolrJsonMapper build() { + return new SolrJsonMapper(this); + } + } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java index c122aa4..1a083a2 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapper.java @@ -1,32 +1,28 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.mapper; import java.io.Serializable; import java.util.List; - import org.apache.solr.client.solrj.SolrRequest; import org.apache.storm.tuple.ITuple; public interface SolrMapper extends Serializable { default void configure() {} + String getCollection(); + SolrRequest toSolrRequest(ITuple tuple) throws SolrMapperException; + SolrRequest toSolrRequest(List<? extends ITuple> tuples) throws SolrMapperException; } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapperException.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapperException.java b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapperException.java index 654ee21..be3a82a 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapperException.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/mapper/SolrMapperException.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.mapper; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/CopyField.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/CopyField.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/CopyField.java index f07584a..2281c8f 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/CopyField.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/CopyField.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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; @@ -28,14 +22,14 @@ public class CopyField implements Serializable { return source; } - public String getDest() { - return dest; - } - public void setSource(String source) { this.source = source; } + public String getDest() { + return dest; + } + public void setDest(String dest) { this.dest = dest; } @@ -43,8 +37,8 @@ public class CopyField implements Serializable { @Override public String toString() { return "CopyField{" + - "source='" + source + '\'' + - ", dest='" + dest + '\'' + - '}'; + "source='" + source + '\'' + + ", dest='" + dest + '\'' + + '}'; } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Field.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Field.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Field.java index 99b14a2..43b0110 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Field.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Field.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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; @@ -28,14 +22,14 @@ public class Field implements Serializable { return name; } - public String getType() { - return type; - } - public void setName(String name) { this.name = name; } + public String getType() { + return type; + } + public void setType(String type) { this.type = type; } @@ -43,8 +37,8 @@ public class Field implements Serializable { @Override public String toString() { return "Field{" + - "name='" + name + '\'' + - ", type='" + type + '\'' + - '}'; + "name='" + name + '\'' + + ", type='" + type + '\'' + + '}'; } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/FieldType.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/FieldType.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/FieldType.java index e5d60bf..240af4b 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/FieldType.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/FieldType.java @@ -1,25 +1,18 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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; import com.google.gson.annotations.SerializedName; - import java.io.Serializable; public class FieldType implements Serializable { @@ -32,22 +25,22 @@ public class FieldType implements Serializable { return name; } - public String getClazz() { - return clazz; - } - - public boolean isMultiValued() { - return multiValued; - } - public void setName(String name) { this.name = name; } + public String getClazz() { + return clazz; + } + public void setClazz(String clazz) { this.clazz = clazz; } + public boolean isMultiValued() { + return multiValued; + } + public void setMultiValued(boolean multiValued) { this.multiValued = multiValued; } @@ -55,9 +48,9 @@ public class FieldType implements Serializable { @Override public String toString() { return "FieldType{" + - "name='" + name + '\'' + - ", clazz='" + clazz + '\'' + - ", multiValued=" + multiValued + - '}'; + "name='" + name + '\'' + + ", clazz='" + clazz + '\'' + + ", multiValued=" + multiValued + + '}'; } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Schema.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Schema.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Schema.java index d8071dd..d9cdbac 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Schema.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/Schema.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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; @@ -40,54 +34,54 @@ public class Schema implements Serializable { return name; } - public String getVersion() { - return version; - } - - public String getUniqueKey() { - return uniqueKey; - } - - public List<FieldType> getFieldTypes() { - return Collections.unmodifiableList(fieldTypes); - } - - public List<Field> getFields() { - return Collections.unmodifiableList(fields); - } - - public List<Field> getDynamicFields() { - return Collections.unmodifiableList(dynamicFields); - } - - public List<CopyField> getCopyFields() { - return Collections.unmodifiableList(copyFields); - } - public void setName(String name) { this.name = name; } + public String getVersion() { + return version; + } + public void setVersion(String version) { this.version = version; } + public String getUniqueKey() { + return uniqueKey; + } + public void setUniqueKey(String uniqueKey) { this.uniqueKey = uniqueKey; } + public List<FieldType> getFieldTypes() { + return Collections.unmodifiableList(fieldTypes); + } + public void setFieldTypes(List<FieldType> fieldTypes) { this.fieldTypes = fieldTypes; } + public List<Field> getFields() { + return Collections.unmodifiableList(fields); + } + public void setFields(List<Field> fields) { this.fields = fields; } + public List<Field> getDynamicFields() { + return Collections.unmodifiableList(dynamicFields); + } + public void setDynamicFields(List<Field> dynamicFields) { this.dynamicFields = dynamicFields; } + public List<CopyField> getCopyFields() { + return Collections.unmodifiableList(copyFields); + } + public void setCopyFields(List<CopyField> copyFields) { this.copyFields = copyFields; } @@ -95,14 +89,14 @@ public class Schema implements Serializable { @Override public String toString() { return "Schema{" + - "name='" + name + '\'' + - ", version='" + version + '\'' + - ", uniqueKey='" + uniqueKey + '\'' + - ", fieldTypes=" + fieldTypes + - ", fields=" + fields + - ", dynamicFields=" + dynamicFields + - ", copyFields=" + copyFields + - '}'; + "name='" + name + '\'' + + ", version='" + version + '\'' + + ", uniqueKey='" + uniqueKey + '\'' + + ", fieldTypes=" + fieldTypes + + ", fields=" + fields + + ", dynamicFields=" + dynamicFields + + ", copyFields=" + copyFields + + '}'; } // Wrapper class handy for the client code to use the JSON parser to build to use with JSON parser http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java index c99d612..aa6802e 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/SolrFieldTypeFinder.java @@ -1,19 +1,13 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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; @@ -26,7 +20,6 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; - import org.apache.storm.solr.schema.builder.SchemaBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,40 +30,11 @@ import org.slf4j.LoggerFactory; */ public class SolrFieldTypeFinder implements Serializable { private static final Logger log = LoggerFactory.getLogger(SolrFieldTypeFinder.class); - private SchemaBuilder schemaBuilder; + private SchemaBuilder schemaBuilder; private Schema schema; private Map<String, FieldTypeWrapper> fieldToWrapper; /** - * Class wrapping all the information for fields and types - * */ - public static class FieldTypeWrapper implements Serializable { - Field field; - FieldType type; - - public FieldTypeWrapper(Field field, FieldType type) { - this.field = field; - this.type = type; - } - - public Field getField() { - return field; - } - - public FieldType getType() { - return type; - } - - @Override - public String toString() { - return "FieldTypeWrapper{" + - "field=" + field + - ", type=" + type + - '}'; - } - } - - /** * Initiates class containing all the information relating fields with their types. * This information is parsed from the schema * @param schemaBuilder schemaBuilder to build the information about fields and types @@ -105,11 +69,11 @@ public class SolrFieldTypeFinder implements Serializable { } private void buildMapForFields(List<FieldType> fieldTypes, List<Field> fields) { - for (Field field: fields) { + for (Field field : fields) { String type = field.getType(); int idx = indexOf(fieldTypes, type); // idx - index of the type of this field in the FieldType list if (idx != -1) { - fieldToWrapper.put(field.getName(), new FieldTypeWrapper(field, fieldTypes.get(idx))); + fieldToWrapper.put(field.getName(), new FieldTypeWrapper(field, fieldTypes.get(idx))); } } } @@ -133,7 +97,7 @@ public class SolrFieldTypeFinder implements Serializable { * */ public FieldTypeWrapper getFieldTypeWrapper(String fieldName) { FieldTypeWrapper typeWrapper = fieldToWrapper.get(fieldName); - // => field name does not match static field, test if it matches dynamic field + // => field name does not match static field, test if it matches dynamic field if (typeWrapper == null) { for (String pattern : fieldToWrapper.keySet()) { if (matchesDynamicField(fieldName, pattern)) { @@ -181,7 +145,7 @@ public class SolrFieldTypeFinder implements Serializable { return true; } } else if (pattern.endsWith("*")) { - if (fieldName.startsWith(pattern.substring(0, pattern.length()-1))) { + if (fieldName.startsWith(pattern.substring(0, pattern.length() - 1))) { log.debug("Field [{}] MATCHES dynamic field {}", fieldName, pattern); return true; } @@ -191,4 +155,33 @@ public class SolrFieldTypeFinder implements Serializable { } return false; } + + /** + * Class wrapping all the information for fields and types + * */ + public static class FieldTypeWrapper implements Serializable { + Field field; + FieldType type; + + public FieldTypeWrapper(Field field, FieldType type) { + this.field = field; + this.type = type; + } + + public Field getField() { + return field; + } + + public FieldType getType() { + return type; + } + + @Override + public String toString() { + return "FieldTypeWrapper{" + + "field=" + field + + ", type=" + type + + '}'; + } + } } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilder.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilder.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilder.java index b9b8f33..405429c 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilder.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilder.java @@ -1,28 +1,21 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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 com.google.gson.Gson; import java.io.IOException; import java.net.URL; import java.util.Scanner; - -import com.google.gson.Gson; import org.apache.storm.solr.schema.Schema; import org.slf4j.Logger; import org.slf4j.LoggerFactory; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java index 8cd66f8..aff8550 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/RestJsonSchemaBuilderV2.java @@ -1,19 +1,13 @@ /** - * 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 + * 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. + * 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; @@ -22,7 +16,6 @@ import java.io.IOException; import java.util.LinkedList; import java.util.List; import java.util.Map; - import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -58,7 +51,7 @@ public class RestJsonSchemaBuilderV2 implements SchemaBuilder { try { solrClient = new CloudSolrClient(solrConfig.getZkHostString()); SchemaRequest schemaRequest = new SchemaRequest(); - logger.debug("Downloading schema for collection: {}", collection ); + logger.debug("Downloading schema for collection: {}", collection); SchemaResponse schemaResponse = schemaRequest.process(solrClient, collection); logger.debug("SchemaResponse Schema: {}", schemaResponse); SchemaRepresentation schemaRepresentation = schemaResponse.getSchemaRepresentation(); @@ -74,20 +67,22 @@ public class RestJsonSchemaBuilderV2 implements SchemaBuilder { logger.error("Error while getting schema for collection: {}", collection, e); throw new IOException("Error while getting schema for collection :" + collection, e); } finally { - if (solrClient != null) + if (solrClient != null) { solrClient.close(); + } } } private List<FieldType> getFieldTypes(SchemaRepresentation schemaRepresentation) { List<FieldType> fieldTypes = new LinkedList<>(); - for (FieldTypeDefinition fd: schemaRepresentation.getFieldTypes()) { + for (FieldTypeDefinition fd : schemaRepresentation.getFieldTypes()) { FieldType ft = new FieldType(); - ft.setName((String)fd.getAttributes().get("name")); - ft.setClazz((String)fd.getAttributes().get("class")); + ft.setName((String) fd.getAttributes().get("name")); + ft.setClazz((String) fd.getAttributes().get("class")); Object multiValued = fd.getAttributes().get("multiValued"); - if (multiValued != null) + if (multiValued != null) { ft.setMultiValued((Boolean) multiValued); + } fieldTypes.add(ft); } return fieldTypes; @@ -95,10 +90,10 @@ public class RestJsonSchemaBuilderV2 implements SchemaBuilder { private List<Field> getFields(List<Map<String, Object>> schemaFields) { List<Field> fields = new LinkedList<>(); - for (Map<String, Object> map: schemaFields) { - Field field = new Field(); - field.setName((String)map.get("name")); - field.setType((String)map.get("type")); + for (Map<String, Object> map : schemaFields) { + Field field = new Field(); + field.setName((String) map.get("name")); + field.setType((String) map.get("type")); fields.add(field); } return fields; @@ -106,10 +101,10 @@ public class RestJsonSchemaBuilderV2 implements SchemaBuilder { private List<CopyField> getCopyFields(SchemaRepresentation schemaRepresentation) { List<CopyField> copyFields = new LinkedList<>(); - for (Map<String, Object> map: schemaRepresentation.getCopyFields()) { - CopyField cp = new CopyField(); - cp.setSource((String)map.get("source")); - cp.setDest((String)map.get("dest")); + for (Map<String, Object> map : schemaRepresentation.getCopyFields()) { + CopyField cp = new CopyField(); + cp.setSource((String) map.get("source")); + cp.setDest((String) map.get("dest")); copyFields.add(cp); } return copyFields; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SchemaBuilder.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SchemaBuilder.java b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SchemaBuilder.java index cebb3fe..3f77e3d 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SchemaBuilder.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SchemaBuilder.java @@ -1,29 +1,23 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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 java.io.IOException; import java.io.Serializable; - import org.apache.storm.solr.schema.Schema; public interface SchemaBuilder extends Serializable { void buildSchema() throws IOException; + Schema getSchema(); } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrState.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrState.java b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrState.java index 4668c5f..14b5717 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrState.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrState.java @@ -1,25 +1,18 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.trident; import java.util.List; - import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.impl.CloudSolrClient; @@ -46,14 +39,15 @@ public class SolrState implements State { } protected void prepare() { - if (solrConfig.isKerberosEnabled()) + if (solrConfig.isKerberosEnabled()) { HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); + } solrMapper.configure(); solrClient = new CloudSolrClient(solrConfig.getZkHostString()); } @Override - public void beginCommit(Long aLong){ } + public void beginCommit(Long aLong) { } @Override public void commit(Long aLong) { } http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrStateFactory.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrStateFactory.java b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrStateFactory.java index 2e8997c..b0ae4a2 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrStateFactory.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrStateFactory.java @@ -1,25 +1,18 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.trident; import java.util.Map; - import org.apache.storm.solr.config.SolrConfig; import org.apache.storm.solr.mapper.SolrMapper; import org.apache.storm.task.IMetricsContext; http://git-wip-us.apache.org/repos/asf/storm/blob/53adebcf/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrUpdater.java ---------------------------------------------------------------------- diff --git a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrUpdater.java b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrUpdater.java index 01c1c27..4e3cecc 100644 --- a/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrUpdater.java +++ b/external/storm-solr/src/main/java/org/apache/storm/solr/trident/SolrUpdater.java @@ -1,30 +1,23 @@ /** - * 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 + * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * - * 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. + * 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.trident; import java.util.List; - import org.apache.storm.trident.operation.TridentCollector; import org.apache.storm.trident.state.BaseStateUpdater; import org.apache.storm.trident.tuple.TridentTuple; -public class SolrUpdater extends BaseStateUpdater<SolrState> { +public class SolrUpdater extends BaseStateUpdater<SolrState> { @Override public void updateState(SolrState solrState, List<TridentTuple> tuples, TridentCollector collector) {
