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;
  }
 @Override
 public String toString() {
   return getClass().getSimpleName() + ", queue" + m_qid + ", state" + m_errorStatus.name();
 }
  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--;
      }
    }
  }