Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5974 - in trunk/perfsonar-java-rrd-ma-SQL_backend: . src/main src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql src/main/resources src/main/resources/META-INF

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r5974 - in trunk/perfsonar-java-rrd-ma-SQL_backend: . src/main src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql src/main/resources src/main/resources/META-INF


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5974 - in trunk/perfsonar-java-rrd-ma-SQL_backend: . src/main src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql src/main/resources src/main/resources/META-INF
  • Date: Wed, 22 Aug 2012 12:10:07 +0100 (BST)

Author: nordunet.behrmann
Date: 2012-08-22 12:10:07 +0100 (Wed, 22 Aug 2012)
New Revision: 5974

Added:
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/META-INF/

trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/META-INF/persistence.xml
Modified:
trunk/perfsonar-java-rrd-ma-SQL_backend/pom.xml

trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql/MysqlMetadataStorageDAOImpl.java
Log:
perfsonar-java-rrd-ma-SQL_backend: Drop base 3 dependency

RRD MA now uses Hibernate 4.1 directly.

Modified: trunk/perfsonar-java-rrd-ma-SQL_backend/pom.xml
===================================================================
--- trunk/perfsonar-java-rrd-ma-SQL_backend/pom.xml 2012-08-22 11:10:06
UTC (rev 5973)
+++ trunk/perfsonar-java-rrd-ma-SQL_backend/pom.xml 2012-08-22 11:10:07
UTC (rev 5974)
@@ -179,17 +179,15 @@
<name>perfSONAR repository</name>
<url>https://artifactory.geant.net/artifactory/geant-repo/</url>
</repository>
-
+ <repository>
+ <id>jboss-repository</id>
+ <name>jboss repository</name>
+
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
+ </repository>
</repositories>

<dependencies>
<dependency>
- <groupId>net.geant.perfsonar</groupId>
- <artifactId>perfsonar-base3-persistence</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
@@ -221,6 +219,28 @@
<version>1.4.1</version>
</dependency>

+ <!-- JPA -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>4.1.6.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ <version>4.1.6.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.1.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.21</version>
+ </dependency>
+
<!-- got for auth -->
<dependency>
<groupId>opensaml</groupId>

Modified:
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql/MysqlMetadataStorageDAOImpl.java
===================================================================
---
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql/MysqlMetadataStorageDAOImpl.java
2012-08-22 11:10:06 UTC (rev 5973)
+++
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql/MysqlMetadataStorageDAOImpl.java
2012-08-22 11:10:07 UTC (rev 5974)
@@ -1,16 +1,16 @@
package org.perfsonar.service.measurementArchive.rrdType.storage.sql;

-import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;

import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
import javax.persistence.Query;

-import net.geant.perfsonar.persistence.HibernateConfiguration;
-import net.geant.perfsonar.persistence.Persistence;
-
import org.perfsonar.base2.service.configuration.Component;
import org.perfsonar.base2.service.configuration.ConfigurationManager;
import org.perfsonar.base2.service.exceptions.PerfSONARException;
@@ -24,49 +24,45 @@
import
org.perfsonar.service.measurementArchive.rrdType.storage.persistence.entity.Interfaces;
import
org.perfsonar.service.measurementArchive.rrdType.storage.sql.query.QueryGenerator;

-import com.mysql.jdbc.Driver;
-
-public class MysqlMetadataStorageDAOImpl extends Component implements
MetadataStorageDAO{
-
-
- protected EntityManager em;
+public class MysqlMetadataStorageDAOImpl extends Component implements
MetadataStorageDAO
+{
+ public static final String PERSISTENCE_UNIT_NAME =
"org.perfsonar.service.measurementArchive.rrdType.storage.sql";
+ protected EntityManager em;
protected final QueryGenerator qg = new QueryGenerator();
-
- @Override
- public void destroy() throws PerfSONARException {
- // TODO Auto-generated method stub
-
+ private EntityManagerFactory entityManagerFactory;
+
+ @Override
+ public void destroy() throws PerfSONARException
+ {
+ em.close();
+ entityManagerFactory.close();
}

@Override
- public void init() throws PerfSONARException {
+ public void init() throws PerfSONARException
+ {
+ Component configuration =
ConfigurationManager.getInstance().getConfiguration().getAuxiliaryComponent(MetadataStorageDAOFactory.METADATA_STORAGE_DAO_NAME);
+ String DB_URI = configuration.getOption("uri").getValue();
+ String SCHEMA = configuration.getOption("schema").getValue();
+ String USERNAME = configuration.getOption("username").getValue();
+ String PASSWORD = configuration.getOption("password").getValue();

- String DB_URI = ConfigurationManager.getInstance().
-
getConfiguration().getAuxiliaryComponent(MetadataStorageDAOFactory.METADATA_STORAGE_DAO_NAME).getOption("uri").getValue();
- String SCHEMA = ConfigurationManager.getInstance().
-
getConfiguration().getAuxiliaryComponent(MetadataStorageDAOFactory.METADATA_STORAGE_DAO_NAME).getOption("schema").getValue();
- String USERNAME = ConfigurationManager.getInstance().
-
getConfiguration().getAuxiliaryComponent(MetadataStorageDAOFactory.METADATA_STORAGE_DAO_NAME).getOption("username").getValue();
- String PASSWORD = ConfigurationManager.getInstance().
-
getConfiguration().getAuxiliaryComponent(MetadataStorageDAOFactory.METADATA_STORAGE_DAO_NAME).getOption("password").getValue();
-
- if(!DB_URI.endsWith("/"))
+ if (!DB_URI.endsWith("/")) {
DB_URI = DB_URI + "/";
-
- try{
- final HibernateConfiguration config = new
HibernateConfiguration();
- config.setDbUri(new URI(DB_URI+SCHEMA));
- config.setDriver(new Driver());
- config.setDDL("update");
- config.addEntity(Interfaces.class);
- final Persistence p = new Persistence(config,
USERNAME, PASSWORD);
- em = p.newEntityManager();
+ }
+
+ try {
+ Map<String, Object> jpaConfig = new HashMap<String, Object>();
+ jpaConfig.put("javax.persistence.jdbc.driver",
"com.mysql.jdbc.Driver");
+ jpaConfig.put("javax.persistence.jdbc.url", DB_URI + SCHEMA);
+ jpaConfig.put("javax.persistence.jdbc.user", USERNAME);
+ jpaConfig.put("javax.persistence.jdbc.password", PASSWORD);
+ entityManagerFactory =
+
Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, jpaConfig);
+ em = entityManagerFactory.createEntityManager();
+ } catch (RuntimeException e){
+ throw new PerfSONARException("Persistence
initialization failed: " + e.getMessage(), e);
}
- //TODO create correct perfsonarException
- catch(Exception e){
- throw new PerfSONARException("Init Hibernate
connection to connection MySQL failed", e.getMessage());
- }
-
}

@Override

Added:
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/META-INF/persistence.xml
===================================================================
---
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/META-INF/persistence.xml
(rev 0)
+++
trunk/perfsonar-java-rrd-ma-SQL_backend/src/main/resources/META-INF/persistence.xml
2012-08-22 11:10:07 UTC (rev 5974)
@@ -0,0 +1,25 @@
+<persistence xmlns="http://java.sun.com/xml/ns/persistence";
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd";
+ version="2.0">
+ <persistence-unit
name="org.perfsonar.service.measurementArchive.rrdType.storage.sql">
+ <description>
+ Persistence unit for meta data store of RRD MA
+ </description>
+
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
<class>org.perfsonar.service.measurementArchive.rrdType.storage.persistence.entity.Interfaces</class>
+
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="update"/>
+ <property name="hibernate.c3p0.min_size" value="1"/>
+ <property name="hibernate.c3p0.max_size" value="30"/>
+ <property name="hibernate.c3p0.timeout" value="5000"/>
+ <property name="hibernate.c3p0.acquireRetryAttempts" value="1"/>
+ <property name="hibernate.c3p0.acquireRetryDelay" value="0"/>
+ <property name="hibernate.c3p0.breakAfterAcquireFailure"
value="true"/>
+ <property name="hibernate.c3p0.testConnectionOnCheckout"
value="true"/>
+ <property name="javax.persistence.transaction"
value="RESOURCE_LOCAL"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file



  • [pS-dev] [GEANT/SA2/ps-java-services] r5974 - in trunk/perfsonar-java-rrd-ma-SQL_backend: . src/main src/main/java/org/perfsonar/service/measurementArchive/rrdType/storage/sql src/main/resources src/main/resources/META-INF, svn-noreply, 08/22/2012

Archive powered by MHonArc 2.6.16.

Top of Page