public LensClient(String username, String password) { this(new LensClientConfig(), username, password); }
/** * Sets the database to connect on lens server * * @param dbName database to connect to */ public void setLensDatabase(String dbName) { this.set(DBNAME_KEY, dbName); }
public void setDbName(String dbName) { this.conf.setLensDatabase(dbName); }
private void setupRequestFilters() { if (this.conf.get(LensClientConfig.SESSION_FILTER_NAMES) != null) { String[] filterNames = this.conf.getStrings(LensClientConfig.SESSION_FILTER_NAMES); for (String filterName : filterNames) { Class wsFilterClass = this.conf.getClass(LensClientConfig.getWSFilterImplConfKey(filterName), null); if (wsFilterClass != null) { requestFilters.add(wsFilterClass); } log.info("Request filter added " + filterName); } } } /**
@BeforeTest public void setUp() throws Exception { super.setUp(); Hive hive = Hive.get(new HiveConf()); Database db = new Database(); db.setName(TEST_DB); hive.createDatabase(db, true); LensClientConfig lensClientConfig = new LensClientConfig(); lensClientConfig.setLensDatabase(TEST_DB); lensClientConfig.set(LensConfConstants.SERVER_BASE_URL, "http://localhost:" + getTestPort() + "/lensapi"); LensClient client = new LensClient(lensClientConfig); mlClient = new LensMLClient(client); }
private LensClientConfig createLensClientConfigWithServerUrl() { LensClientConfig config = new LensClientConfig(); config.set("lens.server.base.url", "http://localhost:" + getTestPort() + "/lensapi"); return config; } }
@Override public String toString() { return new StringBuilder("LensConnectionParams{").append("dbName='").append(this.conf.getLensDatabase()) .append('\'').append(", baseUrl='").append(this.conf.getBaseURL()).append('\'').append(", user=") .append(this.conf.getUser()).append(", lensConfs=").append(lensConfs).append(", lensVars=").append(lensVars) .append(", sessionVars=").append(sessionVars).append('}').toString(); }
/** * Get the username from config * * @return Returns lens client user name */ public String getUser() { return this.get(USER_NAME, DEFAULT_USER_NAME); }
/** * Creates a new client and tests database creation and deletion */ @Test public void testClient() throws Exception { LensClientConfig lensClientConfig = createLensClientConfigWithServerUrl(); lensClientConfig.setLensDatabase(TEST_DB); Assert.assertEquals(lensClientConfig.getLensDatabase(), TEST_DB); try (LensClient client = new LensClient(lensClientConfig)) { Assert.assertEquals(client.getCurrentDatabae(), TEST_DB, "current database"); client.createDatabase("testclientdb", true); Assert.assertTrue(client.getAllDatabases().contains("testclientdb")); client.dropDatabase("testclientdb", false); Assert.assertFalse(client.getAllDatabases().contains("testclientdb")); Assert.assertTrue(RequestTestFilter.isAccessed(), "RequestTestFilter not invoked"); } }
@Test public void testWaitForQueryToCompleteWithAndWithoutRetryOnTimeOut() throws LensAPIException { LensClientConfig config = createLensClientConfigWithServerUrl(); config.set(ENABLE_SLEEP_FOR_GET_QUERY_OP, "true"); config.setInt(LensClientConfig.READ_TIMEOUT_MILLIS, 3000); try (LensClient lensClient = new LensClient(config)) { assertTrue(lensClient.setDatabase(TEST_DB)); //Test waitForQueryToComplete without retry on timeout QueryHandle handle = lensClient.executeQueryAsynch("cube select id,name from test_dim", "test3", new LensConf()); try { lensClient.getStatement().waitForQueryToComplete(handle, false); fail("SocketTimeoutException was expected"); } catch (Exception e) { if (!isExceptionDueToSocketTimeout(e)) { fail("SocketTimeoutException was excepted as part of Read Timeout"); } } //Test waitForQueryToComplete with Retry on timeout handle = lensClient.executeQueryAsynch("cube select id,name from test_dim", "test3", new LensConf()); lensClient.getStatement().waitForQueryToComplete(handle); LensQuery query = lensClient.getQueryDetails(handle); assertTrue(query.getStatus().successful()); } }
public LensClient(LensClientConfig conf) { this(conf, conf.getUser(), DEFAULT_PASSWORD); }
public long getQueryPollInterval() { return this.getLong(QUERY_POLL_INTERVAL_KEY, DEFAULT_QUERY_POLL_INTERVAL); }
/** * Gets the Database to which lens client should connect to. * * @return database to connect to */ public String getDbName() { return conf.getLensDatabase(); }
@BeforeTest public void setUp() throws Exception { super.setUp(); Hive hive = Hive.get(new HiveConf()); Database db = new Database(); db.setName(TEST_DB); hive.createDatabase(db, true); LensClientConfig lensClientConfig = new LensClientConfig(); lensClientConfig.setLensDatabase(TEST_DB); lensClientConfig.set(LensConfConstants.SERVER_BASE_URL, "http://localhost:" + getTestPort() + "/lensapi"); LensClient client = new LensClient(lensClientConfig); mlClient = new LensMLClient(client); }
@Override public String toString() { return new StringBuilder("LensConnectionParams{").append("dbName='").append(this.conf.getLensDatabase()) .append('\'').append(", baseUrl='").append(this.conf.getBaseURL()).append('\'').append(", user=") .append(this.conf.getUser()).append(", lensConfs=").append(lensConfs).append(", lensVars=").append(lensVars) .append(", sessionVars=").append(sessionVars).append('}').toString(); }
private void setupRequestFilters() { requestFilters.add(DelegationTokenClientFilter.class); requestFilters.add(SpnegoClientFilter.class); // add default filter if (this.conf.get(LensClientConfig.SESSION_FILTER_NAMES) != null) { String[] filterNames = this.conf.getStrings(LensClientConfig.SESSION_FILTER_NAMES); for (String filterName : filterNames) { Class wsFilterClass = this.conf.getClass(LensClientConfig.getWSFilterImplConfKey(filterName), null); if (wsFilterClass != null) { requestFilters.add(wsFilterClass); } log.info("Request filter added " + filterName); } } } /**
/** * Returns the configured lens server database client wants to access * * @return database returns database to connect, defaults to 'default' */ public String getLensDatabase() { return this.get(DBNAME_KEY, DEFAULT_DBNAME_VALUE); }
public String getUser() { return this.conf.getUser(); }
public long getQueryPollInterval() { return this.getLong(QUERY_POLL_INTERVAL_KEY, DEFAULT_QUERY_POLL_INTERVAL); }
/** * Gets the Database to which lens client should connect to. * * @return database to connect to */ public String getDbName() { return conf.getLensDatabase(); }