Skip to content

Commit

Permalink
Merge pull request #1 from lucasponce/Initial-Import
Browse files Browse the repository at this point in the history
HWKALERTS-1 Prepare an initial version
  • Loading branch information
jshaughn committed Jan 29, 2015
2 parents 3436f14 + 88f4f1f commit a0312d4
Show file tree
Hide file tree
Showing 94 changed files with 7,685 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,13 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# maven target directories
target/

# IntelliJ
.idea
*.iml

# KDE
.directory
38 changes: 38 additions & 0 deletions README.adoc
@@ -0,0 +1,38 @@
= hawkular-alerts

== hawkular-bus

1. `cd hawkular-bus ; mvn clean install -Pdev`

Note:

Verify that Bus is configured in failover mode due:
https://issues.jboss.org/browse/HAWKULAR-14

== hawkular-alerts

1. `cd hawkular-alerts ; mvn clean install -Pdev`

In case you don't have hawkular-bus and hawkular-alerts project in the same folder you should indicate path of bus:

1. `NEST_HOME=$PATH_TO/hawkular-bus/hawkular-nest/hawkular-nest-distro/target/wildfly-8.2.0.Final`
2. `cd hawkular-alerts ; mvn clean install -Pdev -Dorg.hawkular.wildfly.home=$NEST_HOME`

== Tests

1. Send metrics to Hawkular Bus:

curl -X POST -H "Content-Type: application/json" \
--data "{\"data\" : [ { \"id\": \"NumericData-01\", \"type\" : \"numeric\", \"value\" : 0.1} ]}" \
http://localhost:8080/hawkular-bus/message/MetricsTopic

curl -X POST -H "Content-Type: application/json" \
--data "{\"data\" : [ { \"id\": \"StringData-01\", \"type\" : \"string\", \"value\" : \"Barney\"} ]}" \
http://localhost:8080/hawkular-bus/message/MetricsTopic

curl -X POST -H "Content-Type: application/json" \
--data "{\"data\" : [ { \"id\": \"Availability-01\", \"type\" : \"availability\", \"value\" : \"UP\"} ]}" \
http://localhost:8080/hawkular-bus/message/MetricsTopic



94 changes: 94 additions & 0 deletions examples/example-alerts-ui/pom.xml
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2015 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed 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>org.hawkular.alerts</groupId>
<artifactId>hawkular-alerts</artifactId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
</parent>

<groupId>org.hawkular.alerts</groupId>
<artifactId>example-alerts-ui</artifactId>
<packaging>war</packaging>
<name>Example Alerts UI REST Client</name>

<properties>
<org.hawkular.wildfly.home>${project.basedir}/../../../hawkular-bus/hawkular-nest/hawkular-nest-distro/target/wildfly-${version.org.wildfly}</org.hawkular.wildfly.home>
<org.hawkular.wildfly.deployments>${org.hawkular.wildfly.home}/modules/system/layers/base/org/hawkular/nest/main/deployments</org.hawkular.wildfly.deployments>
</properties>

<dependencies>

<!-- The Servlet API is provided by the container -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.1_spec</artifactId>
<version>${version.org.jboss.spec}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
</build>

<profiles>
<profile>
<id>dev</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<configuration>
<tasks>
<copy file="${project.build.directory}/${project.build.finalName}.war"
todir="${org.hawkular.wildfly.deployments}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
22 changes: 22 additions & 0 deletions examples/example-alerts-ui/src/main/webapp/WEB-INF/jboss-web.xml
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<!--
Copyright 2015 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed 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.
-->
<jboss-web>
<context-root>example-alerts-ui</context-root>
</jboss-web>
24 changes: 24 additions & 0 deletions examples/example-alerts-ui/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,24 @@
<!--
Copyright 2015 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed 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.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

</web-app>
26 changes: 26 additions & 0 deletions examples/example-alerts-ui/src/main/webapp/index.jsp
@@ -0,0 +1,26 @@
<%--
Copyright 2015 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed 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.
--%>
<html>
<head>
<title>Example Hawkular Alerts UI</title>
</head>
<body>
<h3>Example Hawkular Alerts UI</h3>
</body>
</html>
55 changes: 55 additions & 0 deletions hawkular-alerts-api/pom.xml
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2015 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed 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>org.hawkular.alerts</groupId>
<artifactId>hawkular-alerts</artifactId>
<version>1.0.0.Alpha1-SNAPSHOT</version>
</parent>

<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-alerts-api</artifactId>
<packaging>jar</packaging>
<name>Hawkular Alerts Api</name>

<dependencies>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${version.org.slf4j}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
@@ -0,0 +1,94 @@
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed 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.hawkular.alerts.api.model.condition;

import java.util.List;
import java.util.Set;

/**
* A status of an alert thrown by several matched conditions.
*
* @author Jay Shaughnessy
* @author Lucas Ponce
*/
public class Alert {

private String triggerId;
private List<Set<ConditionEval>> evals;
private long time;

public Alert(String triggerId, List<Set<ConditionEval>> evals) {
this.triggerId = triggerId;
this.evals = evals;
this.time = System.currentTimeMillis();
}

public List<Set<ConditionEval>> getEvals() {
return evals;
}

public void setEvals(List<Set<ConditionEval>> evals) {
this.evals = evals;
}

public long getTime() {
return time;
}

public void setTime(long time) {
this.time = time;
}

public String getTriggerId() {
return triggerId;
}

public void setTriggerId(String triggerId) {
this.triggerId = triggerId;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Alert alert = (Alert) o;

if (time != alert.time) return false;
if (evals != null ? !evals.equals(alert.evals) : alert.evals != null) return false;
if (triggerId != null ? !triggerId.equals(alert.triggerId) : alert.triggerId != null) return false;

return true;
}

@Override
public int hashCode() {
int result = triggerId != null ? triggerId.hashCode() : 0;
result = 31 * result + (evals != null ? evals.hashCode() : 0);
result = 31 * result + (int) (time ^ (time >>> 32));
return result;
}

@Override
public String toString() {
return "Alert{" +
"evals=" + evals +
", triggerId='" + triggerId + '\'' +
", time=" + time +
'}';
}
}

0 comments on commit a0312d4

Please sign in to comment.