8 Configuring the Data Source Interceptor

This chapter describes how to configure and use the data source interceptor. Prior to a scale up operation, a database interceptor can be automatically invoked to determine the number of database connections that can be created from a WebLogic domain to a database. This interceptor can be used to ensure that the capacities of the available connections are not exceeded as a result of a subsequent scale up operation.

This chapter includes the following sections:

Overview of the Data Source Interceptor

In a scale up operation, new dynamic server instances are started in a dynamic cluster. If any data sources are targeted to this dynamic cluster, then starting a new server instance may result in the creation of additional connections to the databases. However, the creation of these additional database connections has the potential to exceed database capabilities. The data source interceptor provides the means to determine whether database capacity would be exceeded by the addition of a new server instance and, if so, to prevent a scale up operation from proceeding.

Before a scale up operation, the data source interceptor determines the maximum number of connections that may be created if additional dynamic server instances are added to the dynamic cluster. If this number is not yet currently met, the interceptor allows the scale up operation to proceed. However, if the number is already met or exceeded, then the interceptor stops the scale up operation from being invoked.

Note:

If the execution of an interceptor fails, then neither the associated scaling operation nor any subsequently configured interceptors are invoked.

Configuring Data Source Interceptors

Data source interceptors are configured using the DatasourceInterceptorMBean.

When you configure a data source interceptor, you specify database capacities in terms of the total number of connections allowed. The connection URL specified in a data source interceptor configuration also identifies the database to which the connections are made. It is possible that several databases, with a certain total capacity, map to the same machine that hosts those databases. The data source interceptor configuration identifies a quota corresponding to a group of database URLs, and this quota is the maximum total number of connections that may be created from the domain.

If data sources are targeted to the dynamic cluster that is being scaled up, the data source interceptor will:

  • Determine the maximum number of projected connections that may be created on groups of databases if additional dynamic server instances are added to the dynamic cluster.

  • Allow the scaling operation to proceed if the configured quota is not exceeded.

  • Generate an exception if the configured quota is exceeded, which prevents the scaling operation from proceeding.

Example 8-1 shows a sample configuration for a data source interceptor in the config.xml file.

Example 8-2shows the WLST commands to create and configure a new data source interceptor.

Example 8-1 Sample Configuration for a Data Source Interceptor (in CONFIG.XML)

 <interceptors>
    <interceptor xsi:type="datasource-interceptorType">
      <name>datasource-interceptor-1</name>
      <priority>1073741823</priority>
      <connection-urls-pattern>jdbc:derby://host:1527/(.*)
      </connection-urls-pattern>
      <connection-quota>20</connection-quota>
    </interceptor>
  </interceptors>

Example 8-2 Creating a Data Source Interceptor Using WLST

startEdit()
 
cd('/Interceptors/wl_server')
cmo.createDatasourceInterceptor('datasource-interceptor-1')
 
cd('/Interceptors/wl_server/Interceptors/datasource-interceptor-1')
cmo.setPriority(1073741823)
cmo.setConnectionQuota(20)
cmo.setConnectionUrlsPattern(jdbc:derby://host:1527/(.*))
 
activate()
save()

You can also create and configure data source interceptors using the WebLogic Server Administration Console. For more information, see "Create data source interceptors" and "Configure data source interceptors" in the Oracle WebLogic Server Administration Console Online Help.