Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 336F8200AF5 for ; Thu, 2 Jun 2016 09:08:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 32AB2160A3E; Thu, 2 Jun 2016 07:08:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AA326160A00 for ; Thu, 2 Jun 2016 09:08:33 +0200 (CEST) Received: (qmail 89467 invoked by uid 500); 2 Jun 2016 07:08:32 -0000 Mailing-List: contact commits-help@eagle.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@eagle.incubator.apache.org Delivered-To: mailing list commits@eagle.incubator.apache.org Received: (qmail 89458 invoked by uid 99); 2 Jun 2016 07:08:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 07:08:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 3DC9F1A12DC for ; Thu, 2 Jun 2016 07:08:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id oQL-iLg0m5mf for ; Thu, 2 Jun 2016 07:08:03 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 6AB2A60D53 for ; Thu, 2 Jun 2016 07:07:42 +0000 (UTC) Received: (qmail 86680 invoked by uid 99); 2 Jun 2016 07:07:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jun 2016 07:07:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2507EDFE65; Thu, 2 Jun 2016 07:07:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hao@apache.org To: commits@eagle.incubator.apache.org Date: Thu, 02 Jun 2016 07:08:03 -0000 Message-Id: <459f9e1633e647fc86e825033ab8f1b6@git.apache.org> In-Reply-To: <28e91c5389d941c48b3b7746440487cd@git.apache.org> References: <28e91c5389d941c48b3b7746440487cd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [24/46] incubator-eagle git commit: [EAGLE-325] Initialize next-gen alert engine code on branch-0.5 archived-at: Thu, 02 Jun 2016 07:08:36 -0000 http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/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 new file mode 100644 index 0000000..a46f0c7 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/MongoMetadataDaoImpl.java @@ -0,0 +1,380 @@ +/* + * 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.eagle.alert.metadata.impl; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; + +import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; +import org.apache.eagle.alert.coordination.model.ScheduleState; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.coordination.model.internal.Topology; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.engine.coordinator.Publishment; +import org.apache.eagle.alert.engine.coordinator.PublishmentType; +import org.apache.eagle.alert.engine.coordinator.StreamDefinition; +import org.apache.eagle.alert.engine.coordinator.StreamingCluster; +import org.apache.eagle.alert.metadata.resource.IMetadataDao; +import org.apache.eagle.alert.metadata.resource.Models; +import org.apache.eagle.alert.metadata.resource.OpResult; +import org.bson.BsonDocument; +import org.bson.BsonInt32; +import org.bson.BsonString; +import org.bson.Document; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.mongodb.Function; +import com.mongodb.MongoClient; +import com.mongodb.client.MongoCollection; +import com.mongodb.client.MongoDatabase; +import com.mongodb.client.model.IndexOptions; +import com.mongodb.client.model.UpdateOptions; +import com.mongodb.client.result.DeleteResult; +import com.mongodb.client.result.UpdateResult; +import com.typesafe.config.Config; + +/** + * @since Apr 11, 2016 + * + */ +public class MongoMetadataDaoImpl implements IMetadataDao { + + private static final String DB_NAME = "ump_alert_metadata"; + private static final Logger LOG = LoggerFactory.getLogger(MongoMetadataDaoImpl.class); + private static final ObjectMapper mapper = new ObjectMapper(); + static { + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + } + + private final String connection; + private final MongoClient client; + + private MongoDatabase db; + private MongoCollection cluster; + private MongoCollection schema; + private MongoCollection datasource; + private MongoCollection policy; + private MongoCollection publishment; + private MongoCollection publishmentType; + private MongoCollection scheduleStates; + private MongoCollection assignments; + private MongoCollection topologies; + + public MongoMetadataDaoImpl(Config config) { + this.connection = config.getString("connection"); + this.client = new MongoClient(connection); + init(); + } + + private void init() { + db = client.getDatabase(DB_NAME); + IndexOptions io = new IndexOptions().background(true).unique(true).name("nameIndex"); + BsonDocument doc = new BsonDocument(); + doc.append("name", new BsonInt32(1)); + cluster = db.getCollection("clusters"); + cluster.createIndex(doc, io); + { + BsonDocument doc2 = new BsonDocument(); + doc2.append("streamId", new BsonInt32(1)); + schema = db.getCollection("schemas"); + schema.createIndex(doc2, io); + } + datasource = db.getCollection("datasources"); + datasource.createIndex(doc, io); + policy = db.getCollection("policies"); + policy.createIndex(doc, io); + publishment = db.getCollection("publishments"); + publishment.createIndex(doc, io); + topologies = db.getCollection("topologies"); + topologies.createIndex(doc, io); + + publishmentType = db.getCollection("publishmentTypes"); + { + IndexOptions io1 = new IndexOptions().background(true).unique(true).name("pubTypeIndex"); + BsonDocument doc1 = new BsonDocument(); + doc1.append("type", new BsonInt32(1)); + publishmentType.createIndex(doc1, io1); + } + + scheduleStates = db.getCollection("schedule_specs"); + { + IndexOptions io1 = new IndexOptions().background(true).unique(true).name("nameIndex"); + BsonDocument doc1 = new BsonDocument(); + doc1.append("version", new BsonInt32(1)); + scheduleStates.createIndex(doc1, io1); + } + + assignments = db.getCollection("assignments"); + { + IndexOptions io1 = new IndexOptions().background(true).unique(true).name("policyNameIndex"); + BsonDocument doc1 = new BsonDocument(); + doc1.append("policyName", new BsonInt32(1)); + assignments.createIndex(doc1, io1); + } + } + + @Override + public List listClusters() { + return list(cluster, StreamingCluster.class); + } + + private List list(MongoCollection collection, Class clz) { + List result = new LinkedList(); + collection.find().map(new Function() { + @Override + public T apply(Document t) { + String json = t.toJson(); + try { + return mapper.readValue(json, clz); + } catch (IOException e) { + LOG.error("deserialize config item failed!", e); + } + return null; + } + }).into(result); + return result; + } + + private OpResult addOrReplace(MongoCollection collection, T t) { + BsonDocument filter = new BsonDocument(); + if (t instanceof StreamDefinition) { + filter.append("streamId", new BsonString(InMemMetadataDaoImpl.getKey(t))); + } else { + filter.append("name", new BsonString(InMemMetadataDaoImpl.getKey(t))); + } + + String json = ""; + OpResult result = new OpResult(); + try { + json = mapper.writeValueAsString(t); + UpdateOptions options = new UpdateOptions(); + options.upsert(true); + UpdateResult ur = collection.replaceOne(filter, Document.parse(json), options); + // FIXME: could based on matched count do better matching... + if (ur.getModifiedCount() > 0 || ur.getUpsertedId() != null) { + result.code = 200; + result.message = String.format("update %d configuration item.", ur.getModifiedCount()); + } else { + result.code = 500; + result.message = "no configuration item create/updated."; + } + } catch (Exception e) { + result.code = 500; + result.message = e.getMessage(); + LOG.error("", e); + } + return result; + } + + private OpResult remove(MongoCollection collection, String name) { + BsonDocument filter = new BsonDocument(); + filter.append("name", new BsonString(name)); + DeleteResult dr = collection.deleteOne(filter); + OpResult result = new OpResult(); + result.code = 200; + result.message = String.format(" %d config item removed!", dr.getDeletedCount()); + return result; + } + + @Override + public OpResult addCluster(StreamingCluster cluster) { + return addOrReplace(this.cluster, cluster); + } + + @Override + public OpResult removeCluster(String clusterId) { + return remove(cluster, clusterId); + } + + @Override + public List listStreams() { + return list(schema, StreamDefinition.class); + } + + @Override + public OpResult createStream(StreamDefinition stream) { + return addOrReplace(this.schema, stream); + } + + @Override + public OpResult removeStream(String streamId) { + return remove(schema, streamId); + } + + @Override + public List listDataSources() { + return list(datasource, Kafka2TupleMetadata.class); + } + + @Override + public OpResult addDataSource(Kafka2TupleMetadata dataSource) { + return addOrReplace(this.datasource, dataSource); + } + + @Override + public OpResult removeDataSource(String datasourceId) { + return remove(datasource, datasourceId); + } + + @Override + public List listPolicies() { + return list(policy, PolicyDefinition.class); + } + + @Override + public OpResult addPolicy(PolicyDefinition policy) { + return addOrReplace(this.policy, policy); + } + + @Override + public OpResult removePolicy(String policyId) { + return remove(policy, policyId); + } + + @Override + public List listPublishment() { + return list(publishment, Publishment.class); + } + + @Override + public OpResult addPublishment(Publishment publishment) { + return addOrReplace(this.publishment, publishment); + } + + @Override + public OpResult removePublishment(String pubId) { + return remove(publishment, pubId); + } + + @Override + public List listPublishmentType() { + return list(publishmentType, PublishmentType.class); + } + + @Override + public OpResult addPublishmentType(PublishmentType pubType) { + return addOrReplace(this.publishmentType, pubType); + } + + @Override + public OpResult removePublishmentType(String pubType) { + return remove(publishmentType, pubType); + } + + @Override + public ScheduleState getScheduleState(String versionId) { + BsonDocument doc = new BsonDocument(); + doc.append("version", new BsonString(versionId)); + ScheduleState state = scheduleStates.find(doc).map(new Function() { + @Override + public ScheduleState apply(Document t) { + String json = t.toJson(); + try { + return mapper.readValue(json, ScheduleState.class); + } catch (IOException e) { + LOG.error("deserialize config item failed!", e); + } + return null; + } + }).first(); + return state; + } + + @Override + public OpResult addScheduleState(ScheduleState state) { + return addOne(scheduleStates, state); + } + + private OpResult addOne(MongoCollection collection, T t) { + OpResult result = new OpResult(); + try { + String json = mapper.writeValueAsString(t); + collection.insertOne(Document.parse(json)); + result.code = 200; + result.message = "add state succeed!"; + } catch (Exception e) { + result.code = 400; + result.message = e.getMessage(); + LOG.error("", e); + } + return result; + } + + @Override + public ScheduleState getScheduleState() { + BsonDocument sort = new BsonDocument(); + sort.append("generateTime", new BsonInt32(-1)); + ScheduleState state = scheduleStates.find().sort(sort).map(new Function() { + @Override + public ScheduleState apply(Document t) { + String json = t.toJson(); + try { + return mapper.readValue(json, ScheduleState.class); + } catch (IOException e) { + LOG.error("deserialize config item failed!", e); + } + return null; + } + }).first(); + return state; + } + + @Override + public List listAssignments() { + return list(assignments, PolicyAssignment.class); + } + + @Override + public OpResult addAssignment(PolicyAssignment assignment) { + return addOne(assignments, assignment); + } + + @Override + public List listTopologies() { + return list(topologies, Topology.class); + } + + @Override + public OpResult addTopology(Topology t) { + return addOrReplace(this.topologies, t); + } + + @Override + public OpResult removeTopology(String topologyName) { + return remove(topologies, topologyName); + } + + @Override + public OpResult clear() { + throw new UnsupportedOperationException("clear not support!"); + } + + @Override + public Models export() { + throw new UnsupportedOperationException("export not support!"); + } + + @Override + public OpResult importModels(Models models) { + throw new UnsupportedOperationException("importModels not support!"); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/jdbc/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/jdbc/JdbcMetadataDaoImpl.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/jdbc/JdbcMetadataDaoImpl.java new file mode 100644 index 0000000..9ec119a --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/impl/jdbc/JdbcMetadataDaoImpl.java @@ -0,0 +1,292 @@ +/* + * 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.eagle.alert.metadata.impl.jdbc; + +import java.util.List; + +import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; +import org.apache.eagle.alert.coordination.model.ScheduleState; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.coordination.model.internal.Topology; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.engine.coordinator.Publishment; +import org.apache.eagle.alert.engine.coordinator.PublishmentType; +import org.apache.eagle.alert.engine.coordinator.StreamDefinition; +import org.apache.eagle.alert.engine.coordinator.StreamingCluster; +import org.apache.eagle.alert.metadata.resource.OpResult; +import org.apache.eagle.alert.metadata.resource.IMetadataDao; +import org.apache.eagle.alert.metadata.resource.Models; + +/** + * @since May 26, 2016 + * + */ +public class JdbcMetadataDaoImpl implements IMetadataDao { + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listTopologies() + */ + @Override + public List listTopologies() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addTopology(org.apache.eagle.alert.coordination.model.internal.Topology) + */ + @Override + public OpResult addTopology(Topology t) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removeTopology(java.lang.String) + */ + @Override + public OpResult removeTopology(String topologyName) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listClusters() + */ + @Override + public List listClusters() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addCluster(org.apache.eagle.alert.engine.coordinator.StreamingCluster) + */ + @Override + public OpResult addCluster(StreamingCluster cluster) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removeCluster(java.lang.String) + */ + @Override + public OpResult removeCluster(String clusterId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listStreams() + */ + @Override + public List listStreams() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#createStream(org.apache.eagle.alert.engine.coordinator.StreamDefinition) + */ + @Override + public OpResult createStream(StreamDefinition stream) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removeStream(java.lang.String) + */ + @Override + public OpResult removeStream(String streamId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listDataSources() + */ + @Override + public List listDataSources() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addDataSource(org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata) + */ + @Override + public OpResult addDataSource(Kafka2TupleMetadata dataSource) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removeDataSource(java.lang.String) + */ + @Override + public OpResult removeDataSource(String datasourceId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listPolicies() + */ + @Override + public List listPolicies() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addPolicy(org.apache.eagle.alert.engine.coordinator.PolicyDefinition) + */ + @Override + public OpResult addPolicy(PolicyDefinition policy) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removePolicy(java.lang.String) + */ + @Override + public OpResult removePolicy(String policyId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listPublishment() + */ + @Override + public List listPublishment() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addPublishment(org.apache.eagle.alert.engine.coordinator.Publishment) + */ + @Override + public OpResult addPublishment(Publishment publishment) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#removePublishment(java.lang.String) + */ + @Override + public OpResult removePublishment(String pubId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#getScheduleState(java.lang.String) + */ + @Override + public ScheduleState getScheduleState(String versionId) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#getScheduleState() + */ + @Override + public ScheduleState getScheduleState() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addScheduleState(org.apache.eagle.alert.coordination.model.ScheduleState) + */ + @Override + public OpResult addScheduleState(ScheduleState state) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#listAssignments() + */ + @Override + public List listAssignments() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#addAssignment(org.apache.eagle.alert.coordination.model.internal.PolicyAssignment) + */ + @Override + public OpResult addAssignment(PolicyAssignment assignment) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#clear() + */ + @Override + public OpResult clear() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#export() + */ + @Override + public Models export() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.eagle.service.alert.resource.IMetadataDao#importModels(org.apache.eagle.service.alert.resource.Models) + */ + @Override + public OpResult importModels(Models models) { + // TODO Auto-generated method stub + return null; + } + + @Override + public List listPublishmentType() { + // TODO Auto-generated method stub + return null; + } + + @Override + public OpResult addPublishmentType(PublishmentType publishmentType) { + // TODO Auto-generated method stub + return null; + } + + @Override + public OpResult removePublishmentType(String pubType) { + // TODO Auto-generated method stub + return null; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/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/resource/IMetadataDao.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/IMetadataDao.java new file mode 100644 index 0000000..8eef985 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/IMetadataDao.java @@ -0,0 +1,86 @@ +/* + * 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.eagle.alert.metadata.resource; + +import java.util.List; + +import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; +import org.apache.eagle.alert.coordination.model.ScheduleState; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.coordination.model.internal.Topology; +import org.apache.eagle.alert.engine.coordinator.*; + +public interface IMetadataDao { + + List listTopologies(); + + OpResult addTopology(Topology t); + + OpResult removeTopology(String topologyName); + + List listClusters(); + + OpResult addCluster(StreamingCluster cluster); + + OpResult removeCluster(String clusterId); + + List listStreams(); + + OpResult createStream(StreamDefinition stream); + + OpResult removeStream(String streamId); + + List listDataSources(); + + OpResult addDataSource(Kafka2TupleMetadata dataSource); + + OpResult removeDataSource(String datasourceId); + + List listPolicies(); + + OpResult addPolicy(PolicyDefinition policy); + + OpResult removePolicy(String policyId); + + List listPublishment(); + + OpResult addPublishment(Publishment publishment); + + OpResult removePublishment(String pubId); + + List listPublishmentType(); + + OpResult addPublishmentType(PublishmentType publishmentType); + + OpResult removePublishmentType(String pubType); + + ScheduleState getScheduleState(String versionId); + + ScheduleState getScheduleState(); + + OpResult addScheduleState(ScheduleState state); + + List listAssignments(); + + OpResult addAssignment(PolicyAssignment assignment); + + // APIs for test friendly + OpResult clear(); + Models export(); + OpResult importModels(Models models); + +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/Models.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/Models.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/Models.java new file mode 100644 index 0000000..6bb38f1 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/Models.java @@ -0,0 +1,48 @@ +/* + * 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.eagle.alert.metadata.resource; + +import java.util.ArrayList; +import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; +import org.apache.eagle.alert.coordination.model.ScheduleState; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.coordination.model.internal.Topology; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.engine.coordinator.Publishment; +import org.apache.eagle.alert.engine.coordinator.StreamDefinition; +import org.apache.eagle.alert.engine.coordinator.StreamingCluster; + +/** + * This models used for metadata export/import to easy of test. + * + * @since May 23, 2016 + * + */ +public class Models { + public List clusters = new ArrayList(); + public List schemas = new ArrayList(); + public List datasources = new ArrayList(); + public List policies = new ArrayList(); + public List publishments = new ArrayList(); + public SortedMap scheduleStates = new TreeMap(); + public List assignments = new ArrayList(); + public List topologies = new ArrayList(); +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/OpResult.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/OpResult.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/OpResult.java new file mode 100644 index 0000000..44f507d --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/java/org/apache/eagle/alert/metadata/resource/OpResult.java @@ -0,0 +1,28 @@ +/* + * 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.eagle.alert.metadata.resource; + +/** + * @since Apr 11, 2016 + * + */ +public class OpResult { + + public int code = 200; + public String message = ""; + +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/resources/application.conf b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/resources/application.conf new file mode 100644 index 0000000..9c80298 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/main/resources/application.conf @@ -0,0 +1,23 @@ +# 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. + +{ + "datastore": { + "metadataDao": "org.apache.eagle.service.alert.resource.impl.InMemMetadataDaoImpl", + "connection": "localhost:27017", + "properties" : { + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/InMemoryTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/InMemoryTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/InMemoryTest.java new file mode 100644 index 0000000..54a2ffc --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/InMemoryTest.java @@ -0,0 +1,43 @@ +/* + * 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.eagle.service.alert.resource.impl; + +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.metadata.impl.InMemMetadataDaoImpl; +import org.apache.eagle.alert.metadata.resource.IMetadataDao; +import org.junit.Assert; +import org.junit.Test; + +import com.typesafe.config.ConfigFactory; + +/** + * @since May 1, 2016 + * + */ +public class InMemoryTest { + + private IMetadataDao dao = new InMemMetadataDaoImpl(ConfigFactory.load()); + + @Test + public void test_AddPolicy() { + PolicyDefinition pd = new PolicyDefinition(); + pd.setName("pd1"); + dao.addPolicy(pd); + + Assert.assertEquals(1, dao.listPolicies().size()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/MongoImplTest.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/MongoImplTest.java b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/MongoImplTest.java new file mode 100644 index 0000000..16b53d4 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/java/org/apache/eagle/service/alert/resource/impl/MongoImplTest.java @@ -0,0 +1,187 @@ +/* + * 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.eagle.service.alert.resource.impl; + +import java.util.Date; +import java.util.List; + +import org.apache.eagle.alert.coordination.model.Kafka2TupleMetadata; +import org.apache.eagle.alert.coordination.model.ScheduleState; +import org.apache.eagle.alert.coordination.model.internal.PolicyAssignment; +import org.apache.eagle.alert.coordination.model.internal.Topology; +import org.apache.eagle.alert.engine.coordinator.PolicyDefinition; +import org.apache.eagle.alert.engine.coordinator.Publishment; +import org.apache.eagle.alert.engine.coordinator.PublishmentType; +import org.apache.eagle.alert.engine.coordinator.StreamingCluster; +import org.apache.eagle.alert.metadata.impl.MongoMetadataDaoImpl; +import org.apache.eagle.alert.metadata.resource.IMetadataDao; +import org.apache.eagle.alert.metadata.resource.OpResult; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.typesafe.config.Config; +import com.typesafe.config.ConfigFactory; + +import de.flapdoodle.embed.mongo.MongodExecutable; +import de.flapdoodle.embed.mongo.MongodProcess; +import de.flapdoodle.embed.mongo.MongodStarter; +import de.flapdoodle.embed.mongo.config.MongodConfigBuilder; +import de.flapdoodle.embed.mongo.config.Net; +import de.flapdoodle.embed.mongo.distribution.Version; +import de.flapdoodle.embed.process.runtime.Network; + +/** + * @since May 1, 2016 + * + */ +public class MongoImplTest { + private static Logger LOG = LoggerFactory.getLogger(MongoImplTest.class); + static IMetadataDao dao; + + private static MongodExecutable mongodExe; + private static MongodProcess mongod; + + public static void before() { + try { + MongodStarter starter = MongodStarter.getDefaultInstance(); + mongodExe = starter.prepare(new MongodConfigBuilder().version(Version.V3_2_1) + .net(new Net(27017, Network.localhostIsIPv6())).build()); + mongod = mongodExe.start(); + } catch (Exception e) { + LOG.error("start embed mongod failed, assume some external mongo running. continue run test!", e); + } + } + + @BeforeClass + public static void setup() { + before(); + + System.setProperty("config.resource", "/application-mongo.conf"); + ConfigFactory.invalidateCaches(); + Config config = ConfigFactory.load().getConfig("datastore"); + dao = new MongoMetadataDaoImpl(config); + + } + + @AfterClass + public static void teardown() { + if (mongod != null) { + mongod.stop(); + mongodExe.stop(); + } + } + + private String TOPO_NAME = "topoName"; + + @Test + public void test_apis() { + // topology + { + OpResult result = dao.addTopology(new Topology(TOPO_NAME, 3, 5)); + System.out.println(result.message); + Assert.assertEquals(200, result.code); + List topos = dao.listTopologies(); + Assert.assertEquals(1, topos.size()); + + result = dao.addTopology(new Topology(TOPO_NAME + "-new", 3, 5)); + topos = dao.listTopologies(); + Assert.assertEquals(2, topos.size()); + // add again: replace existing one + result = dao.addTopology(new Topology(TOPO_NAME, 4, 5)); + topos = dao.listTopologies(); + Assert.assertEquals(2, topos.size()); + Assert.assertEquals(TOPO_NAME, topos.get(0).getName()); + Assert.assertEquals(4, topos.get(0).getNumOfGroupBolt()); + } + // assignment + { + PolicyAssignment assignment = new PolicyAssignment(); + assignment.setPolicyName("policy1"); + OpResult result = dao.addAssignment(assignment); + Assert.assertEquals(200, result.code); + List assigns = dao.listAssignments(); + Assert.assertEquals(1, assigns.size()); + } + // cluster + { + StreamingCluster cluster = new StreamingCluster(); + cluster.setName("dd"); + OpResult result = dao.addCluster(cluster); + Assert.assertEquals(200, result.code); + List assigns = dao.listClusters(); + Assert.assertEquals(1, assigns.size()); + } + // data source + { + Kafka2TupleMetadata dataSource = new Kafka2TupleMetadata(); + dataSource.setName("ds"); + OpResult result = dao.addDataSource(dataSource); + Assert.assertEquals(200, result.code); + List assigns = dao.listDataSources(); + Assert.assertEquals(1, assigns.size()); + } + // policy + { + PolicyDefinition policy = new PolicyDefinition(); + policy.setName("ds"); + OpResult result = dao.addPolicy(policy); + Assert.assertEquals(200, result.code); + List assigns = dao.listPolicies(); + Assert.assertEquals(1, assigns.size()); + } + // publishment + { + Publishment publishment = new Publishment(); + publishment.setName("pub-"); + OpResult result = dao.addPublishment(publishment); + Assert.assertEquals(200, result.code); + List assigns = dao.listPublishment(); + Assert.assertEquals(1, assigns.size()); + } + // publishment + { + PublishmentType publishmentType = new PublishmentType(); + publishmentType.setType("KAFKA"); + OpResult result = dao.addPublishmentType(publishmentType); + Assert.assertEquals(200, result.code); + List assigns = dao.listPublishmentType(); + Assert.assertEquals(1, assigns.size()); + } + } + + private void test_addstate() { + ScheduleState state = new ScheduleState(); + state.setVersion("state-" + System.currentTimeMillis()); + state.setGenerateTime(String.valueOf(new Date().getTime())); + OpResult result = dao.addScheduleState(state); + Assert.assertEquals(200, result.code); + } + + @Test + public void test_readCurrentState() { + test_addstate(); + ScheduleState state = dao.getScheduleState(); + Assert.assertNotNull(state); + + System.out.println(state.getVersion()); + System.out.println(state.getGenerateTime()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/application-mongo.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/application-mongo.conf b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/application-mongo.conf new file mode 100644 index 0000000..0becbfc --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/application-mongo.conf @@ -0,0 +1,21 @@ +# 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. + +{ + "datastore": { + "metadataDao": "org.apache.eagle.service.alert.resource.impl.InMemMetadataDaoImpl", + "connection": "localhost:27017" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/policy-sample.json ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/policy-sample.json b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/policy-sample.json new file mode 100644 index 0000000..56a53e7 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/alert-metadata/src/test/resources/policy-sample.json @@ -0,0 +1,32 @@ +{ + "name": "policy1", + "description": "test policy", + "inputStreams": [ + "in-stream-1", + "in-stream-2" + ], + "outputStreams": [ + "out-stream-1" + ], + "definition": { + "type": "siddhiCEPEngine", + "value": "select count(*) from in-stream-1" + }, + "partitionSpec": [ + { + "streamId": "in-stream-1", + "type": "GROUPBY", + "columns": [ + "col-1", + "col-2" + ], + "sortSpec": { + "column": "col-1", + "windowPeriod": "60", + "order": "asc", + "windowMargin": 30000 + } + } + ], + "parallelismHint": 2 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/pom.xml b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/pom.xml new file mode 100644 index 0000000..f344667 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/alert-metadata-parent/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + + + org.apache.eagle + eagle-alert + 0.4.0-incubating-SNAPSHOT + ../pom.xml + + alert-metadata-parent + pom + + + alert-metadata + alert-metadata-service + + http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/eagle-alert/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/eagle-alert/pom.xml b/eagle-core/eagle-alert-parent/eagle-alert/pom.xml new file mode 100644 index 0000000..b065869 --- /dev/null +++ b/eagle-core/eagle-alert-parent/eagle-alert/pom.xml @@ -0,0 +1,392 @@ + + + + 4.0.0 + + + org.apache.eagle + eagle-alert-parent + 0.4.0-incubating-SNAPSHOT + ../pom.xml + + + eagle-alert + pom + + + alert-common + alert-engine + alert-metadata-parent + alert-coordinator + alert-assembly + alert-devtools + + + + + 1.8 + + + UTF-8 + 2.0.2 + + + 4.12 + + + 1.2.1 + 19.0 + 3.3.2 + 3.2.1 + 2.6 + 0.6.1 + 3.1.0 + 3.0.0-M6 + + + 3.0.5 + + + 1.7 + 1.4 + + + 2.4.5 + 1.9.13 + 2.4.5 + 1.9.13 + + + 0.9.3 + 0.9.3.2.2.0.0-2041 + 0.8.2.0 + 0.8.1.2.2.0.0-2041 + kafka_2.10 + 0.3 + 1.7.20 + 1.7.20 + 1.1.7 + + + 1.19.1 + + + + + 9.2.3.v20140905 + 7.0.55 + 1.5.8 + 2.8.0 + 3.2.2 + 1.10.19 + 2.2 + 2.2.0 + + + + + Maven Central Repository + http://central.maven.org/maven2/ + + + HDP Release Repository + http://repo.hortonworks.com/content/repositories/releases/ + + + HDP Central Repository + http://repo.hortonworks.com/content/repositories/central/ + + + WSO2 Public + http://maven.wso2.org/nexus/content/groups/wso2-public + + + + + + + com.fasterxml.jackson.core + jackson-core + ${fastxml.version} + + + com.fasterxml.jackson.core + jackson-databind + ${fastxml.version} + + + javax.mail + mail + ${javax.mail.version} + + + org.apache.velocity + velocity + ${velocity.version} + + + org.mockito + mockito-all + ${mockito.version} + + + org.apache.curator + curator-framework + ${curator-framework.version} + + + org.apache.curator + curator-recipes + ${curator-framework.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${fasterxml-jackson.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + commons-collections + commons-collections + ${commons-collections.version} + + + commons-lang + commons-lang + ${commons-lang.version} + + + junit + junit + ${junit.version} + test + + + com.fasterxml.jackson.core + jackson-databind + ${fasterxml-jackson.version} + + + org.apache.storm + storm-kafka + ${storm-kafka.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j-log4j12.veresion} + + + org.apache.storm + storm-core + ${storm.version} + + + org.slf4j + log4j-over-slf4j + + + org.apache.logging.log4j + log4j-slf4j-impl + + + ch.qos.logback + logback-classic + + + + + org.apache.kafka + ${kafka.artifact.id} + ${kafka.version} + + + org.sfl4j + slf4j-log4j + + + + + com.sun.jersey + jersey-client + ${jersey.version} + + + org.codehaus.jackson + jackson-jaxrs + ${codehaus-jackson.version} + + + org.codehaus.jackson + jackson-xc + ${codehaus-jackson.version} + + + org.codehaus.jackson + jackson-mapper-asl + ${codehaus-jackson.version} + + + com.typesafe + config + ${typesafe-config.version} + + + com.netflix.archaius + archaius-core + ${archaius.version} + + + io.dropwizard.metrics + metrics-core + ${metrics.version} + + + io.dropwizard.metrics + metrics-jvm + ${metrics.version} + + + org.wso2.siddhi + siddhi-core + ${siddhi.version} + + + org.slf4j + slf4j-simple + + + + + org.wso2.siddhi + siddhi-query-api + ${siddhi.version} + + + org.wso2.siddhi + siddhi-query-compiler + ${siddhi.version} + + + org.wso2.siddhi + siddhi-extension-regex + ${siddhi.version} + + + org.wso2.siddhi + siddhi-extension-string + ${siddhi.version} + + + org.apache.kafka + kafka-clients + ${kafka-clients.version} + + + + org.slf4j + slf4j-log4j12 + + + + + com.101tec + zkclient + ${zkclient.version} + + + com.sun.jersey + jersey-server + ${jersey.version} + + + com.sun.jersey + jersey-servlet + ${jersey.version} + + + com.sun.jersey.contribs + jersey-multipart + ${jersey.version} + + + org.apache.tomcat.embed + tomcat-embed-core + ${tomcat-embed.version} + + + com.google.guava + guava + ${guava.version} + + + org.slf4j + slf4j-api + ${slf4j-api.veresion} + + + + + + + + io.swagger + swagger-jaxrs + ${swagger.version} + + + org.mapdb + mapdb + ${mapdb.version} + + + joda-time + joda-time + ${joda.version} + + + + org.elasticsearch + metrics-elasticsearch-reporter + ${metrics-elasticsearch-reporter.version} + + + + + + + + + maven-compiler-plugin + ${maven-compiler.version} + + ${java.version} + ${java.version} + UTF-8 + 2048m + true + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + + + http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert-parent/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert-parent/pom.xml b/eagle-core/eagle-alert-parent/pom.xml new file mode 100644 index 0000000..6a383e8 --- /dev/null +++ b/eagle-core/eagle-alert-parent/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + org.apache.eagle + eagle-core + 0.4.0-incubating-SNAPSHOT + ../pom.xml + + + eagle-alert-parent + pom + + eagle-alert-parent + + eagle-alert + eagle-alert-base + eagle-alert-process + eagle-alert-service + eagle-alert-notification-plugin + + http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/.gitignore ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/.gitignore b/eagle-core/eagle-alert/alert/.gitignore deleted file mode 100644 index 12af842..0000000 --- a/eagle-core/eagle-alert/alert/.gitignore +++ /dev/null @@ -1,80 +0,0 @@ -# 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. - -# Eagle - Git Ignore Configuration -# -# See: https://github.com/github/gitignore/ - -*.class -*.out - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.ear - -.cache-main - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -# Maven -target/ -target/* -*/target/* -**/target/* -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -eagle-security/eagle-security-mltraining/src/test/resources/outputDir/ -eagle-security/eagle-security-userprofile/src/test/resources/models/ - -# IntelliJ IDEA -.idea/ -.metadata/ -**.iml -**.eml -**.patch -mobile.userlibraries - -# Eclipse -build -.metadata -.classpath -.project -.settings -.externalToolBuilders -classes -# bin - -# Temporary files -logs/ -*.log* -# Mac files -.DS_Store - -*.cache-tests -application-local.conf - -*.orig -**/*.pyc -*.bak http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/README.md ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/README.md b/eagle-core/eagle-alert/alert/README.md deleted file mode 100644 index e23ef68..0000000 --- a/eagle-core/eagle-alert/alert/README.md +++ /dev/null @@ -1,169 +0,0 @@ - - -## Prerequisites - -* [Apache Maven](https://maven.apache.org/) -* [Java 8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) - -## Documentation - - -## Build - - mvn install - -## Setup -The alert engine have three dependency module: Coordinator Service, Metadata Service, and engine runtime(storm topologies). - -####0. Dependencies -> Alert engine need kafka as data source, ZK as coordination. Check alert-devtools/bin to start zk and kafka through start-zk-kafka.sh. - -####1. Start metadata service -> For local dev, project alert-metadata-service packaging as a war, and enabled mvn jetty:run to run it. By default, metadata runs on localhost:8080 - -> For deployment, after mvn install, a war is avaialble in alert-metadata-service/target - -####2. Start coordiantor service -> For local dev, project alert-coordinator packaing as a war, and enabled mvn jetty:run to run it. By default, it runs in localhost:9090, and have dependency on metadata. See application.conf for coordinator. - -> For deployment, find war in alert-coordinator/target after mvn install - -####3. Start engine runtime. -> The engine are the topologies that runs in any storm (local or remote) with configuration to connect to the ZK and metadata service. The alert engine runtime main as in UnitTopologyMain.java. The started storm bolt should have the same name described in alert-metadata. Example of the configuration is /alert-engine-base/src/main/resources/application.conf - -See below detailed steps. - - -## Run -* pre-requisites - * zookeeper - * storm - * kafka - * tomcat - * mongdb - -* Run Metadata service - 1. copy alert-metadata/target/alert-metadata-0.0.1-SNAPSHOT.war into tomcat webapps/alertmetadata.war - 2. check config under webapps/alertmetadata/WEB-INF/classes/application.conf - ```json - { - "datastore": { - "metadataDao": "org.apache.eagle.alert.metadata.impl.MongoMetadataDaoImpl", - "connection": "localhost:27017" - } - } - ``` - - 3. start tomcat - -* Run Coordinator service - 1. copy alert-coordinator/target/alert-coordinator-0.0.1-SNAPSHOT.war to tomcat webappes/coordinator.war - 2. check config under webapps/coordinator/WEB-INF/classes/application.conf - ```json - { - "coordinator" : { - "policiesPerBolt" : 5, - "boltParallelism" : 5, - "policyDefaultParallelism" : 5, - "boltLoadUpbound": 0.8, - "topologyLoadUpbound" : 0.8, - "numOfAlertBoltsPerTopology" : 5, - "zkConfig" : { - "zkQuorum" : "localhost:2181", - "zkRoot" : "/alert", - "zkSessionTimeoutMs" : 10000, - "connectionTimeoutMs" : 10000, - "zkRetryTimes" : 3, - "zkRetryInterval" : 3000 - }, - "metadataService" : { - "host" : "localhost", - "port" : 8080, - "context" : "/alertmetadata/api" - }, - "metadataDynamicCheck" : { - "initDelayMillis" : 1000, - "delayMillis" : 30000 - } - } - } - ``` - 3. start tomcat - -* Run UnitTopologyMain - 1. copy alert-assembly/target/alert-engine-0.0.1-SNAPSHOT-alert-assembly.jar to somewhere close to your storm installation - 2. check config application.conf - ```json - { - "topology" : { - "name" : "alertUnitTopology_1", - "numOfTotalWorkers" : 2, - "numOfSpoutTasks" : 1, - "numOfRouterBolts" : 4, - "numOfAlertBolts" : 10, - "numOfPublishTasks" : 1, - "messageTimeoutSecs": 3600, - "localMode" : "true" - }, - "spout" : { - "kafkaBrokerZkQuorum": "localhost:2181", - "kafkaBrokerZkBasePath": "/brokers", - "stormKafkaUseSameZkQuorumWithKafkaBroker": true, - "stormKafkaTransactionZkQuorum": "", - "stormKafkaTransactionZkPath": "/consumers", - "stormKafkaEagleConsumer": "eagle_consumer", - "stormKafkaStateUpdateIntervalMs": 2000, - "stormKafkaFetchSizeBytes": 1048586, - }, - "zkConfig" : { - "zkQuorum" : "localhost:2181", - "zkRoot" : "/alert", - "zkSessionTimeoutMs" : 10000, - "connectionTimeoutMs" : 10000, - "zkRetryTimes" : 3, - "zkRetryInterval" : 3000 - }, - "dynamicConfigSource" : { - "initDelayMillis": 3000, - "delayMillis" : 10000 - }, - "metadataService": { - "context" : "/alertmetadata/api", - "host" : "localhost", - "port" : 8080 - }, - "coordinatorService": { - "host": "localhost", - "port": 8080, - "context" : "/coordinator/api" - } - "metric": { - "sink": { - "stdout": {} - } - } -} -``` - Note: please make sure the above configuration is used by storm instead of the configuration within fat jar - 3. start storm - storm jar alert-engine-0.0.1-SNAPSHOT-alert-assembly.jar org.apache.eagle.alert.engine.UnitTopologyMain - -## Support - http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-assembly/pom.xml b/eagle-core/eagle-alert/alert/alert-assembly/pom.xml deleted file mode 100644 index 3f5b341..0000000 --- a/eagle-core/eagle-alert/alert/alert-assembly/pom.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - 4.0.0 - - - org.apache.eagle - alert-parent - 0.0.1-SNAPSHOT - - - alert-assembly - jar - - - - org.apache.eagle - alert-common - ${project.version} - - - org.apache.eagle - alert-coordinator - ${project.version} - war - - - org.apache.eagle - alert-metadata-service - ${project.version} - war - - - org.apache.eagle - alert-engine-base - ${project.version} - - - - - org.apache.eagle - alert-common - ${project.version} - test-jar - - - org.apache.eagle - alert-coordinator - ${project.version} - test-jar - - - org.apache.eagle - alert-engine-base - ${project.version} - test-jar - - - - - - - src/resources - - - - - maven-assembly-plugin - - src/assembly/alert-assembly.xml - alert-engine-${project.version} - - - - package - - single - - - posix - - - - - - - http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-assembly/src/assembly/alert-assembly.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-assembly/src/assembly/alert-assembly.xml b/eagle-core/eagle-alert/alert/alert-assembly/src/assembly/alert-assembly.xml deleted file mode 100644 index b61e6b2..0000000 --- a/eagle-core/eagle-alert/alert/alert-assembly/src/assembly/alert-assembly.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - alert-assembly - - jar - - false - - - / - false - true - runtime - - - - - org.apache.storm:storm-core - org.slf4j:slf4j-api - org.slf4j:log4j-over-slf4j - org.slf4j:slf4j-log4j12 - log4j:log4j - asm:asm - org.apache.log4j.wso2:log4j - log4j:apache-log4j-extras - - - - - - ${project.build.outputDirectory} - / - - - - - - - \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/.gitignore ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/.gitignore b/eagle-core/eagle-alert/alert/alert-common/.gitignore deleted file mode 100644 index 1dd3331..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target/ -/target/ http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/737e5a2d/eagle-core/eagle-alert/alert/alert-common/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-alert/alert/alert-common/pom.xml b/eagle-core/eagle-alert/alert/alert-common/pom.xml deleted file mode 100644 index 129cff0..0000000 --- a/eagle-core/eagle-alert/alert/alert-common/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - 4.0.0 - - - org.apache.eagle - alert-parent - 0.0.1-SNAPSHOT - - - alert-common - jar - - - - com.typesafe - config - - - com.fasterxml.jackson.core - jackson-annotations - - - org.apache.commons - commons-lang3 - - - commons-collections - commons-collections - - - commons-lang - commons-lang - - - junit - junit - test - - - com.google.guava - guava - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-log4j12 - - - org.apache.curator - curator-framework - - - org.apache.curator - curator-recipes - - - com.fasterxml.jackson.core - jackson-databind - - - com.sun.jersey - jersey-client - - - org.codehaus.jackson - jackson-jaxrs - - - joda-time - joda-time - - - io.dropwizard.metrics - metrics-core - - - org.apache.storm - storm-core - - - org.elasticsearch - metrics-elasticsearch-reporter - - - org.apache.kafka - kafka-clients - - - org.apache.kafka - ${kafka.artifact.id} - - - io.dropwizard.metrics - metrics-jvm - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.6 - - - - test-jar - - - - - - -