private static void tryDropDatasetNodegroup(Dataset source, MetadataProvider metadataProvider) throws Exception { ICcApplicationContext appCtx = metadataProvider.getApplicationContext(); String sourceNodeGroup = source.getNodeGroupName(); appCtx.getMetadataLockManager().acquireNodeGroupWriteLock(metadataProvider.getLocks(), sourceNodeGroup); MetadataManager.INSTANCE.dropNodegroup(metadataProvider.getMetadataTxnContext(), sourceNodeGroup, true); }
protected void handleNodegroupDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception { NodeGroupDropStatement stmtDelete = (NodeGroupDropStatement) stmt; SourceLocation sourceLoc = stmtDelete.getSourceLocation(); String nodegroupName = stmtDelete.getNodeGroupName().getValue(); MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); lockManager.acquireNodeGroupWriteLock(metadataProvider.getLocks(), nodegroupName); try { NodeGroup ng = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodegroupName); if (ng == null) { if (!stmtDelete.getIfExists()) { throw new CompilationException(ErrorCode.UNKNOWN_NODEGROUP, sourceLoc, 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(); } }
lockManager.acquireNodeGroupWriteLock(metadataProvider.getLocks(), nodeGroup); if (MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodeGroup) != null) { MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx, nodeGroup, true);
metadataProvider.getApplicationContext().getMetadataLockManager() .acquireNodeGroupWriteLock(metadataProvider.getLocks(), nodeGroupName); MetadataManager.INSTANCE.dropNodegroup(mdTxnCtx.getValue(), nodeGroupName, true);
metadataProvider.setMetadataTxnContext(mdTxn2); MetadataManager.INSTANCE.dropNodegroup(mdTxn2, nodeGroupName, false); Assert.assertEquals(1, opTracker.getNumActiveOperations());