mayankshriv commented on a change in pull request #6977:
URL: https://github.com/apache/incubator-pinot/pull/6977#discussion_r641184869



##########
File path: 
pinot-common/src/main/java/org/apache/pinot/common/restlet/resources/SegmentErrorInfo.java
##########
@@ -0,0 +1,94 @@
+/**
+ * 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.common.restlet.resources;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+
+
+/**
+ * This class is used to represent errors related to a segment.
+ */
+@SuppressWarnings("unused")
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class SegmentErrorInfo {
+  private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss z";
+  private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new 
SimpleDateFormat(DATE_FORMAT, Locale.getDefault());
+
+  private final String _timestamp;
+  private final String _errorMessage;
+  private final String _exceptionStackTrace;
+
+  /**
+   *
+   * @param exceptionStackTrace Exception object
+   * @param errorMessage Error Message
+   * @param timestampMs Timestamp of the error
+   */
+  public SegmentErrorInfo(Exception exceptionStackTrace, String errorMessage, 
long timestampMs) {
+    _timestamp = epochToSDF(timestampMs);
+    _errorMessage = errorMessage;
+    _exceptionStackTrace = (exceptionStackTrace != null) ? 
ExceptionUtils.getStackTrace(exceptionStackTrace) : null;
+  }
+
+  /**
+   * This constructor is specifically for JSON ser/de.
+   *
+   * @param exceptionStackTrace Exception stack trace
+   * @param errorMessage Error message
+   * @param timestamp Time stamp of the error in Simple Date Format.
+   *
+   */
+  @JsonCreator
+  public SegmentErrorInfo(@JsonProperty("exception") String 
exceptionStackTrace,

Review comment:
       I took the liberty to use slightly different property name. My reasoning 
is that property name is for JSON output and should increase its readability 
(without being too verbose on names), and variable names should improve code 
readability.




-- 
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:
us...@infra.apache.org



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

Reply via email to