private static void bootstrap ( final Storage pStorage , final ResourceConfiguration pResourceConf ) throws TTException { final IBackend storage = pResourceConf . mBackend ; storage . initialize ( ) ; final IBackendWriter writer = storage . getWriter ( ) ; final UberBucket uberBucket = new UberBucket ( 1 , 0 , 1 ) ; long newBucketKey = uberBucket . incrementBucketCounter ( ) ; uberBucket . setReferenceKey ( IReferenceBucket . GUARANTEED_INDIRECT_OFFSET , newBucketKey ) ; uberBucket . setReferenceHash ( IReferenceBucket . GUARANTEED_INDIRECT_OFFSET , IConstants . BOOTSTRAP_HASHED ) ; writer . write ( uberBucket ) ; // --- Create revision tree // ------------------------------------------------ // Initialize revision tree to guarantee that there is a revision root // bucket. IReferenceBucket bucket ; for ( int i = 0 ; i < IConstants . INDIRECT_BUCKET_COUNT . length ; i ++ ) { bucket = new IndirectBucket ( newBucketKey ) ; newBucketKey = uberBucket . incrementBucketCounter ( ) ; bucket . setReferenceKey ( 0 , newBucketKey ) ; bucket . setReferenceHash ( 0 , IConstants . BOOTSTRAP_HASHED ) ; writer . write ( bucket ) ; } RevisionRootBucket revBucket = new RevisionRootBucket ( newBucketKey , 0 , 0 ) ; newBucketKey = uberBucket . incrementBucketCounter ( ) ; // establishing fresh MetaBucket MetaBucket metaBucker = new MetaBucket ( newBucketKey ) ; revBucket . setReferenceKey ( RevisionRootBucket . META_REFERENCE_OFFSET , newBucketKey ) ; revBucket . setReferenceHash ( RevisionRootBucket . META_REFERENCE_OFFSET , IConstants . BOOTSTRAP_HASHED ) ; newBucketKey = uberBucket . incrementBucketCounter ( ) ; bucket = new IndirectBucket ( newBucketKey ) ; revBucket . setReferenceKey ( IReferenceBucket . GUARANTEED_INDIRECT_OFFSET , newBucketKey ) ; revBucket . setReferenceHash ( IReferenceBucket . GUARANTEED_INDIRECT_OFFSET , IConstants . BOOTSTRAP_HASHED ) ; writer . write ( revBucket ) ; writer . write ( metaBucker ) ; // --- Create data tree // ---------------------------------------------------- // Initialize revision tree to guarantee that there is a revision root // bucket. for ( int i = 0 ; i < IConstants . INDIRECT_BUCKET_COUNT . length ; i ++ ) { newBucketKey = uberBucket . incrementBucketCounter ( ) ; bucket . setReferenceKey ( 0 , newBucketKey ) ; bucket . setReferenceHash ( 0 , IConstants . BOOTSTRAP_HASHED ) ; writer . write ( bucket ) ; bucket = new IndirectBucket ( newBucketKey ) ; } final DataBucket ndp = new DataBucket ( newBucketKey , IConstants . NULLDATA ) ; writer . write ( ndp ) ; writer . writeUberBucket ( uberBucket ) ; writer . close ( ) ; storage . close ( ) ; }
Boostraping a resource within this storage .