Search in sources :

Example 1 with FeedConnectionRequest

use of org.apache.asterix.external.feed.management.FeedConnectionRequest in project asterixdb by apache.

the class FeedOperations method getConnectionJob.

private static JobSpecification getConnectionJob(SessionOutput sessionOutput, MetadataProvider metadataProvider, FeedConnection feedConnection, String[] locations, ILangCompilationProvider compilationProvider, IStorageComponentProvider storageComponentProvider, DefaultStatementExecutorFactory qtFactory, IHyracksClientConnection hcc) throws AlgebricksException, RemoteException, ACIDException {
    DataverseDecl dataverseDecl = new DataverseDecl(new Identifier(feedConnection.getDataverseName()));
    FeedConnectionRequest fcr = new FeedConnectionRequest(FeedRuntimeType.INTAKE, feedConnection.getAppliedFunctions(), feedConnection.getDatasetName(), feedConnection.getPolicyName(), feedConnection.getFeedId());
    SubscribeFeedStatement subscribeStmt = new SubscribeFeedStatement(locations, fcr);
    subscribeStmt.initialize(metadataProvider.getMetadataTxnContext());
    List<Statement> statements = new ArrayList<>();
    statements.add(dataverseDecl);
    statements.add(subscribeStmt);
    IStatementExecutor translator = qtFactory.create(metadataProvider.getApplicationContext(), statements, sessionOutput, compilationProvider, storageComponentProvider);
    // configure the metadata provider
    metadataProvider.getConfig().put(FunctionUtil.IMPORT_PRIVATE_FUNCTIONS, "" + Boolean.TRUE);
    metadataProvider.getConfig().put(FeedActivityDetails.FEED_POLICY_NAME, "" + subscribeStmt.getPolicy());
    metadataProvider.getConfig().put(FeedActivityDetails.COLLECT_LOCATIONS, StringUtils.join(subscribeStmt.getLocations(), ','));
    CompiledStatements.CompiledSubscribeFeedStatement csfs = new CompiledStatements.CompiledSubscribeFeedStatement(subscribeStmt.getSubscriptionRequest(), subscribeStmt.getVarCounter());
    return translator.rewriteCompileQuery(hcc, metadataProvider, subscribeStmt.getQuery(), csfs);
}
Also used : IStatementExecutor(org.apache.asterix.translator.IStatementExecutor) DataverseDecl(org.apache.asterix.lang.common.statement.DataverseDecl) Identifier(org.apache.asterix.lang.common.struct.Identifier) SubscribeFeedStatement(org.apache.asterix.lang.aql.statement.SubscribeFeedStatement) SubscribeFeedStatement(org.apache.asterix.lang.aql.statement.SubscribeFeedStatement) Statement(org.apache.asterix.lang.common.base.Statement) FeedConnectionRequest(org.apache.asterix.external.feed.management.FeedConnectionRequest) ArrayList(java.util.ArrayList) CompiledStatements(org.apache.asterix.translator.CompiledStatements)

Aggregations

ArrayList (java.util.ArrayList)1 FeedConnectionRequest (org.apache.asterix.external.feed.management.FeedConnectionRequest)1 SubscribeFeedStatement (org.apache.asterix.lang.aql.statement.SubscribeFeedStatement)1 Statement (org.apache.asterix.lang.common.base.Statement)1 DataverseDecl (org.apache.asterix.lang.common.statement.DataverseDecl)1 Identifier (org.apache.asterix.lang.common.struct.Identifier)1 CompiledStatements (org.apache.asterix.translator.CompiledStatements)1 IStatementExecutor (org.apache.asterix.translator.IStatementExecutor)1