First of all, please keep in mind that I'm a monitoring admin and not a Java developer.
I want to monitor some attribute values of c3p0 pools and I found that such pools have a unique identity Token which is made of an alphanumeric string and a hexadecimal string joined with a pipe character, for instance:
2rxggs9vtsz4i48lg1tk|665e33d4
But the JDBC pools found in the context.xml file of the tomcat server shows only standard names:
<Resource name="jdbc/EXAMPLE"
jdbcUrl="jdbc:oracle:thin:@oracle:1521:PRExxx" user="EXAMPLE"
password="my34xXple" auth="Container" description="DB Connection"
driverClass="oracle.jdbc.driver.OracleDriver" maxPoolSize="50"
minPoolSize="2" maxIdleTime="30" checkoutTimeout="2000"
acquireIncrement="1" maxConnectionAge="3600"
factory="org.apache.naming.factory.BeanFactory" type="com.mchange.v2.c3p0.ComboPooledDataSource"
preferredTestQuery="SELECT 1 FROM dual" />
I use a JAR to query the MBeans of a running Java process via a JMX connection.
Here the Catalina:type=Resource ones:
Catalina:type=Resource,resourcetype=Context,path=/myapp,host=localhost,class=com.mchange.v2.c3p0.ComboPooledDataSource,name="jdbc/EXAMPLE"/scope (String) = Shareable
Catalina:type=Resource,resourcetype=Context,path=/myapp,host=localhost,class=com.mchange.v2.c3p0.ComboPooledDataSource,name="jdbc/EXAMPLE"/description (String) = DB Connection
Catalina:type=Resource,resourcetype=Context,path=/myapp,host=localhost,class=com.mchange.v2.c3p0.ComboPooledDataSource,name="jdbc/EXAMPLE"/name (String) = jdbc/EXAMPLE
Catalina:type=Resource,resourcetype=Context,path=/myapp,host=localhost,class=com.mchange.v2.c3p0.ComboPooledDataSource,name="jdbc/EXAMPLE"/type (String) = com.mchange.v2.c3p0.ComboPooledDataSource
and here the com.mchange.v2.c3p0 ones
com.mchange.v2.c3p0:type=C3P0Registry/AllIdentityTokenCount (Integer) = 15
com.mchange.v2.c3p0:type=C3P0Registry/AllIdentityTokenizedCount (Integer) = 15
com.mchange.v2.c3p0:type=C3P0Registry/AllPooledDataSourcesCount (Integer) = 5
com.mchange.v2.c3p0:type=PooledDataSource[2rxggs9vtsz4i48lg1tk|665e33d4]/dataSourceName (String) = 2rxggs9vtsz4i48lg1tk|665e33d4
com.mchange.v2.c3p0:type=PooledDataSource[2rxggs9vtsz4i48lg1tk|665e33d4]/threadPoolNumIdleThreads (Integer) = 3
com.mchange.v2.c3p0:type=PooledDataSource[2rxggs9vtsz4i48lg1tk|665e33d4]/acquireRetryAttempts (Integer) = 30
com.mchange.v2.c3p0:type=PooledDataSource[2rxggs9vtsz4i48lg1tk|665e33d4]/autoCommitOnClose (Boolean) = false
com.mchange.v2.c3p0:type=PooledDataSource[2rxggs9vtsz4i48lg1tk|665e33d4]/identityToken (String) = 2rxggs9vtsz4i48lg1tk|665e33d4
These are my questions:
How to link the Identity Tokens and the Resource Pool names?
In my example app, there are 5 resources defined in the
context.xmlfile but there are 15 c3p0 pools. That is also found in theC3P0Registry/AllIdentityTokenizedCountand in theC3P0Registry/AllPooledDataSourcesCountattributes. Is not there a one-to-one relationship?How are the identity tokens made? Are they random? What do the two strings mean? Are they linked to process or machine values?
Thanks
The
<Resource name="...">name is a jndi name, with no necessary connection to the JMX name. If you want there to be a Connection, set the propertydataSourceNameamong all the others you are setting to a consistent name.There is not a one-to-one relationship between
PooledDataSourcesand identity tokens / tokenized. A typicalPooledDataSourcemay contain three identity-tokenized elements. However, there should be only one JMX bean perPooledDataSource.The identity tokens are essentially random values, but with some deterministic parts based on the host, intended to ensure no possibility of collision. (Java now has built-in support for UUIDs, but did not when c3p0 was written.)
You may wish to not have to deal with the identity token stuff in your administration of c3p0
DataSources. As long as you ensure that yourDataSources each have uniquedataSourceNames set, you can eliminate the identity token from the JMX name, and have stable, reproducible JMX names. Please see Configuring and Managing c3p0 via JMX.