Search in sources :

Example 6 with QuartzSchedulerMBean

use of org.quartz.core.jmx.QuartzSchedulerMBean in project midpoint by Evolveum.

the class RemoteNodesManager method redirectTaskToNode.

public void redirectTaskToNode(@NotNull Task task, @NotNull NodeType node, @NotNull OperationResult result) {
    LOGGER.trace("Trying to schedule task {} on {}", task, node.getNodeIdentifier());
    Holder<JMXConnector> connectorHolder = new Holder<>();
    try {
        QuartzSchedulerMBean mbeanProxy = getSchedulerBean(node, connectorHolder, result);
        if (mbeanProxy != null) {
            try {
                createStarterJobIfNeeded();
                mbeanProxy.triggerJob(STARTER_JOB_KEY.getName(), STARTER_JOB_KEY.getGroup(), Collections.singletonMap(JobStarter.TASK_OID, task.getOid()));
                LOGGER.debug("Successfully requested start of " + task + " at " + getClusterManager().dumpNodeInfo(node));
                result.recordSuccessIfUnknown();
            } catch (Exception e) {
                // necessary because of mbeanProxy
                String message = "Cannot schedule " + task + " at " + getClusterManager().dumpNodeInfo(node);
                LoggingUtils.logUnexpectedException(LOGGER, message, e);
                result.recordFatalError(message + ":" + e.getMessage(), e);
            }
        } else {
            LOGGER.warn("Couldn't obtain Quartz MBean so couldn't reschedule task {} on {}", task, node.getNodeIdentifier());
        }
    } finally {
        closeJmxConnection(connectorHolder, getClusterManager().dumpNodeInfo(node));
    }
}
Also used : JMXConnector(javax.management.remote.JMXConnector) Holder(com.evolveum.midpoint.util.Holder) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) IOException(java.io.IOException) MalformedObjectNameException(javax.management.MalformedObjectNameException) SystemException(com.evolveum.midpoint.util.exception.SystemException) QuartzSchedulerMBean(org.quartz.core.jmx.QuartzSchedulerMBean)

Aggregations

IOException (java.io.IOException)6 MalformedObjectNameException (javax.management.MalformedObjectNameException)6 JMXConnector (javax.management.remote.JMXConnector)6 QuartzSchedulerMBean (org.quartz.core.jmx.QuartzSchedulerMBean)6 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)5 SystemException (com.evolveum.midpoint.util.exception.SystemException)5 MBeanServerConnection (javax.management.MBeanServerConnection)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 NodeType (com.evolveum.midpoint.xml.ns._public.common.common_3.NodeType)3 Holder (com.evolveum.midpoint.util.Holder)2 ClusterStatusInformation (com.evolveum.midpoint.task.quartzimpl.cluster.ClusterStatusInformation)1 CompositeData (javax.management.openmbean.CompositeData)1 TabularData (javax.management.openmbean.TabularData)1