Toivo,

At this time, NiFi does not allow the developer to set property values 
programmatically. There are a few reasons for this, but the biggest reason is 
that if a processor can change its properties dynamically then one node in a 
cluster may change the value while another node does not. As a result, the 
nodes would be out of sync and would not be able to rejoin the cluster if they 
are disconnected for any reason.


The list of property descriptors, though, does not have to be static. It can 
change. However, it’s a little bit frowned upon only because it means that 
after the user drags the processor onto the graph, they can configure it and 
choose the appropriate value for that property. Then they have to apply those 
changes in order for the onPropertyModified method to get called and the 
properties to get refreshed. So the user would configure the processor, set the 
value, then click OK and then have to go back and configure the processor again 
for the new properties to show up.


That being said, we have recently discussed briefly the idea of allowing a 
property to depend on another. In this case, we would hide the properties 
unless they are applicable. I think this is really what you are wanting. But 
it’s not something that we support at this time.


Thanks

-Mark






From: [email protected]
Sent: ‎Saturday‎, ‎February‎ ‎28‎, ‎2015 ‎11‎:‎01‎ ‎AM
To: [email protected]





Hi, 

Please help.

I still don't know how to set programatically some property value after user
will change some other value.

My current idea is to show to user only one property:
DATABASE_SYSTEM  which contains all known databases as AllowableValue’s. 

When user will choose DATABASE_SYSTEM, service will catch this using
onPropertyModified.
And now service will create other property's and show them to user.
Don't know is this possible at all?

Usual practice is create unmodifiable list of property's.
Can this list be altered later?


Tried to test using TestRunner but onPropertyModified() is not called.

Service DBCPServiceApacheDBCP14 contains:

    @Override
    public void onPropertyModified(final PropertyDescriptor descriptor,
final String oldValue, final String newValue) {
        super.onPropertyModified(descriptor, oldValue, newValue);

        if (descriptor.equals(DATABASE_SYSTEM)) {
         
         DatabaseSystemDescriptor databaseSystemDescriptor =
DatabaseSystems.getDescriptor(newValue);

         // create other PropertyDescriptor's
        }        
    }

and test:

    @Test
    public void testGood() throws InitializationException {
        final TestRunner runner =
TestRunners.newTestRunner(TestProcessor.class);
        final DBCPServiceApacheDBCP14 service = new
DBCPServiceApacheDBCP14();
        runner.addControllerService("test-good1", service);
        
        // Should setProperty call also generate
DBCPServiceApacheDBCP14.onPropertyModified() method call? 
        // It does not currently.
        
        runner.setProperty(service, DBCPServiceApacheDBCP14.DATABASE_SYSTEM,
"JavaDB");
        runner.enableControllerService(service);

        runner.assertValid(service);
        DBCPService dbcpService = (DBCPService)
runner.getProcessContext().getControllerServiceLookup().getControllerService("test-good1");
        Assert.assertNotNull(dbcpService);
        Connection connection = dbcpService.getConnection();
        Assert.assertNotNull(connection);
    }


Thanks
toivo




--
View this message in context: 
http://apache-nifi-incubating-developer-list.39713.n7.nabble.com/New-Database-Connection-Pooling-Controller-Service-tp582p857.html
Sent from the Apache NiFi (incubating) Developer List mailing list archive at 
Nabble.com.

Reply via email to