Package com.fasterxml.storemate.store.file

Examples of com.fasterxml.storemate.store.file.FileReference


            storable = _storableConverter.encodeInlined(key0, creationTime,
                    stdMetadata, customMetadata, data);
        } else {
            // otherwise, need to create file and all that fun...
            final long fileCreationTime = _timeMaster.currentTimeMillis();
            FileReference fileRef = _fileManager.createStorageFile(key0,
                    stdMetadata.compression, fileCreationTime);
            try {
                final long nanoStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
                _throttler.performFileWrite(source, fileCreationTime, key0, fileRef.getFile(),
                        new FileOperationCallback<Void>() {
                    @Override
                    public Void perform(long operationTime, StorableKey key, Storable value, File externalFile)
                            throws IOException, StoreException {
                        final long fsStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
                        IOUtil.writeFile(externalFile, data);
                        if (diag != null) {
                            diag.addFileWriteAccess(nanoStart,  fsStart,  _timeMaster, data.byteLength());
                        }
                        return null;
                    }
                });
            } catch (IOException e) {
                // better remove the file, if one exists...
                fileRef.getFile().delete();
                throw new StoreException.IO(key0,
                        "Failed to write storage file of "+data.byteLength()+" bytes: "+e.getMessage(), e);
            }
            // but modtime better be taken only now, as above may have taken some time (I/O bound)
            creationTime = _timeMaster.currentTimeMillis();
View Full Code Here


         * bucket, start cranking...
         */
       
        // So: start by creating the result file
        long fileCreationTime = _timeMaster.currentTimeMillis();
        final FileReference fileRef = _fileManager.createStorageFile(key0, stdMetadata.compression, fileCreationTime);
        File storedFile = fileRef.getFile();

        final OutputStream out;
        final CountingOutputStream compressedOut;

        if (skipCompression) {
            compressedOut = null;
            out = new FileOutputStream(storedFile);
        } else {
            compressedOut = new CountingOutputStream(new FileOutputStream(storedFile),
                    new IncrementalMurmur3Hasher());
            out = Compressors.compressingStream(compressedOut, stdMetadata.compression);
        }
        final IncrementalMurmur3Hasher hasher = new IncrementalMurmur3Hasher(HASH_SEED);       

        // Need to mix-n-match read, write; trickier to account for each part.
        final long nanoStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
        long copiedBytes = _throttler.performFileWrite(source,
                fileCreationTime, key0, fileRef.getFile(),
                new FileOperationCallback<Long>() {
            @Override
            public Long perform(long operationTime, StorableKey key, Storable value, File externalFile)
                    throws IOException, StoreException {
                final long fsStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
View Full Code Here

            OverwriteChecker allowOverwrites,
            final byte[] readBuffer, final boolean skipCompression, final StreamyBytesMemBuffer offHeap)
        throws IOException, StoreException
    {
        long fileCreationTime = _timeMaster.currentTimeMillis();
        final FileReference fileRef = _fileManager.createStorageFile(key0, stdMetadata.compression, fileCreationTime);
        File storedFile = fileRef.getFile();

        final OutputStream out;
        final CountingOutputStream compressedOut;
       
        if (skipCompression) {
            compressedOut = null;
            out = new FileOutputStream(storedFile);
        } else {
            compressedOut = new CountingOutputStream(new FileOutputStream(storedFile),
                    new IncrementalMurmur3Hasher());
            out = Compressors.compressingStream(compressedOut, stdMetadata.compression);
        }
        final IncrementalMurmur3Hasher hasher = new IncrementalMurmur3Hasher(HASH_SEED);       

        final long nanoStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
        long copiedBytes = _throttler.performFileWrite(source,
                fileCreationTime, key0, fileRef.getFile(),
                new FileOperationCallback<Long>() {
            @Override
            public Long perform(long operationTime, StorableKey key, Storable value, File externalFile)
                    throws IOException, StoreException {
                final long fsStart = (diag == null) ? 0L : _timeMaster.nanosForDiagnostics();
View Full Code Here

        if (!result.succeeded()) {
            // One piece of clean up: for failed insert, delete backing file, if any
//            if (!allowOverwrite) {
            // otherwise, may need to delete file that was created
            FileReference ref = stdMetadata.dataFile;
            if (ref != null) {
                _deleteBackingFile(key0, ref.getFile());
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.storemate.store.file.FileReference

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.