Search in sources :

Example 1 with ResponseStatsPerClientHandler

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

the class JdbcMetricsAccessor method getResponseStatsPerClient.

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

Aggregations

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