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); } }
private void checkIfAuthorized() throws LensException { if (isAuthorizationEnabled()) { String currentdb = SessionState.get().getCurrentDatabase(); AuthorizationUtil.isAuthorized(LensAuthorizer.get().getAuthorizer(), currentdb, LensPrivilegeObject.LensPrivilegeObjectType.DATABASE, ActionType.UPDATE, getConf(), SessionState.getSessionConf()); } }
Class testClass2 = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass2"); Class clz = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass"); loadedDBClass = true; } catch (ClassNotFoundException cnf) { sessionService.acquire(sessionHandle); Class testClass2 = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass2"); Class clz = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass"); loadedDBClass = true; } finally { sessionService.acquire(sessionHandle); Class testClass2 = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass2"); Class clz = session.getCubeMetastoreClient().getConf().getClassByName("ClassLoaderTestClass"); loadedDBClass = true; } catch (ClassNotFoundException cnf) {
@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(); }
assertEquals(Hive.get(client.getConf()).getTable(c1TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertEquals(Hive.get(client.getConf()).getTable(c2TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertEquals(Hive.get(client.getConf()).getTable(c1TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true"); assertEquals(Hive.get(client.getConf()).getTable(c2TableName).getParameters().get( getPartitionTimelineCachePresenceKey()), "true");