You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/08/22 11:07:30 UTC

[GitHub] [incubator-pinot] renato2099 opened a new pull request #5910: 5804: Prints file name of invalid json file when parsing

renato2099 opened a new pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910


   ## Description
   Enhances handling runtime exception thrown when parsing JSON by adding file name to the exception message.
   This was proposed in https://github.com/apache/incubator-pinot/issues/5804
   
   ## Upgrade Notes
   Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
   No
   
   Does this PR fix a zero-downtime upgrade introduced earlier?
   No
   
   Does this PR otherwise need attention when creating release notes? 
   No


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] renato2099 edited a comment on pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
renato2099 edited a comment on pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#issuecomment-681089584


   I was not sure which were the code paths that could use the json parsing, that is why I added it where it actually takes place.
   I moved it now to the createSegmentCommand as per your suggestion @Jackie-Jiang  I decided to keep the test as I think it is good that we add tests for these commands, let me know what you think.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#issuecomment-679273942


   It is better to log the bad file name in the `CreateSegmentCommand.java` under the catch of line 251, where bad files of all types can be logged


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter commented on pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#issuecomment-683185554


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=h1) Report
   > Merging [#5910](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/1beaab59b73f26c4e35f3b9bc856b03806cddf5a?el=desc) will **increase** coverage by `0.80%`.
   > The diff coverage is `69.14%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/5910/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz)](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master    #5910      +/-   ##
   ==========================================
   + Coverage   66.44%   67.25%   +0.80%     
   ==========================================
     Files        1075     1185     +110     
     Lines       54773    62086    +7313     
     Branches     8168     9483    +1315     
   ==========================================
   + Hits        36396    41755    +5359     
   - Misses      15700    17254    +1554     
   - Partials     2677     3077     +400     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | #integration | `43.80% <48.76%> (?)` | |
   | #unittests | `58.72% <56.53%> (?)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [...ot/broker/broker/AllowAllAccessControlFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvYnJva2VyL0FsbG93QWxsQWNjZXNzQ29udHJvbEZhY3RvcnkuamF2YQ==) | `100.00% <ø> (ø)` | |
   | [.../helix/BrokerUserDefinedMessageHandlerFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtYnJva2VyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9icm9rZXIvYnJva2VyL2hlbGl4L0Jyb2tlclVzZXJEZWZpbmVkTWVzc2FnZUhhbmRsZXJGYWN0b3J5LmphdmE=) | `52.83% <0.00%> (-13.84%)` | :arrow_down: |
   | [...ava/org/apache/pinot/client/AbstractResultSet.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0Fic3RyYWN0UmVzdWx0U2V0LmphdmE=) | `53.33% <0.00%> (-3.81%)` | :arrow_down: |
   | [.../main/java/org/apache/pinot/client/Connection.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L0Nvbm5lY3Rpb24uamF2YQ==) | `44.44% <0.00%> (-4.40%)` | :arrow_down: |
   | [.../org/apache/pinot/client/ResultTableResultSet.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY2xpZW50cy9waW5vdC1qYXZhLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY2xpZW50L1Jlc3VsdFRhYmxlUmVzdWx0U2V0LmphdmE=) | `24.00% <0.00%> (-10.29%)` | :arrow_down: |
   | [...ot/common/messages/RoutingTableRebuildMessage.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWVzc2FnZXMvUm91dGluZ1RhYmxlUmVidWlsZE1lc3NhZ2UuamF2YQ==) | `54.54% <ø> (ø)` | |
   | [...ache/pinot/common/metadata/ZKMetadataProvider.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0YWRhdGEvWktNZXRhZGF0YVByb3ZpZGVyLmphdmE=) | `72.22% <ø> (+5.36%)` | :arrow_up: |
   | [...metadata/segment/LLCRealtimeSegmentZKMetadata.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0YWRhdGEvc2VnbWVudC9MTENSZWFsdGltZVNlZ21lbnRaS01ldGFkYXRhLmphdmE=) | `47.61% <ø> (+3.35%)` | :arrow_up: |
   | [...g/apache/pinot/common/metrics/AbstractMetrics.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9BYnN0cmFjdE1ldHJpY3MuamF2YQ==) | `76.22% <ø> (+1.55%)` | :arrow_up: |
   | [...a/org/apache/pinot/common/metrics/BrokerGauge.java](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJHYXVnZS5qYXZh) | `92.30% <ø> (+2.30%)` | :arrow_up: |
   | ... and [857 more](https://codecov.io/gh/apache/incubator-pinot/pull/5910/diff?src=pr&el=tree-more) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=footer). Last update [331b874...32599ed](https://codecov.io/gh/apache/incubator-pinot/pull/5910?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#discussion_r480307439



##########
File path: pinot-tools/src/test/java/org/apache/pinot/tools/TestCreateSegmentCommand.java
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+package org.apache.pinot.tools;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.FileFormat;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.tools.admin.command.CreateSegmentCommand;
+import org.testng.annotations.Test;
+
+
+public class TestCreateSegmentCommand {
+  private static final File JSON_INVALID_SAMPLE_DATA_FILE = new File(Preconditions
+      .checkNotNull(TestCreateSegmentCommand.class.getClassLoader().getResource("test_data/test_invalid_data.json"))
+      .getFile());
+
+  private static CreateSegmentCommand _createSegmentCommand = new CreateSegmentCommand();
+
+  @Test(
+    expectedExceptions = Exception.class,
+    expectedExceptionsMessageRegExp = "^.*test_invalid_data.json.*$"
+  )
+  public void testReadingInvalidJsonFile()
+      throws Exception {
+    final String fileDirectoryPath = JSON_INVALID_SAMPLE_DATA_FILE.getParent();

Review comment:
       We use the style config file located at `config/codestyle-intellij.xml` (`config/codestyle-eclipse.xml` for eclipse)
   Will add some code style guide in the Pinot doc




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] renato2099 commented on a change in pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
renato2099 commented on a change in pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#discussion_r479687713



##########
File path: pinot-tools/src/test/java/org/apache/pinot/tools/TestCreateSegmentCommand.java
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+package org.apache.pinot.tools;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.FileFormat;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.tools.admin.command.CreateSegmentCommand;
+import org.testng.annotations.Test;
+
+
+public class TestCreateSegmentCommand {
+  private static final File JSON_INVALID_SAMPLE_DATA_FILE = new File(Preconditions
+      .checkNotNull(TestCreateSegmentCommand.class.getClassLoader().getResource("test_data/test_invalid_data.json"))
+      .getFile());
+
+  private static CreateSegmentCommand _createSegmentCommand = new CreateSegmentCommand();
+
+  @Test(
+    expectedExceptions = Exception.class,
+    expectedExceptionsMessageRegExp = "^.*test_invalid_data.json.*$"
+  )
+  public void testReadingInvalidJsonFile()
+      throws Exception {
+    final String fileDirectoryPath = JSON_INVALID_SAMPLE_DATA_FILE.getParent();

Review comment:
       sure, btw is there a code style guide where I can check these things?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] renato2099 commented on pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
renato2099 commented on pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#issuecomment-681089584


   I was not sure which were the code paths that could use the json parsing, that is why I added it where it actually takes place.
   I moved it now to the createSegmentCommand as per your suggestion @Jackie-Jiang  I decided to keep the test as I think it is good that we add tests for these commands


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang merged pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] renato2099 commented on a change in pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
renato2099 commented on a change in pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#discussion_r479687614



##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/CreateSegmentCommand.java
##########
@@ -252,7 +252,8 @@ public boolean execute()
             if (j < _retry) {
               LOGGER.warn("Caught exception while creating/verifying segment, will retry", e);
             } else {
-              throw e;
+              final String exceptionMessage = String.format("%s. File: %s", e.getMessage(), dataFiles.get(sequenceId));
+              throw new Exception(exceptionMessage, e);

Review comment:
       updated




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5910: 5804: Prints file name of invalid json file when parsing

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5910:
URL: https://github.com/apache/incubator-pinot/pull/5910#discussion_r479596007



##########
File path: pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/CreateSegmentCommand.java
##########
@@ -252,7 +252,8 @@ public boolean execute()
             if (j < _retry) {
               LOGGER.warn("Caught exception while creating/verifying segment, will retry", e);
             } else {
-              throw e;
+              final String exceptionMessage = String.format("%s. File: %s", e.getMessage(), dataFiles.get(sequenceId));
+              throw new Exception(exceptionMessage, e);

Review comment:
       ```suggestion
                 throw new RuntimeException("Caught exception while generating segment from file: " + dataFiles.get(sequenceId), e);
   ```

##########
File path: pinot-tools/src/test/java/org/apache/pinot/tools/TestCreateSegmentCommand.java
##########
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+package org.apache.pinot.tools;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.data.readers.FileFormat;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.apache.pinot.tools.admin.command.CreateSegmentCommand;
+import org.testng.annotations.Test;
+
+
+public class TestCreateSegmentCommand {
+  private static final File JSON_INVALID_SAMPLE_DATA_FILE = new File(Preconditions
+      .checkNotNull(TestCreateSegmentCommand.class.getClassLoader().getResource("test_data/test_invalid_data.json"))
+      .getFile());
+
+  private static CreateSegmentCommand _createSegmentCommand = new CreateSegmentCommand();
+
+  @Test(
+    expectedExceptions = Exception.class,
+    expectedExceptionsMessageRegExp = "^.*test_invalid_data.json.*$"
+  )
+  public void testReadingInvalidJsonFile()
+      throws Exception {
+    final String fileDirectoryPath = JSON_INVALID_SAMPLE_DATA_FILE.getParent();

Review comment:
       (nit) We don't usually put `final` for local variables




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org