public static FeedPolicyEntity findFeedPolicy(MetadataTransactionContext mdTxnCtx, String dataverse, String policyName) throws AlgebricksException { return MetadataManager.INSTANCE.getFeedPolicy(mdTxnCtx, dataverse, policyName); }
public static FeedPolicyEntity validateIfPolicyExists(String dataverse, String policyName, MetadataTransactionContext ctx) throws AlgebricksException { FeedPolicyEntity feedPolicy = MetadataManager.INSTANCE.getFeedPolicy(ctx, dataverse, policyName); if (feedPolicy == null) { feedPolicy = MetadataManager.INSTANCE.getFeedPolicy(ctx, MetadataConstants.METADATA_DATAVERSE_NAME, policyName); if (feedPolicy == null) { throw new CompilationException("Unknown feed policy" + policyName); } } return feedPolicy; }
metadataProvider.setMetadataTxnContext(mdTxnCtx); FeedPolicyEntity feedPolicy = MetadataManager.INSTANCE.getFeedPolicy(metadataProvider.getMetadataTxnContext(), dataverse, policy); if (feedPolicy != null) { if (cfps.getIfNotExists()) { if (extendingExisting) { FeedPolicyEntity sourceFeedPolicy = MetadataManager.INSTANCE .getFeedPolicy(metadataProvider.getMetadataTxnContext(), dataverse, cfps.getSourcePolicyName()); if (sourceFeedPolicy == null) { sourceFeedPolicy = MetadataManager.INSTANCE.getFeedPolicy(metadataProvider.getMetadataTxnContext(), MetadataConstants.METADATA_DATAVERSE_NAME, cfps.getSourcePolicyName()); if (sourceFeedPolicy == null) {
protected void handleDropFeedPolicyStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception { MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); FeedPolicyDropStatement stmtFeedPolicyDrop = (FeedPolicyDropStatement) stmt; SourceLocation sourceLoc = stmtFeedPolicyDrop.getSourceLocation(); String dataverseName = getActiveDataverse(stmtFeedPolicyDrop.getDataverseName()); String policyName = stmtFeedPolicyDrop.getPolicyName().getValue(); MetadataLockUtil.dropFeedPolicyBegin(lockManager, metadataProvider.getLocks(), dataverseName, dataverseName + "." + policyName); try { FeedPolicyEntity feedPolicy = MetadataManager.INSTANCE.getFeedPolicy(mdTxnCtx, dataverseName, policyName); if (feedPolicy == null) { if (!stmtFeedPolicyDrop.getIfExists()) { throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, "Unknown policy " + policyName + " in dataverse " + dataverseName); } MetadataManager.INSTANCE.commitTransaction(mdTxnCtx); return; } MetadataManager.INSTANCE.dropFeedPolicy(mdTxnCtx, dataverseName, policyName); MetadataManager.INSTANCE.commitTransaction(mdTxnCtx); } catch (Exception e) { abort(e, e, mdTxnCtx); throw e; } finally { metadataProvider.getLocks().unlock(); } }