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/01/31 00:20:48 UTC

[incubator-pinot] branch master updated: [TE] Migrate unsubscribed anomaly functions (#3766)

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 2ce41cf  [TE] Migrate unsubscribed anomaly functions (#3766)
2ce41cf is described below

commit 2ce41cfd00e4984fdb74647b9d5a9f8b3fb0730d
Author: Akshay Rai <ak...@gmail.com>
AuthorDate: Wed Jan 30 16:20:42 2019 -0800

    [TE] Migrate unsubscribed anomaly functions (#3766)
---
 .../detection/DetectionMigrationResource.java      | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

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 19e91f5..afdfbd8 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
@@ -547,8 +547,44 @@ public class DetectionMigrationResource {
   }
 
   @POST
+  @Produces(MediaType.APPLICATION_JSON)
+  @Consumes(MediaType.APPLICATION_JSON)
   @Path("/anomaly-function/{id}")
   public Response migrateAnomalyFunction(@PathParam("id") long anomalyFunctionId) throws Exception {
     return Response.ok(migrateLegacyAnomalyFunction(anomalyFunctionId)).build();
   }
+
+  @POST
+  @Produces(MediaType.APPLICATION_JSON)
+  @Consumes(MediaType.APPLICATION_JSON)
+  @Path("/unsubscribed-anomaly-functions")
+  public Response migrateAnomalyFunction() throws Exception {
+    List<AnomalyFunctionDTO> anomalyFunctionDTOs = anomalyFunctionDAO.findAll();
+    Map<String, String> responseMessage = new HashMap<>();
+
+    for (AnomalyFunctionDTO func : anomalyFunctionDTOs) {
+      if (func.getFunctionName().contains(MIGRATED_TAG)) {
+        LOGGER.info("[MIG] Function already migrated. Name " + func.getFunctionName());
+        continue;
+      }
+
+      try {
+        validateFunction(func);
+      } catch (ValidationException e) {
+        LOGGER.info("[MIG] Function failed validation. Name " + func.getFunctionName() + " Error : " + e.getMessage());
+        continue;
+      }
+
+      try {
+        migrateLegacyAnomalyFunction(func);
+      } catch (Exception e) {
+        // Skip migrating this function and move on to the next
+        responseMessage.put("Status of function " + func.getId(),
+            String.format("Failed to migrate function ID %d with name %s due to %s", func.getId(),
+                func.getFunctionName(), e.getMessage()));
+      }
+    }
+
+    return Response.ok(responseMessage).build();
+  }
 }


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