Search in sources :

Example 1 with BlobMap

use of org.jclouds.blobstore.BlobMap in project archaius by Netflix.

the class BlobStoreConfigurationSource method poll.

@Override
public PollResult poll(boolean initial, Object checkPoint) throws Exception {
    String container = containerName.get();
    BlobMap blobs = ctx.createBlobMap(container);
    Map<String, Object> props = ImmutableMap.copyOf(filterValues(transformEntries(blobs, toStringOrNull), notNull()));
    log.info("{}: {} properties in container {}", new Object[] { ctx.unwrap().getName(), props.size(), container });
    return PollResult.createFull(props);
}
Also used : BlobMap(org.jclouds.blobstore.BlobMap)

Example 2 with BlobMap

use of org.jclouds.blobstore.BlobMap in project qi4j-sdk by Qi4j.

the class JCloudsMapEntityStoreMixin method applyChanges.

@Override
public void applyChanges(MapChanges changes) throws IOException {
    final BlobMap blobMap = storeContext.createBlobMap(container);
    changes.visitMap(new MapChanger() {

        @Override
        public Writer newEntity(final EntityReference ref, EntityDescriptor entityDescriptor) throws IOException {
            return new StringWriter() {

                @Override
                public void close() throws IOException {
                    super.close();
                    Blob blob = blobMap.blobBuilder().payload(toString()).build();
                    blobMap.put(ref.identity(), blob);
                }
            };
        }

        @Override
        public Writer updateEntity(final EntityReference ref, EntityDescriptor entityDescriptor) throws IOException {
            if (!blobMap.containsKey(ref.identity())) {
                throw new EntityNotFoundException(ref);
            }
            return new StringWriter() {

                @Override
                public void close() throws IOException {
                    super.close();
                    Blob blob = blobMap.blobBuilder().payload(toString()).build();
                    blobMap.put(ref.identity(), blob);
                }
            };
        }

        @Override
        public void removeEntity(EntityReference ref, EntityDescriptor entityDescriptor) throws EntityNotFoundException {
            if (!blobMap.containsKey(ref.identity())) {
                throw new EntityNotFoundException(ref);
            }
            blobMap.remove(ref.identity());
        }
    });
}
Also used : EntityDescriptor(org.qi4j.api.entity.EntityDescriptor) Blob(org.jclouds.blobstore.domain.Blob) StringWriter(java.io.StringWriter) EntityReference(org.qi4j.api.entity.EntityReference) IOException(java.io.IOException) EntityNotFoundException(org.qi4j.spi.entitystore.EntityNotFoundException) StringWriter(java.io.StringWriter) Writer(java.io.Writer) BlobMap(org.jclouds.blobstore.BlobMap)

Aggregations

BlobMap (org.jclouds.blobstore.BlobMap)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Blob (org.jclouds.blobstore.domain.Blob)1 EntityDescriptor (org.qi4j.api.entity.EntityDescriptor)1 EntityReference (org.qi4j.api.entity.EntityReference)1 EntityNotFoundException (org.qi4j.spi.entitystore.EntityNotFoundException)1