/**
   * Runs an SQL select statement to determine if the Quartz lock rows exist in the database. If the
   * rows do not exist this method assumes this is the first time the scheduler has been started.
   * The select statement will be defined in the {vendor}/checkTables.sql file within the shared
   * library deployed by this project. The statement should be of the form "SELECT COUNT(*) from
   * QUARTZ_LOCKS;". If the count is zero it is assumed this is a new install. If the count is
   * non-zero it is assumed the QUARTZ_LOCKS table has been initialized and this is not a new
   * install.
   *
   * @param sqlService
   * @return
   */
  private boolean isInitialStartup(SqlService sqlService) {
    String checkTablesScript = sqlService.getVendor() + "/checkTables.sql";
    ClassLoader loader = this.getClass().getClassLoader();
    String chkStmt = null;
    InputStream in = null;
    BufferedReader r = null;

    try {

      // find the resource from the loader
      in = loader.getResourceAsStream(checkTablesScript);

      r = new BufferedReader(new InputStreamReader(in));

      chkStmt = r.readLine();
    } catch (Exception e) {
      LOG.error(
          "Could not read the file "
              + checkTablesScript
              + " to determine if this is a new installation. Preconfigured jobs will only be loaded if the server property scheduler.loadjobs is \"true\"",
          e);
      return false;
    } finally {
      try {
        r.close();
      } catch (Exception e) {
      }
      try {
        in.close();
      } catch (Exception e) {
      }
    }

    List<String> l = sqlService.dbRead(chkStmt);
    if (l != null && l.size() > 0) {
      return (l.get(0).equalsIgnoreCase("0"));
    } else {
      return false;
    }
  }
  /** Final initialization, once all dependencies are set. */
  public void init() {
    setClusterServiceSql(m_sqlService.getVendor());
    try {
      // if we are auto-creating our schema, check and create
      if (m_autoDdl) {
        m_sqlService.ddl(this.getClass().getClassLoader(), "sakai_cluster");
      }

      // start the maintenance thread
      m_maintenance = new Maintenance();
      m_maintenance.start();

      M_log.info(
          "init: refresh: "
              + m_refresh
              + " expired: "
              + m_expired
              + " ghostingPercent: "
              + m_ghostingPercent);
    } catch (Throwable t) {
      M_log.warn("init(): ", t);
    }
  }
示例#3
0
  public static java.lang.String getVendor() {
    org.sakaiproject.db.api.SqlService service = getInstance();
    if (service == null) return null;

    return service.getVendor();
  }