use of io.mycat.proxy.callback.RequestCallback 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();
}
});
}
Aggregations