GlassFish V3 Connectors (JavaEE Connector Architecture, Connection Pooling, JDBC-RA) One Pager[
Unknown macro: {TableOfContents title=' '}
|(TableOfContentstitle='')] 1. Introduction |
Date | Change | Revision | Changes from previous version |
---|---|---|---|
11/30/09 | Modified description of certain features with erroneous attribute names/descriptions | 13 | changes |
10/05/09 | Modified description of Flush connection pool feature | 12 | changes |
09/09/09 | Commented postponed features (multiple-associate-with-thread, application-scoped-resources ) and updated 4.7-Admin/Config Impact sections with latest configuration for sun-resources_1_4.dtd, work-security-map, admin-object | 11 | changes |
06/23/09 | Modified 4.1.7, 4.1.15 and 4.7-Admin/Config Impact sections based on comments from Bill Shannon | 10 | changes |
05/27/09 | Modified 4.1.4, 4.1.9 and 4.1.10 based on comments from Bill Shannon | 9 | changes |
02/09/09 | Added sun-resources.dtd to exported interfaces section | 8 | changes |
02/09/09 | Updated based on comments from Siva | 7 | changes |
02/02/09 | Added Application Scoped Resources | 6 | changes |
01/20/09 | Updated Revision History | 5 | changes |
01/20/09 | Modified based on comments from Vince and Steve | 4 | changes |
01/06/09 | Clarified init-sql, switch-off-pooling, custom-resources sections based on feedback from Binod | 3 | |
12/26/08 | Review Ready | 2 | |
12/12/08 | Draft Created | 1 |
This document describes the functionality changes and enhancements to Connectors, Connection Pooling, JDBC-RA
Following enhancements need to be introduced in GlassFish v3 to overcome or to provide :
Enhancements to the existing connectors, pooling, jdbc modules is very useful as the functionality offered by these modules are used widely among the user-base and based on the competitive appservers, these functionality improvements and changes would not only bring in performance improvements but also feature parity. The proposed features will highly enhance the user experience.
The Connectors, Pooling, JDBC-RA would provide the following enhancements in this release
Statement Caching is a feature to cache statements, prepared-statements, callable-statements that are executed repeatedly by applications, thereby improving performance. Instead of preparing the statement each time, the cache is searched for a match. The overhead of parsing and creating new statements each time is prevented.
Statement Caching, in general, is a functionality of the JDBC driver. This proposal is for supporting statement caching that will be useful for drivers that do not support caching. The feature can be enabled by setting a connection pool configuration attribute statement-cache-size. By default, this attribute is set to zero and the statement caching is turned off. Caching is enabled when set to a positive non-zero value eg: 10 implies upto 10 statements can be maintained in the statement cache.
Built-in cache eviction strategy will be LRU-based (Least Recently Used). This is the only cache eviction strategy provided in this release. When a connection pool is flushed, the connections in the statement cache will be recreated.
Using Custom validation a user can specify his/her own implementation that will be used during connection validation. This feature aids user to call database specific optimized or faster validation routines.
The existing attribute connection-validation-method could be set to a value custom-validation. Other existing validation mechanisms available in JDBC Connection pool are table/auto-commit/metadata.
A public interface org.glassfish.api.jdbc.ConnectionValidation will be introduced which developers can implement to plugin their implementations.
A new attribute validation-classname will be used to specify the fully-qualified name of the Class that implements the ConnectionValidation interface. Administrators or developers could provide the custom validation implementation that should be made available to the application server. When validation is turned on and connection-validation-method is set to custom-validation, the attribute validation-classname is mandatory.
By default, custom validation mechanisms will be provided for Derby, MySQL, Oracle and Postgres for faster and optimized validation routines. Additionally, for JDBC 40 compliant database drivers, a validation mechanism will be provided that uses Connection.isValid(0) implementation.
Init Sql feature aids in executing an arbitrary query provided by the user during connection creation.
Every time a physical connection (ManagedConnection) to the database is created from the pool (not the connections that are reused from the pool), the initSql will be executed to initialize the state of the connection.
A new attribute init-sql is used to specify a SQL string to be executed whenever a connection is created from the pool. This is an optional attribute and should carry a value when initialization SQL is to be executed. This is a useful feature to set the request/session specific properties, suited for homogeneous requests (e.g : for single application usage).
There is no default value and hence enabled only when a value is specified.
A feature to trace the SQL statements executed by applications using a jdbc connection pool. In most cases, administrators refer to the database logs for SQL statements analysis. This is made easy by setting an attribute sql-trace-listeners to a comma separated list of listener implementations.
A public interface org.glassfish.api.jdbc.SQLTraceListener will be introduced which administrators/developers can implement to provide a means of recording the SQLTraceRecord objects.
GlassFish provides an inbuilt SQL tracing logger to log the SQL operations in the form of SQLTraceRecord in server.log file. "javax.enterprise.resource.sqltrace" is the module name using which SQL operation will be logged. SQL traces are logged as FINE messages along with the module name to enable easy filtering of the sql logs. A sample SQL trace record would be like
[#|2009-11-27T15:46:52.202+0530|FINE|glassfishv3.0|javax.enterprise.resource.sqltrace.com.sun.gjc.util|_ThreadID=29;_ThreadName=Thread-1;ClassName=com.sun.gjc.util.SQLTraceLogger;MethodName=sqlTrace;|ThreadID=77 | ThreadName=p: thread-pool-1; w: 6 | TimeStamp=1259317012202 | ClassName=com.sun.gjc.spi.jdbc40.PreparedStatementWrapper40 | MethodName=executeUpdate | arg[0]=insert into table1(colName) values(100) | arg[1]=columnNames | |#]
Above trace shows that an executeUpdate(String sql, String[] columnNames) is being done.
This is a GUI feature that will introspect any newly installed drivers and display the DataSource/Driver implementations. GlassFish displays a predefined list of drivers and its Datasource/Driver implementations. This feature helps the user to configure a pool for an arbitrary (not listed by default in GUI) jdbc driver. Using this feature, the arbitrary driver will be introspected to list the Datasource/Driver implementations during pool creation.
Based on the resource type and database vendor name chosen, the Administration console introspects the available jdbc driver and lists the implementation classname against the datasource/driver classname field. The classnames are listed in a drop-down list box.
The user can select an implementation classname to configure the connection pool whose properties would be listed in the additional properties section.
A default set of classnames for common database vendors are maintained for display in GUI. For uncommon databases, introspection happens to retrieve the classnames.
Flush connection pool is a feature that re-initializes all the connections in the pool without the need for reconfiguring the whole pool. This is a useful feature for administrators.
Flush connection pool will help to solve the issue by recreating the connections established in the pool and bringing the pool to the steady pool size. The existing "live" connections are killed/destroyed and any existing transactions are lost and must be retired. The main purpose of this command is to kill/destroy any aged or old connections in the pool.
Like ping-connection-pool, flush-connection-pool will be an admin CLI command to be executed whenever needed. A button Flush, similar to Ping will be available in Admin GUI for the same purpose.
Custom-Resources aid to create various type of resources that can be shared across applications. Defining built-in object factories and resource template files will help the user to get access to most commonly used custom resources. Users can create custom-resources specifying these built-in factory-class-name and necessary properties. Following object factories will be provided in V3 (refer Packaging & Delivery section for the templates availability & usage).
JavaBeanFactory
PrimitivesAndStringFactory
URLFactory
PropertiesFactory
NOTE : This feature is not implemented in v3
Ease-of-use feature that would turn off connection pooling for the specified pool. The new attribute pooling when set to false will disable connection pooling for the specified pool.
By default, this attribute's value will be true. The existing system property 'com.sun.enterprise.connectors.SwitchoffACCConnectionPooling', that turns off connection pooling in ACC and the new attribute pooling do not affect each other.
Associate-with-thread functionality is invalid when pooling is disabled and hence an exception will be thrown if it is set to true. An exception will be thrown if Flush connection pool is done when pooling is disabled.
A warning will be logged when the following attributes are active as they are useful in pooled environment only :
The following attributes will undergo a change in their default values :
A list of table names would be displayed against the validation-table-name field for the user to choose a table to perform connection validation.
Since the statement objects are not wrapped by default, user will get access to the physical connection which may affect the pooling infrastructure. This can be prevented by setting wrap-jdbc-objects to
"true", hence making this as default behavior.
The connection pool will be automatically tested for valid connectivity, when it is created by setting a new attribute ping to true. This feature is useful to identify erroneous values, if any, specified in the jdbc connection pool configuration.
The existing pooling infrastructure does not warn the user of any unsupported/incorrect value of a database connectivity property while it is created. Only at runtime, the pool is initialized with the properties and attributes specified by the user and while getting a connection a warning would be seen.
Default value of ping is false which indicates that the pool will not be tested during creation. The existing "Ping" button in admin GUI and the "asadmin ping-connection-pool" command would exist and be supported in the future.
This is a proposal to support configuration of JDBC drivers and applications that use java.sql.Driver implementations.
The res-type attribute when set to java.sql.Driver enables the Driver manager based MCF. A new attribute driver-classname will take implementing driver class name as the value. driver-classname will be a mandatory attribute when the res-type is set to java.sql.Driver.
datasource-classname attribute will be an optional attribute when res-type is set to java.sql.Driver, whereas the driver-classname attribute will be mandatory.
JSR-322, Connector Specification introduces Security-Inflow-Context mechanism.
It is possible for a resource-adapter to request for mapping of identities from EIS domain to
application server domain. Application Servers can provide this functionality in a vendor specific
way. GlassFish will have WorkContextSecurityMap(s) configured for a resource-adapter using
CLI/GUI. Refer admin/config impact section for required commands and dtd changes.
JSR-322 introduces a mechanism using which the transaction-level of MCF can be detected by the container
at runtime. During the configuration of MCF (connector-connection-pool), admin console (GUI) can
instantiate the MCF and show the level of transaction-support.
eg: There are 3 levels, no-tx, local-tx, xa-tx.
If an MCF returns local-tx as the level it can support, it is assumed that xa-tx is not supported and
hence admin console (GUI) will show no-tx and local-tx as the available tx-support levels.
This ease-of-use feature will be provided via admin console (GUI) only.
NOTE : This feature is not implemented in v3
Scope of resources
java:app/jdbc/myDataSource. This is in accordance with the new naming scopes introduced in Java EE 6 Specification. Please refer Resources, Naming and Injection, sub-section JNDI Naming Context of Java EE 6 Specification for more details.
sun-resources.xml
Duplicates & Conflicts
Deploy, re-deploy, undeploy
Supported application types
Restriction on resource types in various application types
Tooling support
Monitoring & AMX Support
server.<application-name>.resources.<resource-name>.*
*Interface* | *Stability* | *Former Stability (if changing)* | Comments |
---|---|---|---|
org.glassfish.resources.custom.factory.JavaBeanFactory | NA | Specify bean property name and value as property of custom-resource | |
org.glassfish.resources.custom.factory.PropertiesFactory | NA | org.glassfish.resources.custom.factory.PropertiesFactory.fileName need to be specified as a property of custom-resource, to indicate the properties file | |
org.glassfish.resources.custom.factory.PrimitiviesAndStringFactory | NA | a property named value that needs to be set for the data-type specified in CLI/GUI --restype | |
org.glassfish.resources.custom.factory.URLFactory | NA | protocol, host, port, file, spec are the properties that need to be set for the custom-resource, in accordance with the constructor of java.net.URL that need to be used. | |
org.glassfish.api.jdbc.ConnectionValidation | Evolving | Custom validation public interface | |
org.glassfish.api.jdbc.SQLTraceListener | Evolving | SQLTraceListener interface for custom sql tracing | |
org.glassfish.api.jdbc.SQLTraceRecord | Evolving | SQLTraceRecord for format of sql trace records | |
sun-resources.dtd | Evolving | sun-resources.xml dtd |
All of the above implement org.glassfish.api.jdbc.ConnectionValidation interface.
CLI support :
flush-connection-pool [--terse={true|false}] [--echo={true|false}] [--interactive={true|false}] [--host host] [--port port] [--secure | -s] [--user admin_user] [--passwordfile filename] [--help] pool_name
create-connector-work-security-map --raname resource_adapter_name --principalsmap eis-principal=server-principal[,eis-principal=server-principal]* --groupsmap eis-group=server-group[,eis-group=server-group]* [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] mapname delete-connector-work-security-map --raname resource_adapter_name [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] mapname list-connector-work-security-map [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--securitymap mapname] [--verbose=false] resource-adapter-name update-connector-work-security-map --raname resource_adapter_name [--terse=false] [--echo=false] [--interactive=true] [--host localhost] [--port 4848|4849] [--secure | -s] [--user admin_user] [--passwordfile file_name] [--addprincipals eis-principal=server-principal[,eis-principal=server-principal]*] [--addgroups eis-group=server-group[,eis-group=server-group]*] [--removeprincipals eis-principal[,eis-principal]*] [--removegroups eis-group[,eis-group]*] mapname
deploy [--force=true] [--cascade-resources=true] myApp.ear
list-resources [--app-name application-name] eg: list-resources myApp resource1 <jdbc-resource> resource2 <mail-resource> resource3 <jdbc-resource> resource4 <custom-resource>
list-jdbc-resources [--app-name application-name] eg: list-jdbc-resources --app-name myApp resource1 resource3 list-jdbc-resources --app-name "*" resource1 <app-1> resource2 <app-2>
GUI support :
Config Impact
None.
None.
Templates for custom resource factories
need to be accessible (java permission, if needed) by the application server.
These changes will be documented.
Aligned to overall GlassFish V3 Final release schedules.