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()); } }
@Override public boolean doWrite(ColumnTypeHelper helper, WriteRowsEvent event) { try { boolean doOne = false; for (int i = 0; i < tables.size(); i++) { RedisSchnauzer table = tables.get(i); if (StrHelp.notEqual(helper.databaseName, masterDb.dbname)) continue; if (StrHelp.notEqual(helper.tableName, table.getMasterTableName())) continue; doOne = true; try { innerWrite(helper, event, table); } catch (Exception e) { ErrorHelper.errExit( "[" + table.table.SlaveKey + "]" + Infos.DoInsert + Infos.Failed + e.getMessage()); } } if (!doOne) dbhelper.setBinlogKey( getBinLogName(helper), Long.toString(helper.position), helper.tableName); } catch (Exception e) { ErrorHelper.errExit(Infos.RepFailed + e.getMessage()); } return true; }