modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java | 10 -
modules/enterprise/server/jar/intentional-api-changes-since-4.5.1.xml | 12 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 43 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java | 91 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerRemote.java | 90 +++++++++
5 files changed, 234 insertions(+), 12 deletions(-)
New commits:
commit 48e2ecc14bd7d70b6b02909c9ef0149c24eac2bd
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jan 25 16:54:14 2013 +0100
[BZ [RFE] Schedule an operation using cron expression via JBoss ON CLI] Methods scheduleResourceOperationUsingCron() and scheduleGroupOperationUsingCron() have been added to the OperationManager.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 3ce6064..c2cb5db 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -24,8 +24,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.quartz.CronTrigger;
-
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
@@ -111,14 +109,12 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl implements O
throw getExceptionToThrowToClient(t);
}
}
-
+
public void scheduleResourceOperation(int resourceId, String operationName, Configuration parameters,
String description, int timeout, String cronString) throws RuntimeException {
try {
- CronTrigger cronTrigger = new CronTrigger("resource " + resourceId + "_" + operationName, "group",
- cronString);
- ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperation(getSessionSubject(),
- resourceId, operationName, parameters, cronTrigger, description);
+ ResourceOperationSchedule opSchedule = operationManager.scheduleResourceOperationUsingCron(getSessionSubject(),
+ resourceId, operationName, cronString, timeout, parameters, description);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/intentional-api-changes-since-4.5.1.xml b/modules/enterprise/server/jar/intentional-api-changes-since-4.5.1.xml
index c7a95dd..245503e 100644
--- a/modules/enterprise/server/jar/intentional-api-changes-since-4.5.1.xml
+++ b/modules/enterprise/server/jar/intentional-api-changes-since-4.5.1.xml
@@ -21,4 +21,16 @@
<justification>Removed already deprecated web services in this release, this file was used for WS client-server
compatibility</justification>
</difference>
+ <difference>
+ <className>org/rhq/enterprise/server/operation/OperationManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.operation.bean.ResourceOperationSchedule scheduleResourceOperationUsingCron(org.rhq.core.domain.auth.Subject, int, java.lang.String, java.lang.String, int, org.rhq.core.domain.configuration.Configuration, java.lang.String)</method>
+ <justification>Adding a method to a remote API interface is safe. This class is never to be implemented by users.</justification>
+ </difference>
+ <difference>
+ <className>org/rhq/enterprise/server/operation/OperationManagerRemote</className>
+ <differenceType>7012</differenceType> <!-- method added to an interface -->
+ <method>org.rhq.core.domain.operation.bean.GroupOperationSchedule scheduleGroupOperationUsingCron(org.rhq.core.domain.auth.Subject, int, int[], boolean, java.lang.String, org.rhq.core.domain.configuration.Configuration, java.lang.String, int, java.lang.String)</method>
+ <justification>Adding a method to a remote API interface is safe. This class is never to be implemented by users.</justification>
+ </difference>
</differences>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index ef937c8..e7151fb 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -42,7 +42,6 @@ import org.quartz.SchedulerException;
import org.quartz.SimpleTrigger;
import org.quartz.Trigger;
-import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.agent.operation.CancelResults;
import org.rhq.core.clientapi.agent.operation.CancelResults.InterruptedState;
import org.rhq.core.domain.auth.Subject;
@@ -50,6 +49,7 @@ import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.common.composite.IntegerOptionItem;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUtility;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
@@ -166,6 +166,25 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
+ public ResourceOperationSchedule scheduleResourceOperationUsingCron(Subject subject, int resourceId,
+ String operationName, String cronExpression, int timeout, Configuration parameters, String description)
+ throws ScheduleException {
+ // if the user set a timeout, add it to our configuration
+ if (timeout > 0L) {
+ if (parameters == null) {
+ parameters = new Configuration();
+ }
+ parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, timeout));
+ }
+ try {
+ CronTrigger cronTrigger = new CronTrigger("resource " + resourceId + "_" + operationName, "group",
+ cronExpression);
+ return scheduleResourceOperation(subject, resourceId, operationName, parameters, cronTrigger, description);
+ } catch (Exception e) {
+ throw new ScheduleException(e);
+ }
+ }
+
public int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule) throws ScheduleException {
JobTrigger jobTrigger = schedule.getJobTrigger();
Trigger trigger = convertToTrigger(jobTrigger);
@@ -1944,7 +1963,6 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
if (null == parameters) {
parameters = new Configuration();
}
-
parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, timeout));
}
@@ -1955,6 +1973,27 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
}
+ public GroupOperationSchedule scheduleGroupOperationUsingCron(Subject subject, int groupId,
+ int[] executionOrderResourceIds, boolean haltOnFailure, String operationName, Configuration parameters,
+ String cronExpression, int timeout, String description) throws ScheduleException {
+
+ // if the user set a timeout, add it to our configuration
+ if (timeout > 0L) {
+ if (parameters == null) {
+ parameters = new Configuration();
+ }
+ parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME, timeout));
+ }
+ CronTrigger cronTrigger = new CronTrigger();
+ try {
+ cronTrigger.setCronExpression(cronExpression);
+ return scheduleGroupOperation(subject, groupId, executionOrderResourceIds, haltOnFailure, operationName,
+ parameters, cronTrigger, description);
+ } catch (Exception e) {
+ throw new ScheduleException(e);
+ }
+ }
+
@SuppressWarnings("unchecked")
public List<OperationDefinition> findOperationDefinitionsByCriteria(Subject subject,
OperationDefinitionCriteria criteria) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
index bf2d77c..bce2a18 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerLocal.java
@@ -72,6 +72,45 @@ public interface OperationManagerLocal {
* scheduled operation
*/
int scheduleResourceOperation(Subject subject, ResourceOperationSchedule schedule);
+
+
+ /**
+ * Schedules a Resource operation for execution using the cron expression.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param resourceId the resource that is the target of the operation
+ * @param operationName the actual operation to invoke
+ * @param cronExpression the cron expression specifying the repetition.
+ * For example:
+ * <pre>
+ * 0 0 12 * * ? Fire at 12pm (noon) every day
+ * 0 15 10 ? * * Fire at 10:15am every day
+ * 0 15 10 * * ? Fire at 10:15am every day
+ * 0 15 10 * * ? * Fire at 10:15am every day
+ * 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
+ * 0 * 14 * * ? every minute starting at 2pm and ending at 2:59pm, every day
+ * 0 0/5 14 * * ? every 5 minutes starting at 2pm and ending at 2:55pm, ev. d.
+ * 0 0-5 14 * * ? Fire every minute starting at 2pm and ending at 2:05pm, every day
+ * 0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
+ * 0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
+ * 0 15 10 15 * ? Fire at 10:15am on the 15th day of every month
+ * 0 15 10 L * ? Fire at 10:15am on the last day of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L 2002-2005 at 10:15am on every last friday of every month during the years
+ * 0 15 10 ? * 6#3 Fire at 10:15am on the third Friday of every month
+ * 0 11 11 11 11 ? Fire every November 11th at 11:11am.
+ * </pre>
+ * @param timeout the number of seconds before this operation will fail due to timeout. 0 for no timeout.
+ * @param parameters the names parameters for the operation.
+ * @param description user-entered description of the job to be scheduled
+ *
+ * @return the information on the new schedule
+ *
+ * @throws SchedulerException if failed to schedule the operation
+ */
+ ResourceOperationSchedule scheduleResourceOperationUsingCron(Subject subject, int resourceId, String operationName,
+ String cronExpression, int timeout, Configuration parameters, String description) throws ScheduleException;
/**
* Schedules a Resource group operation for execution.
@@ -632,11 +671,59 @@ public interface OperationManagerLocal {
* @param description user-entered description of the job to be scheduled
*
* @return the information on the new schedule
- * @throws ScheduleException TODO
+ * @throws ScheduleException if failed to schedule the operation
*/
ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
long delay, long repeatInterval, int repeatCount, int timeout, Configuration parameters, String description)
throws ScheduleException;
+
+ /**
+ * Schedules an operation for execution on members of the given group using the cron expression.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param groupId the compatible group whose member resources are the target of the operation
+ * @param executionOrderResourceIds optional order of exection - if not<code>null</code>, these are group members
+ * resource IDs in the order in which the operations are invoked
+ * @param haltOnFailure if <code>true</code>, the group operation will halt whenever one individual
+ * resource fails to execute. When executing in order, this means once a failure
+ * occurs, the resources next in line to execute will abort and not attempt to
+ * execute. If not executing in any particular order, you are not guaranteed which
+ * will stop and which will continue since all are executed as fast as possible,
+ * but the group operation will attempt to stop as best it can.
+ * @param operationName the actual operation to invoke
+ * @param parameters optional parameters to pass into the operation
+ * @param cronExpression the cron expression specifying the repetition.
+ * For example:
+ * <pre>
+ * 0 0 12 * * ? Fire at 12pm (noon) every day
+ * 0 15 10 ? * * Fire at 10:15am every day
+ * 0 15 10 * * ? Fire at 10:15am every day
+ * 0 15 10 * * ? * Fire at 10:15am every day
+ * 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
+ * 0 * 14 * * ? every minute starting at 2pm and ending at 2:59pm, every day
+ * 0 0/5 14 * * ? every 5 minutes starting at 2pm and ending at 2:55pm, ev. d.
+ * 0 0-5 14 * * ? Fire every minute starting at 2pm and ending at 2:05pm, every day
+ * 0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
+ * 0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
+ * 0 15 10 15 * ? Fire at 10:15am on the 15th day of every month
+ * 0 15 10 L * ? Fire at 10:15am on the last day of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L 2002-2005 at 10:15am on every last friday of every month during the years
+ * 0 15 10 ? * 6#3 Fire at 10:15am on the third Friday of every month
+ * 0 11 11 11 11 ? Fire every November 11th at 11:11am.
+ * </pre>
+ * @param timeout the number of seconds before this operation will fail due to timeout. 0 for no timeout.
+ * are ignored and reset by this method)
+ * @param description user-entered description of the job to be scheduled
+ *
+ * @return the information on the new schedule
+ *
+ * @throws SchedulerException if failed to schedule the operation
+ */
+ GroupOperationSchedule scheduleGroupOperationUsingCron(Subject subject, int groupId,
+ int[] executionOrderResourceIds, boolean haltOnFailure, String operationName, Configuration parameters,
+ String cronExpression, int timeout, String description) throws ScheduleException;
/**
* Unschedules the resource operation identified with the given job ID.
@@ -644,7 +731,7 @@ public interface OperationManagerLocal {
* @param subject the user who is asking to unschedule the operation
* @param jobId identifies the operation to unschedule
* @param resourceId the ID of the resource whose operation is getting unscheduled
- * @throws UnscheduleException TODO
+ * @throws UnscheduleException if failed to schedule the operation
*/
void unscheduleResourceOperation(Subject subject, String jobId, int resourceId) throws UnscheduleException;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerRemote.java
index c6f8da1..8a4bf1d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerRemote.java
@@ -22,6 +22,8 @@ import java.util.List;
import javax.ejb.Remote;
+import org.quartz.SchedulerException;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
@@ -111,11 +113,49 @@ public interface OperationManagerRemote {
* user-entered description of the job to be scheduled
*
* @return the information on the new schedule
- * @throws ScheduleException TODO
+ * @throws ScheduleException if failed to schedule the operation
*/
ResourceOperationSchedule scheduleResourceOperation(Subject subject, int resourceId, String operationName,
long delay, long repeatInterval, int repeatCount, int timeout, Configuration parameters, String description)
throws ScheduleException;
+
+ /**
+ * Schedules a Resource operation for execution using the cron expression.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param resourceId the resource that is the target of the operation
+ * @param operationName the actual operation to invoke
+ * @param cronExpression the cron expression specifying the repetition.
+ * For example:
+ * <pre>
+ * 0 0 12 * * ? Fire at 12pm (noon) every day
+ * 0 15 10 ? * * Fire at 10:15am every day
+ * 0 15 10 * * ? Fire at 10:15am every day
+ * 0 15 10 * * ? * Fire at 10:15am every day
+ * 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
+ * 0 * 14 * * ? every minute starting at 2pm and ending at 2:59pm, every day
+ * 0 0/5 14 * * ? every 5 minutes starting at 2pm and ending at 2:55pm, ev. d.
+ * 0 0-5 14 * * ? Fire every minute starting at 2pm and ending at 2:05pm, every day
+ * 0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
+ * 0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
+ * 0 15 10 15 * ? Fire at 10:15am on the 15th day of every month
+ * 0 15 10 L * ? Fire at 10:15am on the last day of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L 2002-2005 at 10:15am on every last friday of every month during the years
+ * 0 15 10 ? * 6#3 Fire at 10:15am on the third Friday of every month
+ * 0 11 11 11 11 ? Fire every November 11th at 11:11am.
+ * </pre>
+ * @param timeout the number of seconds before this operation will fail due to timeout. 0 for no timeout.
+ * @param parameters the names parameters for the operation.
+ * @param description user-entered description of the job to be scheduled
+ *
+ * @return the information on the new schedule
+ *
+ * @throws SchedulerException if failed to schedule the operation
+ */
+ ResourceOperationSchedule scheduleResourceOperationUsingCron(Subject subject, int resourceId, String operationName,
+ String cronExpression, int timeout, Configuration parameters, String description) throws ScheduleException;
/**
* Unschedules the resource operation identified with the given job ID.
@@ -152,6 +192,54 @@ public interface OperationManagerRemote {
throws ScheduleException;
/**
+ * Schedules an operation for execution on members of the given group using the cron expression.
+ *
+ * @param subject the user who is asking to schedule the job
+ * @param groupId the compatible group whose member resources are the target of the operation
+ * @param executionOrderResourceIds optional order of exection - if not<code>null</code>, these are group members
+ * resource IDs in the order in which the operations are invoked
+ * @param haltOnFailure if <code>true</code>, the group operation will halt whenever one individual
+ * resource fails to execute. When executing in order, this means once a failure
+ * occurs, the resources next in line to execute will abort and not attempt to
+ * execute. If not executing in any particular order, you are not guaranteed which
+ * will stop and which will continue since all are executed as fast as possible,
+ * but the group operation will attempt to stop as best it can.
+ * @param operationName the actual operation to invoke
+ * @param parameters optional parameters to pass into the operation
+ * @param cronExpression the cron expression specifying the repetition.
+ * For example:
+ * <pre>
+ * 0 0 12 * * ? Fire at 12pm (noon) every day
+ * 0 15 10 ? * * Fire at 10:15am every day
+ * 0 15 10 * * ? Fire at 10:15am every day
+ * 0 15 10 * * ? * Fire at 10:15am every day
+ * 0 15 10 * * ? 2005 Fire at 10:15am every day during the year 2005
+ * 0 * 14 * * ? every minute starting at 2pm and ending at 2:59pm, every day
+ * 0 0/5 14 * * ? every 5 minutes starting at 2pm and ending at 2:55pm, ev. d.
+ * 0 0-5 14 * * ? Fire every minute starting at 2pm and ending at 2:05pm, every day
+ * 0 10,44 14 ? 3 WED Fire at 2:10pm and at 2:44pm every Wednesday in the month of March.
+ * 0 15 10 ? * MON-FRI Fire at 10:15am every Monday, Tuesday, Wednesday, Thursday and Friday
+ * 0 15 10 15 * ? Fire at 10:15am on the 15th day of every month
+ * 0 15 10 L * ? Fire at 10:15am on the last day of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L Fire at 10:15am on the last Friday of every month
+ * 0 15 10 ? * 6L 2002-2005 at 10:15am on every last friday of every month during the years
+ * 0 15 10 ? * 6#3 Fire at 10:15am on the third Friday of every month
+ * 0 11 11 11 11 ? Fire every November 11th at 11:11am.
+ * </pre>
+ * @param timeout the number of seconds before this operation will fail due to timeout. 0 for no timeout.
+ * are ignored and reset by this method)
+ * @param description user-entered description of the job to be scheduled
+ *
+ * @return the information on the new schedule
+ *
+ * @throws SchedulerException if failed to schedule the operation
+ */
+ GroupOperationSchedule scheduleGroupOperationUsingCron(Subject subject, int groupId,
+ int[] executionOrderResourceIds, boolean haltOnFailure, String operationName, Configuration parameters,
+ String cronExpression, int timeout, String description) throws ScheduleException;
+
+ /**
* Unschedules the group operation identified with the given job ID.
*
* @param subject the user who is asking to unschedule the operation