You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Andrew Gaul <no...@github.com> on 2014/07/16 19:26:39 UTC

[jclouds] Use xattr for filesystem blob metadata (#443)

Proof of concept, do not commit.  This relates to some discussion in
JCLOUDS-626.  Relies on JDK 7 features which jclouds 2.0 will require.
You can merge this Pull Request by running:

  git pull https://github.com/andrewgaul/jclouds jdk7-filesystem-xattr

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds/pull/443

-- Commit Summary --

  * Use xattr for filesystem blob metadata

-- File Changes --

    M apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java (23)
    M project/pom.xml (4)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/443.patch
https://github.com/jclouds/jclouds/pull/443.diff

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

Re: [jclouds] JCLOUDS-658: xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
```
...> mvn clean integration-test
Results :

Tests run: 25, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:16 min
[INFO] Finished at: 2014-08-11T16:29:25-05:00
[INFO] Final Memory: 31M/148M
[INFO] ------------------------------------------------------------------------
```
Works for me too. Thanks, @andrewgaul!

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> Can you test this on Windows

Sure! `mvn clean integration-test` or something else?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #1487](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/1487/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds #1380](https://buildhive.cloudbees.com/job/jclouds/job/jclouds/1380/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> @@ -182,9 +197,65 @@ public Blob getBlob(final String container, final String key) {
>        File file = getFileForBlobKey(container, key);
>        ByteSource byteSource = Files.asByteSource(file);
>        try {
> +         String contentDisposition = null;
> +         String contentEncoding = null;
> +         String contentLanguage = null;
> +         String contentType = null;
> +         Date expires = null;
> +         HashCode hashCode = null;
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            file.toPath(), UserDefinedFileAttributeView.class);
> +         Set<String> attributes = ImmutableSet.copyOf(view.list());

Needed for O(1) lookup.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> +         if (attributes.contains(XATTR_CONTENT_TYPE)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_TYPE));
> +            view.read(XATTR_CONTENT_TYPE, buf);
> +            contentType = new String(buf.array(), Charsets.UTF_8);
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());
> +         }
> +         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();
> +         for (String attribute : attributes) {
> +            if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
> +               continue;
> +            }

As a matter of personal taste I don't think the pre-Java 8 functional stuff is worth the effort.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-6-pull-requests #2](https://jclouds.ci.cloudbees.com/job/jclouds-java-6-pull-requests/2/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] JCLOUDS-658: xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
Pushed to master as 204a6c7f3b3ff8689ad9df9b1084801b89dd901d.

@zack-shoylev Thanks for testing!

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> @@ -182,9 +197,65 @@ public Blob getBlob(final String container, final String key) {
>        File file = getFileForBlobKey(container, key);
>        ByteSource byteSource = Files.asByteSource(file);
>        try {
> +         String contentDisposition = null;
> +         String contentEncoding = null;
> +         String contentLanguage = null;
> +         String contentType = null;
> +         Date expires = null;
> +         HashCode hashCode = null;
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            file.toPath(), UserDefinedFileAttributeView.class);
> +         Set<String> attributes = ImmutableSet.copyOf(view.list());
> +         if (attributes.contains(XATTR_CONTENT_DISPOSITION)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_DISPOSITION));
> +            view.read(XATTR_CONTENT_DISPOSITION, buf);
> +            contentDisposition = new String(buf.array(), Charsets.UTF_8);

[minor] Extract these duplicated three lines into a method `readAttr` or so?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #1488](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/1488/) UNSTABLE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
@demobox @zack-shoylev Can you test this on Windows since this relies on xattr from the underlying filesystem?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> @@ -182,9 +197,65 @@ public Blob getBlob(final String container, final String key) {
>        File file = getFileForBlobKey(container, key);
>        ByteSource byteSource = Files.asByteSource(file);
>        try {
> +         String contentDisposition = null;
> +         String contentEncoding = null;
> +         String contentLanguage = null;
> +         String contentType = null;
> +         Date expires = null;
> +         HashCode hashCode = null;
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            file.toPath(), UserDefinedFileAttributeView.class);
> +         Set<String> attributes = ImmutableSet.copyOf(view.list());

[minor] Any reason for converting the result into an immutable set? Are there duplicates in the list we want to squash down, or..?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds #1486](https://buildhive.cloudbees.com/job/jclouds/job/jclouds/1486/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-7-pull-requests #1471](https://jclouds.ci.cloudbees.com/job/jclouds-java-7-pull-requests/1471/) SUCCESS
This pull request looks good

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> @@ -182,9 +197,65 @@ public Blob getBlob(final String container, final String key) {
>        File file = getFileForBlobKey(container, key);
>        ByteSource byteSource = Files.asByteSource(file);
>        try {
> +         String contentDisposition = null;
> +         String contentEncoding = null;
> +         String contentLanguage = null;
> +         String contentType = null;
> +         Date expires = null;
> +         HashCode hashCode = null;
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            file.toPath(), UserDefinedFileAttributeView.class);
> +         Set<String> attributes = ImmutableSet.copyOf(view.list());
> +         if (attributes.contains(XATTR_CONTENT_DISPOSITION)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_DISPOSITION));
> +            view.read(XATTR_CONTENT_DISPOSITION, buf);
> +            contentDisposition = new String(buf.array(), Charsets.UTF_8);

Done for reads and writes.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> +         }
> +         if (attributes.contains(XATTR_CONTENT_MD5)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
> +            view.read(XATTR_CONTENT_MD5, buf);
> +            hashCode = HashCode.fromBytes(buf.array());
> +         }
> +         if (attributes.contains(XATTR_CONTENT_TYPE)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_TYPE));
> +            view.read(XATTR_CONTENT_TYPE, buf);
> +            contentType = new String(buf.array(), Charsets.UTF_8);
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());

`ByteBuffer.flip` actually *resets* the position, needed for calling `get` but not for `array`.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-java-6-pull-requests #1541](https://jclouds.ci.cloudbees.com/job/jclouds-java-6-pull-requests/1541/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds #1403](https://buildhive.cloudbees.com/job/jclouds/job/jclouds/1403/) ABORTED

[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());
> +         }
> +         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();
> +         for (String attribute : attributes) {
> +            if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
> +               continue;
> +            }
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(attribute));
> +            view.read(attribute, buf);
> +            String value = new String(buf.array(), Charsets.UTF_8);
> +            userMetadata.put(attribute.substring(XATTR_USER_METADATA_PREFIX.length()), value);

Hope the JVM can figure this out?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Zack Shoylev <no...@github.com>.
Passes on my windows machine:
mvn clean install
mvn clean integration-test

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> +         if (attributes.contains(XATTR_CONTENT_TYPE)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_TYPE));
> +            view.read(XATTR_CONTENT_TYPE, buf);
> +            contentType = new String(buf.array(), Charsets.UTF_8);
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());
> +         }
> +         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();
> +         for (String attribute : attributes) {
> +            if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
> +               continue;
> +            }

> As a matter of personal taste I don't think the pre-Java 8 functional stuff is worth the effort.

Fine to leave as-is, then.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #1000](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/1000/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> +         }
> +         if (attributes.contains(XATTR_CONTENT_MD5)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_MD5));
> +            view.read(XATTR_CONTENT_MD5, buf);
> +            hashCode = HashCode.fromBytes(buf.array());
> +         }
> +         if (attributes.contains(XATTR_CONTENT_TYPE)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_TYPE));
> +            view.read(XATTR_CONTENT_TYPE, buf);
> +            contentType = new String(buf.array(), Charsets.UTF_8);
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());

Wow...fun bit-twiddling stuff we still have to do here, I see! ;-)

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
+1. Just minor comments regarding the code - functionality looks good to me. Thanks, @andrewgaul!

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> jclouds-pull-requests #1069 UNSTABLE

This was caused by a Checkstyle violation unrelated to this PR, the build itself completed successfully:
```
[INFO] all ............................................... SUCCESS [5.077s]
[INFO] Apache jclouds .................................... SUCCESS [9.330s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:04:42.230s
[INFO] Finished at: Sat Aug 09 04:45:18 EDT 2014
[INFO] Final Memory: 98M/353M
[INFO] ------------------------------------------------------------------------
```

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

Re: [jclouds] JCLOUDS-658: xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
Closed #443.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Gaul <no...@github.com>.
> @@ -216,7 +287,35 @@ public String putBlob(final String containerName, final Blob blob) throws IOExce
>                    " expected: " + expectedHashCode);
>           }
>           payload.getContentMetadata().setContentMD5(actualHashCode);
> -         // TODO: store metadata in extended attributes when moving to Java 7
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            outputFile.toPath(), UserDefinedFileAttributeView.class);
> +         view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(actualHashCode.asBytes()));
> +         String contentDisposition = payload.getContentMetadata().getContentDisposition();
> +         if (contentDisposition != null) {
> +            view.write(XATTR_CONTENT_DISPOSITION, ByteBuffer.wrap(contentDisposition.getBytes(Charsets.UTF_8)));
> +         }

Done.

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Zack Shoylev <no...@github.com>.
I should be able to get to this today

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by BuildHive <no...@github.com>.
[jclouds » jclouds #1480](https://buildhive.cloudbees.com/job/jclouds/job/jclouds/1480/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> @@ -216,7 +287,35 @@ public String putBlob(final String containerName, final Blob blob) throws IOExce
>                    " expected: " + expectedHashCode);
>           }
>           payload.getContentMetadata().setContentMD5(actualHashCode);
> -         // TODO: store metadata in extended attributes when moving to Java 7
> +         UserDefinedFileAttributeView view = java.nio.file.Files.getFileAttributeView(
> +            outputFile.toPath(), UserDefinedFileAttributeView.class);
> +         view.write(XATTR_CONTENT_MD5, ByteBuffer.wrap(actualHashCode.asBytes()));
> +         String contentDisposition = payload.getContentMetadata().getContentDisposition();
> +         if (contentDisposition != null) {
> +            view.write(XATTR_CONTENT_DISPOSITION, ByteBuffer.wrap(contentDisposition.getBytes(Charsets.UTF_8)));
> +         }

Again, modulo the slight deviations: worth extracting this as a `writeIfPresent` method or so?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #1015](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/1015/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #1016](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/1016/) FAILURE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());
> +         }
> +         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();
> +         for (String attribute : attributes) {
> +            if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
> +               continue;
> +            }
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(attribute));
> +            view.read(attribute, buf);
> +            String value = new String(buf.array(), Charsets.UTF_8);
> +            userMetadata.put(attribute.substring(XATTR_USER_METADATA_PREFIX.length()), value);

[minor] Extract out `XATTR_USER_METADATA_PREFIX.length()`?

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-pull-requests #1069](https://jclouds.ci.cloudbees.com/job/jclouds-pull-requests/1069/) UNSTABLE
Looks like there's a problem with this pull request

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

Re: [jclouds] Use xattr for filesystem blob metadata (#443)

Posted by Andrew Phillips <no...@github.com>.
> +         if (attributes.contains(XATTR_CONTENT_TYPE)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_CONTENT_TYPE));
> +            view.read(XATTR_CONTENT_TYPE, buf);
> +            contentType = new String(buf.array(), Charsets.UTF_8);
> +         }
> +         if (attributes.contains(XATTR_EXPIRES)) {
> +            ByteBuffer buf = ByteBuffer.allocate(view.size(XATTR_EXPIRES));
> +            view.read(XATTR_EXPIRES, buf);
> +            buf.flip();
> +            expires = new Date(buf.asLongBuffer().get());
> +         }
> +         ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder();
> +         for (String attribute : attributes) {
> +            if (!attribute.startsWith(XATTR_USER_METADATA_PREFIX)) {
> +               continue;
> +            }

[minor] Would it make sense to simply run attributes through a filter before getting into the for loop?

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