@Test public void testEstimate() throws Exception { createTable("estimate_test", driver.getEstimateConnection()); insertData("estimate_test", driver.getEstimateConnection()); String query1 = "SELECT * FROM estimate_test"; ExplainQueryContext ctx = createExplainContext(query1, baseConf); Assert.assertNull(ctx.getFinalDriverQuery(driver)); QueryCost cost = driver.estimate(ctx); Assert.assertEquals(cost, JDBC_COST); Assert.assertNotNull(ctx.getFinalDriverQuery(driver)); final int maxEstimateConnections = driver.getEstimateConnectionConf().getInt(JDBC_POOL_MAX_SIZE.getConfigKey(), 50); for (int i = 0; i < maxEstimateConnections + 10; i++) { try { log.info("Iteration#{}", (i + 1)); String query = i > maxEstimateConnections ? "SELECT * FROM estimate_test" : "CREATE TABLE FOO(ID INT)"; ExplainQueryContext context = createExplainContext(query, baseConf); cost = driver.estimate(context); } catch (LensException exc) { Throwable th = exc.getCause(); while (th != null) { assertFalse(th instanceof SQLException); th = th.getCause(); } } } }
@Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { MethodMetricsContext validateGauge = MethodMetricsFactory.createMethodGauge(qctx.getDriverConf(this), true, VALIDATE_GAUGE); validate(qctx); validateGauge.markSuccess(); return calculateQueryCost(qctx); }
JDBCDriver extends AbstractLensDriver { @Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { MethodMetricsContext validateGauge = MethodMetricsFactory.createMethodGauge(qctx.getDriverConf(this), true, VALIDATE_GAUGE); validate(qctx); validateGauge.markSuccess(); return calculateQueryCost(qctx); } }
JDBCDriver extends AbstractLensDriver { @Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { MethodMetricsContext validateGauge = MethodMetricsFactory.createMethodGauge(qctx.getDriverConf(this), true, VALIDATE_GAUGE); validate(qctx); validateGauge.markSuccess(); return calculateQueryCost(qctx); }  }
JDBCDriver extends AbstractLensDriver { @Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { MethodMetricsContext validateGauge = MethodMetricsFactory.createMethodGauge(qctx.getDriverConf(this), true, VALIDATE_GAUGE); validate(qctx); validateGauge.markSuccess(); return calculateQueryCost(qctx); }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); }
JDBCDriver extends AbstractLensDriver { @Override public QueryCost estimate(AbstractQueryContext qctx) throws LensException { MethodMetricsContext validateGauge = MethodMetricsFactory.createMethodGauge(qctx.getDriverConf(this), true, VALIDATE_GAUGE); validate(qctx); validateGauge.markSuccess(); return calculateQueryCost(qctx); }  @Override void configure(Configuration conf, String driverType, String driverName); void init(); QueryCost calculateQueryCost(AbstractQueryContext qctx); @Override QueryCost estimate(AbstractQueryContext qctx); @Override DriverQueryPlan explain(AbstractQueryContext explainCtx); void validate(AbstractQueryContext pContext); @Override void prepare(PreparedQueryContext pContext); @Override DriverQueryPlan explainAndPrepare(PreparedQueryContext pContext); @Override void closePreparedQuery(QueryPrepareHandle handle); @Override LensResultSet execute(QueryContext context); @Override void executeAsync(QueryContext context); @Override void updateStatus(QueryContext context); @Override void closeResultSet(QueryHandle handle); @Override boolean cancelQuery(QueryHandle handle); @Override void closeQuery(QueryHandle handle); @Override void close(); @Override void registerDriverEventListener(LensEventListener<DriverEvent> driverEventListener); @Override void readExternal(ObjectInput arg0); @Override void writeExternal(ObjectOutput arg0); @Override StatusUpdateMethod getStatusUpdateMethod(); static final AtomicInteger THID; }