Package com.antlersoft.odb

Examples of com.antlersoft.odb.DiskAllocator


    }

    public static void walkFreeList( String[] args)
        throws Throwable
    {
        DiskAllocator da=new DiskAllocator( new File( args[0]));
        System.out.println( args[0]+" free:");
        da.walkInternalFreeList( System.out);
        System.out.println( args[0]+" used:");
        da.walkRegions( System.out);

        da.close();
    }
View Full Code Here


            if ( ! file.exists())
                file.mkdirs();
            baseDirectory=file;
            useMemoryMapped = useMapped;
            File allocatorFile=new File( file, "overhead");
            overhead=new DiskAllocator( allocatorFile, INITIAL_REGION_SIZE,
                FAVORED_CHUNK_SIZE, 204800, useMemoryMapped ? DiskAllocator.USE_MEMORY_MAPPED : 0);

            overheadStreams=new StreamPair( overhead,
                factory.getCustomizer( EntryPage.class));
            rootModified=false;
            offsets=new byte[INITIAL_REGION_SIZE];

            if ( overhead.isNewFile())
            {
                classList=new ClassList();
                entryList=new EntryPageList();
                rootObject=null;
                entryOffset=overheadStreams.writeObject( entryList, 0);
                classOffset=overheadStreams.writeObject( classList, 0);
                rootOffset=0;
            }
            else
            {
                int offset=overhead.getInitialRegion();
                byte[] offsetBuffer=overhead.read( offset, INITIAL_REGION_SIZE);
                int version=NetByte.quadToInt( offsetBuffer, 0);
                if ( version!=DIR_ALLOC_VERSION)
                {
                  throw new ObjectStoreException( "Mismatched version:" + version);
                }
                entryOffset=NetByte.quadToInt( offsetBuffer, 4);
                classOffset=NetByte.quadToInt( offsetBuffer, 8);
                rootOffset=NetByte.quadToInt( offsetBuffer, 12);
                entryList=(EntryPageList)overheadStreams.readObject(
                    entryOffset);
                entryList.initialize( overheadStreams);
                classList=(ClassList)overheadStreams.readObject( classOffset);
                if ( rootOffset!=0)
                    rootObject=(Serializable)overheadStreams.
                        readObject( rootOffset);
            }
            // Traverse class list; create class and index maps and stream
            // pairs
            classList.factory=factory;
            classList.classMap=new HashMap();
            classList.classChangeLock=new Semaphore();
            classList.indexMap=new HashMap();
            indexPageFlushLock=new Semaphore();
            for ( Iterator i=classList.classEntries.iterator(); i.hasNext();)
            {
                ClassEntry entry=(ClassEntry)i.next();
                classList.classMap.put( Class.forName( entry.className),
                    entry);
                DiskAllocator allocator=createDiskAllocator(entry.fileName,128,DiskAllocator.FORCE_EXIST);
                ObjectStreamCustomizer customizer=factory.getCustomizer(
                    Class.forName( entry.className));
                entry.objectStreams=new StreamPair( allocator,
                    customizer);
                if ( entry.indices.size()>0)
View Full Code Here

    DiskAllocator createDiskAllocator( String fileName, int chunkSize, int createFlags)
      throws DiskAllocatorException, IOException
    {
      if (useMemoryMapped)
        createFlags |= DiskAllocator.USE_MEMORY_MAPPED;
      return new DiskAllocator(new File(baseDirectory, fileName), 4, chunkSize, 102400, createFlags);
    }
View Full Code Here

                    result.className=toFind.getName();
                    result.fileName=Integer.toString( classIndex);
                    result.indices=new ArrayList();
                    try
                    {
                        DiskAllocator allocator=manager.createDiskAllocator(result.fileName, 128, DiskAllocator.FORCE_CREATE);
                        result.objectStreams=new StreamPair( allocator,
                            factory.getCustomizer( toFind));
                    }
                    catch ( Exception dae)
                    {
                        throw new ObjectStoreException( "Failed creating allocator "+
                            result.fileName+" for class "+result.className, dae);
                    }
                }
                else
                {
                    classIndex=classEntries.size();
                    result=new ClassEntry();
                    result.reuseCount=0;
                    result.index=classEntries.size();
                    result.className=toFind.getName();
                    result.fileName=Integer.toString( classIndex);
                    result.indices=new ArrayList();
                    try
                    {
                        DiskAllocator allocator=manager.createDiskAllocator(result.fileName, 128, DiskAllocator.FORCE_CREATE);
                        result.objectStreams=new StreamPair( allocator,
                            factory.getCustomizer( toFind));
                    }
                    catch ( Exception dae)
                    {
View Full Code Here

TOP

Related Classes of com.antlersoft.odb.DiskAllocator

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.