You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by pa...@apache.org on 2017/02/26 13:09:46 UTC

[1/3] polygene-java git commit: jclouds-es: add convenience ‘endpoint’ configuration property

Repository: polygene-java
Updated Branches:
  refs/heads/develop 120a15ced -> 9bae5065e


jclouds-es: add convenience \u2018endpoint\u2019 configuration property

It was already possible to set it using the \u2018properties\u2019 configuration
property, added for convenience.


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/5a2782c8
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/5a2782c8
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/5a2782c8

Branch: refs/heads/develop
Commit: 5a2782c8194801e4f2bf56fcd50a5ecb4f5553ae
Parents: 120a15c
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Feb 26 12:32:28 2017 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Feb 26 12:32:28 2017 +0100

----------------------------------------------------------------------
 .../JCloudsMapEntityStoreConfiguration.java     |  4 +++
 .../jclouds/JCloudsMapEntityStoreMixin.java     | 33 +++++++++++++-------
 2 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5a2782c8/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
index 452994c..3123555 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreConfiguration.java
@@ -47,6 +47,10 @@ public interface JCloudsMapEntityStoreConfiguration
      * Name of the JClouds container to use. Defaults to 'polygene-entities'.
      */
     @Optional Property<String> container();
+    /**
+     * Endpoint for the BlobStore provider.
+     */
+    @Optional Property<String> endpoint();
     // END SNIPPET: config
 
 }

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/5a2782c8/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
index 21a2abb..38cdd80 100644
--- a/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
+++ b/extensions/entitystore-jclouds/src/main/java/org/apache/polygene/entitystore/jclouds/JCloudsMapEntityStoreMixin.java
@@ -104,6 +104,7 @@ public class JCloudsMapEntityStoreMixin
         String provider = configuration.get().provider().get();
         String identifier = configuration.get().identifier().get();
         String credentials = configuration.get().credential().get();
+        String endpoint = configuration.get().endpoint().get();
         Map<String, String> properties = configuration.get().properties().get();
         container = configuration.get().container().get();
         if( provider != null )
@@ -118,10 +119,11 @@ public class JCloudsMapEntityStoreMixin
         {
             container = "polygene-entities";
         }
-        storeContext = ContextBuilder.newBuilder( provider ).
-            credentials( identifier, credentials ).
-            overrides( asProperties( properties ) ).
-            buildView( BlobStoreContext.class );
+        storeContext = ContextBuilder.newBuilder( provider )
+                                     .endpoint( endpoint == null ? "" : endpoint )
+                                     .credentials( identifier, credentials )
+                                     .overrides( asProperties( properties ) )
+                                     .buildView( BlobStoreContext.class );
         BlobStore blobStore = storeContext.getBlobStore();
         if( !blobStore.containerExists( container ) )
         {
@@ -200,12 +202,14 @@ public class JCloudsMapEntityStoreMixin
                     {
                         @Override
                         public void close()
-                        throws IOException
+                            throws IOException
                         {
                             super.close();
+                            ByteSource payload = ByteSource.wrap( toString().getBytes( UTF_8 ) );
                             Blob blob = blobStore.blobBuilder( ref.identity().toString() )
-                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
-                                .build();
+                                                 .payload( payload )
+                                                 .contentLength( payload.size() )
+                                                 .build();
                             blobStore.putBlob( container, blob );
                         }
                     };
@@ -223,12 +227,14 @@ public class JCloudsMapEntityStoreMixin
                     {
                         @Override
                         public void close()
-                        throws IOException
+                            throws IOException
                         {
                             super.close();
+                            ByteSource payload = ByteSource.wrap( toString().getBytes( UTF_8 ) );
                             Blob blob = blobStore.blobBuilder( ref.identity().toString() )
-                                .payload( ByteSource.wrap( toString().getBytes( UTF_8 ) ) )
-                                .build();
+                                                 .payload( payload )
+                                                 .contentLength( payload.size() )
+                                                 .build();
                             blobStore.putBlob( container, blob );
                         }
                     };
@@ -255,10 +261,13 @@ public class JCloudsMapEntityStoreMixin
             .getBlobStore().list( container ).stream()
             .map( metadata ->
                   {
-                      Payload payload = storeContext.getBlobStore().getBlob( container, metadata.getName() ).getPayload();
+                      Payload payload = storeContext.getBlobStore()
+                                                    .getBlob( container, metadata.getName() )
+                                                    .getPayload();
                       if( payload == null )
                       {
-                          throw new EntityNotFoundException( EntityReference.parseEntityReference( metadata.getName() ) );
+                          EntityReference reference = EntityReference.parseEntityReference( metadata.getName() );
+                          throw new EntityNotFoundException( reference );
                       }
                       try( InputStream input = payload.openStream() )
                       {


[2/3] polygene-java git commit: jclouds-es: integration test with S3 provider

Posted by pa...@apache.org.
jclouds-es: integration test with S3 provider

Using docker and https://s3.scality.com/


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/f54ad6d8
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/f54ad6d8
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/f54ad6d8

Branch: refs/heads/develop
Commit: f54ad6d8e1323f0d148123a1a33309ffc2c8e5d3
Parents: 5a2782c
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Feb 26 12:33:54 2017 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Feb 26 13:08:54 2017 +0100

----------------------------------------------------------------------
 dependencies.gradle                             | 19 ++++---
 extensions/entitystore-jclouds/build.gradle     |  2 +-
 .../entitystore/jclouds/JCloudsS3Test.java      | 53 ++++++++++++++++++++
 .../src/main/docker/s3server/Dockerfile         | 20 ++++++++
 4 files changed, 86 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f54ad6d8/dependencies.gradle
----------------------------------------------------------------------
diff --git a/dependencies.gradle b/dependencies.gradle
index 932bf85..adb7bb6 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -78,8 +78,7 @@ def velocityVersion = '1.7'
 dependencies.libraries << [
   bonecp              : "com.jolbox:bonecp:$bonecpVersion",
   bouncy_castle       : "org.bouncycastle:bcprov-jdk15on:$bouncyVersion",
-  cassandra_client    : [ "com.datastax.cassandra:cassandra-driver-core:$cassandraClientVersion",
-          ],
+  cassandra_client    : "com.datastax.cassandra:cassandra-driver-core:$cassandraClientVersion",
   codahale_metrics    : [ "io.dropwizard.metrics:metrics-core:$codahaleMetricsVersion",
                           "io.dropwizard.metrics:metrics-healthchecks:$codahaleMetricsVersion" ],
   commons_dbcp        : "org.apache.commons:commons-dbcp2:$commonsDbcpVersion",
@@ -177,6 +176,7 @@ def easyMockVersion = '3.4'
 def embedMongoVersion = '1.50.5'
 def h2Version = '1.4.193'
 def hamcrestVersion = '1.3'
+def jaxRsApiVersion = '2.0.1'
 def junitVersion = '4.12'
 def logbackVersion = '1.1.7'
 def mockitoVersion = '2.2.9'
@@ -229,6 +229,11 @@ dependencies.dependencySubstitutionSpec = { DependencySubstitution substitution,
   {
     substitution.useTarget group: dep.group, name: dep.module, version: jacksonVersion
   }
+  // Always resolve JAX-RS API to the same version
+  else if( [ 'jaxrs-api', 'jsr311-api', 'javax.ws.rs-api' ].contains( dep.module ) )
+  {
+    substitution.useTarget group: 'javax.ws.rs', name: 'javax.ws.rs-api', version: jaxRsApiVersion
+  }
   // woodstox:wstx-asl is broken (no pom), use org.codehaus.woodstox:wstx-asl instead
   else if( dep.group == 'woodstox' && dep.module == 'wstx-asl' )
   {
@@ -255,10 +260,10 @@ dependencies.buildToolsVersions << [
 // Docker Images
 dependencies.dockerImagesVersions << [
   cassandra: 'cassandra:3.10',
-  fakeS3: 'lphoward/fake-s3:14.04',
   memcached: 'memcached:1.4-alpine',
-  mariadb: 'mariadb:10.1',
-  postgres: 'postgres:9.6-alpine',
-  redis: 'redis:3.2-alpine',
-  riak: 'basho/riak-kv:ubuntu-2.2.0'
+  mariadb  : 'mariadb:10.1',
+  postgres : 'postgres:9.6-alpine',
+  redis    : 'redis:3.2-alpine',
+  riak     : 'basho/riak-kv:ubuntu-2.2.0',
+  s3server : 'scality/s3server:mem-e2a2574'
 ]

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f54ad6d8/extensions/entitystore-jclouds/build.gradle
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/build.gradle b/extensions/entitystore-jclouds/build.gradle
index f0ccb8e..01a732e 100644
--- a/extensions/entitystore-jclouds/build.gradle
+++ b/extensions/entitystore-jclouds/build.gradle
@@ -36,7 +36,7 @@ dependencies {
   runtimeOnly polygene.core.runtime
   runtimeOnly libraries.jaxb_api
 
-  testImplementation polygene.core.testsupport
+  testImplementation polygene.internals.testsupport
   testImplementation polygene.extension( 'valueserialization-orgjson' )
   testImplementation libraries.jclouds_filesystem
 

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f54ad6d8/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
----------------------------------------------------------------------
diff --git a/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
new file mode 100644
index 0000000..f375b02
--- /dev/null
+++ b/extensions/entitystore-jclouds/src/test/java/org/apache/polygene/entitystore/jclouds/JCloudsS3Test.java
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ *
+ */
+package org.apache.polygene.entitystore.jclouds;
+
+import org.apache.polygene.api.common.Visibility;
+import org.apache.polygene.bootstrap.ModuleAssembly;
+import org.apache.polygene.entitystore.jclouds.assembly.JCloudsEntityStoreAssembler;
+import org.apache.polygene.test.EntityTestAssembler;
+import org.apache.polygene.test.entity.AbstractEntityStoreTest;
+import org.apache.polygene.test.internal.DockerRule;
+import org.apache.polygene.valueserialization.orgjson.OrgJsonValueSerializationAssembler;
+import org.junit.ClassRule;
+
+public class JCloudsS3Test extends AbstractEntityStoreTest
+{
+    @ClassRule
+    public static final DockerRule DOCKER = new DockerRule( "s3server", 8000 );
+
+    @Override
+    public void assemble( ModuleAssembly module )
+    {
+        super.assemble( module );
+        ModuleAssembly config = module.layer().module( "config" );
+        new EntityTestAssembler().assemble( config );
+        new OrgJsonValueSerializationAssembler().assemble( module );
+        new JCloudsEntityStoreAssembler().withConfig( config, Visibility.layer ).assemble( module );
+        JCloudsMapEntityStoreConfiguration defaults = config.forMixin( JCloudsMapEntityStoreConfiguration.class )
+                                                            .declareDefaults();
+        String host = DOCKER.getDockerHost();
+        int port = DOCKER.getExposedContainerPort( "8000/tcp" );
+        defaults.provider().set( "s3" );
+        defaults.endpoint().set( "http://" + host + ':' + port );
+        defaults.identifier().set( "dummyIdentifier" );
+        defaults.credential().set( "dummyCredential" );
+    }
+}

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f54ad6d8/internals/testsupport-internal/src/main/docker/s3server/Dockerfile
----------------------------------------------------------------------
diff --git a/internals/testsupport-internal/src/main/docker/s3server/Dockerfile b/internals/testsupport-internal/src/main/docker/s3server/Dockerfile
new file mode 100644
index 0000000..552569f
--- /dev/null
+++ b/internals/testsupport-internal/src/main/docker/s3server/Dockerfile
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM @s3server@
+
+# See https://github.com/scality/S3/blob/master/DOCKER.md
+ENV ACCESS_KEY dummyIdentifier
+ENV SECRET_KEY dummyCredential


[3/3] polygene-java git commit: Javadoc fix

Posted by pa...@apache.org.
Javadoc fix


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/9bae5065
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/9bae5065
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/9bae5065

Branch: refs/heads/develop
Commit: 9bae5065ee8098fbbb3f5da9486f2dd829f53bbc
Parents: f54ad6d
Author: Paul Merlin <pa...@apache.org>
Authored: Sun Feb 26 14:08:58 2017 +0100
Committer: Paul Merlin <pa...@apache.org>
Committed: Sun Feb 26 14:08:58 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/polygene/api/entity/Lifecycle.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/9bae5065/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java b/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
index 187ef37..f5d84f2 100644
--- a/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
+++ b/core/api/src/main/java/org/apache/polygene/api/entity/Lifecycle.java
@@ -48,12 +48,12 @@ package org.apache.polygene.api.entity;
  *          String thisId = meAsIdentity.reference().get();
  *          EntityBuilder builder = uow.newEntityBuilder( thisId + ":1", UserComposite.class );
  *          User admin = builder.newInstance();
- *          admin.set( admin );
+ *          admin().set( admin );
  *      }
  *
  *      public void remove()
  *      {
- *          uow.remove( admin.get() );
+ *          uow.remove( admin().get() );
  *      }
  * }
  *