コード例 #1
0
ファイル: SyncThread.java プロジェクト: tchukuchuk/rhodes
  public static void stopSync() throws Exception {
    LOG.INFO("STOP sync");

    if (getSyncEngine().isSyncing()) {
      getSyncEngine().stopSyncByUser();
      getInstance().stopWait();

      int nWait = 0;
      // while( nWait < 30000 && getSyncEngine().getState() != SyncEngine.esNone )
      while (nWait < 30000 && DBAdapter.isAnyInsideTransaction())
        try {
          Thread.sleep(100);
          nWait += 100;
        } catch (Exception e) {
        }

      // if (getSyncEngine().getState() != SyncEngine.esNone)
      if (DBAdapter.isAnyInsideTransaction()) {
        getSyncEngine().exitSync();
        getInstance().stop(0);
        RhoClassFactory ptrFactory = getInstance().getFactory();
        m_pInstance = null;

        Create(ptrFactory);
      }
    }
  }
コード例 #2
0
ファイル: SyncThread.java プロジェクト: tchukuchuk/rhodes
  public void Destroy() {
    m_oSyncEngine.exitSync();
    stop(SYNC_WAIT_BEFOREKILL_SECONDS);

    if (ClientRegister.getInstance() != null) ClientRegister.getInstance().Destroy();

    DBAdapter.closeAll();

    m_pInstance = null;
  }
コード例 #3
0
ファイル: SyncThread.java プロジェクト: tchukuchuk/rhodes
  public int getLastPollInterval() {
    try {
      long nowTime = (TimeInterval.getCurrentTime().toULong()) / 1000;
      long latestTimeUpdated = 0;

      Vector /*<String>*/ arPartNames = DBAdapter.getDBAllPartitionNames();
      for (int i = 0; i < (int) arPartNames.size(); i++) {
        DBAdapter dbPart = DBAdapter.getDB((String) arPartNames.elementAt(i));
        IDBResult res = dbPart.executeSQL("SELECT last_updated from sources");
        for (; !res.isEnd(); res.next()) {
          long timeUpdated = res.getLongByIdx(0);
          if (latestTimeUpdated < timeUpdated) latestTimeUpdated = timeUpdated;
        }
      }

      return latestTimeUpdated > 0 ? (int) (nowTime - latestTimeUpdated) : 0;
    } catch (Exception exc) {
      LOG.ERROR("isStartSyncNow failed.", exc);
    }
    return 0;
  }