My geoserver application needs to connect to potentially hundreds of different Oracle schemas. There is a workspace associated with each schema. My goal is to have a single connection pool that is shared by all of these workspaces.
Andrea shared this URL which tends to point me in the right direction. http://docs.geoserver.org/latest/en/user/data/database/sqlsession.html#data-sqlsession
The above solution allows for one DataStore to be shared by all of my workspaces, which is exactly what I need. But this won’t work with the Oracle database. Unfortunately Oracle does not support the SET SESSION AUTHORIZATION sql and apparently has no SQL-based equivalent.
However, Oracle does have exactly what I need. The problem is that it can’t be accomplished by executing a SQL statement. Instead it requires a proprietary call to the JDBC driver.
With Oracle, ‘impersonating’ a user is accomplished by creating a proxy connection. The basics of this are at http://docs.oracle.com/cd/B28359_01/java.111/b31224/proxya.htm#BABEJEIA. The idea is that basically you setup the connection pool based on a database user with minimal privilege and no meaningful default schema. Then you can borrow one of the connections in the pool and switch it so it now behaves as a connection to the user account you want to behave-as.
Doing the equivalent of SET SESSION AUTHORIZATION is accomplished with a call to the Oracle driver oracle.jdbc.OracleConnection.openProxySession. And then when the connection is returned to the pool, an overload of the OracleConnection.close() method closes the proxy session while keeping the connection otherwise open.
I’m looking for any comments you might have on how to extend the geoserver code to support this. Rather than hack the code for my own purposes I’d like to hope I might contribute a solution that gets rolled into the core product.
Thanks in advance for any thoughts on how to implement this in geoserver. References to specific geoserver/geotools interfaces are appreciated!
Walter Stovall
Byers Engineering Company
···
From: Walter Stovall
Sent: Tuesday, June 14, 2016 5:11 AM
To: Andrea Aime <andrea.aime@…1268…>
Cc: Rob L <Robert.Langford@…4471…>; geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Can geoserver 2.8 manage number of database connections to a given Oracle instance?
My situation is not so clean as that in that my users don’t literally have database accounts. But that doesn’t mean I can’t learn what the database user/schema is from the authenticated user name. I may be able to work with the framework you point to for impersonation and get a solution that works for me.
Thanks for the suggestion!
Walter
From: andrea.aime@…403… [mailto:andrea.aime@…403…] On Behalf Of Andrea Aime
Sent: Monday, June 13, 2016 10:08 AM
To: Walter Stovall <walter.stovall@…4309…>
Cc: Rob L <Robert.Langford@…4471…>; geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Can geoserver 2.8 manage number of database connections to a given Oracle instance?
Hi Walter,
I don’t think I’ve ever heard of any connection pooling library able to limit the total amount
of connections across several pools.
A Google search for “limit number of jdbc connections across multiple connection pools” also comes out empty as far as I can tell.
If in your use case there is a correspondence between a GeoServer user and a database user, maybe you can use
a single connection pool, and impersonation to change the current user:
http://docs.geoserver.org/latest/en/user/data/database/sqlsession.html#data-sqlsession
Just thinking out loud here
Cheers
Andrea
On Mon, Jun 13, 2016 at 3:45 PM, Walter Stovall <walter.stovall@…4309…> wrote:
Thanks but I don’t yet see how this would solve my problem? When I look at the tutorial it shows setting up a tomcat pool that connects to oracle under a specific user name and password.
But in my case I want to limit the number of connections to the Oracle instance itself independent of the user id and password. For example let’s say I have 100 geoserver workspaces, each of which manage a pool of connections to a specific Oracle schema (with all such schemas in one oracle instance). Each such pool would login to Oracle under a different user and password. I might want each pool to have as many as 50 active connections, and yet I want to see that regardless, no more than 200 total connections (in all the pools combined) will be created.
In the above scenario of 100 workspaces with 50 connections each you might normally see as many as 5,000 connections. I’m looking for something that will see that regardless, the total connections are kept below a limit of say 200. So three particular pools might create 50 connections and if a 4th pool tries to create a new connection (to this specific oracle instance regardless of schema) that connection will block waiting for the limit to go below 200.
Does JNDI create a way of doing that?
Thanks, Walter
-----Original Message-----
From: Rob L [mailto:Robert.Langford@…4471…]
Sent: Monday, June 13, 2016 8:45 AM
To: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] Can geoserver 2.8 manage number of database connections to a given Oracle instance?Walter,
Have a look at using a JNDI connection.
http://docs.geoserver.org/maintain/en/user/tutorials/tomcat-jndi/tomcat-jndi.html#tomcat-jndi
<http://docs.geoserver.org/maintain/en/user/tutorials/tomcat-jndi/tomcat-jndi.html#tomcat-jndi>–
View this message in context: http://osgeo-org.1560.x6.nabble.com/Can-geoserver-2-8-manage-number-of-database-connections-to-a-given-Oracle-instance-tp5271268p5271381.html
Sent from the GeoServer - User mailing list archive at Nabble.com.
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
–
==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.
==
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://twitter.com/geosolutions_it
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy’s New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.