Package com.fasterxml.storemate.shared

Examples of com.fasterxml.storemate.shared.ByteContainer


            } 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());
        }
        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 (put with
View Full Code Here

        StorableCreationResult result;
        StorableCreationMetadata stdMetadata = new StorableCreationMetadata(header.compression,
                header.checksum, header.checksumForCompressed);
        stdMetadata.uncompressedSize = header.size;
        stdMetadata.storageSize = header.storageSize;
        ByteContainer customMetadata = _entryConverter.createMetadata(_timeMaster.currentTimeMillis(),
                header.lastAccessMethod, header.minTTLSecs, header.maxTTLSecs);

        // although not 100% required, we can simplify handling of smallest entries
        if (expSize <= _stuff.getServiceConfig().storeConfig.maxInlinedStorageSize) { // inlineable
            ByteContainer data;

            if (expSize == 0) {
                data = ByteContainer.emptyContainer();
            } else {
                byte[] bytes = new byte[(int) expSize];
View Full Code Here

        StorableCreationResult result;
        StorableCreationMetadata stdMetadata = new StorableCreationMetadata(header.compression,
                header.checksum, header.checksumForCompressed);
        stdMetadata.uncompressedSize = header.size;
        stdMetadata.storageSize = header.storageSize;
        ByteContainer customMetadata = _entryConverter.createMetadata(_timeMaster.currentTimeMillis(),
                header.lastAccessMethod, header.minTTLSecs, header.maxTTLSecs);

        // although not 100% required, we can simplify handling of smallest entries
        if (expSize <= _stuff.getServiceConfig().storeConfig.maxInlinedStorageSize) { // inlineable
            ByteContainer data;

            if (expSize == 0) {
                data = ByteContainer.emptyContainer();
            } else {
                byte[] bytes = new byte[(int) expSize];
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 = initRequest("PUT", conn, path, timeoutMsecs);
                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

        StorableCreationResult result;
        StorableCreationMetadata stdMetadata = new StorableCreationMetadata(header.compression,
                header.checksum, header.checksumForCompressed);
        stdMetadata.uncompressedSize = header.size;
        stdMetadata.storageSize = header.storageSize;
        ByteContainer customMetadata = _entryConverter.createMetadata(_timeMaster.currentTimeMillis(),
                header.lastAccessMethod, header.minTTLSecs, header.maxTTLSecs);

        // although not 100% required, we can simplify handling of smallest entries
        if (expSize <= _stuff.getServiceConfig().storeConfig.maxInlinedStorageSize) { // inlineable
            ByteContainer data;

            if (expSize == 0) {
                data = ByteContainer.emptyContainer();
            } else {
                byte[] bytes = new byte[(int) expSize];
View Full Code Here

    public File getExternalFile(FileManager mgr)
    {
        if (_externalPathLength <= 0) {
            return null;
        }
        ByteContainer extRef = _rawEntry.view(_payloadOffset, _externalPathLength);
        String filename = IOUtil.getLatin1String(extRef);
        return mgr.derefenceFile(filename);
    }
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

        {
            _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

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.