Search in sources :

Example 26 with ResultSetBuilder

use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.

the class ShowEnginesSQLHandler method onExecute.

@Override
protected Future<Void> onExecute(SQLRequest<MySqlShowEnginesStatement> request, MycatDataContext dataContext, Response response) {
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    resultSetBuilder.addColumnInfo("Engine", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("Support", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("Comment", JDBCType.VARCHAR);
    resultSetBuilder.addObjectRowPayload(Arrays.asList("InnoDB", "DEFAULT", "Supports transactions, row-level locking, foreign keys and encryption for tables"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("CSV", "YES", "Stores tables as CSV files"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("MRG_MyISAM", "YES", "Collection of identical MyISAM tables"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("MEMORY", "YES", "Hash based, stored in memory, useful for temporary tables"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("MyISAM", "YES", "Non-transactional engine with good performance and small data footprint"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("SEQUENCE", "YES", "Generated tables filled with sequential values"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("Aria", "YES", "Crash-safe tables with MyISAM heritage"));
    resultSetBuilder.addObjectRowPayload(Arrays.asList("PERFORMANCE_SCHEMA", "YES", "Performance Schema"));
    return response.sendResultSet(() -> resultSetBuilder.build());
}
Also used : ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder)

Example 27 with ResultSetBuilder

use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.

the class AnalyzeHanlder method onExecute.

@Override
protected Future<Void> onExecute(SQLRequest<MySqlAnalyzeStatement> request, MycatDataContext dataContext, Response response) {
    MySqlAnalyzeStatement ast = request.getAst();
    List<SQLExprTableSource> tableSources = Optional.ofNullable(ast.getTableSources()).orElse(Collections.emptyList());
    if (tableSources.isEmpty()) {
        return response.sendError(new MycatException("need tables"));
    } else {
        ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
        resultSetBuilder.addColumnInfo("Table", JDBCType.VARCHAR);
        resultSetBuilder.addColumnInfo("Op", JDBCType.VARCHAR);
        resultSetBuilder.addColumnInfo("Msg_type", JDBCType.VARCHAR);
        resultSetBuilder.addColumnInfo("Msg_Text", JDBCType.VARCHAR);
        for (SQLExprTableSource tableSource : tableSources) {
            String schemaName = SQLUtils.normalize(tableSource.getSchema());
            String tableName = SQLUtils.normalize(tableSource.getTableName());
            resultSetBuilder.addObjectRowPayload(Arrays.asList(schemaName + "." + tableName, "analyze", "status", "OK"));
            MetadataManager metadataManager = MetaClusterCurrent.wrapper(MetadataManager.class);
            TableHandler tableHandler = metadataManager.getTable(schemaName, tableName);
            if (tableHandler == null) {
                return response.sendError(new MycatException(tableSource + "不存在"));
            }
            StatisticCenter statisticCenter = MetaClusterCurrent.wrapper(StatisticCenter.class);
            statisticCenter.fetchTableRowCount(tableHandler);
        }
        return response.sendResultSet(resultSetBuilder.build());
    }
}
Also used : MySqlAnalyzeStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlAnalyzeStatement) MycatException(io.mycat.MycatException) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) MetadataManager(io.mycat.MetadataManager) TableHandler(io.mycat.TableHandler) StatisticCenter(io.mycat.statistic.StatisticCenter) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource)

Example 28 with ResultSetBuilder

use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.

the class HintHandler method showClusters.

public static RowBaseIterator showClusters(String clusterName) {
    MycatRouterConfig routerConfig = MetaClusterCurrent.wrapper(MycatRouterConfig.class);
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    resultSetBuilder.addColumnInfo("NAME", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("SWITCH_TYPE", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("MAX_REQUEST_COUNT", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("TYPE", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("WRITE_DS", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("READ_DS", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("WRITE_L", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("READ_L", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("AVAILABLE", JDBCType.VARCHAR);
    Collection<ReplicaSelector> values = MetaClusterCurrent.wrapper(ReplicaSelectorManager.class).getReplicaMap().values();
    Map<String, ClusterConfig> clusterConfigMap = routerConfig.getClusters().stream().collect(Collectors.toMap(k -> k.getName(), v -> v));
    for (ReplicaSelector value : values.stream().filter(v -> {
        if (clusterName != null) {
            return clusterName.equalsIgnoreCase(v.getName());
        }
        return true;
    }).collect(Collectors.toList())) {
        String NAME = value.getName();
        Optional<ClusterConfig> e = Optional.ofNullable(clusterConfigMap.get(NAME));
        ReplicaSwitchType SWITCH_TYPE = value.getSwitchType();
        int MAX_REQUEST_COUNT = value.maxRequestCount();
        String TYPE = value.getBalanceType().name();
        String WRITE_DS = ((List<PhysicsInstance>) value.getWriteDataSourceByReplicaType()).stream().map(i -> i.getName()).collect(Collectors.joining(","));
        String READ_DS = (value.getReadDataSourceByReplica()).stream().map(i -> i.getName()).collect(Collectors.joining(","));
        String WL = Optional.ofNullable(value.getDefaultWriteLoadBalanceStrategy()).map(i -> i.getClass().getName()).orElse(null);
        String RL = Optional.ofNullable(value.getDefaultReadLoadBalanceStrategy()).map(i -> i.getClass().getName()).orElse(null);
        String AVAILABLE = Boolean.toString(((List<PhysicsInstance>) value.getWriteDataSourceByReplicaType()).stream().anyMatch(PhysicsInstance::isAlive));
        resultSetBuilder.addObjectRowPayload(Arrays.asList(NAME, SWITCH_TYPE, MAX_REQUEST_COUNT, TYPE, WRITE_DS, READ_DS, WL, RL, AVAILABLE));
    }
    return resultSetBuilder.build();
}
Also used : MycatdbCommand(io.mycat.commands.MycatdbCommand) io.mycat(io.mycat) CSVRecord(org.apache.commons.csv.CSVRecord) JdbcDataSource(io.mycat.datasource.jdbc.datasource.JdbcDataSource) CSVFormat(org.apache.commons.csv.CSVFormat) HeartbeatFlow(io.mycat.replica.heartbeat.HeartbeatFlow) Duration(java.time.Duration) MySQLErrorCode(io.mycat.beans.mysql.MySQLErrorCode) JsonUtil(io.mycat.util.JsonUtil) MySqlHintStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlHintStatement) io.mycat.config(io.mycat.config) Timestamp(java.sql.Timestamp) Reader(java.io.Reader) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) MycatSQLLogMonitor(io.mycat.monitor.MycatSQLLogMonitor) io.mycat.sqlhandler(io.mycat.sqlhandler) NormalTable(io.mycat.calcite.table.NormalTable) Nullable(org.jetbrains.annotations.Nullable) ReplicaSelector(io.mycat.replica.ReplicaSelector) UpdateSQLHandler(io.mycat.sqlhandler.dml.UpdateSQLHandler) Stream(java.util.stream.Stream) ReplicaSelectorManager(io.mycat.replica.ReplicaSelectorManager) DrdsRunnerHelper(io.mycat.calcite.DrdsRunnerHelper) PhysicsInstance(io.mycat.replica.PhysicsInstance) NotNull(org.jetbrains.annotations.NotNull) ShardingTable(io.mycat.calcite.table.ShardingTable) VertxExecuter(io.mycat.vertx.VertxExecuter) SqlEntry(io.mycat.monitor.SqlEntry) java.util(java.util) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) SQLIdentifierExpr(com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr) LocalDateTime(java.time.LocalDateTime) XaLog(cn.mycat.vertx.xa.XaLog) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) SqlResultSetService(io.mycat.commands.SqlResultSetService) InterruptThreadHint(io.mycat.hint.InterruptThreadHint) MycatSQLExprTableSourceUtil(io.mycat.util.MycatSQLExprTableSourceUtil) KillThreadHint(io.mycat.hint.KillThreadHint) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) JDBCType(java.sql.JDBCType) PrepareExecutor(io.mycat.calcite.PrepareExecutor) SchemaHandler(io.mycat.calcite.table.SchemaHandler) MySqlInsertStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement) ImmutableList(com.google.common.collect.ImmutableList) DatasourceStatus(io.mycat.replica.heartbeat.DatasourceStatus) Observable(io.reactivex.rxjava3.core.Observable) JdbcConnectionManager(io.mycat.datasource.jdbc.datasource.JdbcConnectionManager) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RowBaseIterator(io.mycat.api.collector.RowBaseIterator) StreamSupport(java.util.stream.StreamSupport) GlobalTable(io.mycat.calcite.table.GlobalTable) SQLVariantRefExpr(com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr) SQLUtils(com.alibaba.druid.sql.SQLUtils) Flowable(io.reactivex.rxjava3.core.Flowable) PromiseInternal(io.vertx.core.impl.future.PromiseInternal) io.mycat.hint(io.mycat.hint) VertxUpdateExecuter(io.mycat.vertx.VertxUpdateExecuter) StringWriter(java.io.StringWriter) SQLInsertStatement(com.alibaba.druid.sql.ast.statement.SQLInsertStatement) ExecutorProvider(io.mycat.calcite.ExecutorProvider) IOException(java.io.IOException) QuoteMode(org.apache.commons.csv.QuoteMode) SQLCommentHint(com.alibaba.druid.sql.ast.SQLCommentHint) SqlRecorderRuntime(io.mycat.exporter.SqlRecorderRuntime) VertxUtil(io.mycat.util.VertxUtil) ReplicaSwitchType(io.mycat.replica.ReplicaSwitchType) SQLCharExpr(com.alibaba.druid.sql.ast.expr.SQLCharExpr) MycatInsertRel(io.mycat.calcite.physical.MycatInsertRel) io.mycat.calcite.spm(io.mycat.calcite.spm) NameMap(io.mycat.util.NameMap) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) JdbcUtils(com.alibaba.druid.util.JdbcUtils) CodeExecuterContext(io.mycat.calcite.CodeExecuterContext) HeartBeatStatus(io.mycat.replica.heartbeat.HeartBeatStatus) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) FileReader(java.io.FileReader) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource) StorageManager(io.mycat.sqlhandler.config.StorageManager) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) ReplicaSelector(io.mycat.replica.ReplicaSelector) ReplicaSwitchType(io.mycat.replica.ReplicaSwitchType) ImmutableList(com.google.common.collect.ImmutableList) InterruptThreadHint(io.mycat.hint.InterruptThreadHint) KillThreadHint(io.mycat.hint.KillThreadHint) io.mycat.hint(io.mycat.hint) SQLCommentHint(com.alibaba.druid.sql.ast.SQLCommentHint)

Example 29 with ResultSetBuilder

use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.

the class HintHandler method showHeatbeatStat.

public static RowBaseIterator showHeatbeatStat() {
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    resultSetBuilder.addColumnInfo("NAME", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("TYPE", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("READABLE", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("SESSION_COUNT", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("WEIGHT", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("ALIVE", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("MASTER", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("LIMIT_SESSION_COUNT", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("REPLICA", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("SLAVE_THRESHOLD", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("IS_HEARTBEAT_TIMEOUT", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("HB_ERROR_COUNT", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("HB_LAST_SWITCH_TIME", JDBCType.TIMESTAMP);
    resultSetBuilder.addColumnInfo("HB_MAX_RETRY", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("IS_CHECKING", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("MIN_SWITCH_TIME_INTERVAL", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("HEARTBEAT_TIMEOUT", JDBCType.BIGINT);
    resultSetBuilder.addColumnInfo("SYNC_DS_STATUS", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("HB_DS_STATUS", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("IS_SLAVE_BEHIND_MASTER", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("LAST_SEND_QUERY_TIME", JDBCType.TIMESTAMP);
    resultSetBuilder.addColumnInfo("LAST_RECEIVED_QUERY_TIME", JDBCType.TIMESTAMP);
    if (MetaClusterCurrent.exist(MycatRouterConfig.class) && MetaClusterCurrent.exist(ReplicaSelectorManager.class)) {
        MycatRouterConfig routerConfig = MetaClusterCurrent.wrapper(MycatRouterConfig.class);
        ReplicaSelectorManager replicaSelectorRuntime = MetaClusterCurrent.wrapper(ReplicaSelectorManager.class);
        Map<String, DatasourceConfig> dataSourceConfig = routerConfig.getDatasources().stream().collect(Collectors.toMap(k -> k.getName(), v -> v));
        for (HeartbeatFlow heartbeatFlow : replicaSelectorRuntime.getHeartbeatDetectorMap().values()) {
            PhysicsInstance instance = heartbeatFlow.instance();
            String NAME = instance.getName();
            String TYPE = instance.getType().name();
            boolean READABLE = instance.asSelectRead();
            int SESSION_COUNT = instance.getSessionCounter();
            int WEIGHT = instance.getWeight();
            boolean ALIVE = instance.isAlive();
            boolean MASTER = instance.isMaster();
            double SLAVE_THRESHOLD = heartbeatFlow.getSlaveThreshold();
            boolean IS_HEARTBEAT_TIMEOUT = heartbeatFlow.isHeartbeatTimeout();
            final HeartBeatStatus HEART_BEAT_STATUS = heartbeatFlow.getHbStatus();
            int HB_ERROR_COUNT = HEART_BEAT_STATUS.getErrorCount();
            LocalDateTime HB_LAST_SWITCH_TIME = new Timestamp(HEART_BEAT_STATUS.getLastSwitchTime()).toLocalDateTime();
            int HB_MAX_RETRY = HEART_BEAT_STATUS.getMaxRetry();
            boolean IS_CHECKING = HEART_BEAT_STATUS.isChecking();
            long MIN_SWITCH_TIME_INTERVAL = HEART_BEAT_STATUS.getMinSwitchTimeInterval();
            final long HEARTBEAT_TIMEOUT = (heartbeatFlow.getHeartbeatTimeout());
            DatasourceStatus DS_STATUS_OBJECT = heartbeatFlow.getDsStatus();
            String SYNC_DS_STATUS = DS_STATUS_OBJECT.getDbSynStatus().name();
            String HB_DS_STATUS = DS_STATUS_OBJECT.getStatus().name();
            boolean IS_SLAVE_BEHIND_MASTER = DS_STATUS_OBJECT.isSlaveBehindMaster();
            LocalDateTime LAST_SEND_QUERY_TIME = new Timestamp(heartbeatFlow.getLastSendQryTime()).toLocalDateTime();
            LocalDateTime LAST_RECEIVED_QUERY_TIME = new Timestamp(heartbeatFlow.getLastReceivedQryTime()).toLocalDateTime();
            Optional<DatasourceConfig> e = Optional.ofNullable(dataSourceConfig.get(NAME));
            String replicaDataSourceSelectorList = String.join(",", replicaSelectorRuntime.getReplicaNameListByInstanceName(NAME));
            resultSetBuilder.addObjectRowPayload(Arrays.asList(NAME, TYPE, READABLE, SESSION_COUNT, WEIGHT, ALIVE, MASTER, e.map(i -> i.getMaxCon()).orElse(-1), replicaDataSourceSelectorList, SLAVE_THRESHOLD, IS_HEARTBEAT_TIMEOUT, HB_ERROR_COUNT, HB_LAST_SWITCH_TIME, HB_MAX_RETRY, IS_CHECKING, MIN_SWITCH_TIME_INTERVAL, HEARTBEAT_TIMEOUT, SYNC_DS_STATUS, HB_DS_STATUS, IS_SLAVE_BEHIND_MASTER, LAST_SEND_QUERY_TIME, LAST_RECEIVED_QUERY_TIME));
        }
    }
    RowBaseIterator rowBaseIterator = resultSetBuilder.build();
    return rowBaseIterator;
}
Also used : ReplicaSelectorManager(io.mycat.replica.ReplicaSelectorManager) MycatdbCommand(io.mycat.commands.MycatdbCommand) io.mycat(io.mycat) CSVRecord(org.apache.commons.csv.CSVRecord) JdbcDataSource(io.mycat.datasource.jdbc.datasource.JdbcDataSource) CSVFormat(org.apache.commons.csv.CSVFormat) HeartbeatFlow(io.mycat.replica.heartbeat.HeartbeatFlow) Duration(java.time.Duration) MySQLErrorCode(io.mycat.beans.mysql.MySQLErrorCode) JsonUtil(io.mycat.util.JsonUtil) MySqlHintStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlHintStatement) io.mycat.config(io.mycat.config) Timestamp(java.sql.Timestamp) Reader(java.io.Reader) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) ArrayBindable(org.apache.calcite.runtime.ArrayBindable) MycatSQLLogMonitor(io.mycat.monitor.MycatSQLLogMonitor) io.mycat.sqlhandler(io.mycat.sqlhandler) NormalTable(io.mycat.calcite.table.NormalTable) Nullable(org.jetbrains.annotations.Nullable) ReplicaSelector(io.mycat.replica.ReplicaSelector) UpdateSQLHandler(io.mycat.sqlhandler.dml.UpdateSQLHandler) Stream(java.util.stream.Stream) ReplicaSelectorManager(io.mycat.replica.ReplicaSelectorManager) DrdsRunnerHelper(io.mycat.calcite.DrdsRunnerHelper) PhysicsInstance(io.mycat.replica.PhysicsInstance) NotNull(org.jetbrains.annotations.NotNull) ShardingTable(io.mycat.calcite.table.ShardingTable) VertxExecuter(io.mycat.vertx.VertxExecuter) SqlEntry(io.mycat.monitor.SqlEntry) java.util(java.util) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) SQLIdentifierExpr(com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr) LocalDateTime(java.time.LocalDateTime) XaLog(cn.mycat.vertx.xa.XaLog) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) SqlResultSetService(io.mycat.commands.SqlResultSetService) InterruptThreadHint(io.mycat.hint.InterruptThreadHint) MycatSQLExprTableSourceUtil(io.mycat.util.MycatSQLExprTableSourceUtil) KillThreadHint(io.mycat.hint.KillThreadHint) Schedulers(io.reactivex.rxjava3.schedulers.Schedulers) JDBCType(java.sql.JDBCType) PrepareExecutor(io.mycat.calcite.PrepareExecutor) SchemaHandler(io.mycat.calcite.table.SchemaHandler) MySqlInsertStatement(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement) ImmutableList(com.google.common.collect.ImmutableList) DatasourceStatus(io.mycat.replica.heartbeat.DatasourceStatus) Observable(io.reactivex.rxjava3.core.Observable) JdbcConnectionManager(io.mycat.datasource.jdbc.datasource.JdbcConnectionManager) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) RowBaseIterator(io.mycat.api.collector.RowBaseIterator) StreamSupport(java.util.stream.StreamSupport) GlobalTable(io.mycat.calcite.table.GlobalTable) SQLVariantRefExpr(com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr) SQLUtils(com.alibaba.druid.sql.SQLUtils) Flowable(io.reactivex.rxjava3.core.Flowable) PromiseInternal(io.vertx.core.impl.future.PromiseInternal) io.mycat.hint(io.mycat.hint) VertxUpdateExecuter(io.mycat.vertx.VertxUpdateExecuter) StringWriter(java.io.StringWriter) SQLInsertStatement(com.alibaba.druid.sql.ast.statement.SQLInsertStatement) ExecutorProvider(io.mycat.calcite.ExecutorProvider) IOException(java.io.IOException) QuoteMode(org.apache.commons.csv.QuoteMode) SQLCommentHint(com.alibaba.druid.sql.ast.SQLCommentHint) SqlRecorderRuntime(io.mycat.exporter.SqlRecorderRuntime) VertxUtil(io.mycat.util.VertxUtil) ReplicaSwitchType(io.mycat.replica.ReplicaSwitchType) SQLCharExpr(com.alibaba.druid.sql.ast.expr.SQLCharExpr) MycatInsertRel(io.mycat.calcite.physical.MycatInsertRel) io.mycat.calcite.spm(io.mycat.calcite.spm) NameMap(io.mycat.util.NameMap) MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) JdbcUtils(com.alibaba.druid.util.JdbcUtils) CodeExecuterContext(io.mycat.calcite.CodeExecuterContext) HeartBeatStatus(io.mycat.replica.heartbeat.HeartBeatStatus) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) UnmodifiableIterator(com.google.common.collect.UnmodifiableIterator) FileReader(java.io.FileReader) SQLExprTableSource(com.alibaba.druid.sql.ast.statement.SQLExprTableSource) StorageManager(io.mycat.sqlhandler.config.StorageManager) LocalDateTime(java.time.LocalDateTime) ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) HeartbeatFlow(io.mycat.replica.heartbeat.HeartbeatFlow) Timestamp(java.sql.Timestamp) InterruptThreadHint(io.mycat.hint.InterruptThreadHint) KillThreadHint(io.mycat.hint.KillThreadHint) io.mycat.hint(io.mycat.hint) SQLCommentHint(com.alibaba.druid.sql.ast.SQLCommentHint) HeartBeatStatus(io.mycat.replica.heartbeat.HeartBeatStatus) DatasourceStatus(io.mycat.replica.heartbeat.DatasourceStatus) PhysicsInstance(io.mycat.replica.PhysicsInstance) RowBaseIterator(io.mycat.api.collector.RowBaseIterator)

Example 30 with ResultSetBuilder

use of io.mycat.beans.mycat.ResultSetBuilder in project Mycat2 by MyCATApache.

the class ShowPluginsSQLHandler method onExecute.

@Override
protected Future<Void> onExecute(SQLRequest<MySqlShowPluginsStatement> request, MycatDataContext dataContext, Response response) {
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    resultSetBuilder.addColumnInfo("Name", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("Status", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("Type", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("Library", JDBCType.VARCHAR);
    resultSetBuilder.addColumnInfo("License", JDBCType.VARCHAR);
    return response.sendResultSet(resultSetBuilder.build());
}
Also used : ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder)

Aggregations

ResultSetBuilder (io.mycat.beans.mycat.ResultSetBuilder)32 RowBaseIterator (io.mycat.api.collector.RowBaseIterator)13 JDBCType (java.sql.JDBCType)12 LocalDateTime (java.time.LocalDateTime)11 io.mycat.config (io.mycat.config)10 ReplicaSelectorManager (io.mycat.replica.ReplicaSelectorManager)10 IOException (java.io.IOException)10 Timestamp (java.sql.Timestamp)10 java.util (java.util)10 Collectors (java.util.stream.Collectors)10 NotNull (org.jetbrains.annotations.NotNull)10 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)9 NameMap (io.mycat.util.NameMap)9 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)8 SQLExprTableSource (com.alibaba.druid.sql.ast.statement.SQLExprTableSource)8 SQLInsertStatement (com.alibaba.druid.sql.ast.statement.SQLInsertStatement)8 SQLCommentHint (com.alibaba.druid.sql.ast.SQLCommentHint)7 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)7 ImmutableList (com.google.common.collect.ImmutableList)7 MysqlPayloadObject (io.mycat.api.collector.MysqlPayloadObject)7