private String getTableMetaSeriFullName(String fullname) throws Exception { if (!tableMetaSeriFullPathMap.containsKey(fullname)) { String serverhost = connection.getAddress().getHostName(); String dir = ProFileUtil.findMsgString(Const.sysconfigFileClasspath, "binlogpares.eventseri.dir"); String tableEventSeriFullPath = dir + "/" + serverhost + "_" + slaveId + "_TableMeta_" + fullname; tableMetaSeriFullPathMap.put(fullname, tableEventSeriFullPath); } String tableEventSeriFullPath = tableMetaSeriFullPathMap.get(fullname); return tableEventSeriFullPath; }
private synchronized TableMeta getTableMeta0(String fullname) throws Exception { String serFullPath = this.getTableMetaSeriFullName(fullname); TableMeta res = null; String errMsg = null; try { ResultSetPacket packet = connection.query("desc " + fullname); res = new TableMeta(fullname, parserTableMeta(packet)); BeanUtil.seriObject2File(serFullPath, res); } catch (Throwable e) { errMsg = e.getMessage(); e.printStackTrace(); System.err.println("获取表元信息出错,从文件中抽取,err:" + errMsg); File f = new File(serFullPath); if (f.exists() && f.canRead()) { res = (TableMeta) BeanUtil.getSeriObjFromFile(serFullPath); } } if (res == null) { throw new SocketUnexpectedEndException("获取表元信息出错,err:" + errMsg); } return res; }