Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge pull request #338 from hawkular/integration-latest-of-everything
Browse files Browse the repository at this point in the history
Integration latest of everything
  • Loading branch information
jkremser committed Jul 22, 2015
2 parents 5614902 + 8c21500 commit f2031fc
Show file tree
Hide file tree
Showing 54 changed files with 2,567 additions and 204 deletions.
31 changes: 31 additions & 0 deletions console/src/main/scripts/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#
# 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.
#

# EditorConfig: http://EditorConfig.org

# top-most EditorConfig file
root= true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{js,ts,html,less,css,json}]
indent_style = space
indent_size = 2
2 changes: 1 addition & 1 deletion console/src/main/scripts/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"angular-toastr": "1.4.1",
"bootstrap-select": "1.6",
"hawkular-charts": "~0.4.6",
"hawkular-ui-services": "0.5.1",
"hawkular-ui-services": "0.5.2",
"hawtio-core-navigation": "2.0.51",
"hawtio-core": "2.0.16",
"hawtio-template-cache": "2.0.3",
Expand Down
29 changes: 15 additions & 14 deletions console/src/main/scripts/plugins/metrics/ts/alertsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ module HawkularMetrics {
addEmailAction(email: EmailType): ng.IPromise<void>;
createAction(email: EmailType): ng.IPromise<void>;
updateTrigger(triggerId: TriggerId, data: any): ng.IPromise<void>;
createTrigger(triggerName: string, enabled: boolean, conditionType: string, email: EmailType): ng.IPromise<void>;
createTrigger(triggerId: TriggerId, triggerName: string, enabled: boolean, conditionType: string,
email: EmailType): ng.IPromise<void>;
deleteTrigger(triggerId: TriggerId): ng.IPromise<void>;
createCondition(triggerId: TriggerId, condition: any): ng.IPromise<void>;
updateCondition(triggerId: TriggerId, conditionId: ConditionId, condition: any): ng.IPromise<void>;
Expand All @@ -56,7 +57,7 @@ module HawkularMetrics {
private AlertService:any) {
}

public createTrigger(triggerName: string, enabled: boolean,
public createTrigger(id: TriggerId, triggerName: string, enabled: boolean,
conditionType: string, email: EmailType): ng.IPromise<void> {
// Create a trigger
var triggerId: TriggerId;
Expand All @@ -66,7 +67,7 @@ module HawkularMetrics {

return this.HawkularAlert.Trigger.save({
name: triggerName,
id: triggerName,
id: id,
description: 'Created on ' + Date(),
firingMatch: 'ALL',
autoResolveMatch: 'ALL',
Expand All @@ -78,7 +79,7 @@ module HawkularMetrics {
triggerId = trigger.id;

// Parse metrics id from the trigger name
var dataId: string = trigger.name.slice(0,-14) + '.status.duration';
var dataId: string = trigger.id.slice(0,-14) + '.status.duration';

// Create a conditions for that trigger
if (conditionType === 'THRESHOLD') {
Expand All @@ -102,14 +103,14 @@ module HawkularMetrics {
return this.createCondition(triggerId, {
type: conditionType,
triggerId: triggerId,
dataId: trigger.name.slice(0,-14),
dataId: trigger.id.slice(0,-14),
operator: 'DOWN'
}).then(()=> {
return this.createCondition(triggerId, {
type: conditionType,
triggerId: triggerId,
triggerMode: 'AUTORESOLVE',
dataId: trigger.name.slice(0,-14),
dataId: trigger.id.slice(0,-14),
operator: 'UP'
});
});
Expand Down Expand Up @@ -290,18 +291,18 @@ module HawkularMetrics {
var count: number = 0.0;

for (var j = 0; j < serverAlert.evalSets.length; j++) {
var eval = serverAlert.evalSets[j][0];
var evalItem = serverAlert.evalSets[j][0];

if (!consoleAlert.start && eval.dataTimestamp) {
consoleAlert.start = eval.dataTimestamp;
if (!consoleAlert.start && evalItem.dataTimestamp) {
consoleAlert.start = evalItem.dataTimestamp;
}

if (!consoleAlert.threshold && eval.condition.threshold) {
consoleAlert.threshold = eval.condition.threshold;
if (!consoleAlert.threshold && evalItem.condition.threshold) {
consoleAlert.threshold = evalItem.condition.threshold;
}

if (!consoleAlert.type && eval.condition.type) {
consoleAlert.type = eval.condition.type;
if (!consoleAlert.type && evalItem.condition.type) {
consoleAlert.type = evalItem.condition.type;
}

var momentAlert = this.$moment(consoleAlert.end);
Expand All @@ -313,7 +314,7 @@ module HawkularMetrics {
}
}

sum += eval.value;
sum += evalItem.value;
count++;
}

Expand Down
16 changes: 8 additions & 8 deletions console/src/main/scripts/plugins/metrics/ts/urlList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ module HawkularMetrics {

var resourceId = this.md5.createHash(url || '');
var resource = {
resourceTypeId: 'URL',
resourceTypePath: '/URL',
id: resourceId,
properties: {
url: url
Expand All @@ -110,16 +110,16 @@ module HawkularMetrics {
console.dir(newResource);
this.$log.info('New Resource ID: ' + metricId + ' created.');

var metricsIds: string[] = [metricId + '.status.duration', metricId + '.status.code'];
var metricsIds: string[] = [metricId + '.status.duration',metricId + '.status.code'];
var metrics = [{
id: metricsIds[0],
metricTypeId: 'status.duration.type',
metricTypePath: '/status.duration.type',
properties: {
description: 'Response Time in ms.'
}
}, {
id: metricsIds[1],
metricTypeId: 'status.code.type',
metricTypePath: '/status.code.type',
properties: {
description: 'Status Code'
}
Expand All @@ -135,7 +135,7 @@ module HawkularMetrics {
this.HawkularInventory.ResourceMetric.save({
environmentId: globalEnvironmentId,
resourceId: resourceId
}, metricsIds).$promise;
}, ['../' + metricsIds[0], '../' + metricsIds[1]]).$promise;

/// For right now we will just Register a couple of metrics automatically
return this.$q.all([createMetric(metrics[0]), createMetric(metrics[1])])
Expand All @@ -148,13 +148,13 @@ module HawkularMetrics {
(e) => err(e, 'Error during saving metrics.'))

// Create threshold trigger for newly created metrics
.then(() => this.HawkularAlertsManager.createTrigger(metricId + '_trigger_thres', true, 'THRESHOLD',
.then(() => this.HawkularAlertsManager.createTrigger(metricId + '_trigger_thres', url, true, 'THRESHOLD',
defaultEmail),
(e) => err(e, 'Error saving email action.'))

// Create availability trigger for newly created metrics
.then((alert) => this.HawkularAlertsManager.createTrigger(metricId + '_trigger_avail', false, 'AVAILABILITY',
defaultEmail),
.then((alert) => this.HawkularAlertsManager.createTrigger(metricId + '_trigger_avail', url, false,
'AVAILABILITY', defaultEmail),
(e) => err(e, 'Error saving threshold trigger.'))

//this.$location.url('/hawkular/' + metricId);
Expand Down
3 changes: 2 additions & 1 deletion dist/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>org.hawkular.inventory:hawkular-integrated-inventory-rest</include>
<include>org.hawkular:hawkular-feed-comm-war</include>
<include>org.hawkular:hawkular-pinger</include>
<include>org.hawkular:hawkular-avail-creator</include>
<include>org.hawkular.accounts:hawkular-accounts:war</include>
<include>org.hawkular.alerts:hawkular-alerts-ear</include>
<include>org.hawkular.alerts:hawkular-alerts-rest:war</include>
<include>org.hawkular.alerts:hawkular-actions-email</include>
<include>org.hawkular.metrics:hawkular-metrics-api-jaxrs</include>
<include>org.hawkular.commons:hawkular-commons-embedded-cassandra-ear</include>
Expand Down
9 changes: 7 additions & 2 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<artifactId>hawkular-integrated-inventory-rest</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.hawkular</groupId>
<artifactId>hawkular-feed-comm-war</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.hawkular</groupId>
<artifactId>hawkular-pinger</artifactId>
Expand All @@ -84,8 +89,8 @@
</dependency>
<dependency>
<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-alerts-ear</artifactId>
<type>ear</type>
<artifactId>hawkular-alerts-rest</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.hawkular.alerts</groupId>
Expand Down
17 changes: 6 additions & 11 deletions modules/avail-creator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.1_spec</artifactId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -49,6 +49,11 @@
<version>1.1-rev-1</version> <!-- TODO move to parent -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand All @@ -59,11 +64,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version> <!-- TODO move to parent -->
</dependency>

<dependency>
<groupId>org.hawkular.bus</groupId>
Expand Down Expand Up @@ -99,11 +99,6 @@
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</artifactItem>
<artifactItem>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.component.availcreator;

import java.util.List;

import org.hawkular.bus.common.BasicMessage;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* @author Lucas Ponce
*/
public class AvailDataMessage extends BasicMessage {

@JsonInclude
private AvailData availData;

protected AvailDataMessage() {
}

public AvailDataMessage(AvailData metricData) {
this.availData = metricData;
}

public AvailData getAvailData() {
return availData;
}

public void setAvailData(AvailData availData) {
this.availData = availData;
}

public static class AvailData {
@JsonInclude
List<SingleAvail> data;

public AvailData() {
}

public List<SingleAvail> getData() {
return data;
}

public void setData(List<SingleAvail> data) {
this.data = data;
}

@Override
public String toString() {
return "AvailData [data=" + data + "]";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
Expand All @@ -32,14 +30,13 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.hawkular.bus.common.BasicMessage;
import org.hawkular.bus.common.ConnectionContextFactory;
import org.hawkular.bus.common.Endpoint;
import org.hawkular.bus.common.MessageProcessor;
import org.hawkular.bus.common.ObjectMessage;
import org.hawkular.bus.common.producer.ProducerConnectionContext;

import com.google.gson.Gson;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Publish Avail data
Expand Down Expand Up @@ -77,7 +74,12 @@ public void sendToMetricsViaRest(List<SingleAvail> availabilities) {
Availability availability = new Availability(avr.timestamp, avr.avail.toLowerCase());
List<Availability> list = new ArrayList<>(1);
list.add(availability);
String payload = new Gson().toJson(list);
String payload = null;
try {
payload = new ObjectMapper().writeValueAsString(list);
} catch (JsonProcessingException e) {
Log.LOG.eCouldNotParseMessage(e);
}
request.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON));

try {
Expand All @@ -93,16 +95,14 @@ public void sendToMetricsViaRest(List<SingleAvail> availabilities) {

public void publishToTopic(List<SingleAvail> availRecordList, MetricReceiver metricReceiver) {
if (metricReceiver.topic != null) {
Map<String, Object> outer = new HashMap<>(1);
Map<String, Object> data = new HashMap<>(2);
data.put("data", availRecordList);
outer.put("availData", data);
AvailDataMessage.AvailData availData = new AvailDataMessage.AvailData();
availData.setData(availRecordList);

try (ConnectionContextFactory factory = new ConnectionContextFactory(metricReceiver.connectionFactory)) {
Endpoint endpoint = new Endpoint(Endpoint.Type.TOPIC, metricReceiver.topic.getTopicName());
ProducerConnectionContext pc = factory.createProducerConnectionContext(endpoint);
BasicMessage msg = new ObjectMessage(outer);
MessageProcessor processor = new MessageProcessor();
AvailDataMessage msg = new AvailDataMessage(availData);
processor.send(pc, msg);
} catch (Exception e) {
Log.LOG.eCouldNotSendMessage(e);
Expand Down

0 comments on commit f2031fc

Please sign in to comment.