Search in sources :

Example 16 with RawStore

use of org.apache.hadoop.hive.metastore.RawStore in project hive by apache.

the class TestHBaseImport method importOneRole.

// TODO test for bogus function name
// TODO test for bogus table name
// TODO test for non-existent items
@Test
public void importOneRole() throws Exception {
    RawStore rdbms;
    rdbms = new ObjectStore();
    rdbms.setConf(conf);
    String[] dbNames = new String[] { "oneroledb1", "oneroledb2" };
    String[] roles = new String[] { "onerolerole1", "onerolerole2" };
    String[] tokenIds = new String[] { "oneroletokenid1", "oneroletokenid2" };
    String[] tokens = new String[] { "oneroletoken1", "oneroletoken2" };
    String[] masterKeys = new String[] { "onerolemk1", "onerolemk2" };
    int now = (int) System.currentTimeMillis() / 1000;
    setupObjectStore(rdbms, roles, dbNames, tokenIds, tokens, masterKeys, now);
    int baseNumRoles = store.listRoleNames() == null ? 0 : store.listRoleNames().size();
    int baseNumDbs = store.getAllDatabases() == null ? 0 : store.getAllDatabases().size();
    int baseNumToks = store.getAllTokenIdentifiers() == null ? 0 : store.getAllTokenIdentifiers().size();
    int baseNumKeys = store.getMasterKeys() == null ? 0 : store.getMasterKeys().length;
    HBaseImport importer = new HBaseImport("-r", roles[0]);
    importer.setConnections(rdbms, store);
    importer.run();
    Role role = store.getRole(roles[0]);
    Assert.assertNotNull(role);
    Assert.assertEquals(roles[0], role.getRoleName());
    // Make sure there aren't any extra roles
    Assert.assertEquals(baseNumRoles + 1, store.listRoleNames().size());
    Assert.assertEquals(baseNumDbs, store.getAllDatabases().size());
    Assert.assertEquals(baseNumToks, store.getAllTokenIdentifiers().size());
    String[] hbaseKeys = store.getMasterKeys();
    Assert.assertEquals(baseNumKeys, hbaseKeys.length);
    // Have to do this last as it will throw an exception
    thrown.expect(NoSuchObjectException.class);
    store.getRole(roles[1]);
}
Also used : Role(org.apache.hadoop.hive.metastore.api.Role) TestObjectStore(org.apache.hadoop.hive.metastore.TestObjectStore) ObjectStore(org.apache.hadoop.hive.metastore.ObjectStore) RawStore(org.apache.hadoop.hive.metastore.RawStore) Test(org.junit.Test)

Example 17 with RawStore

use of org.apache.hadoop.hive.metastore.RawStore in project hive by apache.

the class EventCleanerTask method run.

@Override
public void run() {
    try {
        RawStore ms = handler.getMS();
        long deleteCnt = ms.cleanupEvents();
        if (deleteCnt > 0L) {
            LOG.info("Number of events deleted from event Table: " + deleteCnt);
        }
    } catch (Exception e) {
        LOG.error("Exception while trying to delete events ", e);
    }
}
Also used : RawStore(org.apache.hadoop.hive.metastore.RawStore)

Aggregations

RawStore (org.apache.hadoop.hive.metastore.RawStore)17 ObjectStore (org.apache.hadoop.hive.metastore.ObjectStore)12 TestObjectStore (org.apache.hadoop.hive.metastore.TestObjectStore)12 Test (org.junit.Test)10 Database (org.apache.hadoop.hive.metastore.api.Database)8 Table (org.apache.hadoop.hive.metastore.api.Table)7 Partition (org.apache.hadoop.hive.metastore.api.Partition)5 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 Index (org.apache.hadoop.hive.metastore.api.Index)2 Role (org.apache.hadoop.hive.metastore.api.Role)2 SerDeInfo (org.apache.hadoop.hive.metastore.api.SerDeInfo)2 StorageDescriptor (org.apache.hadoop.hive.metastore.api.StorageDescriptor)2 SQLForeignKey (org.apache.hadoop.hive.metastore.api.SQLForeignKey)1 SQLPrimaryKey (org.apache.hadoop.hive.metastore.api.SQLPrimaryKey)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1