nifi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toivo Adams <toivo.ad...@gmail.com>
Subject Re: New Database Connection Pooling Controller Service
Date Sat, 28 Feb 2015 15:51:27 GMT
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.

Mime
View raw message