/** * Execute query with timeout option. * If the query does not finish within the timeout time, server returns the query handle which can be used to * track further progress. * * @param sql : query/command to be executed * @param queryName : optional query name * @param timeOutMillis : timeout milliseconds for the query execution. * @return * @throws LensAPIException */ @Deprecated public QueryHandleWithResultSet executeQueryWithTimeout(String sql, String queryName, long timeOutMillis) throws LensAPIException { return executeQueryWithTimeout(sql, queryName, timeOutMillis, new LensConf()); }
/** * Execute query with timeout option. * If the query does not finish within the timeout time, server returns the query handle which can be used to * track further progress. * * @param sql : query/command to be executed * @param queryName : optional query name * @param timeOutMillis : timeout milliseconds for the query execution. * @return * @throws LensAPIException */ @Deprecated public QueryHandleWithResultSet executeQueryWithTimeout(String sql, String queryName, long timeOutMillis) throws LensAPIException { return executeQueryWithTimeout(sql, queryName, timeOutMillis, new LensConf()); }
@Test public void testTimeout() throws LensAPIException { LensClientConfig config = createLensClientConfigWithServerUrl(); LensClient lensClient = new LensClient(config); assertTrue(lensClient.setDatabase(TEST_DB)); try { // Setting very small timeout. Expecting timeouts after this // Note: Timeout values can be changed even after LensClient has been created. config.setInt(LensClientConfig.READ_TIMEOUT_MILLIS, 200); lensClient.executeQueryWithTimeout("cube select id,name from test_dim", "test1", 100000, new LensConf()); fail("Read Timeout was expected"); } catch (Exception e) { if (!(isExceptionDueToSocketTimeout(e))) { log.error("Unexpected Exception", e); fail("SocketTimeoutException was excepted as part of Read Timeout"); } else { log.debug("Expected Exception", e); } } //Setting back default timeout. Not expecting timeouts after this config.setInt(LensClientConfig.READ_TIMEOUT_MILLIS, LensClientConfig.DEFAULT_READ_TIMEOUT_MILLIS); QueryHandleWithResultSet result = lensClient.executeQueryWithTimeout("cube select id,name from test_dim", "test2", 100000, new LensConf()); assertTrue(result.getStatus().successful()); lensClient.closeConnection(); }
LensCliConfigConstants.DEFAULT_QUERY_EXECUTE_TIMEOUT_MILLIS); LensClient.getCliLogger().info("Executing query with timeout of {} milliseconds", timeOutMillis); QueryHandleWithResultSet result = getClient().executeQueryWithTimeout(sql, queryName, timeOutMillis, new LensConf()); if (result.getResult() == null) {
LensCliConfigConstants.DEFAULT_QUERY_EXECUTE_TIMEOUT_MILLIS); LensClient.getCliLogger().info("Executing query with timeout of {} milliseconds", timeOutMillis); QueryHandleWithResultSet result = getClient().executeQueryWithTimeout(sql, queryName, timeOutMillis, new LensConf()); if (result.getResult() == null) {