2009-06-29 11 views

Odpowiedz

0

Założę się, że jednym ze sposobów jest bezpośredni dostęp do bazy danych, chociaż jest to nieco ryzykowne, ponieważ API całkowicie to obsługuje.

W tym celu występuje problem dotyczący ich Jiry. Ich wniosek jest taki, że trzeba zmienić mechanizm szeregowania, jeśli chcą zaspokoić świadomość klastra.

Można odwołać się do http://jira.opensymphony.com/browse/QUARTZ-372

3

Wygląda jak remonty mechanizm szeregowania nie dzieje się w najbliższym czasie.

Więc, oto jak ja bezpośrednio sprawdzając tabelę - dodanie wsparcia grupowego, jeśli chcesz to:

class QuartzClusterJobStatusService 
{ 
    def quartzScheduler 

    boolean isJobRunning(String job) { 
     return isJobRunningHere(job) || isJobRunningElsewhere(job) 
    } 

    boolean isJobRunningHere(String job) { 
     for (JobExecutionContext j : quartzScheduler.getCurrentlyExecutingJobs()) { 
      if (new JobKey(job,"GRAILS_JOBS").equals(j.jobDetail.key)) { 
       return true 
      } 
     } 
     return false 
    } 

    boolean isJobRunningElsewhere(String job) { 
     JobStoreSupport js = quartzScheduler.sched.resources.jobStore 
     if (!js.isClustered()) { 
      return false 
     } 
     Connection conn = DBConnectionManager.getInstance().getConnection(js.getDataSource()); 
     PreparedStatement stmt = null 
     try { 
      stmt = conn.prepareStatement("SELECT 1 FROM " + js.getTablePrefix() + "FIRED_TRIGGERS where JOB_NAME = ?") 
      stmt.setString(1, job) 
      ResultSet rs = stmt.executeQuery() 
      return rs.next() 
     } finally { 
      if (stmt != null) 
       stmt.close() 
     } 
    } 
} 
Powiązane problemy