nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (NIFI-5239) Make MongoDBControllerService able to act as a configuration source for MongoDB processors
Date Mon, 17 Sep 2018 04:08:00 GMT

    [ https://issues.apache.org/jira/browse/NIFI-5239?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16617056#comment-16617056
] 

ASF GitHub Bot commented on NIFI-5239:
--------------------------------------

Github user zenfenan commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2896#discussion_r217945280
  
    --- Diff: nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java
---
    @@ -17,156 +17,162 @@
     
     package org.apache.nifi.mongodb;
     
    -import com.mongodb.client.FindIterable;
    +import com.mongodb.MongoClient;
    +import com.mongodb.MongoClientOptions;
    +import com.mongodb.MongoClientURI;
    +import com.mongodb.WriteConcern;
     import com.mongodb.client.MongoCollection;
    -import com.mongodb.client.MongoCursor;
     import com.mongodb.client.MongoDatabase;
    -import com.mongodb.client.model.UpdateOptions;
    -
    +import org.apache.commons.lang3.StringUtils;
     import org.apache.nifi.annotation.documentation.CapabilityDescription;
     import org.apache.nifi.annotation.documentation.Tags;
     import org.apache.nifi.annotation.lifecycle.OnDisabled;
     import org.apache.nifi.annotation.lifecycle.OnEnabled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.authentication.exception.ProviderCreationException;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.controller.AbstractControllerService;
     import org.apache.nifi.controller.ConfigurationContext;
    -import org.apache.nifi.reporting.InitializationException;
    +import org.apache.nifi.security.util.SslContextFactory;
    +import org.apache.nifi.ssl.SSLContextService;
     import org.bson.Document;
     
    -import java.io.IOException;
    +import javax.net.ssl.SSLContext;
     import java.util.ArrayList;
     import java.util.List;
     
     @Tags({"mongo", "mongodb", "service"})
     @CapabilityDescription(
         "Provides a controller service that wraps most of the functionality of the MongoDB
driver."
     )
    -public class MongoDBControllerService extends AbstractMongoDBControllerService implements
MongoDBClientService {
    +public class MongoDBControllerService extends AbstractControllerService implements MongoDBClientService
{
         private MongoDatabase db;
         private MongoCollection<Document> col;
    +    private String uri;
     
         @OnEnabled
    -    public void onEnabled(final ConfigurationContext context) throws InitializationException,
IOException, InterruptedException {
    +    public void onEnabled(final ConfigurationContext context) {
    +        this.uri = context.getProperty(URI).evaluateAttributeExpressions().getValue();
             this.createClient(context);
    -        this.db = this.mongoClient.getDatabase(context.getProperty(MongoDBControllerService.DATABASE_NAME).getValue());
    -        this.col = this.db.getCollection(context.getProperty(MongoDBControllerService.COLLECTION_NAME).getValue());
    -    }
    -
    -    @OnDisabled
    -    public void onDisable() {
    -        this.mongoClient.close();
    -    }
    -
    -    @Override
    -    public long count(Document query) {
    -        return this.col.count(query);
    -    }
    -
    -    @Override
    -    public void delete(Document query) {
    -        this.col.deleteMany(query);
         }
     
    -    @Override
    -    public boolean exists(Document query) {
    -        return this.col.count(query) > 0;
    -    }
    -
    -    @Override
    -    public Document findOne(Document query) {
    -        MongoCursor<Document> cursor  = this.col.find(query).limit(1).iterator();
    -        Document retVal = cursor.tryNext();
    -        cursor.close();
    -
    -        return retVal;
    -    }
    +    static List<PropertyDescriptor> descriptors = new ArrayList<>();
     
    -    @Override
    -    public Document findOne(Document query, Document projection) {
    -        MongoCursor<Document> cursor  = projection != null
    -                ? this.col.find(query).projection(projection).limit(1).iterator()
    -                : this.col.find(query).limit(1).iterator();
    -        Document retVal = cursor.tryNext();
    -        cursor.close();
    -
    -        return retVal;
    -    }
    -
    -    @Override
    -    public List<Document> findMany(Document query) {
    -        return findMany(query, null, -1);
    +    static {
    +        descriptors.add(URI);
    +        descriptors.add(SSL_CONTEXT_SERVICE);
    --- End diff --
    
    Why are we only exposing `URI` alone? I thought this PR intends to offer a controller
service where we can configure a connection to a MongoDB database & collection and use
that controller service optionally instead of the processor level `URI`, `Database Name`,
`Collection Name`.


> Make MongoDBControllerService able to act as a configuration source for MongoDB processors
> ------------------------------------------------------------------------------------------
>
>                 Key: NIFI-5239
>                 URL: https://issues.apache.org/jira/browse/NIFI-5239
>             Project: Apache NiFi
>          Issue Type: New Feature
>            Reporter: Mike Thomsen
>            Assignee: Mike Thomsen
>            Priority: Major
>
> The MongoDBControllerService should be able to provide the getDatabase and getCollection
functionality that are built into the MongoDB processors through AbstractMongoDBProcessor.
Using the controller service with the processors should be optional in the first release it's
added and then mandatory going forward.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message