Search in sources :

Example 1 with MycatSQLLogMonitor

use of io.mycat.monitor.MycatSQLLogMonitor in project Mycat2 by MyCATApache.

the class HintHandler method getSqlTimeFilter.

private Future<Void> getSqlTimeFilter(Response response, String body, MetadataManager metadataManager) {
    ResultSetBuilder resultSetBuilder = ResultSetBuilder.create();
    resultSetBuilder.addColumnInfo("value", JDBCType.VARCHAR);
    long sqlTimeFilter = -1;
    if (MetaClusterCurrent.exist(MycatSQLLogMonitor.class)) {
        MycatSQLLogMonitor mycatSQLLogMonitor = MetaClusterCurrent.wrapper(MycatSQLLogMonitor.class);
        sqlTimeFilter = mycatSQLLogMonitor.getSqlTimeFilter();
    }
    resultSetBuilder.addObjectRowPayload(Arrays.asList(sqlTimeFilter));
    return response.sendResultSet(resultSetBuilder.build());
}
Also used : ResultSetBuilder(io.mycat.beans.mycat.ResultSetBuilder) MycatSQLLogMonitor(io.mycat.monitor.MycatSQLLogMonitor)

Example 2 with MycatSQLLogMonitor

use of io.mycat.monitor.MycatSQLLogMonitor in project Mycat2 by MyCATApache.

the class HintHandler method setSqlTimeFilter.

private Future<Void> setSqlTimeFilter(Response response, String body, MetadataManager metadataManager) {
    Map map = JsonUtil.from(body, Map.class);
    Object value = map.get("value");
    if (value != null) {
        long s = Long.parseLong(value.toString());
        if (MetaClusterCurrent.exist(MycatSQLLogMonitor.class)) {
            MycatSQLLogMonitor mycatSQLLogMonitor = MetaClusterCurrent.wrapper(MycatSQLLogMonitor.class);
            mycatSQLLogMonitor.setSqlTimeFilter(s);
        }
    }
    return response.sendOk();
}
Also used : MysqlPayloadObject(io.mycat.api.collector.MysqlPayloadObject) NameMap(io.mycat.util.NameMap) MycatSQLLogMonitor(io.mycat.monitor.MycatSQLLogMonitor)

Aggregations

MycatSQLLogMonitor (io.mycat.monitor.MycatSQLLogMonitor)2 MysqlPayloadObject (io.mycat.api.collector.MysqlPayloadObject)1 ResultSetBuilder (io.mycat.beans.mycat.ResultSetBuilder)1 NameMap (io.mycat.util.NameMap)1