use of org.apache.asterix.lang.common.statement.NodeGroupDropStatement in project asterixdb by apache.
the class QueryTranslator method handleNodegroupDropStatement.
protected void handleNodegroupDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception {
NodeGroupDropStatement stmtDelete = (NodeGroupDropStatement) stmt;
String nodegroupName = stmtDelete.getNodeGroupName().getValue();
MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
metadataProvider.setMetadataTxnContext(mdTxnCtx);
MetadataLockManager.INSTANCE.acquireNodeGroupWriteLock(metadataProvider.getLocks(), nodegroupName);
try {
NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodegroupName);
if (ng == null) {
if (!stmtDelete.getIfExists()) {
throw new AlgebricksException("There is no nodegroup with this name " + nodegroupName + ".");
}
} else {
MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx, nodegroupName, false);
}
MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
} catch (Exception e) {
abort(e, e, mdTxnCtx);
throw e;
} finally {
metadataProvider.getLocks().unlock();
}
}
Aggregations