Search code examples
jdbcglassfish-3connection-poolingchef-infra

Dynamically reloading jdbc-connection-pool settings


I have a connection pool setup properly on Glassfish 3.1.2.2. This is working properly.

My setup is to multiple slave database servers, therefore the URL property of my jdbc-connection-pool. This one looks like so:

jdbc:mysql:loadbalance://my.database.host1,my.database.host2/dbName

Once again, functional. We then have a Chef server that, when slaves are overloaded, spins up a new one. It then modifies the domain.xml of my web servers to append the new host to the URL property. I now have:

jdbc:mysql:loadbalance://my.database.host1,my.database.host2,newly.created.host/dbName

Our current solution is to restart Glassfish in order to have the new values taken into account. This has the consequence that it kicks out all who have a session with said server, among other negative impacts. Is there a way to get these values reloaded without restarting the server? - On the fly/dynamically.


Solution

  • I just figured this one out! I, and I would assume many others from reading on different forums have forgotten about the RESTful admin interface to Glassfish.

    By updating the URL for the connection pool via REST, I can update the value without having to reset the server instance.

    Here is the cURL request I am using:

    curl –X POST –H ”X-Requested-By: Glassfish REST HTML Interface” 
        –d “value=jdbc:mysql://my.database.host1,my.database.host2,newly.created.host/dbname” 
        –u “username”:”password” 
        https://admin.host.url:4848/management/domain/resources/jdbc-connection-pool/poolname/property/URL 
        -k
    

    I have added the -k since my security certificate isn't in my cacert file and I wanted to save time for the moment. It would be better practice to have cURL validate your security certificate.

    Useful Links: