Search in sources :

Example 1 with MySQLPacketSplitter

use of io.mycat.beans.mysql.packet.MySQLPacketSplitter in project Mycat2 by MyCATApache.

the class LoaddataContext method proxy.

public void proxy(MycatSession mycat, String replicaName, String defaultDataBaseName) {
    int packetId = 2;
    MySQLPacketSplitter splitter = new PacketSplitterImpl();
    splitter.init(context.size());
    while (splitter.nextPacketInPacketSplitter()) {
        packetId++;
    }
    byte[] bytes = MySQLPacketUtil.generateMySQLPacket(2, context.toByteArray());
    context = null;
    splitter = null;
    int emptyPacketId = packetId;
    mycat.setHandleContentOfFilename(false);
    MySQLClientSession mySQLSession = mycat.getMySQLSession();
    mySQLSession.setMonopolizeType(MySQLSessionMonopolizeType.NONE);
    RequestHandler.INSTANCE.request(mycat.getMySQLSession(), bytes, new RequestCallback() {

        @Override
        public void onFinishedSend(MySQLClientSession session, Object sender, Object attr) {
            byte[] emptyPacket = MySQLPacketUtil.generateMySQLPacket(emptyPacketId, new byte[] {});
        // @todo
        // MySQLProxyNIOHandler
        // .INSTANCE.proxyBackend(mycat, emptyPacket, targetName,defaultDataBaseName, null, ResponseType.QUERY,
        // MySQLProxyNIOHandler.INSTANCE, DEFAULT_BACKEND_SESSION_REQUEST_FAILED_CALLBACK
        // );
        }

        @Override
        public void onFinishedSendException(Exception e, Object sender, Object attr) {
            mycat.setMySQLSession(null);
            mycat.setLastMessage(e.toString());
            mycat.writeErrorEndPacketBySyncInProcessError();
        }
    });
}
Also used : MySQLPacketSplitter(io.mycat.beans.mysql.packet.MySQLPacketSplitter) RequestCallback(io.mycat.proxy.callback.RequestCallback) PacketSplitterImpl(io.mycat.beans.mysql.packet.PacketSplitterImpl) MySQLClientSession(io.mycat.proxy.session.MySQLClientSession)

Aggregations

MySQLPacketSplitter (io.mycat.beans.mysql.packet.MySQLPacketSplitter)1 PacketSplitterImpl (io.mycat.beans.mysql.packet.PacketSplitterImpl)1 RequestCallback (io.mycat.proxy.callback.RequestCallback)1 MySQLClientSession (io.mycat.proxy.session.MySQLClientSession)1