Search in sources :

Example 6 with ReactorEnvThread

use of io.mycat.proxy.reactor.ReactorEnvThread in project Mycat2 by MyCATApache.

the class Session method lazyClose.

default PromiseInternal<Void> lazyClose(boolean normal, String hint) {
    PromiseInternal<Void> promise = VertxUtil.newPromise();
    getIOThread().addNIOJob(new NIOJob() {

        @Override
        public void run(ReactorEnvThread reactor) throws Exception {
            close(normal, hint).onComplete(o -> promise.tryComplete());
        }

        @Override
        public void stop(ReactorEnvThread reactor, Exception reason) {
            close(normal, hint).onComplete(o -> promise.tryComplete());
        }

        @Override
        public String message() {
            return hint;
        }
    });
    return promise;
}
Also used : PrintWriter(java.io.PrintWriter) NIOHandler(io.mycat.proxy.handler.NIOHandler) PromiseInternal(io.vertx.core.impl.future.PromiseInternal) Logger(org.slf4j.Logger) Wrapper(io.mycat.Wrapper) StringWriter(java.io.StringWriter) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) VertxUtil(io.mycat.util.VertxUtil) NIOJob(io.mycat.proxy.reactor.NIOJob) SocketChannel(java.nio.channels.SocketChannel) ReactorEnvThread(io.mycat.proxy.reactor.ReactorEnvThread) MycatReactorThread(io.mycat.proxy.reactor.MycatReactorThread) ReactorEnvThread(io.mycat.proxy.reactor.ReactorEnvThread) NIOJob(io.mycat.proxy.reactor.NIOJob) IOException(java.io.IOException)

Example 7 with ReactorEnvThread

use of io.mycat.proxy.reactor.ReactorEnvThread in project Mycat2 by MyCATApache.

the class MySQLAPIRuntimeImpl method addPengdingJob.

@Override
public void addPengdingJob(MySQLJobCallback callback) {
    MycatReactorThread thread = (MycatReactorThread) Thread.currentThread();
    thread.addNIOJob(new NIOJob() {

        @Override
        public void run(ReactorEnvThread reactor) throws Exception {
            callback.run();
        }

        @Override
        public void stop(ReactorEnvThread reactor, Exception reason) {
            callback.stop(reason);
        }

        @Override
        public String message() {
            return callback.message();
        }
    });
}
Also used : ReactorEnvThread(io.mycat.proxy.reactor.ReactorEnvThread) MycatReactorThread(io.mycat.proxy.reactor.MycatReactorThread) NIOJob(io.mycat.proxy.reactor.NIOJob)

Aggregations

ReactorEnvThread (io.mycat.proxy.reactor.ReactorEnvThread)7 NIOJob (io.mycat.proxy.reactor.NIOJob)5 MycatException (io.mycat.MycatException)4 MySQLClientSession (io.mycat.proxy.session.MySQLClientSession)3 PromiseInternal (io.vertx.core.impl.future.PromiseInternal)3 MycatReactorThread (io.mycat.proxy.reactor.MycatReactorThread)2 VertxUtil (io.mycat.util.VertxUtil)2 Future (io.vertx.core.Future)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Wrapper (io.mycat.Wrapper)1 MySQLCommandType (io.mycat.beans.mysql.MySQLCommandType)1 MySQLErrorCode (io.mycat.beans.mysql.MySQLErrorCode)1 ErrorPacketImpl (io.mycat.beans.mysql.packet.ErrorPacketImpl)1 ResultSetCallBack (io.mycat.proxy.callback.ResultSetCallBack)1 NIOHandler (io.mycat.proxy.handler.NIOHandler)1 AsyncResult (io.vertx.core.AsyncResult)1 CompositeFuture (io.vertx.core.CompositeFuture)1 Handler (io.vertx.core.Handler)1 MySQLClient (io.vertx.mysqlclient.MySQLClient)1