private boolean didCheckPass(Database conn,int id) throws SQLException, InterruptedException, ReplicatorException {
  String query=String.format("SELECT %s,%s,%s,%s FROM %s.%s WHERE %s = %d",ConsistencyTable.thisCrcColumnName,ConsistencyTable.thisCntColumnName,ConsistencyTable.masterCrcColumnName,ConsistencyTable.masterCntColumnName,serviceSchema,ConsistencyTable.TABLE_NAME,ConsistencyTable.idColumnName,id);
  int timeLeft=checkTimeout * 1000;
  while (timeLeft > 0) {
    long startSleepMillis=System.currentTimeMillis();
    Statement st=null;
    ResultSet rs=null;
    try {
      st=conn.createStatement();
      rs=st.executeQuery(query);
      if (rs.next()) {
        String thisCrc=rs.getString(ConsistencyTable.thisCrcColumnName);
        String thisCnt=rs.getString(ConsistencyTable.thisCntColumnName);
        String masterCrc=rs.getString(ConsistencyTable.masterCrcColumnName);
        String masterCnt=rs.getString(ConsistencyTable.masterCntColumnName);
        if (thisCnt.compareTo(masterCnt) == 0 && thisCrc.compareTo(masterCrc) == 0) {
          return true;
        }
 else {
          if (logger.isDebugEnabled()) {
            logger.debug("          |              CRC                 | cnt");
            logger.debug("this      | " + thisCrc + " | "+ thisCnt);
            logger.debug("master    | " + masterCrc + " | "+ masterCnt);
          }
          return false;
        }
      }
    }
  finally {
      if (rs != null) {
        try {
          rs.close();
        }
 catch (        SQLException e) {
        }
      }
      if (st != null) {
        try {
          st.close();
        }
 catch (        SQLException e) {
        }
      }
    }
    Thread.sleep(50);
    long sleepMillis=System.currentTimeMillis() - startSleepMillis;
    timeLeft-=sleepMillis;
  }
  throw new ReplicatorException(String.format("Timeout (%ds) while waiting for consistency check to complete",checkTimeout));
}

private boolean didCheckPass ( Database conn , int id ) throws SQLException , InterruptedException , ReplicatorException { String query = String . format ( "SELECT %s,%s,%s,%s FROM %s.%s WHERE %s = %d" , ConsistencyTable . thisCrcColumnName , ConsistencyTable . thisCntColumnName , ConsistencyTable . masterCrcColumnName , ConsistencyTable . masterCntColumnName , serviceSchema , ConsistencyTable . TABLE_NAME , ConsistencyTable . idColumnName , id ) ; int timeLeft = checkTimeout * 1000 ; while ( timeLeft > 0 ) { long startSleepMillis = System . currentTimeMillis ( ) ; Statement st = null ; ResultSet rs = null ; try { st = conn . createStatement ( ) ; rs = st . executeQuery ( query ) ; if ( rs . next ( ) ) { String thisCrc = rs . getString ( ConsistencyTable . thisCrcColumnName ) ; String thisCnt = rs . getString ( ConsistencyTable . thisCntColumnName ) ; String masterCrc = rs . getString ( ConsistencyTable . masterCrcColumnName ) ; String masterCnt = rs . getString ( ConsistencyTable . masterCntColumnName ) ; if ( thisCnt . compareTo ( masterCnt ) == 0 && thisCrc . compareTo ( masterCrc ) == 0 ) { return true ; } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "          |              CRC                 | cnt" ) ; logger . debug ( "this      | " + thisCrc + " | " + thisCnt ) ; logger . debug ( "master    | " + masterCrc + " | " + masterCnt ) ; } return false ; } } } finally { if ( rs != null ) { try { rs . close ( ) ; } catch ( SQLException e ) { } } if ( st != null ) { try { st . close ( ) ; } catch ( SQLException e ) { } } } Thread . sleep ( 50 ) ; long sleepMillis = System . currentTimeMillis ( ) - startSleepMillis ; timeLeft -= sleepMillis ; } throw new ReplicatorException ( String . format ( "Timeout (%ds) while waiting for consistency check to complete" , checkTimeout ) ) ; }
retrieve consistency check from specific dbms and check whether it passed or failed .
