You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Roman Coedo <no...@github.com> on 2015/07/27 09:08:38 UTC

[jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Simple jpa provider with a preconfigured embedded database.
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/193

-- Commit Summary --

  * JCLOUDS-826: Add H2 provider

-- File Changes --

    A h2-jdbc/pom.xml (158)
    A h2-jdbc/src/main/java/org/jclouds/h2/jdbc/H2JdbcApiMetadata.java (60)
    A h2-jdbc/src/main/java/org/jclouds/h2/jdbc/H2JdbcProviderMetadata.java (63)
    A h2-jdbc/src/main/java/org/jclouds/h2/jdbc/config/H2JdbcBlobStoreContextModule.java (38)
    A h2-jdbc/src/main/resources/META-INF/persistence.xml (43)
    A h2-jdbc/src/test/java/org/jclouds/h2/jdbc/H2JdbcProviderTest.java (29)
    A h2-jdbc/src/test/java/org/jclouds/h2/jdbc/blobstore/H2JdbcBlobIntegrationTest.java (34)
    A h2-jdbc/src/test/java/org/jclouds/h2/jdbc/blobstore/H2JdbcContainerIntegrationTest.java (34)
    A h2-jdbc/src/test/resources/log4j.properties (25)

-- Patch Links --

https://github.com/jclouds/jclouds-labs/pull/193.patch
https://github.com/jclouds/jclouds-labs/pull/193.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
> +
> +import java.util.Properties;
> +
> +import org.jclouds.jdbc.config.JdbcBlobStoreContextModule;
> +
> +import com.google.inject.persist.jpa.JpaPersistModule;
> +
> +public class H2JdbcBlobStoreContextModule extends JdbcBlobStoreContextModule {
> +
> +   private static final String DEFAULT_FILE = "./jclouds-db";
> +
> +   protected void configure() {
> +      super.configure();
> +
> +      Properties properties = new Properties();
> +      properties.setProperty("hibernate.connection.url", "jdbc:h2:" + DEFAULT_FILE);

If I move it to the metadata, how can I inject it to the module? I tried so many things to make this work but I just couldn't find a way to do it! :(

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35515364

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Zack Shoylev <no...@github.com>.
Closed #193.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#event-375752633

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> + * limitations under the License.
> + */
> +package org.jclouds.h2.jdbc;
> +
> +import com.google.auto.service.AutoService;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.inject.Module;
> +import org.jclouds.apis.ApiMetadata;
> +import org.jclouds.blobstore.BlobStoreContext;
> +import org.jclouds.h2.jdbc.config.H2JdbcBlobStoreContextModule;
> +import org.jclouds.jdbc.JdbcApiMetadata;
> +
> +/**
> + * Implementation of {@link H2JdbcApiMetadata} for the H2 database
> + */
> +@AutoService(ApiMetadata.class)

In fact, this class should be removed and let the provider metadata use the `JdbcApiMetadata` directly. That's how generic apis and providers are supposed to be used. (A provider is an API + defaults + location).

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35514882

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> + * limitations under the License.
> + */
> +package org.jclouds.h2.jdbc;
> +
> +import com.google.auto.service.AutoService;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.inject.Module;
> +import org.jclouds.apis.ApiMetadata;
> +import org.jclouds.blobstore.BlobStoreContext;
> +import org.jclouds.h2.jdbc.config.H2JdbcBlobStoreContextModule;
> +import org.jclouds.jdbc.JdbcApiMetadata;
> +
> +/**
> + * Implementation of {@link H2JdbcApiMetadata} for the H2 database
> + */
> +@AutoService(ApiMetadata.class)

Remove this annotation. The provider metadata has the same ID than the API metadata and we want the ServiceLoader to pick just one of them.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35514660

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> +
> +import java.util.Properties;
> +
> +import org.jclouds.jdbc.config.JdbcBlobStoreContextModule;
> +
> +import com.google.inject.persist.jpa.JpaPersistModule;
> +
> +public class H2JdbcBlobStoreContextModule extends JdbcBlobStoreContextModule {
> +
> +   private static final String DEFAULT_FILE = "./jclouds-db";
> +
> +   protected void configure() {
> +      super.configure();
> +
> +      Properties properties = new Properties();
> +      properties.setProperty("hibernate.connection.url", "jdbc:h2:" + DEFAULT_FILE);

Move this properties to the provider metadata `defaultProperties` method.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35514907

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> +-->
> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
> +  <modelVersion>4.0.0</modelVersion>
> +  <parent>
> +    <groupId>org.apache.jclouds.labs</groupId>
> +    <artifactId>jclouds-labs</artifactId>
> +    <version>2.0.0-SNAPSHOT</version>
> +  </parent>
> +  <artifactId>h2-jdbc</artifactId>
> +  <name>jclouds h2 jdbc provider</name>
> +  <description>jclouds implementation to target h2 databases</description>
> +  <packaging>bundle</packaging>
> +
> +  <properties>
> +    <maven.compile.source>1.6</maven.compile.source>
> +    <maven.compile.target>1.6</maven.compile.target>

Is this really needed? Remove it if possible to inherit the global config.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35514516

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
LGTM now. Mind squashing the commits? Also, do you have an output of the live tests you could share in a gist or pastie? Thanks @rcoedo!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127933346

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
Seems like it's passing now!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-128504117

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> +
> +import java.util.Properties;
> +
> +import org.jclouds.jdbc.config.JdbcBlobStoreContextModule;
> +
> +import com.google.inject.persist.jpa.JpaPersistModule;
> +
> +public class H2JdbcBlobStoreContextModule extends JdbcBlobStoreContextModule {
> +
> +   private static final String DEFAULT_FILE = "./jclouds-db";
> +
> +   protected void configure() {
> +      super.configure();
> +
> +      Properties properties = new Properties();
> +      properties.setProperty("hibernate.connection.url", "jdbc:h2:" + DEFAULT_FILE);

IT would be good to have the file configurable via context properties in some way, if possible.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35515164

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Zack Shoylev <no...@github.com>.
merged

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-128507662

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Zack Shoylev <no...@github.com>.
You might have to rebuild the other projects, as it might be using your local snapshot first.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127979623

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> +        <configuration>
> +          <signature>
> +            <groupId>org.codehaus.mojo.signature</groupId>
> +            <artifactId>java16</artifactId>
> +            <version>1.0</version>
> +          </signature>
> +        </configuration>
> +      </plugin>
> +      <plugin>
> +        <groupId>org.basepom.maven</groupId>
> +        <artifactId>duplicate-finder-maven-plugin</artifactId>
> +        <configuration>
> +          <checkTestClasspath>false</checkTestClasspath>
> +        </configuration>
> +      </plugin>
> +    </plugins>

Same for these plugins. Is this configuration really needed? Is there something to fix in the parent pom instead?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35514610

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
Sure, you just have to summon jenkins by saying: rebuild please! :)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127886274

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Ignasi Barrera <no...@github.com>.
> +
> +import java.util.Properties;
> +
> +import org.jclouds.jdbc.config.JdbcBlobStoreContextModule;
> +
> +import com.google.inject.persist.jpa.JpaPersistModule;
> +
> +public class H2JdbcBlobStoreContextModule extends JdbcBlobStoreContextModule {
> +
> +   private static final String DEFAULT_FILE = "./jclouds-db";
> +
> +   protected void configure() {
> +      super.configure();
> +
> +      Properties properties = new Properties();
> +      properties.setProperty("hibernate.connection.url", "jdbc:h2:" + DEFAULT_FILE);

Agree. Thinking about it I reworded the comment (and it seems that was *during* your reply). I don't know if it is possible at the Guice config time, so it is not a strong requirement.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193/files#r35515533

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
I may be using an old snapshot or maybe a new bug was introduced, but one test in the jdbc api is still failing (BaseBlobIntegrationTest.testGetTwoRanges). http://pastebin.com/JR8DcJZQ

I'll take a look.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127953800

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
Can we rebuild? It should be good now.

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127885031

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
I knew there were some magic words but I couldn't remember them!

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-127895576

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
About the failed tests, it's a problem with the jdbc api. Here is a link to the JIRA issue https://issues.apache.org/jira/browse/JCLOUDS-979

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-126926804

Re: [jclouds-labs] JCLOUDS-826: Add H2 provider (#193)

Posted by Roman Coedo <no...@github.com>.
Rebuild please

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/193#issuecomment-128503530