Search in sources :

Example 1 with ResponseStatsPerPlanHandler

use of io.apiman.manager.api.jdbc.handlers.ResponseStatsPerPlanHandler in project apiman by apiman.

the class JdbcMetricsAccessor method getResponseStatsPerPlan.

/**
 * @see io.apiman.manager.api.core.IMetricsAccessor#getResponseStatsPerPlan(java.lang.String, java.lang.String, java.lang.String, org.joda.time.DateTime, org.joda.time.DateTime)
 */
@Override
public ResponseStatsPerPlanBean getResponseStatsPerPlan(String organizationId, String apiId, String version, DateTime from, DateTime to) {
    try {
        QueryRunner run = new QueryRunner(ds);
        // $NON-NLS-1$
        String sql = "SELECT plan, resp_type, count(*) FROM gw_requests WHERE api_org_id = ? AND api_id = ? AND api_version = ? AND rstart >= ? AND rstart < ? GROUP BY plan, resp_type";
        ResultSetHandler<ResponseStatsPerPlanBean> handler = new ResponseStatsPerPlanHandler();
        return run.query(sql, handler, organizationId, apiId, version, from.getMillis(), to.getMillis());
    } catch (SQLException e) {
        e.printStackTrace();
        return new ResponseStatsPerPlanBean();
    }
}
Also used : ResponseStatsPerPlanBean(io.apiman.manager.api.beans.metrics.ResponseStatsPerPlanBean) SQLException(java.sql.SQLException) ResponseStatsPerPlanHandler(io.apiman.manager.api.jdbc.handlers.ResponseStatsPerPlanHandler) QueryRunner(org.apache.commons.dbutils.QueryRunner)

Aggregations

ResponseStatsPerPlanBean (io.apiman.manager.api.beans.metrics.ResponseStatsPerPlanBean)1 ResponseStatsPerPlanHandler (io.apiman.manager.api.jdbc.handlers.ResponseStatsPerPlanHandler)1 SQLException (java.sql.SQLException)1 QueryRunner (org.apache.commons.dbutils.QueryRunner)1