You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Devin Fisher <de...@perfectsearchcorp.com> on 2016/03/15 23:51:07 UTC

Cross NAR Controller Services

I'm having issues using a standard controller service (DBCPConnectionPool)
that is provided by nifi-dbcp-service-nar. But I'm having issues with my
nar. I have included a dependency on nifi-dbcp-service-api in my maven pom
and have used the property description that is the same as ExecuteSQL for
the DBCP_SERVICE property. When I load my processor in nifi I don't get a
list of DBCPConnectionPool controller service like I expect. I have an
ExecuteSQL processor in the same flow (for testing) and it list the
controller service I created just fine and uses it just fine.

The problem seems to me (I don't have a development environment to confirm)
that the DBCPService.class that I use in my processor is not seen as the
same class object (because of the isolation features of NAR) as the one
that DBCPCOnnectionPool implements. I think I have mostly confirmed this by
implementing a dummy controller service that implements DBCPService in the
same NAR as my processor and my processor is able to list it just fine. But
the ExecuteSQL don't list my dummy controller service. So they seem to be
considered different classes.

I think I'm doing something wrong because ExecuteSQL is not in the same nar
as DBCPConnectionPool. So they play nice together somehow but I don't see
what I need to do so that my nar works the same way.

I'm enjoying developing against nifi and sorry if this is a rookie mistake.

Devin

Re: Cross NAR Controller Services

Posted by Devin Fisher <de...@perfectsearchcorp.com>.
Thanks Bryan. That should give me plenty to work on tomorrow. I'll write
back if I can't figure it out.

Devin

On Tue, Mar 15, 2016 at 6:11 PM, Bryan Bende <bb...@gmail.com> wrote:

> Devin,
>
> This WIki page shows how to create the appropriate dependencies between
> your NAR and the ControllerService:
>
>
> https://cwiki.apache.org/confluence/display/NIFI/Maven+Projects+for+Extensions#MavenProjectsforExtensions-LinkingProcessorsandControllerServices
>
> I also created an example project on GitHub to show a working example:
>   https://github.com/bbende/nifi-dependency-example
>
> Hope that helps.
>
> -Bryan
>
> On Tue, Mar 15, 2016 at 7:33 PM, Oleg Zhurakousky <
> ozhurakousky@hortonworks.com> wrote:
>
> > Devin
> >
> > Your problem is most likely in your NAR poms where you may satisfy
> compile
> > dependency but not NAR to participate in class loader runtime
> inheritance.
> > Is there a way to look at your poms and also the general structure of the
> > project?
> >
> > Oleg
> >
> > Sent from my iPhone
> >
> > > On Mar 15, 2016, at 18:51, Devin Fisher <
> > devin.fisher@perfectsearchcorp.com> wrote:
> > >
> > > I'm having issues using a standard controller service
> > (DBCPConnectionPool)
> > > that is provided by nifi-dbcp-service-nar. But I'm having issues with
> my
> > > nar. I have included a dependency on nifi-dbcp-service-api in my maven
> > pom
> > > and have used the property description that is the same as ExecuteSQL
> for
> > > the DBCP_SERVICE property. When I load my processor in nifi I don't
> get a
> > > list of DBCPConnectionPool controller service like I expect. I have an
> > > ExecuteSQL processor in the same flow (for testing) and it list the
> > > controller service I created just fine and uses it just fine.
> > >
> > > The problem seems to me (I don't have a development environment to
> > confirm)
> > > that the DBCPService.class that I use in my processor is not seen as
> the
> > > same class object (because of the isolation features of NAR) as the one
> > > that DBCPCOnnectionPool implements. I think I have mostly confirmed
> this
> > by
> > > implementing a dummy controller service that implements DBCPService in
> > the
> > > same NAR as my processor and my processor is able to list it just fine.
> > But
> > > the ExecuteSQL don't list my dummy controller service. So they seem to
> be
> > > considered different classes.
> > >
> > > I think I'm doing something wrong because ExecuteSQL is not in the same
> > nar
> > > as DBCPConnectionPool. So they play nice together somehow but I don't
> see
> > > what I need to do so that my nar works the same way.
> > >
> > > I'm enjoying developing against nifi and sorry if this is a rookie
> > mistake.
> > >
> > > Devin
> >
>

Re: Cross NAR Controller Services

Posted by Bryan Bende <bb...@gmail.com>.
Devin,

This WIki page shows how to create the appropriate dependencies between
your NAR and the ControllerService:

https://cwiki.apache.org/confluence/display/NIFI/Maven+Projects+for+Extensions#MavenProjectsforExtensions-LinkingProcessorsandControllerServices

I also created an example project on GitHub to show a working example:
  https://github.com/bbende/nifi-dependency-example

Hope that helps.

-Bryan

On Tue, Mar 15, 2016 at 7:33 PM, Oleg Zhurakousky <
ozhurakousky@hortonworks.com> wrote:

> Devin
>
> Your problem is most likely in your NAR poms where you may satisfy compile
> dependency but not NAR to participate in class loader runtime  inheritance.
> Is there a way to look at your poms and also the general structure of the
> project?
>
> Oleg
>
> Sent from my iPhone
>
> > On Mar 15, 2016, at 18:51, Devin Fisher <
> devin.fisher@perfectsearchcorp.com> wrote:
> >
> > I'm having issues using a standard controller service
> (DBCPConnectionPool)
> > that is provided by nifi-dbcp-service-nar. But I'm having issues with my
> > nar. I have included a dependency on nifi-dbcp-service-api in my maven
> pom
> > and have used the property description that is the same as ExecuteSQL for
> > the DBCP_SERVICE property. When I load my processor in nifi I don't get a
> > list of DBCPConnectionPool controller service like I expect. I have an
> > ExecuteSQL processor in the same flow (for testing) and it list the
> > controller service I created just fine and uses it just fine.
> >
> > The problem seems to me (I don't have a development environment to
> confirm)
> > that the DBCPService.class that I use in my processor is not seen as the
> > same class object (because of the isolation features of NAR) as the one
> > that DBCPCOnnectionPool implements. I think I have mostly confirmed this
> by
> > implementing a dummy controller service that implements DBCPService in
> the
> > same NAR as my processor and my processor is able to list it just fine.
> But
> > the ExecuteSQL don't list my dummy controller service. So they seem to be
> > considered different classes.
> >
> > I think I'm doing something wrong because ExecuteSQL is not in the same
> nar
> > as DBCPConnectionPool. So they play nice together somehow but I don't see
> > what I need to do so that my nar works the same way.
> >
> > I'm enjoying developing against nifi and sorry if this is a rookie
> mistake.
> >
> > Devin
>

Re: Cross NAR Controller Services

Posted by Oleg Zhurakousky <oz...@hortonworks.com>.
Devin

Your problem is most likely in your NAR poms where you may satisfy compile dependency but not NAR to participate in class loader runtime  inheritance. Is there a way to look at your poms and also the general structure of the project?

Oleg

Sent from my iPhone

> On Mar 15, 2016, at 18:51, Devin Fisher <de...@perfectsearchcorp.com> wrote:
> 
> I'm having issues using a standard controller service (DBCPConnectionPool)
> that is provided by nifi-dbcp-service-nar. But I'm having issues with my
> nar. I have included a dependency on nifi-dbcp-service-api in my maven pom
> and have used the property description that is the same as ExecuteSQL for
> the DBCP_SERVICE property. When I load my processor in nifi I don't get a
> list of DBCPConnectionPool controller service like I expect. I have an
> ExecuteSQL processor in the same flow (for testing) and it list the
> controller service I created just fine and uses it just fine.
> 
> The problem seems to me (I don't have a development environment to confirm)
> that the DBCPService.class that I use in my processor is not seen as the
> same class object (because of the isolation features of NAR) as the one
> that DBCPCOnnectionPool implements. I think I have mostly confirmed this by
> implementing a dummy controller service that implements DBCPService in the
> same NAR as my processor and my processor is able to list it just fine. But
> the ExecuteSQL don't list my dummy controller service. So they seem to be
> considered different classes.
> 
> I think I'm doing something wrong because ExecuteSQL is not in the same nar
> as DBCPConnectionPool. So they play nice together somehow but I don't see
> what I need to do so that my nar works the same way.
> 
> I'm enjoying developing against nifi and sorry if this is a rookie mistake.
> 
> Devin

Re: Cross NAR Controller Services

Posted by Matt Burgess <ma...@gmail.com>.
Devin,

DBCPConnectionPool is an implementation of the DBCPService interface. The
DBCPService interface is in the nifi-dbcp-service-api and is the way you'd
interact with the instance(s), which currently happen to be
DBCPConnectionPool objects.

If you implement your own class that implements DBCPService (_not_
DBCPConnectionPool), you will need to declare it for the ServiceLoader,
namely as a file in your project called
src/main/resources/META-INF/services/org.apache.nifi.controller.ControllerService
containing a line with the fully-qualified name of your implementation. You
can follow the DBCPConnectionPool example, but note that you would not
refer to DBCPConnectionPool at all in your NAR.

Hopefully this hasn't made things more confusing, please let me know if you
have more questions.

Regards,
Matt

On Tue, Mar 15, 2016 at 6:51 PM, Devin Fisher <
devin.fisher@perfectsearchcorp.com> wrote:

> I'm having issues using a standard controller service (DBCPConnectionPool)
> that is provided by nifi-dbcp-service-nar. But I'm having issues with my
> nar. I have included a dependency on nifi-dbcp-service-api in my maven pom
> and have used the property description that is the same as ExecuteSQL for
> the DBCP_SERVICE property. When I load my processor in nifi I don't get a
> list of DBCPConnectionPool controller service like I expect. I have an
> ExecuteSQL processor in the same flow (for testing) and it list the
> controller service I created just fine and uses it just fine.
>
> The problem seems to me (I don't have a development environment to confirm)
> that the DBCPService.class that I use in my processor is not seen as the
> same class object (because of the isolation features of NAR) as the one
> that DBCPCOnnectionPool implements. I think I have mostly confirmed this by
> implementing a dummy controller service that implements DBCPService in the
> same NAR as my processor and my processor is able to list it just fine. But
> the ExecuteSQL don't list my dummy controller service. So they seem to be
> considered different classes.
>
> I think I'm doing something wrong because ExecuteSQL is not in the same nar
> as DBCPConnectionPool. So they play nice together somehow but I don't see
> what I need to do so that my nar works the same way.
>
> I'm enjoying developing against nifi and sorry if this is a rookie mistake.
>
> Devin
>