Package com.fasterxml.storemate.shared

Examples of com.fasterxml.storemate.shared.ByteContainer


       
        @Override
        public Body createBody() throws IOException
        {
            int checksum = _checksum.get();
            ByteContainer bytes = _content.contentAsBytes();
            if (bytes != null) {
                if (checksum == 0) {
                    checksum = _keyConverter.contentHashFor(bytes);
                    _checksum.set(checksum);
                }
                return bytes.withBytes(BodyCallback.instance);
            }
            File f = _content.contentAsFile();
            if (f != null) {
                try {
                    return new BodyFileBacked(f, _content.length(), _checksum);
View Full Code Here


        {
            _content = content;
            _keyConverter = keyConverter;
            // Let's see if we can calculate content checksum early, for even the first request
            int checksum = 0;
            ByteContainer bytes = _content.contentAsBytes();
            if (bytes != null) {
                checksum = _keyConverter.contentHashFor(bytes);
            }
            _checksum = new AtomicInteger(checksum);
        }
View Full Code Here

       
        @Override
        public Body createBody() throws IOException
        {
            int checksum = _checksum.get();
            ByteContainer bytes = _content.contentAsBytes();
            if (bytes != null) {
                if (checksum == 0) {
                    checksum = _keyConverter.contentHashFor(bytes);
                    _checksum.set(checksum);
                }
                return bytes.withBytes(BodyCallback.instance);
            }
            File f = _content.contentAsFile();
            if (f != null) {
                try {
                    return new BodyFileBacked(f, _content.length(), _checksum);
View Full Code Here

            } catch (StoreException e) {
                LOG.error("Problem trying to GET entry '"+key+"': "+e.getMessage());
                return response.internalFileNotFound(new GetErrorResponse<K>(key, e.getMessage()));
            }
        } else { // inline
            ByteContainer inlined = entry.getRaw().getInlinedData();
            if (!skipCompression) {
                try {
                    inlined = Compressors.uncompress(inlined, comp, (int) entry.getRaw().getOriginalLength());
                } catch (IOException e) {
                    return internalGetError(response, e, key, "Failed to decompress inline data");
                }
            }
            output = new SimpleStreamingResponseContent(diag, _timeMaster, inlined, range, inlined.byteLength());
        }
        // #21: provide content length header
        long cl = output.getLength();
        if (cl >= 0L) {
            response = response.setContentLength(cl);
View Full Code Here

            stdMetadata.uncompressedSize = uncompLen;
        }

        // assumption here is that we may be passed hash code of orig content, but
        // not that of compressed (latter is easy to calculate on server anyway)
        ByteContainer customMetadata = constructPutMetadata(request, key, creationTime,
            minTTLSinceAccess, maxTTL);
        StorableCreationResult result;

        try {
            /* This gets quite convoluted but that's how it goes: if undelete is
View Full Code Here

        OutputStream out = null;
        HttpURLConnection conn;
        int hash = content.getContentHash();

        try {
            ByteContainer bc = content.contentAsBytes();
            if (bc != null) { // most efficient, yay
                if (hash == HashConstants.NO_CHECKSUM) {
                    hash = _keyConverter.contentHashFor(bc);
                    content.setContentHash(hash);
                }
                path = addChecksum(path, hash);
                URL url = path.asURL();
                conn = (HttpURLConnection) url.openConnection();
                conn.setDoOutput(true);
                conn.setFixedLengthStreamingMode(bc.byteLength());
                conn.setRequestMethod("PUT");
                out = conn.getOutputStream();
                bc.writeBytes(out);
            } else {
                InputStream in; // closed in copy()
                File f = content.contentAsFile();
                // !!! TODO: add wrapper for calculating hash sum, if not yet calculated
                if (f != null) {
View Full Code Here

TOP

Related Classes of com.fasterxml.storemate.shared.ByteContainer

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.