sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1751343 - in /sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl: avro/AvroContentSerializer.java kryo/KryoContentSerializer.java
Date Mon, 04 Jul 2016 16:54:27 GMT
Author: tommaso
Date: Mon Jul  4 16:54:27 2016
New Revision: 1751343

URL: http://svn.apache.org/viewvc?rev=1751343&view=rev
Log:
DataFileWriter should not be reused across requests, moving created resource log to debug

Modified:
    sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializer.java
    sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializer.java

Modified: sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializer.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializer.java?rev=1751343&r1=1751342&r2=1751343&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializer.java
(original)
+++ sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/avro/AvroContentSerializer.java
Mon Jul  4 16:54:27 2016
@@ -67,15 +67,12 @@ public class AvroContentSerializer imple
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private final String name;
-    private final DataFileWriter<AvroShallowResource> dataFileWriter;
     private final Schema schema;
     private final Set<String> ignoredProperties;
     private final Set<String> ignoredNodeNames;
     private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.sss+hh:mm");
 
     public AvroContentSerializer(String name) {
-        DatumWriter<AvroShallowResource> datumWriter = new SpecificDatumWriter<AvroShallowResource>(AvroShallowResource.class);
-        this.dataFileWriter = new DataFileWriter<AvroShallowResource>(datumWriter);
         try {
             schema = new Schema.Parser().parse(getClass().getResourceAsStream("/shallowresource.avsc"));
         } catch (IOException e) {
@@ -102,22 +99,21 @@ public class AvroContentSerializer imple
     @Override
     public void exportToStream(ResourceResolver resourceResolver, DistributionRequest request,
OutputStream outputStream) throws DistributionException {
 
-        DataFileWriter<AvroShallowResource> writer;
+        DatumWriter<AvroShallowResource> datumWriter = new SpecificDatumWriter<AvroShallowResource>(AvroShallowResource.class);
+        DataFileWriter<AvroShallowResource> writer = new DataFileWriter<AvroShallowResource>(datumWriter);
         try {
-            writer = dataFileWriter.create(schema, outputStream);
+            writer.create(schema, outputStream);
         } catch (IOException e) {
             throw new DistributionException(e);
         }
 
         try {
-
             for (String path : request.getPaths()) {
                 Resource resource = resourceResolver.getResource(path);
                 AvroShallowResource avroShallowResource = getAvroShallowResource(request.isDeep(path),
path, resource);
                 writer.append(avroShallowResource);
             }
             outputStream.flush();
-
         } catch (Exception e) {
             throw new DistributionException(e);
         } finally {
@@ -127,7 +123,6 @@ public class AvroContentSerializer imple
                 // do nothing
             }
         }
-
     }
 
     @Override
@@ -237,7 +232,7 @@ public class AvroContentSerializer imple
             parent = createParent(resourceResolver, parentPath);
         }
         Resource createdResource = resourceResolver.create(parent, name, map);
-        log.info("created resource {}", createdResource);
+        log.debug("created resource {}", createdResource);
         for (AvroShallowResource child : r.getChildren()) {
             persistResource(createdResource.getResourceResolver(), child);
         }

Modified: sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializer.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializer.java?rev=1751343&r1=1751342&r2=1751343&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializer.java
(original)
+++ sling/trunk/contrib/extensions/distribution/extensions/src/main/java/org/apache/sling/distribution/serialization/impl/kryo/KryoContentSerializer.java
Mon Jul  4 16:54:27 2016
@@ -134,7 +134,7 @@ public class KryoContentSerializer imple
             parent = createParent(resourceResolver, parentPath);
         }
         Resource createdResource = resourceResolver.create(parent, name, resource.getValueMap());
-        log.info("created resource {}", createdResource);
+        log.debug("created resource {}", createdResource);
     }
 
     private Resource createParent(ResourceResolver resourceResolver, String path) throws
PersistenceException {



Mime
View raw message