Search in sources :

Example 6 with IOExecutor

use of io.mycat.IOExecutor in project Mycat2 by MyCATApache.

the class ThreadMycatConnectionImplWrapper method prepareQuery.

@Override
public void prepareQuery(String sql, List<Object> params, MysqlCollector collector) {
    IOExecutor ioExecutor = MetaClusterCurrent.wrapper(IOExecutor.class);
    ioExecutor.executeBlocking(promise -> {
        try {
            this.stat.plusThread();
            newMycatConnection.prepareQuery(sql, params, collector);
            promise.tryComplete();
        } catch (Exception e) {
            promise.tryFail(e);
        } finally {
            this.stat.decThread();
        }
    });
}
Also used : IOExecutor(io.mycat.IOExecutor)

Example 7 with IOExecutor

use of io.mycat.IOExecutor in project Mycat2 by MyCATApache.

the class ThreadMycatConnectionImplWrapper method insert.

@Override
public Future<SqlResult> insert(String sql) {
    IOExecutor ioExecutor = MetaClusterCurrent.wrapper(IOExecutor.class);
    return ioExecutor.executeBlocking(promise -> {
        try {
            this.stat.plusThread();
            newMycatConnection.insert(sql).onComplete(promise);
        } catch (Exception e) {
            promise.tryFail(e);
        } finally {
            this.stat.decThread();
        }
    });
}
Also used : IOExecutor(io.mycat.IOExecutor)

Example 8 with IOExecutor

use of io.mycat.IOExecutor in project Mycat2 by MyCATApache.

the class ThreadMycatConnectionImplWrapper method query.

@Override
public Future<RowSet> query(String sql, List<Object> params) {
    IOExecutor ioExecutor = MetaClusterCurrent.wrapper(IOExecutor.class);
    return ioExecutor.executeBlocking(promise -> {
        try {
            this.stat.plusThread();
            newMycatConnection.query(sql, params).onComplete(promise);
        } catch (Exception e) {
            promise.tryFail(e);
        } finally {
            this.stat.decThread();
        }
    });
}
Also used : IOExecutor(io.mycat.IOExecutor)

Example 9 with IOExecutor

use of io.mycat.IOExecutor in project Mycat2 by MyCATApache.

the class ThreadMycatConnectionImplWrapper method update.

@Override
public Future<SqlResult> update(String sql) {
    IOExecutor ioExecutor = MetaClusterCurrent.wrapper(IOExecutor.class);
    return ioExecutor.executeBlocking(promise -> {
        try {
            this.stat.plusThread();
            newMycatConnection.update(sql).onComplete(promise);
        } catch (Exception e) {
            promise.tryFail(e);
        } finally {
            this.stat.decThread();
        }
    });
}
Also used : IOExecutor(io.mycat.IOExecutor)

Aggregations

IOExecutor (io.mycat.IOExecutor)9 MetaClusterCurrent (io.mycat.MetaClusterCurrent)2 Handler (io.vertx.core.Handler)2 Promise (io.vertx.core.Promise)2 Consumer (java.util.function.Consumer)2 SneakyThrows (lombok.SneakyThrows)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 JdbcUtils (com.alibaba.druid.util.JdbcUtils)1 ExecutorUtil (io.mycat.ExecutorUtil)1 MetadataManager (io.mycat.MetadataManager)1 NameableExecutor (io.mycat.NameableExecutor)1 MonitorConfig (io.mycat.config.MonitorConfig)1 SqlLogConfig (io.mycat.config.SqlLogConfig)1 TimerConfig (io.mycat.config.TimerConfig)1 DefaultConnection (io.mycat.datasource.jdbc.datasource.DefaultConnection)1 JdbcConnectionManager (io.mycat.datasource.jdbc.datasource.JdbcConnectionManager)1 SqlEntry (io.mycat.monitor.SqlEntry)1 GaugeMetricFamily (io.prometheus.client.GaugeMetricFamily)1 MultiMap (io.vertx.core.MultiMap)1