3

I want measure metrics on my datasource comparing HikariCP and C3pO. I don’t understand how I can use FlexyPool in my project. I have Tomcat context.xml and HikariCP:

          <Resource name="jdbc/dictionaryDB"
            auth="Container"
            factory="com.zaxxer.hikari.HikariJNDIFactory"
            type="javax.sql.DataSource"
            driverClassName="org.postgresql.Driver"
            jdbcUrl="jdbc:postgresql://localhost:5432/deversdb"
            username="user"
            password="pass"
            maxActive="8"
            maxIdle="4"/>

Please help me, i’am very newbie in connection pooling theme. What I must to do with this https://github.com/vladmihalcea/flexy-pool/wiki/HikariCP-Configuration ?

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
S_T_I_M
  • 31
  • 6

1 Answers1

4

Since you already have a DataSource that is provided via JNDI, you could try to use the Java EE installation mode.

For this, you need a flexy-pool.properties configuration file on your classpath root, which must contain the following properties:

flexy.pool.data.source.unique.name=some-unique-name
flexy.pool.data.source.jndi.name=jdbc/dictionaryDB
flexy.pool.metrics.reporter.jmx.auto.start=true

As dependencies, you need:

<dependency>
    <groupId>com.vladmihalcea.flexy-pool</groupId>
    <artifactId>flexy-java-ee</artifactId>
    <version>${flexy-pool.version}</version>
</dependency>
Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • Ok, I added this dependencies to my pom.xml flexy-java-ee and flexy-pool-core and flexy-pool.properties to my classpath and com.vladmihalcea.flexypool.adaptor.FlexyPoolHibernateConnectionProvider to hibernate config and running my app, but i don't see any mbean with name starting "com.vladmihalcea.flexypool" in JConsole in tomcat process, what I did wrong? – S_T_I_M Jul 29 '16 at 08:08
  • You'll have to debug the [`FlexypoolDataSource`](https://github.com/vladmihalcea/flexy-pool/blob/master/flexy-pool-core/src/main/java/com/vladmihalcea/flexypool/FlexyPoolDataSource.java) to see what's going on. – Vlad Mihalcea Jul 29 '16 at 08:12
  • "Caused by: java.lang.IllegalStateException: No MetricsFactory could be loaded!" How i can solve this? – S_T_I_M Aug 01 '16 at 05:39
  • Do you have the `flexy-java-ee` dependency? You should also see the `flexy-codahale-metrics` and `flexy-dropwizard-metrics` in your classpath. – Vlad Mihalcea Aug 01 '16 at 05:43
  • I added also metrics-core-3.1.2.jar into classpath and I succesfully see mbean in jConsole – S_T_I_M Aug 01 '16 at 08:10
  • Thanks you for help! And last question: what are you use for plotting metrics? – S_T_I_M Aug 01 '16 at 08:44
  • You can use anything that Codahale/Dropwizard Metrics supports: Graphana, Graphite. – Vlad Mihalcea Aug 01 '16 at 08:58
  • By the way, would you mind adding a Testimonial to FlexyPool? You can advertise your company or your product too. Check out the current testimonials: https://github.com/vladmihalcea/flexy-pool#who-uses-flexypool – Vlad Mihalcea Aug 08 '16 at 08:41