Skip to content

Commit

Permalink
HWKALERTS-40 Tenant integration
Browse files Browse the repository at this point in the history
Conflicts:
	hawkular-alerts-api/src/main/java/org/hawkular/alerts/api/model/trigger/Tag.java
	hawkular-alerts-api/src/main/java/org/hawkular/alerts/api/services/AlertsService.java
	hawkular-alerts-api/src/main/java/org/hawkular/alerts/api/services/DefinitionsService.java
	hawkular-alerts-engine/pom.xml
	hawkular-alerts-engine/src/main/resources/hawkular-alerts/actions.data
	hawkular-alerts-engine/src/main/resources/hawkular-alerts/triggers.data
	hawkular-alerts-engine/src/test/resources/hawkular-alerts/actions.data
	hawkular-alerts-engine/src/test/resources/hawkular-alerts/triggers.data
	hawkular-alerts-rest-tests/pom.xml
	hawkular-alerts-rest-tests/src/test/wildfly-data/hawkular-alerts/actions.data
	hawkular-alerts-rest-tests/src/test/wildfly-data/hawkular-alerts/triggers.data
	pom.xml
  • Loading branch information
lucasponce committed May 27, 2015
1 parent 3239fcb commit 1fd3783
Show file tree
Hide file tree
Showing 60 changed files with 3,593 additions and 2,530 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ notifications:
install:
- mvn -version -B
script:
- mvn -s .travis.maven.settings.xml verify -Prest
# -Prest profile is disabled until hakwular-dist is stable in nexus and we can integrate keycloak changes
# Integration tests should be run locally until we fix this.
#
# - mvn -s .travis.maven.settings.xml verify -Prest
- mvn -s .travis.maven.settings.xml verify
env:
global:
- secure: TQJ1pIBM6dGgCQj59OiYxmKI2Nk+0XIT9His/iBt4FGRXHQ4BqWZuMVbtiX0ngGJbyg6Ntq9mJwmioGNl3tyK3jY9eqD/pWg8XjA9YAn+UINSBS3ooPYgAwIjTuJp6o7x9xExLEKCdzyttFjQ0BG+AkNvIEVyjSTZq7ky/ngbP4=
Expand Down
22 changes: 11 additions & 11 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,21 @@ is required for unit and integration tests.
1.5. mvn install
```

2. Prepare *hawkular-bus* in your local environment
2. Prepare *hawkular* in your local environment

```shell
git clone https://github.com/hawkular/hawkular-bus.git
cd hawkular-bus
git clone https://github.com/hawkular/hawkular.git
cd hawkular
mvn clean install -Pdev
```

Profile *-Pdev* creates a pre-configured wildfly-8.2.0.Final server with all dependencies needed in

```shell
$YOUR_FOLDER/hawkular-bus/hawkular-nest/hawkular-nest-distro/target/wildfly-8.2.0.Final
$YOUR_FOLDER/hawkular/dist/target/hawkular-1.0.0-SNAPSHOT/wildfly-8.2.0.Final
```

We will call this wildfly server as *$NEST_HOME*
We will call this wildfly server as *$HAWKULAR_HOME*

[start=3]
3. Prepare *hawkular-alerts* in your local environment
Expand All @@ -132,19 +132,19 @@ cd hawkular-alerts
mvn clean install -Pdev
```

Profile *-Pdev* copies *hawkular-alerts* artifacts into *$NEST_HOME*. +
If *hawkular-bus* and *hawkular-alerts* are not in the same folder, you can define the location of wildfly server like:
Profile *-Pdev* copies *hawkular-alerts* artifacts into *$HAWKULAR_HOME*. +
If *hawkular* and *hawkular-alerts* are not in the same folder, you can define the location of wildfly server like:

```shell
NEST_HOME=$PATH_TO/hawkular-bus/hawkular-nest/hawkular-nest-distro/target/wildfly-8.2.0.Final
mvn clean install -Pdev -Dorg.hawkular.wildfly.home=$NEST_HOME
HAWKULAR_HOME=$PATH_TO/hawkular/dist/target/hawkular-1.0.0-SNAPSHOT/wildfly-8.2.0.Final
mvn clean install -Pdev -Dorg.hawkular.wildfly.home=$HAWKULAR_HOME
```

[start=4]
4. Start the nest:
4. Start hawkular with your local :

```shell
cd $NEST_HOME
cd $HAWKULAR_HOME
bin/standalone.sh
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
*/
public class Action {

@JsonInclude
private String tenantId;

@JsonInclude
private String actionPlugin;

@JsonInclude
private String actionId;

Expand All @@ -41,11 +47,21 @@ public class Action {

public Action() { }

public Action(String actionId, String message) {
public Action(String tenantId, String actionPlugin, String actionId, String message) {
this.tenantId = tenantId;
this.actionPlugin = actionPlugin;
this.actionId = actionId;
this.message = message;
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

public String getMessage() {
return message;
}
Expand All @@ -62,31 +78,45 @@ public void setActionId(String actionId) {
this.actionId = actionId;
}

public String getActionPlugin() {
return actionPlugin;
}

public void setActionPlugin(String actionPlugin) {
this.actionPlugin = actionPlugin;
}

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

Action that = (Action) o;
Action action = (Action) o;

if (message != null ? !message.equals(that.message) : that.message != null) return false;
if (actionId != null ? !actionId.equals(that.actionId) : that.actionId != null) return false;
if (tenantId != null ? !tenantId.equals(action.tenantId) : action.tenantId != null) return false;
if (actionPlugin != null ? !actionPlugin.equals(action.actionPlugin) : action.actionPlugin != null)
return false;
if (actionId != null ? !actionId.equals(action.actionId) : action.actionId != null) return false;
return !(message != null ? !message.equals(action.message) : action.message != null);

return true;
}

@Override
public int hashCode() {
int result = actionId != null ? actionId.hashCode() : 0;
int result = tenantId != null ? tenantId.hashCode() : 0;
result = 31 * result + (actionPlugin != null ? actionPlugin.hashCode() : 0);
result = 31 * result + (actionId != null ? actionId.hashCode() : 0);
result = 31 * result + (message != null ? message.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "Action{" +
"message=" + (message == null ? null : '\'' + message + '\'') +
"tenantId='" + tenantId + '\'' +
", actionPlugin='" + actionPlugin + '\'' +
", actionId='" + actionId + '\'' +
", message='" + message + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public enum Status {
OPEN, ACKNOWLEDGED, RESOLVED
};

@JsonInclude
private String tenantId;

// This is a generated composite of form: triggerId|ctime
@JsonInclude
private String alertId;
Expand Down Expand Up @@ -75,7 +78,8 @@ public Alert() {
// for json assembly
}

public Alert(String triggerId, List<Set<ConditionEval>> evalSets) {
public Alert(String tenantId, String triggerId, List<Set<ConditionEval>> evalSets) {
this.tenantId = tenantId;
this.triggerId = triggerId;
this.evalSets = evalSets;
this.ctime = System.currentTimeMillis();
Expand All @@ -84,6 +88,14 @@ public Alert(String triggerId, List<Set<ConditionEval>> evalSets) {
this.alertId = triggerId + "|" + ctime;
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

public String getAlertId() {
return alertId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public enum Type {
AVAILABILITY, COMPARE, STRING, THRESHOLD, RANGE
}

@JsonInclude
protected String tenantId;

/**
* The owning trigger
*/
Expand Down Expand Up @@ -121,6 +124,14 @@ public String getConditionId() {
return conditionId;
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

private void updateId() {
StringBuilder sb = new StringBuilder(triggerId);
sb.append("-").append(triggerMode.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public enum Type {
@JsonIgnore
private transient List<Set<ConditionEval>> satisfyingEvals = new ArrayList<Set<ConditionEval>>();

@JsonInclude
private String tenantId;

public Dampening() {
this("Default", Mode.FIRING, Type.STRICT, 1, 1, 0);
}
Expand Down Expand Up @@ -281,6 +284,14 @@ public void addSatisfyingEvals(ConditionEval... satisfyingEvals) {
this.satisfyingEvals.add(new HashSet<ConditionEval>(Arrays.asList(satisfyingEvals)));
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

public void perform(ConditionEval... conditionEvals) {
boolean trueEval = true;
for (ConditionEval ce : conditionEvals) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
public class Tag {

private String tenantId;
private String triggerId;
private String category;
private String name;
Expand All @@ -46,21 +47,21 @@ public Tag(String name) {
* Create a searchable Tag on category + name
*
* @param category Nullable
* @param tag NotEmpty
* @param name NotEmpty
*/
public Tag(String category, String tag) {
this(null, category, tag, false);
public Tag(String category, String name) {
this(null, category, name, false);
}

/**
* Create an invisible Tag for persisting.
*
* @param triggerId Nullable Note, required for storage but not search.
* @param category Nullable
* @param tag NotEmpty
* @param name NotEmpty
*/
public Tag(String triggerId, String category, String tag) {
this(triggerId, category, tag, false);
public Tag(String triggerId, String category, String name) {
this(triggerId, category, name, false);
}

/**
Expand Down Expand Up @@ -113,47 +114,47 @@ public void setVisible(boolean visible) {
this.visible = visible;
}

public String getTenantId() {
return tenantId;
}

public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}

@Override
public String toString() {
return "Tag [triggerId=" + triggerId + ", category=" + category + ", name=" + name + ", visible=" + visible
+ "]";
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Tag tag = (Tag) o;

if (visible != tag.visible) return false;
if (tenantId != null ? !tenantId.equals(tag.tenantId) : tag.tenantId != null) return false;
if (triggerId != null ? !triggerId.equals(tag.triggerId) : tag.triggerId != null) return false;
if (category != null ? !category.equals(tag.category) : tag.category != null) return false;
return !(name != null ? !name.equals(tag.name) : tag.name != null);

}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((category == null) ? 0 : category.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((triggerId == null) ? 0 : triggerId.hashCode());
int result = tenantId != null ? tenantId.hashCode() : 0;
result = 31 * result + (triggerId != null ? triggerId.hashCode() : 0);
result = 31 * result + (category != null ? category.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (visible ? 1 : 0);
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Tag other = (Tag) obj;
if (category == null) {
if (other.category != null)
return false;
} else if (!category.equals(other.category))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (triggerId == null) {
if (other.triggerId != null)
return false;
} else if (!triggerId.equals(other.triggerId))
return false;
return true;
public String toString() {
return "Tag{" +
"tenantId='" + tenantId + '\'' +
", triggerId='" + triggerId + '\'' +
", category='" + category + '\'' +
", name='" + name + '\'' +
", visible=" + visible +
'}';
}

}

0 comments on commit 1fd3783

Please sign in to comment.