private void createDefaultUriProperties() { config = new LensConf(); config.addProperty(PATH_PREFIX + "hdfs", "://"); config.addProperty(PATH_PREFIX + "s3", "://"); config.addProperty(PATH_PREFIX + "s3n", "://"); }
/** * To lens conf. * * @param conf the conf * @return the lens conf */ private LensConf toLensConf(HiveConf conf) { LensConf lensConf = new LensConf(); lensConf.getProperties().putAll(conf.getValByRegex(".*")); return lensConf; }
public PathValidator(LensConf config) { createDefaultUriProperties(); this.config.addProperties(config.getProperties()); }
/** * Instantiates a new prepared query context. * * @param query the query * @param user the user * @param conf the conf */ public PreparedQueryContext(String query, String user, Configuration conf, Collection<LensDriver> drivers) { this(query, user, conf, new LensConf(), drivers); }
LensConf lensConf = new LensConf(); lensConf.addProperty(LensConfConstants.RESULT_SET_PARENT_DIR, "hdfs://lens-test:8020/tmp/lensreports"); logger.info("Modified Conf : " + gq.getConf().getProperties().get("lens.query.result.parent.dir")); Assert.assertEquals(gq.getConf().getProperties().get(LensConfConstants.RESULT_SET_PARENT_DIR), "hdfs://lens-test:8020/tmp/lensreports", "Update on Prepared Query Failed!!");
/** * Update conf. * * @param confoverlay the conf to set */ public void updateConf(Map<String, String> confoverlay) { lensConf.getProperties().putAll(confoverlay); for (Map.Entry<String, String> prop : confoverlay.entrySet()) { this.conf.set(prop.getKey(), prop.getValue()); } } }
QueryContext queryContext = service.createContext(userQuery, "foo@localhost", new LensConf(), new Configuration(), 0); long submissionTime = queryContext.getSubmissionTime(); queryContext.setQueryName("daoTestQuery1"); queryContext.getDriverContext().setSelectedDriver(new MockDriver()); queryContext.getLensConf().addProperty("prop", "value"); Assert.assertEquals(actual.getConf().getProperty("prop"), "value"); "foo@localhost", new LensConf(), new Configuration(), 0);
@Test(dataProvider = "testIterableHttpResultSetDP") public void testHttpResultSet(String query, Map<String, String> queryConf, boolean isResultZipped, int columnNamesExpected, int rowsExpected) throws Exception { for (Map.Entry<String, String> e : queryConf.entrySet()) { client.setConnectionParam(e.getKey(), e.getValue()); } LensConf conf = new LensConf(); Map<String, String> confProps = new HashMap<>(); confProps.put("custom.property.for.validation", "present"); conf.addProperties(confProps); QueryHandle handle = client.executeQueryAsynch(query, "testQuery", conf); client.getStatement().waitForQueryToComplete(handle); assertTrue(client.getStatement().wasQuerySuccessful()); LensQuery persistedQuery = client.getQueryDetails(handle); Assert.assertNotNull(persistedQuery.getQueryConf()); Assert.assertEquals(persistedQuery.getQueryConf().getProperty("custom.property.for.validation"), "present"); ResultSet result = null; boolean isHeaderRowPresent = columnNamesExpected > 0 ? true : false; result = client.getHttpResultSet(handle); assertNotNull(result); validateResult(result, columnNamesExpected, rowsExpected); }
CubeQueryConfUtil.FAIL_QUERY_ON_PARTIAL_DATA, "false", LensConfConstants.PURGE_INTERVAL, "5000"); LensConf lensConf = new LensConf(); lensConf.addProperties(confMap); String session1 = sHelper.openSession("diff1", "diff1", lens.getCurrentDB()); sHelper.setAndValidateParam(confMap, session1);
private QueryHandle launchInmemoryQuery(MediaType mt) { LensConf conf = LensServerAPITestUtil.getLensConf(QUERY_METRIC_UNIQUE_ID_CONF_KEY, UUID.randomUUID()); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_SET, "false"); conf.addProperty(LensConfConstants.QUERY_PERSISTENT_RESULT_INDRIVER, "false"); conf.addProperty(LensConfConstants.INMEMORY_RESULT_SET_TTL_SECS, 600); return RestAPITestUtil.executeAndGetHandle(target(), Optional.of(lensSessionId), Optional.of("select ID from " + TEST_TABLE), Optional.of(conf), mt); }
@Override public QueryCost estimate(final AbstractQueryContext ctx) throws LensException { LensConf lensConf = ctx.getLensConf(); String driverSleep = lensConf.getProperty("mock.driver.sleep"); if (ctx.getUserQuery().contains("fail")) { return new FactPartitionBasedQueryCost(0.0); } else if (driverSleep != null && driverSleep.equals("true")) { try { String sleepMS = lensConf.getProperty("mock.driver.sleep.ms"); if (sleepMS != null && !sleepMS.isEmpty()) { Thread.sleep(Long.parseLong(sleepMS)); } } catch (InterruptedException e) { log.error("Sleeping thread interrupted", e); } return new FactPartitionBasedQueryCost(0.0); } else { throw new LensException("Simulated Estimate Failure"); } }
/** * Instantiates a new prepared query context. * * @param query the query * @param user the user * @param conf the conf */ public PreparedQueryContext(String query, String user, Configuration conf, Collection<LensDriver> drivers) { this(query, user, conf, new LensConf(), drivers); }
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), "select ID from " + TEST_TABLE)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain_and_prepare")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); assertNull(ctx.getConf().getProperties().get("my.property")); LensConf conf = new LensConf(); conf.addProperty("my.property", "myvalue"); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); assertEquals(ctx.getConf().getProperties().get("my.property"), "myvalue");
/** * Update conf. * * @param confoverlay the conf to set */ public void updateConf(Map<String, String> confoverlay) { lensConf.getProperties().putAll(confoverlay); for (Map.Entry<String, String> prop : confoverlay.entrySet()) { this.conf.set(prop.getKey(), prop.getValue()); } }
private String getDriverProperty(QueryContext ctx, String name) { return ctx.getLensConf().getProperty("driver." + this.getFullyQualifiedName() + "." + name); }
private void createDefaultUriProperties() { config = new LensConf(); config.addProperty(PATH_PREFIX + "hdfs", "://"); config.addProperty(PATH_PREFIX + "s3", "://"); config.addProperty(PATH_PREFIX + "s3n", "://"); }
/** * Prepare query. * * @param sql the sql * @param queryName the query name * @return the query prepare handle * @throws LensAPIException */ @Deprecated public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName) throws LensAPIException { return prepareQuery(sql, queryName, new LensConf()); }
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), "testQuery1")); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(), mt)); assertNull(ctx.getConf().getProperties().get("my.property")); LensConf conf = new LensConf(); conf.addProperty("my.property", "myvalue"); confpart.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(), lensSessionId, mt)); assertEquals(ctx.getConf().getProperties().get("my.property"), "myvalue");
/** * Update conf. * * @param confoverlay the conf to set */ public void updateConf(Map<String, String> confoverlay) { lensConf.getProperties().putAll(confoverlay); for (Map.Entry<String, String> prop : confoverlay.entrySet()) { this.conf.set(prop.getKey(), prop.getValue()); } }
public PathValidator(LensConf config) { createDefaultUriProperties(); this.config.addProperties(config.getProperties()); }