/** * Closes the supplied <code>Connection</code>. * <p> * Ignores a <code>null Connection</code>. * Any exception thrown trying to close the <code>Connection</code> is * logged and ignored. * </p> * * @param conn The <code>Connection</code> to close (Optional). */ protected void closeConnection(Connection conn) { if (conn != null) { try { conn.close(); } catch (SQLException e) { getLog().error("Failed to close Connection", e); } catch (Throwable e) { getLog().error( "Unexpected exception closing Connection." + " This is often due to a Connection being returned after or during shutdown.", e); } } }
/** * Closes the supplied <code>Connection</code>. * <p> * Ignores a <code>null Connection</code>. * Any exception thrown trying to close the <code>Connection</code> is * logged and ignored. * </p> * * @param conn The <code>Connection</code> to close (Optional). */ protected void closeConnection(Connection conn) { if (conn != null) { try { conn.close(); } catch (SQLException e) { getLog().error("Failed to close Connection", e); } catch (Throwable e) { getLog().error( "Unexpected exception closing Connection." + " This is often due to a Connection being returned after or during shutdown.", e); } } }
private RecoverMisfiredJobsResult manage() { try { getLog().debug("MisfireHandler: scanning for misfires..."); RecoverMisfiredJobsResult res = doRecoverMisfires(); numFails = 0; return res; } catch (Exception e) { if(numFails % 4 == 0) { getLog().error( "MisfireHandler: Error handling misfires: " + e.getMessage(), e); } numFails++; } return RecoverMisfiredJobsResult.NO_OP; }
private RecoverMisfiredJobsResult manage() { try { getLog().debug("MisfireHandler: scanning for misfires..."); RecoverMisfiredJobsResult res = doRecoverMisfires(); numFails = 0; return res; } catch (Exception e) { if(numFails % 4 == 0) { getLog().error( "MisfireHandler: Error handling misfires: " + e.getMessage(), e); } numFails++; } return RecoverMisfiredJobsResult.NO_OP; }
/** * Rollback the supplied connection. * * <p> * Logs any SQLException it gets trying to rollback, but will not propogate * the exception lest it mask the exception that caused the caller to * need to rollback in the first place. * </p> * * @param conn (Optional) */ protected void rollbackConnection(Connection conn) { if (conn != null) { try { conn.rollback(); } catch (SQLException e) { getLog().error( "Couldn't rollback jdbc connection. "+e.getMessage(), e); } } }
/** * Rollback the supplied connection. * * <p> * Logs any SQLException it gets trying to rollback, but will not propogate * the exception lest it mask the exception that caused the caller to * need to rollback in the first place. * </p> * * @param conn (Optional) */ protected void rollbackConnection(Connection conn) { if (conn != null) { try { conn.rollback(); } catch (SQLException e) { getLog().error( "Couldn't rollback jdbc connection. "+e.getMessage(), e); } } }
protected <T> T retryExecuteInNonManagedTXLock(String lockName, TransactionCallback<T> txCallback) { for (int retry = 1; !shutdown; retry++) { try { return executeInNonManagedTXLock(lockName, txCallback, null); } catch (JobPersistenceException jpe) { if(retry % 4 == 0) { schedSignaler.notifySchedulerListenersError("An error occurred while " + txCallback, jpe); } } catch (RuntimeException e) { getLog().error("retryExecuteInNonManagedTXLock: RuntimeException " + e.getMessage(), e); } try { Thread.sleep(getDbRetryInterval()); // retry every N seconds (the db connection must be failed) } catch (InterruptedException e) { throw new IllegalStateException("Received interrupted exception", e); } } throw new IllegalStateException("JobStore is shutdown - aborting retry"); }
protected <T> T retryExecuteInNonManagedTXLock(String lockName, TransactionCallback<T> txCallback) { for (int retry = 1; !shutdown; retry++) { try { return executeInNonManagedTXLock(lockName, txCallback, null); } catch (JobPersistenceException jpe) { if(retry % 4 == 0) { schedSignaler.notifySchedulerListenersError("An error occurred while " + txCallback, jpe); } } catch (RuntimeException e) { getLog().error("retryExecuteInNonManagedTXLock: RuntimeException " + e.getMessage(), e); } try { Thread.sleep(getDbRetryInterval()); // retry every N seconds (the db connection must be failed) } catch (InterruptedException e) { throw new IllegalStateException("Received interrupted exception", e); } } throw new IllegalStateException("JobStore is shutdown - aborting retry"); }
protected void releaseLock(String lockName, boolean doIt) { if (doIt) { try { getLockHandler().releaseLock(lockName); } catch (LockException le) { getLog().error("Error returning lock: " + le.getMessage(), le); } } }
protected void releaseLock(String lockName, boolean doIt) { if (doIt) { try { getLockHandler().releaseLock(lockName); } catch (LockException le) { getLog().error("Error returning lock: " + le.getMessage(), le); } } }
getLog().warn( "Found orphaned fired triggers for instance: " + orphanedInstance.getSchedulerInstanceId());
void resetTriggerFromErrorState(Connection conn, final TriggerKey triggerKey) throws JobPersistenceException { try { String newState = STATE_WAITING; if(getDelegate().isTriggerGroupPaused(conn, triggerKey.getGroup())) { newState = STATE_PAUSED; } getDelegate().updateTriggerStateFromOtherState(conn, triggerKey, newState, STATE_ERROR); getLog().info("Trigger " + triggerKey + " reset from ERROR state to: " + newState); } catch (SQLException e) { throw new JobPersistenceException( "Couldn't reset from error state of trigger (" + triggerKey + "): " + e.getMessage(), e); } }
void resetTriggerFromErrorState(Connection conn, final TriggerKey triggerKey) throws JobPersistenceException { try { String newState = STATE_WAITING; if(getDelegate().isTriggerGroupPaused(conn, triggerKey.getGroup())) { newState = STATE_PAUSED; } getDelegate().updateTriggerStateFromOtherState(conn, triggerKey, newState, STATE_ERROR); getLog().info("Trigger " + triggerKey + " reset from ERROR state to: " + newState); } catch (SQLException e) { throw new JobPersistenceException( "Couldn't reset from error state of trigger (" + triggerKey + "): " + e.getMessage(), e); } }
/** * <P> * Get the driver delegate for DB operations. * </p> */ protected DriverDelegate getDelegate() throws NoSuchDelegateException { synchronized(this) { if(null == delegate) { try { if(delegateClassName != null) { delegateClass = getClassLoadHelper().loadClass(delegateClassName, DriverDelegate.class); } delegate = delegateClass.newInstance(); delegate.initialize(getLog(), tablePrefix, instanceName, instanceId, getClassLoadHelper(), canUseProperties(), getDriverDelegateInitString()); } catch (InstantiationException e) { throw new NoSuchDelegateException("Couldn't create delegate: " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new NoSuchDelegateException("Couldn't create delegate: " + e.getMessage(), e); } catch (ClassNotFoundException e) { throw new NoSuchDelegateException("Couldn't load delegate class: " + e.getMessage(), e); } } return delegate; } }
/** * @see org.quartz.spi.JobStore#schedulerStarted() */ public void schedulerStarted() throws SchedulerException { if (isClustered()) { clusterManagementThread = new ClusterManager(); if(initializersLoader != null) clusterManagementThread.setContextClassLoader(initializersLoader); clusterManagementThread.initialize(); } else { try { recoverJobs(); } catch (SchedulerException se) { throw new SchedulerConfigException( "Failure occured during job recovery.", se); } } misfireHandler = new MisfireHandler(); if(initializersLoader != null) misfireHandler.setContextClassLoader(initializersLoader); misfireHandler.initialize(); schedulerRunning = true; getLog().debug("JobStore background threads started (as scheduler was started)."); }
/** * @see org.quartz.spi.JobStore#schedulerStarted() */ public void schedulerStarted() throws SchedulerException { if (isClustered()) { clusterManagementThread = new ClusterManager(); if(initializersLoader != null) clusterManagementThread.setContextClassLoader(initializersLoader); clusterManagementThread.initialize(); } else { try { recoverJobs(); } catch (SchedulerException se) { throw new SchedulerConfigException( "Failure occured during job recovery.", se); } } misfireHandler = new MisfireHandler(); if(initializersLoader != null) misfireHandler.setContextClassLoader(initializersLoader); misfireHandler.initialize(); schedulerRunning = true; getLog().debug("JobStore background threads started (as scheduler was started)."); }