Package io.fathom.cloud.blobs

Examples of io.fathom.cloud.blobs.BlobData


        md5.update(src);

        ByteString hashResume = md5.getState();
        ByteString hash = ByteString.copyFrom(md5.digest());

        BlobData blob = new BlobData(src, hash);
        return new FileBlob(hash, hashResume, dataLength, blob);
    }
View Full Code Here


            if (checked.contains(node)) {
                continue;
            }

            try {
                BlobData is = node.getBlobStore(blobStoreKey).find(key);
                if (is != null) {
                    log.debug("Found blob {} on node {}", Hex.toHex(key.toByteArray()), node.getKey());
                    return is;
                }
            } catch (IOException e) {
View Full Code Here

        if (yes.size() >= cluster.dataReplicaCount) {
            return;
        }

        BlobData data = null;
        try {
            for (StorageNode node : yes) {
                try {
                    data = node.getBlobStore(blobStoreKey).find(key);
                    break;
                } catch (IOException e) {
                    log.warn("Error communicating with node " + node, e);
                }
            }

            if (data == null) {
                data = global.find(key);
            }

            if (data == null) {
                log.error("Unable to find blob: {}", forDebug(key));
                return;
            }

            // TODO: This won't scale to big data sizes..
            log.info("Writing replica on {}: {}", local, forDebug(key));
            local.put(data);
        } finally {
            if (data != null) {
                data.close();
            }
        }
    }
View Full Code Here

            ImageKey imageKey = image.getUniqueKey();

            if (!host.hasImage(imageKey)) {
                // TODO: Support side-load

                BlobData imageData = imageService.getImageBlob(image);

                host.uploadImage(imageKey, imageData);
            }
        }
View Full Code Here

        try (HashingOutputStream hos = new HashingOutputStream(ByteStreams.nullOutputStream(), md5)) {
            List<FileRange> ranges = file.getRangesList();
            for (int i = 0; i < ranges.size(); i++) {
                FileRange range = ranges.get(i);

                BlobData blob = blobStore.find(range.getContentKey());
                if (blob == null) {
                    throw new IllegalStateException("Unable to find blob for range: " + range);
                }

                log.debug("Sanity check: fetch blob {}", Hex.toHex(range.getContentKey().toByteArray()));
                if (blob.size() != (range.getEnd() - range.getStart())) {
                    throw new IllegalStateException();
                }

                blob.copyTo(hos);

                if (i != 0) {
                    FileRange prev = ranges.get(i - 1);

                    if (prev.getEnd() != range.getStart()) {
View Full Code Here

                    }
                    if (i == (bestEnd - 1)) {
                        c.setEnd(range.getEnd());
                    }

                    final BlobData blob = blobStore.find(range.getContentKey());
                    if (blob == null) {
                        throw new IOException("Unable to open storage for range: " + range);
                    }

                    blob.copyTo(fos);
                }
            }

            if (!c.hasStart() || !c.hasEnd()) {
                throw new IllegalStateException();
            }

            ByteString hash = ByteString.copyFrom(md5.hash().asBytes());
            BlobData blobData = new BlobData(tempFile.getFile(), hash);
            blobStore.put(blobData);

            if (PARANOID) {
                BlobData blob = blobStore.find(blobData.getHash());
                if (blob == null) {
                    throw new IllegalStateException();
                }
                ByteString checkHash = ByteString.copyFrom(blob.hash(Hashing.md5()).asBytes());
                if (!blobData.getHash().equals(checkHash)) {
                    log.warn("Hash mismatch: {} vs {}", blobData.getHash(), checkHash);
                    throw new IllegalStateException();
                }
            }
View Full Code Here

        metadata.put(ImageService.METADATA_KEY_DISK_FORMAT, "raw");

        UUID containerId = UUID.fromString(hostCookie);
        try (TempFile snapshot = host.createImage(containerId)) {
            ImageService.Image image = imageService.createImage(instance.getProjectId(), metadata);
            BlobData blobData = BlobData.build(snapshot.getFile());
            image = imageService.uploadData(image, blobData);
            return image;
        }
    }
View Full Code Here

    public BlobData findImageData(Project project, ImageData image) throws IOException {
        ImageLocation imageLocation = image.getLocation();
        if (imageLocation.hasStored()) {
            String cookie = imageLocation.getStored();

            BlobData blob = imageDataService.getImageFile(cookie);

            return blob;
        }
        return null;
    }
View Full Code Here

    public BlobData getImageBlob(Image i) throws IOException {
        ImageImpl image = (ImageImpl) i;
        ImageData data = image.getData();

        Project project = new Project(data.getOwnerProject());
        BlobData imageData = findImageData(project, data);
        return imageData;
    }
View Full Code Here

    public BlobData getImageFile(String cookie) throws IOException {
        BlobStore blobStore = getBlobStore();

        ByteString key = ByteString.copyFrom(Hex.fromHex(cookie));

        BlobData blobData = blobStore.find(key);

        return blobData;
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.blobs.BlobData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.