Exemple #1
0
        public override 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);
        }
Exemple #2
0
        public SyncSource(int id, String name, String strSyncType, DBAdapter db, SyncEngine syncEngine)
        {
            m_syncEngine  = syncEngine;
            m_dbAdapter   = db;
            m_nID         = id;
            m_strName     = name;
            m_strSyncType = strSyncType;

            m_nCurPageCount      = 0;
            m_nInserted          = 0;
            m_nDeleted           = 0;
            m_nTotalCount        = 0;
            m_bGetAtLeastOnePage = false;

            m_nErrCode = RhoAppAdapter.ERR_NONE;

            IDBResult res = db.executeSQL("SELECT token,associations from sources WHERE source_id=?", m_nID);

            if (!res.isEnd())
            {
                m_token        = res.getLongByIdx(0);
                m_bTokenFromDB = true;
            }
            else
            {
                m_token        = 0;
                m_bTokenFromDB = true;
            }

            m_bSchemaSource = db.isTableExist(m_strName);
            parseAssociations(res.getStringByIdx(1));
        }