Exemplo n.º 1
1
 private void doInitiate() {
   try {
     dbhelper.flushDataDB();
     LOGGER.info("Redis flushdb " + Infos.OK);
     String sql = "";
     MySQLDbHelper mhelper = new MySQLDbHelper(masterDb);
     for (int i = 0; i < tables.size(); i++) {
       RedisSchnauzer table = tables.get(i);
       sql = table.getSQL();
       if (StrHelp.empty(sql)) ErrorHelper.errExit(Infos.SQLNotFound + table.table.SlaveKey);
       ResultSet rs = mhelper.getRS(sql);
       switch (table.getType()) {
         case Set:
         case SortedSet:
         case String:
           initSet(table, rs);
           break;
         default:
           ErrorHelper.errExit(LOGGER.getName() + " '" + table.getType() + "' Not Impliment....");
       }
     }
   } catch (Exception e) {
     ErrorHelper.errExit(Infos.Init + "RedisData" + Infos.Failed + ": " + e.getMessage());
   }
 }
Exemplo n.º 2
0
  private void getTheLastBinlogAndPos() {
    try {
      MySQLDbHelper mhelper = new MySQLDbHelper(masterDb);
      ResultSet rs = mhelper.getRS("show master logs");
      String binlog = "";
      Long pos = 0L;
      while (rs.next()) {
        binlog = rs.getString("log_name");
      }
      rs.close();
      rs = mhelper.getRS("show binlog events in '" + binlog + "'");
      while (rs.next()) {
        pos = rs.getLong("pos");
      }
      rs.close();
      masterDb.binlog = binlog;
      masterDb.pos = pos;
      slaveDb.binlog = binlog;
      slaveDb.pos = pos;

    } catch (Exception e) {
      ErrorHelper.errExit("Get binlog filename " + Infos.Failed + ": " + e.getMessage());
    }
  }