Package net.sf.ehcache.util

Examples of net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream


        try {
            int bufferLength;
            long expirationTime = element.getExpirationTime();

            try {
                MemoryEfficientByteArrayOutputStream buffer =
                        MemoryEfficientByteArrayOutputStream.serialize(element, estimatedPayloadSize());

                bufferLength = buffer.size();
                DiskElement diskElement = checkForFreeBlock(bufferLength);

                // Write the record
                randomAccessFile.seek(diskElement.position);
                randomAccessFile.write(buffer.toByteArray(), 0, bufferLength);
                buffer = null;

                // Add to index, update stats
                diskElement.payloadSize = bufferLength;
                diskElement.key = key;
View Full Code Here


    }


    private void writeElement(Element element, Serializable key) throws IOException {
        try {
            MemoryEfficientByteArrayOutputStream buffer = serializeElement(element);
            if (buffer == null) {
                return;
            }
           
            int bufferLength = buffer.size();
            try {
                DiskElement diskElement = checkForFreeBlock(bufferLength);

                // Write the record
                synchronized (randomAccessFile) {
                    randomAccessFile.seek(diskElement.position);
                    randomAccessFile.write(buffer.toByteArray(), 0, bufferLength);
                }
                buffer = null;

                // Add to index, update stats
                diskElement.payloadSize = bufferLength;
View Full Code Here

     * @param element to write
     * @return marker representing the element
     * @throws IOException on write error
     */
    protected DiskMarker write(Element element) throws IOException {
        MemoryEfficientByteArrayOutputStream buffer = serializeElement(element);
        int bufferLength = buffer.size();
        elementSize = bufferLength;
        DiskMarker marker = alloc(element, bufferLength);
        // Write the record
        RandomAccessFile data = getDataAccess(element.getObjectKey());
        synchronized (data) {
            data.seek(marker.getPosition());
            data.write(buffer.toByteArray(), 0, bufferLength);
        }
        return marker;
    }
View Full Code Here

        writeElement(element, key);
    }

    private void writeElement(Element element, Serializable key) throws IOException {
        try {
            MemoryEfficientByteArrayOutputStream buffer = serializeElement(element);
            if (buffer == null) {
                return;
            }

            int bufferLength = buffer.size();
            try {
                DiskElement diskElement = checkForFreeBlock(bufferLength);
                // Write the record
                RandomAccessFile randomAccessFile = selectRandomAccessFile(key);
                synchronized (randomAccessFile) {
                    randomAccessFile.seek(diskElement.position);
                    randomAccessFile.write(buffer.toByteArray(), 0, bufferLength);
                }
                buffer = null;
                // Add to index, update stats
                diskElement.payloadSize = bufferLength;
                diskElement.key = key;
View Full Code Here

TOP

Related Classes of net.sf.ehcache.util.MemoryEfficientByteArrayOutputStream

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.