Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HWKALERTS-68 #78

Merged
merged 14 commits into from
Jul 31, 2015
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions hawkular-alerts-actions-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@

<dependencies>

<!-- Hawkular Alerts dependencies -->
<dependency>
<groupId>org.hawkular.alerts</groupId>
<artifactId>hawkular-alerts-api</artifactId>
<version>${project.version}</version>
</dependency>

<!-- The hawkular platform will provide these -->
<dependency>
<groupId>org.hawkular.bus</groupId>
<artifactId>hawkular-bus-mdb</artifactId>
<version>${version.org.hawkular.bus}</version>
<scope>provided</scope>
</dependency>

<!-- Wildfly dependencies -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
Expand All @@ -56,6 +50,7 @@
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -70,6 +65,7 @@
<scope>provided</scope>
</dependency>

<!-- Tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.actions.api;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Define an alerts actions plugin implementation
* Plugin must have a valid name that will be used at registration phase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what is a valid name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.
At the moment there is not any strict validation, the plugin must be just a string.
But I think that in the future we can add some regexp for valid (i.e. not starting with number, special characters, etc).
So, no restriction on this version now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

* Plugin must implement ActionPluginListener interface
*
* @author Lucas Ponce
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface ActionPlugin {
String name();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.actions.api;

import java.util.Map;
import java.util.Set;

/**
* A listener that will initialize the plugin and process incoming messages.
*
* @author Lucas Ponce
*/
public interface ActionPluginListener {

/**
* The alerts engine registers the plugins available with their properties.
* This method is invoked at plugin registration time.
*
* @return a list of properties available on this plugin
*/
Set<String> getProperties();

/**
* The alerts engine registers the plugins available with their default values.
* This method is invoked at plugin registration time.
* Default values can be modified by the alerts engine.
*
*
* @return a list of default values for properties available on this plugin
*/
Map<String, String> getDefaultProperties();

/**
* This method is invoked by the ActionService to process a new action generated by the engine.
*
* @param msg PluginMessage received to be processed by the plugin
* @throws Exception any problem
*/
void process(PluginMessage msg) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.alerts.actions.api.log;
package org.hawkular.alerts.actions.api;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.actions.api;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Map;
import org.hawkular.alerts.api.model.action.Action;

/**
* A message sent to the plugin from the alerts engine
* It has the alert payload as well as action properties
*
* @author Lucas Ponce
*/
public interface PluginMessage {

@JsonInclude
Action getAction();

@JsonInclude
Map<String, String> getProperties();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.actions.api;

import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Map;
import java.util.Set;

/**
* A message sent to the alerts engine from the plugin
* It defines a code of operation and payloads
*
* It used for plugin registration but additional operations should be supported
*
* @author Lucas Ponce
*/
public interface PluginOpMessage {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal preference, less abbreviation: PluginOperationMessage. Having said that. "Operation" is a term that may be getting overused. Perhaps PluginMessageType.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer PluginOperationMessage. PluginMessageType is not meaningful here - I think - as this is an operation message sent by the plugin.
The type is an internal field to define the operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


enum Operation {
REGISTRATION
}

@JsonInclude
Operation getOperation();

@JsonInclude
String getActionPlugin();

@JsonInclude
Set<String> getPropertyNames();

@JsonInclude
Map<String, String> getDefaultProperties();
}

This file was deleted.

Loading