@Override public Table markPartitionForEvent(String catName, String dbName, String tblName, Map<String,String> partName, PartitionEventType evtType) throws MetaException, UnknownTableException, InvalidPartitionException, UnknownPartitionException { LOG.debug("Begin executing markPartitionForEvent"); boolean success = false; Table tbl = null; try{ openTransaction(); tbl = getTable(catName, dbName, tblName, null); // Make sure dbName and tblName are valid. if(null == tbl) { throw new UnknownTableException("Table: "+ tblName + " is not found."); } pm.makePersistent(new MPartitionEvent(catName, dbName,tblName,getPartitionStr(tbl, partName), evtType.getValue())); success = commitTransaction(); LOG.debug("Done executing markPartitionForEvent"); } finally { if(!success) { rollbackTransaction(); } } return tbl; }
@Override public List<String> getAllTables(String catName, String dbName) throws MetaException { return getTables(catName, dbName, ".*"); }
public DummyRawStoreControlledCommit() { objectStore = new ObjectStore(); }
@Override public List<RuntimeStat> getRuntimeStats(int maxEntries, int maxCreateTime) throws MetaException { boolean committed = false; try { openTransaction(); List<RuntimeStat> stats = getMRuntimeStats(maxEntries, maxCreateTime); committed = commitTransaction(); return stats; } finally { if (!committed) { rollbackTransaction(); } } }
@Override public Function getFunction(String catName, String dbName, String funcName) throws MetaException { boolean commited = false; Function func = null; Query query = null; try { openTransaction(); func = convertToFunction(getMFunction(catName, dbName, funcName)); commited = commitTransaction(); } finally { rollbackAndCleanup(commited, query); } return func; }
@Override public boolean dropPartition(String catName, String dbName, String tableName, List<String> part_vals) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException { boolean success = false; try { openTransaction(); MPartition part = getMPartition(catName, dbName, tableName, part_vals); dropPartitionCommon(part); success = commitTransaction(); } finally { if (!success) { rollbackTransaction(); } } return success; }
boolean success = false; try { openTransaction(); MPartition mpart = getMPartition(catName, dbName, tblName, partVals); if (mpart == null) { commitTransaction(); throw new NoSuchObjectException("partition values=" + partVals.toString()); part = convertToPart(mpart); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), partVals); PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(catName, dbName, tblName, partName, user_name, group_names); part.setPrivileges(partAuth); success = commitTransaction(); return part; } finally { if (!success) { rollbackTransaction();
boolean success = false; try { openTransaction(); MTable tbl = getMTable(catName, dbName, tableName); pm.retrieve(tbl); if (tbl != null) { materializedView = TableType.MATERIALIZED_VIEW.toString().equals(tbl.getTableType()); List<MTablePrivilege> tabGrants = listAllTableGrants(catName, dbName, tableName); if (CollectionUtils.isNotEmpty(tabGrants)) { pm.deletePersistentAll(tabGrants); List<MTableColumnPrivilege> tblColGrants = listTableAllColumnGrants(catName, dbName, tableName); if (CollectionUtils.isNotEmpty(tblColGrants)) { List<MPartitionPrivilege> partGrants = this.listTableAllPartitionGrants(catName, dbName, tableName); if (CollectionUtils.isNotEmpty(partGrants)) { pm.deletePersistentAll(partGrants); List<MPartitionColumnPrivilege> partColGrants = listTableAllPartitionColumnGrants(catName, dbName, tableName); if (CollectionUtils.isNotEmpty(partColGrants)) { deleteTableColumnStatistics(catName, dbName, tableName, null); } catch (NoSuchObjectException e) { LOG.info("Found no table level column statistics associated with {} to delete", List<MConstraint> tabConstraints = listAllTableConstraintsWithOptionalConstraintName(
throws InvalidObjectException, MetaException { boolean success = false; openTransaction(); try { List<MTablePrivilege> tabGrants = null; List<MTableColumnPrivilege> tabColumnGrants = null; MTable table = this.getMTable(catName, dbName, tblName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { tabGrants = this.listAllTableGrants(catName, dbName, tblName); tabColumnGrants = this.listTableAllColumnGrants(catName, dbName, tblName); + dbName + "." + tblName + ": " + part); MPartition mpart = convertToMPart(part, table, true); success = commitTransaction(); } finally { if (!success) { rollbackTransaction();
boolean success = false; try { openTransaction(); List<MPartition> mparts = listMPartitions(dbName, tblName, max); List<Partition> parts = new ArrayList<Partition>(mparts.size()); if (mparts != null && mparts.size()>0) { for (MPartition mpart : mparts) { MTable mtbl = mpart.getTable(); Partition part = convertToPart(mpart); parts.add(part); String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(dbName, tblName, partName, userName, groupNames); part.setPrivileges(partAuth); success = commitTransaction(); return parts; } finally { if (!success) { rollbackTransaction();
throws InvalidObjectException, MetaException { boolean success = false; openTransaction(); try { List<MTablePrivilege> tabGrants = null; List<MTableColumnPrivilege> tabColumnGrants = null; MTable table = this.getMTable(catName, dbName, tblName); if ("TRUE".equalsIgnoreCase(table.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { tabGrants = this.listAllTableGrants(catName, dbName, tblName); tabColumnGrants = this.listTableAllColumnGrants(catName, dbName, tblName); List<FieldSchema> partitionKeys = convertToFieldSchemas(table.getPartitionKeys()); while (iterator.hasNext()) { Partition part = iterator.next(); if (isValidPartition(part, partitionKeys, ifNotExists)) { MPartition mpart = convertToMPart(part, table, true); pm.makePersistent(mpart); if (tabGrants != null) { success = commitTransaction(); } finally { if (!success) { rollbackTransaction();
@Override public List<Partition> getPartitionsWithAuth(String catName, String dbName, String tblName, short max, String userName, List<String> groupNames) throws MetaException, InvalidObjectException { boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); List<MPartition> mparts = listMPartitions(catName, dbName, tblName, max, queryWrapper); List<Partition> parts = new ArrayList<>(mparts.size()); if (CollectionUtils.isNotEmpty(mparts)) { for (MPartition mpart : mparts) { MTable mtbl = mpart.getTable(); Partition part = convertToPart(mpart); parts.add(part); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(catName, dbName, tblName, partName, userName, groupNames); part.setPrivileges(partAuth); } } } success = commitTransaction(); return parts; } finally { rollbackAndCleanup(success, queryWrapper); } }
public boolean dropTable(String dbName, String tableName) throws MetaException { boolean success = false; try { openTransaction(); MTable tbl = getMTable(dbName, tableName); pm.retrieve(tbl); if (tbl != null) { List<MTablePrivilege> tabGrants = listAllTableGrants(dbName, tableName); if (tabGrants != null && tabGrants.size() > 0) { pm.deletePersistentAll(tabGrants); List<MTableColumnPrivilege> tblColGrants = listTableAllColumnGrants(dbName, tableName); if (tblColGrants != null && tblColGrants.size() > 0) { List<MPartitionPrivilege> partGrants = this.listTableAllPartitionGrants(dbName, tableName); if (partGrants != null && partGrants.size() > 0) { pm.deletePersistentAll(partGrants); List<MPartitionColumnPrivilege> partColGrants = listTableAllPartitionColumnGrants(dbName, tableName); if (partColGrants != null && partColGrants.size() > 0) { pm.deletePersistentAll(partColGrants); pm.deletePersistentAll(listMPartitions(dbName, tableName, -1)); success = commitTransaction(); } finally { if (!success) {
public Type getType(String typeName) { Type type = null; boolean commited = false; try { openTransaction(); Query query = pm.newQuery(MType.class, "name == typeName"); query.declareParameters("java.lang.String typeName"); query.setUnique(true); MType mtype = (MType) query.execute(typeName.trim()); pm.retrieve(type); if (mtype != null) { type = getType(mtype); } commited = commitTransaction(); } finally { if (!commited) { rollbackTransaction(); } } return type; }
openTransaction(); LOG.debug("executing listPartitionNamesPsWithAuth"); Collection parts = getPartitionPsQueryResults(catName, db_name, tbl_name, part_vals, max_parts, null, queryWrapper); MTable mtbl = getMTable(catName, db_name, tbl_name); for (Object o : parts) { Partition part = convertToPart((MPartition) o); String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = getPartitionPrivilegeSet(catName, db_name, tbl_name, partName, userName, groupNames); part.setPrivileges(partAuth); success = commitTransaction(); } finally { rollbackAndCleanup(success, queryWrapper);
isInitialized = false; hiveConf = conf; Properties propsFromConf = getDataSourceProps(conf); boolean propsChanged = !propsFromConf.equals(prop); assert(!isActiveTransaction()); shutdown(); transactionStatus = TXN_STATUS.NO_STATE; initialize(propsFromConf);
.setLocation("locationurl") .build(conf); objectStore.createDatabase(db1); StorageDescriptor sd1 = new StorageDescriptor(ImmutableList.of(new FieldSchema("pk_col", "double", null)), Table tbl1 = new Table(TABLE1, DB1, "owner", 1, 2, 3, sd1, null, params, null, null, "MANAGED_TABLE"); objectStore.createTable(tbl1); List<String> tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(1, tables.size()); Assert.assertEquals(TABLE1, tables.get(0)); objectStore.alterTable(DEFAULT_CATALOG_NAME, DB1, TABLE1, newTbl1, null); tables = objectStore.getTables(DEFAULT_CATALOG_NAME, DB1, "new*"); Assert.assertEquals(1, tables.size()); Assert.assertEquals("new" + TABLE1, tables.get(0)); Table alteredTable = objectStore.getTable(DEFAULT_CATALOG_NAME, DB1, "new" + TABLE1); Assert.assertEquals("Owner of table was not altered", newTbl1.getOwner(), alteredTable.getOwner()); Assert.assertEquals("Owner type of table was not altered", newTbl1.getOwnerType(), alteredTable.getOwnerType()); objectStore.createTable(tbl1); tables = objectStore.getAllTables(DEFAULT_CATALOG_NAME, DB1); Assert.assertEquals(2, tables.size()); List<SQLForeignKey> foreignKeys = objectStore.getForeignKeys(DEFAULT_CATALOG_NAME, DB1, TABLE1, null, null); Assert.assertEquals(0, foreignKeys.size());
@Override public boolean createType(Type type) { boolean success = false; MType mtype = getMType(type); boolean commited = false; try { openTransaction(); pm.makePersistent(mtype); commited = commitTransaction(); success = true; } finally { if (!commited) { rollbackTransaction(); } } return success; }
@Override public boolean isPartitionMarkedForEvent(String catName, String dbName, String tblName, Map<String, String> partName, PartitionEventType evtType) throws UnknownTableException, MetaException, InvalidPartitionException, UnknownPartitionException { boolean success = false; Query query = null; try { LOG.debug("Begin Executing isPartitionMarkedForEvent"); openTransaction(); query = pm.newQuery(MPartitionEvent.class, "dbName == t1 && tblName == t2 && partName == t3 && eventType == t4 && catalogName == t5"); query .declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String t3, int t4," + "java.lang.String t5"); Table tbl = getTable(catName, dbName, tblName, null); // Make sure dbName and tblName are valid. if (null == tbl) { throw new UnknownTableException("Table: " + tblName + " is not found."); } Collection<MPartitionEvent> partEvents = (Collection<MPartitionEvent>) query.executeWithArray(dbName, tblName, getPartitionStr(tbl, partName), evtType.getValue(), catName); pm.retrieveAll(partEvents); success = commitTransaction(); LOG.debug("Done executing isPartitionMarkedForEvent"); return (partEvents != null && !partEvents.isEmpty()) ? true : false; } finally { rollbackAndCleanup(success, query); } }
@Override public Type getType(String typeName) { Type type = null; boolean commited = false; Query query = null; try { openTransaction(); query = pm.newQuery(MType.class, "name == typeName"); query.declareParameters("java.lang.String typeName"); query.setUnique(true); MType mtype = (MType) query.execute(typeName.trim()); pm.retrieve(type); if (mtype != null) { type = getType(mtype); } commited = commitTransaction(); } finally { rollbackAndCleanup(commited, query); } return type; }