You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/02/01 19:38:26 UTC

[incubator-pinot] branch master updated: [TE] Clean up the useless exceptions (#3779)

This is an automated email from the ASF dual-hosted git repository.

akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 7e14e4f  [TE] Clean up the useless exceptions (#3779)
7e14e4f is described below

commit 7e14e4f5f6cca0d60c70e4345c607f5efe2e0896
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Fri Feb 1 11:38:22 2019 -0800

    [TE] Clean up the useless exceptions (#3779)
---
 .../dashboard/resources/DetectionJobResource.java        | 16 ++++------------
 .../pinot/thirdeye/datalayer/dto/AnomalyFunctionDTO.java | 10 ++--------
 .../thirdeye/detection/DetectionMigrationResource.java   | 16 ++++++++--------
 3 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/DetectionJobResource.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/DetectionJobResource.java
index fd40feb..be19524 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/DetectionJobResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/dashboard/resources/DetectionJobResource.java
@@ -1210,12 +1210,8 @@ public class DetectionJobResource {
     TimeUnit detectionUnit = anomalyFunctionSpec.getBucketUnit();
     int detectionBucketSize = anomalyFunctionSpec.getBucketSize();
     int detectionMinBuckets = 1;
-    try {
-      Properties functionProps = toProperties(anomalyFunctionSpec.getProperties());
-      detectionMinBuckets = Integer.valueOf(functionProps.getProperty(SIGN_TEST_WINDOW_SIZE, "1"));
-    } catch (IOException e) {
-      LOG.warn("Failed to fetch function properties when evaluating mttd!");
-    }
+    Properties functionProps = toProperties(anomalyFunctionSpec.getProperties());
+    detectionMinBuckets = Integer.valueOf(functionProps.getProperty(SIGN_TEST_WINDOW_SIZE, "1"));
     double functionMTTDInHour = TimeUnit.HOURS.convert(detectionBucketSize * detectionMinBuckets, detectionUnit);
     return Response.ok(Math.max(functionMTTDInHour, alertFilterMTTDInHour)).build();
   }
@@ -1255,12 +1251,8 @@ public class DetectionJobResource {
     TimeUnit detectionUnit = anomalyFunctionSpec.getBucketUnit();
     int detectionBucketSize = anomalyFunctionSpec.getBucketSize();
     int detectionMinBuckets = 1;
-    try {
-      Properties functionProps = toProperties(anomalyFunctionSpec.getProperties());
-      detectionMinBuckets = Integer.valueOf(functionProps.getProperty(SIGN_TEST_WINDOW_SIZE, "1"));
-    } catch (IOException e) {
-      LOG.warn("Failed to fetch function properties when evaluating mttd!");
-    }
+    Properties functionProps = toProperties(anomalyFunctionSpec.getProperties());
+    detectionMinBuckets = Integer.valueOf(functionProps.getProperty(SIGN_TEST_WINDOW_SIZE, "1"));
     double functionMTTDInHour = TimeUnit.HOURS.convert(detectionBucketSize * detectionMinBuckets, detectionUnit);
     return Response.ok(Math.max(functionMTTDInHour, alertFilterMTTDInHour)).build();
   }
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/dto/AnomalyFunctionDTO.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/dto/AnomalyFunctionDTO.java
index 3e523c1..8c7525f 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/dto/AnomalyFunctionDTO.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/dto/AnomalyFunctionDTO.java
@@ -72,13 +72,7 @@ public class AnomalyFunctionDTO extends AnomalyFunctionBean {
    * @return a Properties object corresponds to the properties String of this anomaly function.
    */
   public Properties toProperties() {
-    Properties props = null;
-    try {
-      props = toProperties(getProperties());
-    } catch (IOException e) {
-      LOGGER.warn("Failed to parse property string ({}) for anomaly function: {}", getProperties(), getId());
-    }
-    return props;
+    return toProperties(getProperties());
   }
 
   /**
@@ -86,7 +80,7 @@ public class AnomalyFunctionDTO extends AnomalyFunctionBean {
    *
    * @return a Properties object corresponds to the properties String of this anomaly function.
    */
-  public static Properties toProperties(String properties) throws IOException {
+  public static Properties toProperties(String properties) {
     if (properties == null || properties.isEmpty()) {
       return new Properties();
     }
diff --git a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionMigrationResource.java b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionMigrationResource.java
index bc51de7..1b62a44 100644
--- a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionMigrationResource.java
+++ b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/detection/DetectionMigrationResource.java
@@ -114,7 +114,7 @@ public class DetectionMigrationResource {
     this.yaml = new Yaml(options);
   }
 
-  private Map<String, Object> translateAnomalyFunctionToYaml(AnomalyFunctionDTO anomalyFunctionDTO) throws Exception {
+  private Map<String, Object> translateAnomalyFunctionToYaml(AnomalyFunctionDTO anomalyFunctionDTO) {
     Map<String, Object> yamlConfigs = new LinkedHashMap<>();
     yamlConfigs.put("detectionName", anomalyFunctionDTO.getFunctionName());
     yamlConfigs.put("metric", anomalyFunctionDTO.getMetric());
@@ -190,7 +190,7 @@ public class DetectionMigrationResource {
     return yamlConfigs;
   }
 
-  private Map<String, Object> getDimensionExplorationParams(AnomalyFunctionDTO functionDTO) throws IOException {
+  private Map<String, Object> getDimensionExplorationParams(AnomalyFunctionDTO functionDTO) {
     Map<String, Object> dimensionExploreYaml = new LinkedHashMap<>();
     dimensionExploreYaml.put("dimensions", Collections.singletonList(functionDTO.getExploreDimensions()));
     if (functionDTO.getDataFilter() != null && !functionDTO.getDataFilter().isEmpty() && functionDTO.getDataFilter().get("type").equals("average_threshold")) {
@@ -248,7 +248,7 @@ public class DetectionMigrationResource {
     return new Period(TimeUnit.MILLISECONDS.convert(functionDTO.getBucketSize(), functionDTO.getBucketUnit())).toString();
   }
 
-  private Map<String, Object> getPercentageChangeRuleDetectorParams(AnomalyFunctionDTO functionDTO) throws IOException {
+  private Map<String, Object> getPercentageChangeRuleDetectorParams(AnomalyFunctionDTO functionDTO) {
     Map<String, Object> detectorYaml = new LinkedHashMap<>();
     Properties properties = AnomalyFunctionDTO.toProperties(functionDTO.getProperties());
     double threshold = Double.valueOf(properties.getProperty("changeThreshold"));
@@ -263,7 +263,7 @@ public class DetectionMigrationResource {
     return detectorYaml;
   }
 
-  private Map<String, Object> getMinMaxThresholdRuleDetectorParams(AnomalyFunctionDTO functionDTO) throws IOException {
+  private Map<String, Object> getMinMaxThresholdRuleDetectorParams(AnomalyFunctionDTO functionDTO) {
     Map<String, Object> detectorYaml = new LinkedHashMap<>();
     Properties properties = AnomalyFunctionDTO.toProperties(functionDTO.getProperties());
     if (properties.containsKey("min")){
@@ -275,7 +275,7 @@ public class DetectionMigrationResource {
     return detectorYaml;
   }
 
-  private Map<String, Object> getAlgorithmDetectorParams(AnomalyFunctionDTO functionDTO) throws Exception {
+  private Map<String, Object> getAlgorithmDetectorParams(AnomalyFunctionDTO functionDTO) {
     Map<String, Object> detectorYaml = new LinkedHashMap<>();
     Map<String, Object> params = new LinkedHashMap<>();
     detectorYaml.put("configuration", params);
@@ -495,7 +495,7 @@ public class DetectionMigrationResource {
   @Produces(MediaType.TEXT_PLAIN)
   @Consumes(MediaType.APPLICATION_JSON)
   @Path("/legacy-anomaly-function-to-yaml/{id}")
-  public Response getYamlFromLegacyAnomalyFunction(@PathParam("id") long anomalyFunctionID) throws Exception {
+  public Response getYamlFromLegacyAnomalyFunction(@PathParam("id") long anomalyFunctionID) {
     AnomalyFunctionDTO anomalyFunctionDTO = this.anomalyFunctionDAO.findById(anomalyFunctionID);
     if (anomalyFunctionDTO == null) {
       return Response.status(Response.Status.BAD_REQUEST)
@@ -509,7 +509,7 @@ public class DetectionMigrationResource {
   @Produces(MediaType.TEXT_PLAIN)
   @Consumes(MediaType.APPLICATION_JSON)
   @Path("/legacy-alert-to-yaml/{id}")
-  public Response getYamlFromLegacyAlert(@PathParam("id") long alertId) throws Exception {
+  public Response getYamlFromLegacyAlert(@PathParam("id") long alertId) {
     AlertConfigDTO alertConfigDTO = this.alertConfigDAO.findById(alertId);
     if (alertConfigDTO == null) {
       return Response.status(Response.Status.BAD_REQUEST)
@@ -523,7 +523,7 @@ public class DetectionMigrationResource {
   @Produces(MediaType.APPLICATION_JSON)
   @Consumes(MediaType.APPLICATION_JSON)
   @Path("/application/{name}")
-  public Response migrateApplication(@PathParam("name") String application) throws Exception {
+  public Response migrateApplication(@PathParam("name") String application) {
     List<AlertConfigDTO> alertConfigDTOList = alertConfigDAO.findByPredicate(Predicate.EQ("application", application));
     Map<String, String> responseMessage = new HashMap<>();
 


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