public static CubeMetastoreClient getClient(HiveConf conf) throws LensException { try { return CubeMetastoreClient.getInstance(conf); } catch (HiveException e) { throw new LensException("Couldn't get instance of metastore client", e); } }
public CubeMetastoreClient getCubeMetastoreClient() throws LensException { try { CubeMetastoreClient cubeClient = CubeMetastoreClient.getInstance(getHiveConf()); // since cube client's configuration is a copy of the session conf passed, setting classloader in cube client's // configuration does not modify session conf's classloader. // We are doing this on the cubeClient instance than doing a copy of conf and setting classloader and pass it to // cube metastore client because CubeMetastoreClient would have been cached and refreshing the classloader // should not result in invalidating the CubeMetastoreClient cache. cubeClient.getConf().setClassLoader(getClassLoader()); return cubeClient; } catch (HiveException e) { throw new LensException(e); } }
@Test public void testChainsWithMultipleStorage() throws ParseException, HiveException, LensException { Configuration conf = new Configuration(hconf); conf.unset(CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES); // supports all storages String dimOnlyQuery = "select testDim2.name, testDim2.cityStateCapital FROM testDim2 where " + TWO_DAYS_RANGE; CubeQueryRewriter driver = new CubeQueryRewriter(conf, hconf); CubeQueryContext rewrittenQuery = driver.rewrite(dimOnlyQuery); rewrittenQuery.toHQL(); Dimension citydim = CubeMetastoreClient.getInstance(hconf).getDimension("citydim"); Set<String> cdimTables = new HashSet<>(); for (CandidateDim cdim : rewrittenQuery.getCandidateDims().get(citydim)) { cdimTables.add(cdim.getName()); } Assert.assertTrue(cdimTables.contains("citytable")); Assert.assertTrue(cdimTables.contains("citytable2")); Assert.assertFalse(cdimTables.contains("citytable3")); Assert.assertFalse(cdimTables.contains("citytable4")); }
@AfterClass public static void teardown() throws Exception { // Drop the cube client.dropCube(CUBE_NAME); client.dropCube(VIRTUAL_CUBE_NAME); client = CubeMetastoreClient.getInstance(conf); assertFalse(client.tableExists(CUBE_NAME)); Hive.get().dropDatabase(TestCubeMetastoreClient.class.getSimpleName(), true, true, true); CubeMetastoreClient.close(); }
/** * Test db storage. * * @throws HiveException the hive exception */ @Test(groups = "first") public void testDBStorage() throws Exception { CubeMetastoreClient cc = CubeMetastoreClient.getInstance(conf); if (!cc.tableExists(DB_STORAGE1)) { cc.createStorage(db1); } if (!cc.tableExists(DB_STORAGE2)) { cc.createStorage(db2); } }
@Test(priority = 3) public void testCaching() throws HiveException, LensException { client = CubeMetastoreClient.getInstance(conf); CubeMetastoreClient client2 = CubeMetastoreClient.getInstance(new HiveConf(TestCubeMetastoreClient.class)); assertEquals(6, client.getAllCubes().size()); assertEquals(6, client2.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); client2 = CubeMetastoreClient.getInstance(conf); assertEquals(10, client.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); client = CubeMetastoreClient.getInstance(conf); client2 = CubeMetastoreClient.getInstance(conf); assertEquals(10, client.getAllCubes().size()); assertEquals(10, client2.getAllCubes().size()); assertEquals(14, client2.getAllCubes().size()); conf.setBoolean(MetastoreConstants.METASTORE_ENABLE_CACHING, true); client = CubeMetastoreClient.getInstance(conf);
CubeMetastoreClient client = CubeMetastoreClient.getInstance(conf); String dimTblName = "ziptableMeta";
@Test(priority = 4) public void testMetastoreAuthorization() throws HiveException, LensException { client = CubeMetastoreClient.getInstance(new HiveConf(TestCubeMetastoreClient.class)); SessionState.getSessionConf().set(LensConfConstants.SESSION_USER_GROUPS, "lens-auth-test2"); try { client.createCube("testcache5", cubeMeasures, cubeDimensions); fail("Privilege exception supposed to be thrown for updating TestCubeMetastoreClient" + " database, however not seeing expected behaviour"); } catch (PrivilegeException actualException) { PrivilegeException expectedException = new PrivilegeException("DATABASE", "TestCubeMetastoreClient", "UPDATE"); assertEquals(expectedException, actualException); } SessionState.getSessionConf().set(LensConfConstants.SESSION_USER_GROUPS, "lens-auth-test1"); client.createCube("testcache5", cubeMeasures, cubeDimensions); }
final Table tbl = CubeMetastoreClient.getInstance(context.getHiveConf()).getHiveTable(lensTable); final String index = tbl.getProperty(LensConfConstants.ES_INDEX_NAME); final String type = tbl.getProperty(LensConfConstants.ES_TYPE_NAME);
final Table tbl = CubeMetastoreClient.getInstance(context.getHiveConf()).getHiveTable(lensTable); final String index = tbl.getProperty(LensConfConstants.ES_INDEX_NAME); final String type = tbl.getProperty(LensConfConstants.ES_TYPE_NAME);
tblName = tableIdentifier.getText(); String lensTable = dbIdentifier.getText() + "." + tblName; tbl = CubeMetastoreClient.getInstance(metastoreConf).getHiveTable(lensTable); String table = getUnderlyingTableName(tbl); String db = getUnderlyingDBName(tbl); ASTNode tableIdentifier = (ASTNode) tabNameChild.getChild(0); tblName = tableIdentifier.getText(); tbl = CubeMetastoreClient.getInstance(metastoreConf).getHiveTable(tblName); String table = getUnderlyingTableName(tbl);
tblName = tableIdentifier.getText(); String lensTable = dbIdentifier.getText() + "." + tblName; tbl = CubeMetastoreClient.getInstance(metastoreConf).getHiveTable(lensTable); String table = getUnderlyingTableName(tbl); String db = getUnderlyingDBName(tbl); ASTNode tableIdentifier = (ASTNode) tabNameChild.getChild(0); tblName = tableIdentifier.getText(); tbl = CubeMetastoreClient.getInstance(metastoreConf).getHiveTable(tblName); String table = getUnderlyingTableName(tbl);
this.timeRanges = new ArrayList<>(); try { metastoreClient = CubeMetastoreClient.getInstance(metastoreConf); } catch (HiveException e) { throw new LensException(e);
this.timeRanges = new ArrayList<>(); try { metastoreClient = CubeMetastoreClient.getInstance(metastoreConf); } catch (HiveException e) { throw new LensException(e);
@BeforeClass public static void setup() throws HiveException, AlreadyExistsException, LensException { SessionState.start(conf); conf.set(LensConfConstants.AUTHORIZER_CLASS, "org.apache.lens.cube.parse.MockAuthorizer"); LensAuthorizer.get().init(conf); Database database = new Database(); database.setName(TestCubeMetastoreClient.class.getSimpleName()); Hive.get(conf).createDatabase(database); SessionState.get().setCurrentDatabase(TestCubeMetastoreClient.class.getSimpleName()); client = CubeMetastoreClient.getInstance(conf); client.getConf().setBoolean(LensConfConstants.ENABLE_METASTORE_SCHEMA_AUTHORIZATION_CHECK, true); client.getConf().setBoolean(LensConfConstants.USER_GROUPS_BASED_AUTHORIZATION, true); SessionState.getSessionConf().set(LensConfConstants.SESSION_USER_GROUPS, "lens-auth-test1"); defineCube(CUBE_NAME, CUBE_NAME_WITH_PROPS, DERIVED_CUBE_NAME, DERIVED_CUBE_NAME_WITH_PROPS); defineUberDims(); }
testConf.setBoolean(DISABLE_AUTO_JOINS, false); CubeMetastoreClient client = CubeMetastoreClient.getInstance(testConf); Cube cube = (Cube) client.getCube(TEST_CUBE_NAME);
public void createSources(HiveConf conf, String dbName) throws Exception { try { Database database = new Database(); database.setName(dbName); Hive.get(conf).dropDatabase(dbName, true, true, true); Hive.get(conf).createDatabase(database); SessionState.get().setCurrentDatabase(dbName); CubeMetastoreClient client = CubeMetastoreClient.getInstance(conf); createFromXML(client); assertTestFactTimelineClass(client); createCubeCheapFactPartitions(client); // commenting this as the week date format throws IllegalPatternException // createCubeFactWeekly(client); createTestFact2Partitions(client); createTestFact2RawPartitions(client); createBaseCubeFactPartitions(client); createSummaryPartitions(client); // dump(client); } catch (Exception exc) { log.error("Exception while creating sources.", exc); throw exc; } } private static final StrSubstitutor GREGORIAN_SUBSTITUTOR = new StrSubstitutor(new StrLookup<String>() {