eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ji...@apache.org
Subject incubator-eagle git commit: [EAGLE-744] add rest api for searching alerts by a policy id
Date Mon, 07 Nov 2016 10:27:41 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master ceeebb423 -> a28e2c485


[EAGLE-744] add rest api for searching alerts by a policy id

https://issues.apache.org/jira/browse/EAGLE-744

GET    /rest/metadata/policies/{policyId}/alerts

Author: Zhao, Qingwen <qingwzhao@apache.org>

Closes #616 from qingwen220/EAGLE-744.


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/a28e2c48
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/a28e2c48
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/a28e2c48

Branch: refs/heads/master
Commit: a28e2c4858f4c66172106e95f7c63e34adc651b2
Parents: ceeebb4
Author: Zhao, Qingwen <qingwzhao@apache.org>
Authored: Mon Nov 7 18:27:30 2016 +0800
Committer: zombieJ <smith3816@gmail.com>
Committed: Mon Nov 7 18:27:30 2016 +0800

----------------------------------------------------------------------
 .../eagle/service/metadata/resource/MetadataResource.java    | 6 ++++++
 .../java/org/apache/eagle/alert/metadata/IMetadataDao.java   | 2 ++
 .../eagle/alert/metadata/impl/InMemMetadataDaoImpl.java      | 7 +++++++
 .../eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java       | 8 ++++++++
 .../eagle/alert/metadata/impl/MongoMetadataDaoImpl.java      | 8 ++++++++
 5 files changed, 31 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a28e2c48/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata-service/src/main/java/org/apache/eagle/service/metadata/resource/MetadataResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata-service/src/main/java/org/apache/eagle/service/metadata/resource/MetadataResource.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata-service/src/main/java/org/apache/eagle/service/metadata/resource/MetadataResource.java
index 2a2047f..a658933 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata-service/src/main/java/org/apache/eagle/service/metadata/resource/MetadataResource.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata-service/src/main/java/org/apache/eagle/service/metadata/resource/MetadataResource.java
@@ -242,6 +242,12 @@ public class MetadataResource {
         return dao.removePolicy(policyId);
     }
 
+    @Path("/policies/{policyId}/alerts")
+    @GET
+    public List<AlertPublishEvent> getAlertPublishEventByPolicyId(@PathParam("policyId")
String policyId) {
+        return dao.getAlertPublishEventByPolicyId(policyId);
+    }
+
     @Path("/policies/{policyId}/publishments")
     @GET
     public List<Publishment> getPolicyPublishments(@PathParam("policyId") String policyId)
{

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a28e2c48/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/IMetadataDao.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/IMetadataDao.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/IMetadataDao.java
index 33a3c39..4321796 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/IMetadataDao.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/IMetadataDao.java
@@ -82,6 +82,8 @@ public interface IMetadataDao extends Closeable {
 
     AlertPublishEvent getAlertPublishEvent(String alertId);
 
+    List<AlertPublishEvent> getAlertPublishEventByPolicyId(String policyId);
+
     OpResult addAlertPublishEvent(AlertPublishEvent event);
 
     ScheduleState getScheduleState(String versionId);

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a28e2c48/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/InMemMetadataDaoImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/InMemMetadataDaoImpl.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/InMemMetadataDaoImpl.java
index ad7d353..03dad05 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/InMemMetadataDaoImpl.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/InMemMetadataDaoImpl.java
@@ -34,6 +34,7 @@ import org.slf4j.LoggerFactory;
 import java.io.IOException;
 import java.util.*;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
 /**
  * In memory service for simple service start. Make all service API as
@@ -217,6 +218,12 @@ public class InMemMetadataDaoImpl implements IMetadataDao {
     }
 
     @Override
+    public List<AlertPublishEvent> getAlertPublishEventByPolicyId(String policyId)
{
+        List<AlertPublishEvent> result = alerts.stream().filter(alert -> alert.getPolicyId().equals(policyId)).collect(Collectors.toList());
+        return result;
+    }
+
+    @Override
     public OpResult addAlertPublishEvent(AlertPublishEvent event) {
         alerts.add(event);
         OpResult result = new OpResult();

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a28e2c48/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java
index af5da51..c540b52 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/JdbcMetadataDaoImpl.java
@@ -30,6 +30,7 @@ import com.typesafe.config.Config;
 
 import java.io.IOException;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @since May 26, 2016.
@@ -87,6 +88,13 @@ public class JdbcMetadataDaoImpl implements IMetadataDao {
     }
 
     @Override
+    public List<AlertPublishEvent> getAlertPublishEventByPolicyId(String policyId)
{
+        List<AlertPublishEvent> alerts = handler.list(AlertPublishEvent.class);
+        List<AlertPublishEvent> result = alerts.stream().filter(alert -> alert.getPolicyId().equals(policyId)).collect(Collectors.toList());
+        return result;
+    }
+
+    @Override
     public ScheduleState getScheduleState(String versionId) {
         return handler.listWithFilter(versionId, ScheduleState.class);
         //return null;

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/a28e2c48/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java
b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java
index 088896c..dd1e586 100644
--- a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java
+++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @since Apr 11, 2016.
@@ -367,6 +368,13 @@ public class MongoMetadataDaoImpl implements IMetadataDao {
     }
 
     @Override
+    public List<AlertPublishEvent> getAlertPublishEventByPolicyId(String policyId)
{
+        List<AlertPublishEvent> results = list(alerts, AlertPublishEvent.class);
+        List<AlertPublishEvent> ret = results.stream().filter(alert -> alert.getPolicyId().equals(policyId)).collect(Collectors.toList());
+        return ret;
+    }
+
+    @Override
     public OpResult addAlertPublishEvent(AlertPublishEvent event) {
         return addOrReplace(alerts, event);
     }


Mime
View raw message