public void update(String cmd) throws IOException { MysqlUpdateExecutor exector = new MysqlUpdateExecutor(connector); exector.update(cmd); }
public MysqlConnector fork() { MysqlConnector connector = new MysqlConnector(); connector.setCharsetNumber(getCharsetNumber()); connector.setDefaultSchema(getDefaultSchema()); connector.setAddress(getAddress()); connector.setPassword(password); connector.setUsername(getUsername()); connector.setReceiveBufferSize(getReceiveBufferSize()); connector.setSendBufferSize(getSendBufferSize()); connector.setSoTimeout(getSoTimeout()); connector.setConnTimeout(connTimeout); return connector; }
public ResultSetPacket query(String cmd) throws IOException { MysqlQueryExecutor exector = new MysqlQueryExecutor(connector); return exector.query(cmd); }
private void sendBinlogDump(String binlogfilename, Long binlogPosition) throws IOException { BinlogDumpCommandPacket binlogDumpCmd = new BinlogDumpCommandPacket(); binlogDumpCmd.binlogFileName = binlogfilename; binlogDumpCmd.binlogPosition = binlogPosition; binlogDumpCmd.slaveServerId = this.slaveId; byte[] cmdBody = binlogDumpCmd.toBytes(); logger.info("COM_BINLOG_DUMP with position:{}", binlogDumpCmd); HeaderPacket binlogDumpHeader = new HeaderPacket(); binlogDumpHeader.setPacketBodyLength(cmdBody.length); binlogDumpHeader.setPacketSequenceNumber((byte) 0x00); PacketManager.writePkg(connector.getChannel(), binlogDumpHeader.toBytes(), cmdBody); connector.setDumping(true); }
private void sendBinlogDumpGTID(GTIDSet gtidSet) throws IOException { BinlogDumpGTIDCommandPacket binlogDumpCmd = new BinlogDumpGTIDCommandPacket(); binlogDumpCmd.slaveServerId = this.slaveId; binlogDumpCmd.gtidSet = gtidSet; byte[] cmdBody = binlogDumpCmd.toBytes(); logger.info("COM_BINLOG_DUMP_GTID:{}", binlogDumpCmd); HeaderPacket binlogDumpHeader = new HeaderPacket(); binlogDumpHeader.setPacketBodyLength(cmdBody.length); binlogDumpHeader.setPacketSequenceNumber((byte) 0x00); PacketManager.writePkg(connector.getChannel(), binlogDumpHeader.toBytes(), cmdBody); connector.setDumping(true); }
public void sendSemiAck(String binlogfilename, Long binlogPosition) throws IOException { SemiAckCommandPacket semiAckCmd = new SemiAckCommandPacket(); semiAckCmd.binlogFileName = binlogfilename; semiAckCmd.binlogPosition = binlogPosition; byte[] cmdBody = semiAckCmd.toBytes(); logger.info("SEMI ACK with position:{}", semiAckCmd); HeaderPacket semiAckHeader = new HeaderPacket(); semiAckHeader.setPacketBodyLength(cmdBody.length); semiAckHeader.setPacketSequenceNumber((byte) 0x00); PacketManager.writePkg(connector.getChannel(), semiAckHeader.toBytes(), cmdBody); }
public MysqlConnection(InetSocketAddress address, String username, String password){ authInfo = new AuthenticationInfo(); authInfo.setAddress(address); authInfo.setUsername(username); authInfo.setPassword(password); connector = new MysqlConnector(address, username, password); // 将connection里面的参数透传下 connector.setSoTimeout(soTimeout); connector.setConnTimeout(connTimeout); }
private MysqlConnection buildMysqlConnection() { MysqlConnection connection = new MysqlConnection(runningInfo.getAddress(), runningInfo.getUsername(), runningInfo.getPassword(), connectionCharsetNumber, runningInfo.getDefaultDatabaseName()); connection.getConnector().setReceiveBufferSize(64 * 1024); connection.getConnector().setSendBufferSize(64 * 1024); connection.getConnector().setSoTimeout(30 * 1000); connection.setCharset(connectionCharset); return connection; }
public void reconnect() throws IOException { disconnect(); connect(); }
public MysqlQueryExecutor(MysqlConnector connector) throws IOException{ if (!connector.isConnected()) { throw new IOException("should execute connector.connect() first"); } this.channel = connector.getChannel(); }
private boolean readEofPacket() throws IOException { byte[] eofBody = readNextPacket(); EOFPacket packet = new EOFPacket(); packet.fromBytes(eofBody); if (eofBody[0] != -2) { throw new IOException("EOF Packet is expected, but packet with field_count=" + eofBody[0] + " is found."); } return (packet.statusFlag & 0x0008) != 0; }
public boolean isConnected() { return connector.isConnected(); }
public List<ResultSetPacket> queryMulti(String cmd) throws IOException { MysqlQueryExecutor exector = new MysqlQueryExecutor(connector); return exector.queryMulti(cmd); }
public void connect() throws IOException { connector.connect(); }
public void disconnect() throws IOException { connector.disconnect(); }
@Override protected void afterDump(ErosaConnection connection) { if (metaConnection != null) { try { metaConnection.disconnect(); } catch (IOException e) { logger.error("ERROR # disconnect meta connection for address:{}", metaConnection.getConnector() .getAddress(), e); } } }
public MysqlConnection fork() { MysqlConnection connection = new MysqlConnection(); connection.setCharset(getCharset()); connection.setSlaveId(getSlaveId()); connection.setConnector(connector.fork()); // set authInfo connection.setAuthInfo(authInfo); return connection; }
public void reconnect() throws IOException { connector.reconnect(); }
public MysqlConnection(InetSocketAddress address, String username, String password, byte charsetNumber, String defaultSchema){ authInfo = new AuthenticationInfo(); authInfo.setAddress(address); authInfo.setUsername(username); authInfo.setPassword(password); authInfo.setDefaultDatabaseName(defaultSchema); connector = new MysqlConnector(address, username, password, charsetNumber, defaultSchema); // 将connection里面的参数透传下 connector.setSoTimeout(soTimeout); connector.setConnTimeout(connTimeout); }
public MysqlUpdateExecutor(MysqlConnector connector) throws IOException{ if (!connector.isConnected()) { throw new IOException("should execute connector.connect() first"); } this.connector = connector; }