http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-embed/eagle-embed-server/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-embed/eagle-embed-server/pom.xml b/eagle-core/eagle-embed/eagle-embed-server/pom.xml deleted file mode 100644 index d5b5e50..0000000 --- a/eagle-core/eagle-embed/eagle-embed-server/pom.xml +++ /dev/null @@ -1,85 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>eagle</groupId> - <artifactId>eagle-embed-parent</artifactId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>eagle-embed-server</artifactId> - <packaging>jar</packaging> - <name>eagle-embed-server</name> - <dependencies> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-core</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-el</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-jasper</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-logging-juli</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-logging-log4j</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-websocket</artifactId> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </dependency> - <!--<dependency>--> - <!--<groupId>org.slf4j</groupId>--> - <!--<artifactId>slf4j-log4j12</artifactId>--> - <!--</dependency>--> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>log4j-over-slf4j</artifactId> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>test-jar</id> - <phase>test-compile</phase> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project>
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-embed/eagle-embed-server/runEmbeddedServer.sh ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-embed/eagle-embed-server/runEmbeddedServer.sh b/eagle-core/eagle-embed/eagle-embed-server/runEmbeddedServer.sh deleted file mode 100755 index a1ac537..0000000 --- a/eagle-core/eagle-embed/eagle-embed-server/runEmbeddedServer.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# 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. - -export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) -mvn -X exec:java -Dexec.mainClass="org.apache.eagle.service.embedded.tomcat.EmbeddedServer" -Dexec.args="../../../eagle-security/eagle-security-webservice/target/eagle-service 38080" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-embed/eagle-embed-server/src/main/java/org/apache/eagle/service/embedded/tomcat/EmbeddedServer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-embed/eagle-embed-server/src/main/java/org/apache/eagle/service/embedded/tomcat/EmbeddedServer.java b/eagle-core/eagle-embed/eagle-embed-server/src/main/java/org/apache/eagle/service/embedded/tomcat/EmbeddedServer.java deleted file mode 100644 index 35d3967..0000000 --- a/eagle-core/eagle-embed/eagle-embed-server/src/main/java/org/apache/eagle/service/embedded/tomcat/EmbeddedServer.java +++ /dev/null @@ -1,109 +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. - */ -package org.apache.eagle.service.embedded.tomcat; - -import java.io.File; - -import org.apache.catalina.LifecycleState; -import org.apache.catalina.startup.Tomcat; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EmbeddedServer { - - private static EmbeddedServer server; - private Tomcat tomcat; - private String webappDirLocation; - private int port; - private static int DEFAULT_TOMCAT_PORT = 38080; - private static final Logger LOG = LoggerFactory.getLogger(EmbeddedServer.class); - - public static void main(String[] args) { - // args: webappLocation, port - int tomcatPort; - if (args.length > 1) { - tomcatPort = Integer.valueOf(args[1]); - } else { - tomcatPort = DEFAULT_TOMCAT_PORT; - } - new EmbeddedServer(args[0], tomcatPort).start(); - } - - private EmbeddedServer(String webappDirLocation) { - this(webappDirLocation, DEFAULT_TOMCAT_PORT); - } - - private EmbeddedServer(String webappDirLocation, int port) { - this.webappDirLocation = webappDirLocation; - this.port = port; - } - - public static EmbeddedServer getInstance(String webappDirLocation) { - if (server == null) { - synchronized(EmbeddedServer.class) { - if (server == null) { - server = new EmbeddedServer(webappDirLocation); - server.start(); - } - } - } - return server; - } - - public int getPort() { - return port; - } - - public void start() { - tomcat = new Tomcat(); - tomcat.setHostname("localhost"); - tomcat.setPort(port); - try { - tomcat.addWebapp("/eagle-service", new File(webappDirLocation).getAbsolutePath()); - tomcat.start(); - - } catch (Exception ex) { - LOG.error("Got an exception " + ex.getMessage()); - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - shutdown(); - } - catch (Throwable t) { - LOG.error("Got an exception why shutting down..." + t.getMessage()); - } - } - }); - try { - Thread.sleep(10000000); - }catch(Exception ex){ - ex.printStackTrace(); - } - } - - public void shutdown() throws Throwable { - if (tomcat.getServer() != null && tomcat.getServer().getState() != LifecycleState.DESTROYED) { - if (tomcat.getServer().getState() != LifecycleState.STOPPED) { - tomcat.stop(); - } - tomcat.destroy(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-embed/eagle-embed-server/src/test/java/org/apache/eagle/service/embedded/tomcat/TestEmbeddedServer.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-embed/eagle-embed-server/src/test/java/org/apache/eagle/service/embedded/tomcat/TestEmbeddedServer.java b/eagle-core/eagle-embed/eagle-embed-server/src/test/java/org/apache/eagle/service/embedded/tomcat/TestEmbeddedServer.java deleted file mode 100644 index 1351ac7..0000000 --- a/eagle-core/eagle-embed/eagle-embed-server/src/test/java/org/apache/eagle/service/embedded/tomcat/TestEmbeddedServer.java +++ /dev/null @@ -1,26 +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. - */ -package org.apache.eagle.service.embedded.tomcat; - -public class TestEmbeddedServer { - - //@Test - public void test() throws Throwable{ - String webappDirLocation = "../../../eagle-webservice/target/eagle-service"; - EmbeddedServer.getInstance(webappDirLocation); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-embed/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-embed/pom.xml b/eagle-core/eagle-embed/pom.xml deleted file mode 100644 index 098e9a6..0000000 --- a/eagle-core/eagle-embed/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>eagle-core</artifactId> - <groupId>eagle</groupId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>eagle-embed-parent</artifactId> - <packaging>pom</packaging> - - <modules> - <module>eagle-embed-hbase</module> - <module>eagle-embed-server</module> - </modules> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/pom.xml b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/pom.xml deleted file mode 100644 index ed0ac4d..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>eagle</groupId> - <artifactId>eagle-machinelearning-parent</artifactId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - <artifactId>eagle-machinelearning-base</artifactId> - <name>eagle-machinelearning-base</name> - <url>http://maven.apache.org</url> - <dependencies> - <dependency> - <groupId>eagle</groupId> - <artifactId>eagle-alert-process</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAlgorithmEvaluator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAlgorithmEvaluator.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAlgorithmEvaluator.java deleted file mode 100644 index 800b6e0..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAlgorithmEvaluator.java +++ /dev/null @@ -1,50 +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. - */ -package org.apache.eagle.ml; - -import com.typesafe.config.Config; -import org.apache.eagle.dataproc.core.ValuesArray; -import org.apache.eagle.ml.model.MLAlgorithm; -import org.apache.eagle.policy.PolicyEvaluationContext; - -/** - * Machine Learning Algorithm Evaluator - */ -public interface MLAlgorithmEvaluator { - /** - * Prepare Machine learning algorithm - * - * @param algorithm MLAlgorithm instance - */ - public void init(MLAlgorithm algorithm, Config config, PolicyEvaluationContext context); - - /** - * Evaluate input user profile model - * - * @param data ValuesArray - * @throws Exception - */ - public void evaluate(ValuesArray data) throws Exception; - - /** - * Register callback - * - * @param callbackObj MachineLearningCallback - * @throws Exception - */ - public void register(MLAnomalyCallback callbackObj) throws Exception; -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAnomalyCallback.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAnomalyCallback.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAnomalyCallback.java deleted file mode 100644 index 5005c42..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLAnomalyCallback.java +++ /dev/null @@ -1,28 +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. - */ -package org.apache.eagle.ml; - -import org.apache.eagle.policy.PolicyEvaluationContext; -import org.apache.eagle.ml.model.MLCallbackResult; - -public interface MLAnomalyCallback { - /** - * @param callbackResult call-backed result - * @param alertContext context - */ - void receive(MLCallbackResult callbackResult,PolicyEvaluationContext alertContext); -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLConstants.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLConstants.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLConstants.java deleted file mode 100644 index 9197d59..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLConstants.java +++ /dev/null @@ -1,24 +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. - */ - -package org.apache.eagle.ml; - -public class MLConstants { - public final static String ML_MODEL_SERVICE_NAME = "MLModelService"; - public final static String ALGORITHM = "algorithm"; - public final static String USER = "user"; -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLModelDAO.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLModelDAO.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLModelDAO.java deleted file mode 100644 index 13eb7e1..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLModelDAO.java +++ /dev/null @@ -1,30 +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. - */ -package org.apache.eagle.ml; - -import org.apache.eagle.ml.model.MLModelAPIEntity; - -import java.util.List; - -public interface MLModelDAO { - /** - * @param user - * @param algorithm - * @return - */ - List<MLModelAPIEntity> findMLModelByContext(String user, String algorithm); -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLPolicyEvaluator.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLPolicyEvaluator.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLPolicyEvaluator.java deleted file mode 100644 index 36bcaec..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/MLPolicyEvaluator.java +++ /dev/null @@ -1,170 +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. - */ -package org.apache.eagle.ml; - -import com.typesafe.config.Config; -import org.apache.commons.lang3.StringUtils; -import org.apache.eagle.alert.entity.AlertAPIEntity; -import org.apache.eagle.alert.entity.AlertDefinitionAPIEntity; -import org.apache.eagle.dataproc.core.JsonSerDeserUtils; -import org.apache.eagle.dataproc.core.ValuesArray; -import org.apache.eagle.ml.impl.MLAnomalyCallbackImpl; -import org.apache.eagle.ml.model.MLAlgorithm; -import org.apache.eagle.ml.model.MLPolicyDefinition; -import org.apache.eagle.ml.utils.MLReflectionUtils; -import org.apache.eagle.policy.PolicyEvaluationContext; -import org.apache.eagle.policy.PolicyEvaluator; -import org.apache.eagle.policy.PolicyManager; -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.policy.config.AbstractPolicyDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class MLPolicyEvaluator implements PolicyEvaluator<AlertDefinitionAPIEntity> { - private static Logger LOG = LoggerFactory.getLogger(MLPolicyEvaluator.class); - private volatile MLRuntime mlRuntime; - private Config config; - private Map<String,String> context; - private final PolicyEvaluationContext<AlertDefinitionAPIEntity, AlertAPIEntity> evalContext; - - private class MLRuntime{ - MLPolicyDefinition mlPolicyDef; - MLAlgorithmEvaluator[] mlAlgorithmEvaluators; - List<MLAnomalyCallback> mlAnomalyCallbacks = new ArrayList<>(); - } - - public MLPolicyEvaluator(Config config, PolicyEvaluationContext<AlertDefinitionAPIEntity, AlertAPIEntity> evalContext, AbstractPolicyDefinition policyDef, String[] sourceStreams){ - this(config, evalContext, policyDef, sourceStreams, false); - } - - /** - * needValidation does not take effect for machine learning use case - * @param policyDef - * @param sourceStreams - * @param needValidation - */ - public MLPolicyEvaluator(Config config, PolicyEvaluationContext<AlertDefinitionAPIEntity, AlertAPIEntity> evalContext, AbstractPolicyDefinition policyDef, String[] sourceStreams, boolean needValidation){ - this.config = config; - this.evalContext = evalContext; - LOG.info("Initializing policy named: " + evalContext.policyId); - this.context = new HashMap<>(); - this.context.put(Constants.SOURCE_STREAMS, StringUtils.join(sourceStreams,",")); - this.init(policyDef); - } - - public void init(AbstractPolicyDefinition policyDef){ - LOG.info("Initializing MLPolicyEvaluator ..."); - try{ - mlRuntime = newMLRuntime((MLPolicyDefinition) policyDef); - }catch(Exception e){ - LOG.error("ML Runtime creation failed: " + e.getMessage()); - } - } - - private MLRuntime newMLRuntime(MLPolicyDefinition mlPolicyDef) { - MLRuntime runtime = new MLRuntime(); - - try{ - runtime.mlPolicyDef = mlPolicyDef; - - LOG.info("policydef: " + ((runtime.mlPolicyDef == null)? "policy definition is null": "policy definition is not null")); - Properties alertContext = runtime.mlPolicyDef.getContext(); - LOG.info("alert context received null? " + ((alertContext == null? "yes": "no"))); - MLAnomalyCallback callbackImpl = new MLAnomalyCallbackImpl(this, config); - runtime.mlAnomalyCallbacks.add(callbackImpl); - - MLAlgorithm[] mlAlgorithms = mlPolicyDef.getAlgorithms(); - runtime.mlAlgorithmEvaluators = new MLAlgorithmEvaluator[mlAlgorithms.length]; - LOG.info("mlAlgorithms size:: " + mlAlgorithms.length); - int i = 0; - for(MLAlgorithm algorithm:mlAlgorithms){ - MLAlgorithmEvaluator mlAlgorithmEvaluator = MLReflectionUtils.newMLAlgorithmEvaluator(algorithm); - mlAlgorithmEvaluator.init(algorithm, config, evalContext); - runtime.mlAlgorithmEvaluators[i] = mlAlgorithmEvaluator; - LOG.info("mlAlgorithmEvaluator: " + mlAlgorithmEvaluator.toString()); - mlAlgorithmEvaluator.register(callbackImpl); - i++; - } - }catch(Exception ex){ - LOG.error("Failed to create runtime for policy named: "+this.getPolicyName(),ex); - } - return runtime; - } - - @Override - public void evaluate(ValuesArray data) throws Exception { - LOG.info("Evaluate called with input: " + data.size()); - synchronized(mlRuntime){ - for(MLAlgorithmEvaluator mlAlgorithm:mlRuntime.mlAlgorithmEvaluators){ - mlAlgorithm.evaluate(data); - } - } - } - - @Override - public void onPolicyUpdate(AlertDefinitionAPIEntity newAlertDef) { - LOG.info("onPolicyUpdate called"); - AbstractPolicyDefinition policyDef = null; - try { - policyDef = JsonSerDeserUtils.deserialize(newAlertDef.getPolicyDef(), - AbstractPolicyDefinition.class, PolicyManager.getInstance().getPolicyModules(newAlertDef.getTags().get("policyType"))); - } catch (Exception ex) { - LOG.error("initial policy def error, ", ex); - } - MLRuntime previous = mlRuntime; - mlRuntime = newMLRuntime((MLPolicyDefinition) policyDef); - synchronized (previous) { - previous.mlAnomalyCallbacks = null; - previous.mlAlgorithmEvaluators = null; - previous.mlPolicyDef = null; - } - previous = null; - } - - @Override - public void onPolicyDelete() { - LOG.info("onPolicyDelete called"); - MLRuntime previous = mlRuntime; - synchronized (previous) { - previous.mlAnomalyCallbacks = null; - previous.mlAlgorithmEvaluators = null; - previous.mlPolicyDef = null; - } - previous = null; - } - - public String getPolicyName() { - return evalContext.policyId; - } - - @Override - public Map<String, String> getAdditionalContext() { - return this.context; - } - - public List<String> getOutputStreamAttrNameList() { - return new ArrayList<String>(); - } - - @Override - public boolean isMarkdownEnabled() { return false; } - - @Override - public String getMarkdownReason() { return null; } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLAnomalyCallbackImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLAnomalyCallbackImpl.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLAnomalyCallbackImpl.java deleted file mode 100644 index a889361..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLAnomalyCallbackImpl.java +++ /dev/null @@ -1,107 +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. - */ -package org.apache.eagle.ml.impl; - -import java.lang.management.ManagementFactory; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.alert.entity.AlertAPIEntity; -import org.apache.eagle.policy.PolicyEvaluationContext; -import org.apache.eagle.common.DateTimeUtil; -import org.apache.eagle.common.config.EagleConfigConstants; -import org.apache.eagle.common.metric.AlertContext; -import org.apache.eagle.ml.MLAnomalyCallback; -import org.apache.eagle.ml.MLPolicyEvaluator; -import org.apache.eagle.ml.model.MLCallbackResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.typesafe.config.Config; - -public class MLAnomalyCallbackImpl implements MLAnomalyCallback { - private static Logger LOG = LoggerFactory.getLogger(MLAnomalyCallbackImpl.class); - private MLPolicyEvaluator mlAlertEvaluator; - private Config config; - - - public static final String source = ManagementFactory.getRuntimeMXBean().getName(); - - public MLAnomalyCallbackImpl(MLPolicyEvaluator mlAlertEvaluator, Config config){ - this.mlAlertEvaluator = mlAlertEvaluator; - this.config = config; - } - - /** - * TODO: generate alert - * - * @param aResult - * @param alertContext context - */ - @Override - public void receive(MLCallbackResult aResult,PolicyEvaluationContext alertContext) { - LOG.info("Receive called with : " + aResult.toString()); - AlertAPIEntity alert = renderAlert(aResult,alertContext); - alertContext.alertExecutor.onEvalEvents(alertContext, Arrays.asList(alert)); - } - - private AlertAPIEntity renderAlert(MLCallbackResult aResult,PolicyEvaluationContext alertContext){ - String site = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.SITE); - String applicatioin = config.getString(EagleConfigConstants.EAGLE_PROPS + "." + EagleConfigConstants.APPLICATION); - - AlertAPIEntity entity = new AlertAPIEntity(); - entity.setDescription(aResult.toString()); - - Map<String, String> tags = new HashMap<>(); - tags.put(EagleConfigConstants.SITE, site); - tags.put(EagleConfigConstants.APPLICATION, applicatioin); - tags.put(Constants.SOURCE_STREAMS, (String)alertContext.evaluator.getAdditionalContext().get(Constants.SOURCE_STREAMS)); - tags.put(Constants.POLICY_ID, alertContext.policyId); - tags.put(Constants.ALERT_SOURCE, source); - tags.put(Constants.ALERT_EXECUTOR_ID, alertContext.alertExecutor.getExecutorId()); - entity.setTags(tags); - - entity.setTimestamp(aResult.getTimestamp()); - - AlertContext context = new AlertContext(); - - if(aResult.getContext() != null) context.addAll(aResult.getContext()); - - String alertMessage = "Anomaly activities detected by algorithm ["+aResult.getAlgorithmName()+"] with information: " + aResult.toString() ; - context.addProperty(Constants.ALERT_EVENT, aResult.toString()); - context.addProperty(Constants.ALERT_MESSAGE, alertMessage); - context.addProperty(Constants.ALERT_TIMESTAMP_PROPERTY, DateTimeUtil.millisecondsToHumanDateWithSeconds(System.currentTimeMillis())); - - try { - site = config.getString("eagleProps.site"); - applicatioin = config.getString("eagleProps.application"); - context.addProperty(EagleConfigConstants.APPLICATION, applicatioin); - context.addProperty(EagleConfigConstants.SITE, site); - } catch (Exception ex) { - LOG.error("site, dataSource not set in config file, ", ex); - } - - context.addProperty(EagleConfigConstants.APPLICATION, applicatioin); - context.addProperty(EagleConfigConstants.SITE, site); - context.addProperty(Constants.POLICY_NAME, alertContext.policyId); - - entity.setAlertContext(context); - return entity; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLModelDAOImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLModelDAOImpl.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLModelDAOImpl.java deleted file mode 100644 index 1e3067e..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLModelDAOImpl.java +++ /dev/null @@ -1,62 +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. - */ -package org.apache.eagle.ml.impl; - -import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity; -import org.apache.eagle.ml.MLConstants; -import org.apache.eagle.ml.MLModelDAO; -import org.apache.eagle.ml.model.MLModelAPIEntity; -import org.apache.eagle.service.client.EagleServiceConnector; -import org.apache.eagle.service.client.IEagleServiceClient; -import org.apache.eagle.service.client.impl.EagleServiceClientImpl; -import org.apache.commons.lang.time.DateUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -public class MLModelDAOImpl implements MLModelDAO { - private final Logger LOG = LoggerFactory.getLogger(MLModelDAOImpl.class); - private final EagleServiceConnector connector; - - public MLModelDAOImpl(EagleServiceConnector connector){ - this.connector = connector; - } - - @Override - public List<MLModelAPIEntity> findMLModelByContext(String user, String algorithm) { - try { - IEagleServiceClient client = new EagleServiceClientImpl(connector); - String query = MLConstants.ML_MODEL_SERVICE_NAME + "[@user=\"" + user + "\" AND @algorithm=\"" - + algorithm + "\"]{*}"; - GenericServiceAPIResponseEntity<MLModelAPIEntity> response = client.search().startTime(0) - .endTime(10 * DateUtils.MILLIS_PER_DAY) - .pageSize(Integer.MAX_VALUE) - .query(query) - .send(); - if(!response.isSuccess()) { - LOG.error(String.format("Failed to get model for user: %s, algorithm: %s, due to: %s",user,algorithm,response.getException())); - } - - client.close(); - return response.getObj(); - } catch (Exception ex) { - LOG.info("Got an exception when query machinelearning model service ", ex); - throw new IllegalStateException(ex); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLPolicyEvaluatorServiceProviderImpl.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLPolicyEvaluatorServiceProviderImpl.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLPolicyEvaluatorServiceProviderImpl.java deleted file mode 100644 index d0ac75f..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/impl/MLPolicyEvaluatorServiceProviderImpl.java +++ /dev/null @@ -1,52 +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. - */ -package org.apache.eagle.ml.impl; - -import org.apache.eagle.policy.common.Constants; -import org.apache.eagle.policy.PolicyEvaluator; -import org.apache.eagle.policy.PolicyEvaluatorServiceProvider; -import org.apache.eagle.ml.MLPolicyEvaluator; -import org.apache.eagle.ml.model.MLPolicyDefinition; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.databind.module.SimpleModule; - -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -public class MLPolicyEvaluatorServiceProviderImpl implements PolicyEvaluatorServiceProvider { - - private final static String ALERT_CONTEXT = "alertContext"; - - @Override - public String getPolicyType() { - return Constants.policyType.MachineLearning.name(); - } - - @Override - public Class<? extends PolicyEvaluator> getPolicyEvaluator() { - return MLPolicyEvaluator.class; - } - - @Override - public List<Module> getBindingModules() { - Module module1 = new SimpleModule(Constants.POLICY_DEFINITION).registerSubtypes(new NamedType(MLPolicyDefinition.class, getPolicyType())); - Module module2 = new SimpleModule(ALERT_CONTEXT).registerSubtypes(new NamedType(Properties.class, getPolicyType())); - return Arrays.asList(module1, module2); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLAlgorithm.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLAlgorithm.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLAlgorithm.java deleted file mode 100644 index 24b4bad..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLAlgorithm.java +++ /dev/null @@ -1,61 +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. - */ -package org.apache.eagle.ml.model; - -import java.io.Serializable; - -public class MLAlgorithm implements Serializable { - private static final long serialVersionUID = -223531147520123L; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - private String name; - private String evaluator; - private String description; - - public String getFeatures() { - return features; - } - - public void setFeatures(String features) { - this.features = features; - } - - private String features; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getEvaluator() { - return evaluator; - } - - public void setEvaluator(String evaluator) { - this.evaluator = evaluator; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLCallbackResult.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLCallbackResult.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLCallbackResult.java deleted file mode 100644 index b457973..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLCallbackResult.java +++ /dev/null @@ -1,137 +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. - */ -package org.apache.eagle.ml.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class MLCallbackResult { - private boolean isAnomaly; - private List<String> feature; - private double confidence; - private long timestamp; - private List<String> datapoints; - private String id; - private String algorithmName; - - public Map<String, String> getContext() { - return context; - } - - public void setContext(Map<String, String> context) { - this.context = context; - } - - public void setAlgorithmName(String algorithmName) { - this.algorithmName = algorithmName; - } - - private Map<String,String> context; - - public String getAlgorithmName() { - return algorithmName; - } - public void setAlgorithm(String algorithmName) { - this.algorithmName = algorithmName; - } - public MLCallbackResult(){ - feature = new ArrayList<String>(); - setDatapoints(new ArrayList<String>()); - } - public boolean isAnomaly() { - return isAnomaly; - } - public void setAnomaly(boolean isAnomaly) { - this.isAnomaly = isAnomaly; - } - public List<String> getFeature() { - return feature; - } - public void setFeature(List<String> feature) { - this.feature = feature; - } - - private boolean doesFeatureExist(String f){ - boolean alreadyExist = false; - for(String s:feature){ - if(s.equalsIgnoreCase(f)) - alreadyExist = true; - } - return alreadyExist; - } - public void setFeature(String aFeature) { - if(doesFeatureExist(aFeature) == false) - feature.add(aFeature); - } - public double getConfidence() { - return confidence; - } - public void setConfidence(double confidence) { - this.confidence = confidence; - } - public String toString(){ - StringBuffer resultStr = new StringBuffer(); - resultStr.append("datapoint :<"); - int i=0; - for(String d:datapoints){ - if(i < datapoints.size()-1){ - resultStr.append(d.trim()); - resultStr.append(","); - i++; - }else - resultStr.append(d.trim()); - } - resultStr.append("> for user: ").append(id).append(" is anomaly: ").append(this.isAnomaly).append(" at timestamp: ").append(this.timestamp); - if(this.isAnomaly){ - //resultStr.append(" with confidence: " + this.confidence); - resultStr.append(" with algorithm: " + algorithmName); - resultStr.append(" with features: "); - int p=0; - resultStr.append("["); - for(String s:feature){ - if(p < feature.size()-1){ - resultStr.append(s.trim()); - resultStr.append(","); - p++; - }else - resultStr.append(s.trim()); - } - resultStr.append("]"); - } - return resultStr.toString(); - } - - public long getTimestamp() { - return timestamp; - } - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - public List<String> getDatapoints() { - return datapoints; - } - public void setDatapoints(List<String> datapoints) { - this.datapoints = datapoints; - } - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLEntityRepository.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLEntityRepository.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLEntityRepository.java deleted file mode 100644 index 883847a..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLEntityRepository.java +++ /dev/null @@ -1,25 +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. - */ -package org.apache.eagle.ml.model; - -import org.apache.eagle.log.entity.repo.EntityRepository; - -public class MLEntityRepository extends EntityRepository { - public MLEntityRepository() { - entitySet.add(MLModelAPIEntity.class); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLModelAPIEntity.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLModelAPIEntity.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLModelAPIEntity.java deleted file mode 100644 index 6f91ca6..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLModelAPIEntity.java +++ /dev/null @@ -1,67 +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. - */ -package org.apache.eagle.ml.model; - -import org.apache.eagle.ml.MLConstants; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; - -import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity; -import org.apache.eagle.log.entity.meta.Column; -import org.apache.eagle.log.entity.meta.ColumnFamily; -import org.apache.eagle.log.entity.meta.Prefix; -import org.apache.eagle.log.entity.meta.Service; -import org.apache.eagle.log.entity.meta.Table; -import org.apache.eagle.log.entity.meta.Tags; -import org.apache.eagle.log.entity.meta.TimeSeries; - -/** - * DDL for creating the table - * create 'mlmodel', {NAME => 'f', BLOOMFILTER => 'ROW', VERSIONS => '1', COMPRESSION => 'SNAPPY'} - */ -@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) -@Table("mlmodel") -@ColumnFamily("f") -@Prefix("mlmodel") -@Service(MLConstants.ML_MODEL_SERVICE_NAME) -@JsonIgnoreProperties(ignoreUnknown = true) -@TimeSeries(false) -@Tags({"site","user", "algorithm"}) -public class MLModelAPIEntity extends TaggedLogAPIEntity{ - @Column("b") - private String content; - @Column("c") - private long version; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - valueChanged("content"); - } - - public long getVersion() { - return version; - } - - public void setVersion(long version) { - this.version = version; - valueChanged("version"); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLPolicyDefinition.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLPolicyDefinition.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLPolicyDefinition.java deleted file mode 100644 index 70e0f71..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/model/MLPolicyDefinition.java +++ /dev/null @@ -1,82 +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. - */ -package org.apache.eagle.ml.model; - -import org.apache.eagle.policy.config.AbstractPolicyDefinition; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import java.util.Properties; - -/** - { - "type":"MachineLearning", - "context":{ - "site":"dev", - "dataSource":"userprofile" - "component":"dev-component", - "description":"ML based user profile anomaly detection", - "severity":"WARNING", - "notificationByEmail":"true" - }, - "algorithms":[ - { - "name":"eagle.security.userprofile.util.EigenBasedAnomalyDetection", - "description":"EigenBasedAnomalyDetection", - "features":"getfileinfo, open, listStatus, setTimes, setPermission, rename, mkdirs, create, setReplication, contentSummary, delete" - }, - { - "name":"eagle.security.userprofile.util.KDEBasedAnomalyDetection", - "description":"DensityBasedAnomalyDetection", - "features":"getfileinfo, open, listStatus, setTimes, setPermission, rename, mkdirs, create, setReplication, contentSummary, delete" - } - ] -} - version field is used for model update, so eagle framework can understand that something changes. - - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible=true) -@JsonIgnoreProperties(ignoreUnknown = true) -public class MLPolicyDefinition extends AbstractPolicyDefinition{ - private String version; - private Properties context; - private MLAlgorithm[] algorithms; - - public MLAlgorithm[] getAlgorithms() { - return algorithms; - } - - public void setAlgorithms(MLAlgorithm[] algorithms) { - this.algorithms = algorithms; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public Properties getContext() { - return context; - } - - public void setContext(Properties context) { - this.context = context; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/utils/MLReflectionUtils.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/utils/MLReflectionUtils.java b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/utils/MLReflectionUtils.java deleted file mode 100644 index fe70165..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/java/org/apache/eagle/ml/utils/MLReflectionUtils.java +++ /dev/null @@ -1,38 +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. - */ -package org.apache.eagle.ml.utils; - -import org.apache.eagle.ml.MLAlgorithmEvaluator; -import org.apache.eagle.ml.model.MLAlgorithm; - -/** - * @since 8/14/15 - */ -public class MLReflectionUtils { - /** - * Create a new MLAlgorithmEvaluator based on MLAlgorithm - * - * @param algorithm MLAlgorithm - * @return MLAlgorithmEvaluator object instance - * @throws ClassNotFoundException - * @throws IllegalAccessException - * @throws InstantiationException - */ - public static MLAlgorithmEvaluator newMLAlgorithmEvaluator(MLAlgorithm algorithm) throws ClassNotFoundException, IllegalAccessException, InstantiationException { - return (MLAlgorithmEvaluator) Class.forName(algorithm.getEvaluator()).newInstance(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider deleted file mode 100644 index d7a2754..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/main/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider +++ /dev/null @@ -1,16 +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. - -org.apache.eagle.ml.impl.MLPolicyEvaluatorServiceProviderImpl \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider deleted file mode 100644 index d7a2754..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/META-INF/services/org.apache.eagle.policy.PolicyEvaluatorServiceProvider +++ /dev/null @@ -1,16 +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. - -org.apache.eagle.ml.impl.MLPolicyEvaluatorServiceProviderImpl \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/application.conf ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/application.conf b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/application.conf deleted file mode 100644 index 2125cbc..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/application.conf +++ /dev/null @@ -1,57 +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. - -{ - "envContextConfig" : { - "env" : "storm", - "topologyName" : "securityLogProcessTopology", - "mode" : "local", - "parallelismConfig" : { - } - }, - "dataSourceConfig": { - "flavor" : "stormhdfs", - "hdfsConnection" : "10.225.92.42:9000", - "hdfsPath" : "/tmp/user1", - "copyToPath" : "/Users/user1/Security/hive_files/weeks_file/MLDemo_testing/consolidated", - "fileFormat" : "CSV", - "typeOperation" : "user profile generation", - "userlist": "/UserList.txt", - "containsFileHeader": true - }, - "eagleProps" : { - "application" : "hdfsAuditLog-ML", - "env" : "test", - "mail.host" : "mailHost.com", - "mail.debug" : "true", - "eagleService": { - "host": "localhost", - "port": 9099, - "username": "admin", - "password": "secret" - } - }, - "alertExecutorConfigs" : { - "userAnomalousActivityDetectionAlertExecutor" : { - "parallelism" : 2, - "partitioner" : "org.apache.eagle.policy.DefaultPolicyPartitioner" - } - }, - "dynamicConfigSource" : { - "eagleServiceHost" : "localhost", - "eagleServicePort" : "8080", - "enabled" : "true" - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/log4j.properties b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/log4j.properties deleted file mode 100644 index 71a5dac..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/log4j.properties +++ /dev/null @@ -1,34 +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. - -log4j.rootLogger=INFO, DRFA, stdout -eagle.log.dir=./logs -eagle.log.file=eagle.log - -# standard output -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n - -# Daily Rolling File Appender -log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender -log4j.appender.DRFA.File=${eagle.log.dir}/${eagle.log.file} -log4j.appender.DRFA.DatePattern=.yyyy-MM-dd -# 30-day backup -#log4j.appender.DRFA.MaxBackupIndex=30 -log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout - -# Pattern format: Date LogLevel LoggerName LogMessage -log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p [%t] %c{2}[%L]: %m%n \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/ml-policyDef-UserProfile.txt ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/ml-policyDef-UserProfile.txt b/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/ml-policyDef-UserProfile.txt deleted file mode 100644 index 2f4bcb1..0000000 --- a/eagle-core/eagle-machinelearning/eagle-machinelearning-base/src/test/resources/ml-policyDef-UserProfile.txt +++ /dev/null @@ -1,51 +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. - */ - -{ - "type":"MachineLearning", - "fileTypes":[ - { - "type":"CSV", - "containsHeader":"true", - "fileParserClass":"eagle.ml.CSVFileFormatParser" - } - ], - "alertContext":{ - "cluster":"testCluster", - "datacenter":"testDataCenter", - "component":"testComponent", - "description":"ML based user profile anomaly detection", - "severity":"WARNING", - "notificationByEmail":"true" - }, - "algorithms":[ - { - "name":"org.apache.eagle.security.userprofile.util.EigenBasedAnomalyDetection", - "description":"EigenBasedAnomalyDetection", - "modelPath":"/models/", - "featureSet":"getfileinfo, open, listStatus, setTimes, setPermission, rename, mkdirs, create, setReplication, contentSummary, delete, setOwner, fsck", - "type":"CSV" - }, - { - "name":"org.apache.eagle.security.userprofile.util.KDEBasedAnomalyDetection", - "description":"DensityBasedAnomalyDetection", - "modelPath":"/models/", - "featureSet":"getfileinfo, open, listStatus, setTimes, setPermission, rename, mkdirs, create, setReplication, contentSummary, delete, setOwner, fsck", - "type":"CSV" - } - ] -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-machinelearning/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-machinelearning/pom.xml b/eagle-core/eagle-machinelearning/pom.xml deleted file mode 100644 index 24514d0..0000000 --- a/eagle-core/eagle-machinelearning/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>eagle-core</artifactId> - <groupId>eagle</groupId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>eagle-machinelearning-parent</artifactId> - <packaging>pom</packaging> - <modules> - <module>eagle-machinelearning-base</module> - </modules> -</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/pom.xml ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/pom.xml b/eagle-core/eagle-metric/pom.xml deleted file mode 100644 index c12a2b9..0000000 --- a/eagle-core/eagle-metric/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>eagle</groupId> - <artifactId>eagle-core</artifactId> - <version>0.3.0</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>eagle-metric</artifactId> - <packaging>jar</packaging> - <name>eagle-metric</name> - - <dependencies> - <dependency> - <groupId>io.dropwizard.metrics</groupId> - <artifactId>metrics-core</artifactId> - <version>3.1.2</version> - </dependency> - <dependency> - <groupId>eagle</groupId> - <artifactId>eagle-entity-base</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>eagle</groupId> - <artifactId>eagle-client-base</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> - http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/MetricConstants.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/MetricConstants.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/MetricConstants.java deleted file mode 100644 index 54c069d..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/MetricConstants.java +++ /dev/null @@ -1,24 +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. - * - */ - -package org.apache.eagle.metric; - -public class MetricConstants { - public static final String GENERIC_METRIC_ENTITY_ENDPOINT = "GenericMetricService"; -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleCounterMetric.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleCounterMetric.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleCounterMetric.java deleted file mode 100644 index 0a7f70e..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleCounterMetric.java +++ /dev/null @@ -1,73 +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. - * - */ - -package org.apache.eagle.metric.reportor; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; - -public class EagleCounterMetric extends EagleMetric { - - private static final Logger LOG = LoggerFactory.getLogger(EagleCounterMetric.class); - - public EagleCounterMetric(long latestUserTimeClock, String name, double value, long granularity) { - super(latestUserTimeClock, name, value, granularity); - } - - public EagleCounterMetric(EagleCounterMetric metric) { - super(metric); - } - - public long trim(long latestUserTimeClock) { - return latestUserTimeClock / granularity * granularity; - } - - public void flush(long latestUserTimeClock) { - for (EagleMetricListener listener : metricListeners) { - EagleCounterMetric newEagleMetric = new EagleCounterMetric(this); - newEagleMetric.name = MetricKeyCodeDecoder.addTimestampToMetricKey(trim(latestUserTimeClock), newEagleMetric.name); - listener.onMetricFlushed(Arrays.asList((EagleMetric)newEagleMetric)); - } - } - - public boolean checkIfNeedFlush(long currentUserTimeClock) { - if (currentUserTimeClock - latestUserTimeClock > granularity) { - return true; - } - return false; - } - - public boolean update(double d, long currentUserTimeClock) { - Boolean readyToFlushed = checkIfNeedFlush(currentUserTimeClock); - if (!readyToFlushed) { - if (currentUserTimeClock < latestUserTimeClock) { - LOG.warn("Something must be wrong, event should come in order of userTimeClock"); - } - value.addAndGet(d); - } - else { - flush(latestUserTimeClock); - value.getAndSet(1); - latestUserTimeClock = currentUserTimeClock; - } - return readyToFlushed; - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleGaugeMetric.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleGaugeMetric.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleGaugeMetric.java deleted file mode 100644 index e6fc098..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleGaugeMetric.java +++ /dev/null @@ -1,45 +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. - * - */ - -package org.apache.eagle.metric.reportor; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.Map; - -public class EagleGaugeMetric extends EagleMetric { - - private static final Logger LOG = LoggerFactory.getLogger(EagleGaugeMetric.class); - - public EagleGaugeMetric(long latestUserTimeClock, String name, double value) { - super(latestUserTimeClock, name, value, 0); - } - - public EagleGaugeMetric(EagleGaugeMetric metric) { - super(metric); - } - - public boolean update(double d, long currentUserTimeClock) { - value.getAndSet(d); - this.latestUserTimeClock = currentUserTimeClock; - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetric.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetric.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetric.java deleted file mode 100644 index e45a8ce..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetric.java +++ /dev/null @@ -1,64 +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. - * - */ - -package org.apache.eagle.metric.reportor; - -import com.google.common.util.concurrent.AtomicDouble; -import org.apache.commons.lang.time.DateUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -public abstract class EagleMetric implements IEagleMetric { - - public long latestUserTimeClock; - public AtomicDouble value; - public String name; - public long granularity; - public List<EagleMetricListener> metricListeners = new ArrayList<>(); - private static final Logger LOG = LoggerFactory.getLogger(EagleCounterMetric.class); - - public EagleMetric(EagleMetric metric) { - this.latestUserTimeClock = metric.latestUserTimeClock; - this.name = metric.name; - this.value = new AtomicDouble(metric.value.doubleValue()); - this.granularity = metric.granularity; - } - - public EagleMetric(long latestUserTimeClock, String name, double value, long granularity) { - this.latestUserTimeClock = latestUserTimeClock; - this.name = name; - this.value = new AtomicDouble(value); - this.granularity = granularity; - } - - public EagleMetric(long latestUserTimeClock, String metricName, double value) { - this(latestUserTimeClock, metricName, value, 5 * DateUtils.MILLIS_PER_MINUTE); - } - - public void registerListener(EagleMetricListener listener) { - metricListeners.add(listener); - } - - public Double getValue() { - return value.doubleValue(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricKey.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricKey.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricKey.java deleted file mode 100644 index daf6ddf..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricKey.java +++ /dev/null @@ -1,28 +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. - * - */ - -package org.apache.eagle.metric.reportor; - -import java.util.Map; - -public class EagleMetricKey { - public String metricName; - public Map<String, String> tags; - public long timestamp; -} http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricListener.java ---------------------------------------------------------------------- diff --git a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricListener.java b/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricListener.java deleted file mode 100644 index d8fe7b2..0000000 --- a/eagle-core/eagle-metric/src/main/java/org/apache/eagle/metric/reportor/EagleMetricListener.java +++ /dev/null @@ -1,31 +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. - * - */ - -package org.apache.eagle.metric.reportor; - -import java.util.List; - -public interface EagleMetricListener { - - /** - * The method should be called in thread-safe mode - * @param metrics - */ - void onMetricFlushed(List<EagleMetric> metrics); -}