예제 #1
0
  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
  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
  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;
  }