コード例 #1
0
  public static MDS createFromResSet(ResSet resSet) {

    if (resSet == null) return null;

    MDS mds = new MDS();

    ResultSetMetaData md;
    try {

      md = resSet.getResultSet().getMetaData();
      int columnCount = md.getColumnCount();

      List<String> names = new ArrayList<String>();

      for (int i = 1; i <= columnCount; i++) {
        names.add(md.getColumnName(i));
      }
      mds.appendNames(names);

      while (resSet.next()) {
        IMDSRow row = new MDSRow();
        for (int i = 1; i <= columnCount; i++) {
          row.add(resSet.getObject(i));
        }
        mds.appendRow(row);
      }
    } catch (Exception e) {
      ApiAlgs.rethrowException(e);
    }

    return mds;
  }
コード例 #2
0
 private List<Long> getIds() {
   ArrayList<Long> res = new ArrayList<Long>();
   ResSet rs = queueBL().getIds();
   while (rs.next()) {
     res.add(rs.getLong(1));
   }
   return res;
 }
コード例 #3
0
  public synchronized QSyncQueueInfo getQueueInfo(long qid) {
    QSyncQueueInfo res = null;
    ResSet rs = queueBL().getQueueInfo(qid);
    if (rs.next()) {
      res = new QSyncQueueInfo();
      QueueExecutionInfo syncerInfo = m_syncers.get(qid);
      if (null != syncerInfo) {
        res.lastAttempt = syncerInfo.m_lastAttempt;
        res.lastError = syncerInfo.m_lastError;
        res.lastSynced = syncerInfo.m_lastSynced;
      }

      QSyncTaskStatus status =
          QSyncTaskStatus.valueOf(QSyncTaskStatus.class, rs.getString(3).trim());
      if (EnumSet.of(QSyncTaskStatus.ERROR, QSyncTaskStatus.INITIAL_SYNC_ERROR).contains(status)) {
        res.result =
            new QSyncTaskResult(
                qid, rs.getLong(2), status, rs.getString(4), rs.getString(5), rs.getString(6));
      } else {
        res.result = new QSyncTaskResult(qid, rs.getLong(2), status, null);
      }
    }
    return res;
  }
コード例 #4
0
  private void startTasks(Long excludedQueue) {
    ResSet rs =
        null == excludedQueue ? queueBL().getQueues() : queueBL().getQueuesExclude(excludedQueue);
    int nrunning = 0;
    int nInitRunning = 0;

    for (QueueExecutionInfo info : m_syncers.values()) {
      if (info.m_currentTask != null) {
        nrunning++;
        if (info.m_currentTask instanceof InitialSync) nInitRunning++;
      }
    }
    int nexec = m_maxNumberOfSyncTasks - nrunning;
    int nExecInit = m_maxNumberOfInitTasks - nInitRunning;

    while (nexec > 0 && rs.next()) {
      long qid = rs.getLong(1);
      long syncerId = rs.getLong(2);

      QueueExecutionInfo syncerInfo;
      try {
        syncerInfo = getSyncerInfo(qid, syncerId);
      } catch (IQSyncManagerExternals.EQSyncerNotFound e) {
        ApiAlgs.getLog(this).error("", e);
        continue;
      }

      if (syncerInfo.m_currentTask != null) continue;

      QSyncTaskStatus status = QSyncTaskStatus.valueOf(rs.getString(3).trim());

      SyncTask task = null;

      if (EnumSet.of(QSyncTaskStatus.ERROR, QSyncTaskStatus.INITIAL_SYNC_ERROR).contains(status)) {

        ApiAlgs.getLog(this).trace("Period: " + (Math.pow(2, (syncerInfo.m_errorCounter - 1)) - 1));

        if (syncerInfo.m_missedExecutions
            < Math.min(EXEC_PER_HOUR, Math.pow(2, (syncerInfo.m_errorCounter - 1)) - 1)) {
          syncerInfo.m_missedExecutions++;
        } else {
          if (QSyncTaskStatus.ERROR.equals(status))
            task = new RecordSync(this, getSyncer(qid, syncerId), qid, syncerId);
          else if (nExecInit > 0) {
            task = new InitialSync(this, getSyncer(qid, syncerId), qid, syncerId);
            nExecInit--;
          }
        }
      } else if (EnumSet.of(QSyncTaskStatus.INITIAL_SYNC).contains(status)) {
        if (nExecInit > 0) {
          task = new InitialSync(this, getSyncer(qid, syncerId), qid, syncerId);
          nExecInit--;
        }
      } else if (EnumSet.of(QSyncTaskStatus.SYNCED, QSyncTaskStatus.EXEC_TIMEOUT)
          .contains(status)) {
        if (!isEmptyQueue(qid))
          task = new RecordSync(this, getSyncer(qid, syncerId), qid, syncerId);
      }
      //
      //			if(QSyncTaskStatus.IN_PROCESS.equals(status)){
      //				nexec --;
      //			}

      if (null != task) {
        if (startQueueTask(qid, syncerId, task)) ;
        nexec--;
      }
    }
  }
コード例 #5
0
 public Long get() {
   ResSet rs =
       select(new IName[] {new ApiAlgs.SimpleName(value)}, new IName[] {}, new Object[] {});
   return rs.next() ? rs.getLong(1) : null;
 }