private void close() { if (!success) { rollbackTransaction(); } }
@Override public void rollbackTransaction() { objectStore.rollbackTransaction(); }
/** * This is a cleanup method which is used to rollback a active transaction * if the success flag is false and close the associated QueryWrapper object. This method is used * internally and visible for testing purposes only * @param success Rollback the current active transaction if false * @param queryWrapper QueryWrapper object which needs to be closed */ @VisibleForTesting void rollbackAndCleanup(boolean success, QueryWrapper queryWrapper) { try { if (!success) { rollbackTransaction(); } } finally { if (queryWrapper != null) { queryWrapper.close(); } } }
/** * This is a cleanup method which is used to rollback a active transaction * if the success flag is false and close the associated Query object. This method is used * internally and visible for testing purposes only * @param success Rollback the current active transaction if false * @param query Query object which needs to be closed */ @VisibleForTesting void rollbackAndCleanup(boolean success, Query query) { try { if (!success) { rollbackTransaction(); } } finally { if (query != null) { query.closeAll(); } } }
@Override public List<String> listPartitionNames(String catName, String dbName, String tableName, short max) throws MetaException { List<String> pns = null; boolean success = false; try { openTransaction(); LOG.debug("Executing getPartitionNames"); pns = getPartitionNamesNoTxn(catName, dbName, tableName, max); success = commitTransaction(); } finally { if (!success) { rollbackTransaction(); } } return pns; }
@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 void addRuntimeStat(RuntimeStat stat) throws MetaException { LOG.debug("runtimeStat: " + stat); MRuntimeStat mStat = MRuntimeStat.fromThrift(stat); boolean committed = false; openTransaction(); try { pm.makePersistent(mStat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void createCatalog(Catalog cat) throws MetaException { LOG.debug("Creating catalog " + cat.getName()); boolean committed = false; MCatalog mCat = catToMCat(cat); try { openTransaction(); pm.makePersistent(mCat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void createFunction(Function func) throws InvalidObjectException, MetaException { boolean committed = false; try { openTransaction(); MFunction mfunc = convertToMFunction(func); pm.makePersistent(mfunc); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@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 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; }
@Override public void dropCatalog(String catalogName) throws NoSuchObjectException, MetaException { LOG.debug("Dropping catalog " + catalogName); boolean committed = false; try { openTransaction(); MCatalog mCat = getMCatalog(catalogName); pm.retrieve(mCat); if (mCat == null) { throw new NoSuchObjectException("No catalog " + catalogName); } pm.deletePersistent(mCat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void dropFunction(String catName, String dbName, String funcName) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException { boolean success = false; try { openTransaction(); MFunction mfunc = getMFunction(catName, dbName, funcName); pm.retrieve(mfunc); if (mfunc != null) { // TODO: When function privileges are implemented, they should be deleted here. pm.deletePersistentAll(mfunc); } success = commitTransaction(); } finally { if (!success) { rollbackTransaction(); } } }
@Override public SerDeInfo getSerDeInfo(String serDeName) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MSerDeInfo mSerDeInfo = getMSerDeInfo(serDeName); if (mSerDeInfo == null) { throw new NoSuchObjectException("No SerDe named " + serDeName); } SerDeInfo serde = convertToSerDeInfo(mSerDeInfo, false); committed = commitTransaction(); return serde; } finally { if (!committed) { rollbackTransaction(); } } }
private boolean dropCreationMetadata(String catName, String dbName, String tableName) throws MetaException, NoSuchObjectException, InvalidObjectException, InvalidInputException { boolean success = false; try { openTransaction(); MCreationMetadata mcm = getCreationMetadata(catName, dbName, tableName); pm.retrieve(mcm); if (mcm != null) { pm.deletePersistentAll(mcm); } success = commitTransaction(); } finally { if (!success) { rollbackTransaction(); } } return success; }
@Override public ISchema getISchema(ISchemaName schemaName) throws MetaException { boolean committed = false; try { openTransaction(); ISchema schema = convertToISchema(getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName())); committed = commitTransaction(); return schema; } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void addSerde(SerDeInfo serde) throws AlreadyExistsException, MetaException { boolean committed = false; try { openTransaction(); if (getMSerDeInfo(serde.getName()) != null) { throw new AlreadyExistsException("Serde with name " + serde.getName() + " already exists"); } MSerDeInfo mSerde = convertToMSerDeInfo(serde); pm.makePersistent(mSerde); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void dropISchema(ISchemaName schemaName) throws NoSuchObjectException, MetaException { boolean committed = false; try { openTransaction(); MISchema mSchema = getMISchema(schemaName.getCatName(), schemaName.getDbName(), schemaName.getSchemaName()); if (mSchema != null) { pm.deletePersistentAll(mSchema); } else { throw new NoSuchObjectException("Schema " + schemaName + " does not exist"); } committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
@Override public SchemaVersion getSchemaVersion(SchemaVersionDescriptor version) throws MetaException { boolean committed = false; try { openTransaction(); SchemaVersion schemaVersion = convertToSchemaVersion(getMSchemaVersion( version.getSchema().getCatName(), version.getSchema().getDbName(), version.getSchema().getSchemaName(), version.getVersion())); committed = commitTransaction(); return schemaVersion; } finally { if (!committed) { rollbackTransaction(); } } }
@Override public void createISchema(ISchema schema) throws AlreadyExistsException, MetaException, NoSuchObjectException { boolean committed = false; MISchema mSchema = convertToMISchema(schema); try { openTransaction(); if (getMISchema(schema.getCatName(), schema.getDbName(), schema.getName()) != null) { throw new AlreadyExistsException("Schema with name " + schema.getDbName() + "." + schema.getName() + " already exists"); } pm.makePersistent(mSchema); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }