static long readDefragCount( FileSystemAbstraction fileSystem, File file ) throws IOException { try ( StoreChannel channel = fileSystem.open( file, OpenMode.READ ) ) { return FreeIdKeeper.countFreeIds( new OffsetChannel( channel, HEADER_SIZE ) ); } }
/** * Initializes the id generator and performs a simple validation. Returns true if the initialization restored * properly on disk state, false otherwise (such as creating an id file from scratch). * Will throw {@link InvalidIdGeneratorException} if the id file is found to be damaged or unclean. */ public boolean init() { boolean result = true; try { if ( !fs.fileExists( file ) ) { createEmptyIdFile( fs, file, 0, false ); result = false; } fileChannel = fs.open( file, OpenMode.READ_WRITE ); initialHighId = readAndValidateHeader(); markAsSticky(); this.freeIdKeeper = new FreeIdKeeper( new OffsetChannel( fileChannel, HEADER_SIZE ), grabSize, aggressiveReuse ); closed = false; } catch ( IOException e ) { throw new UnderlyingStorageException( "Unable to init id file " + file, e ); } return result; }
static long readDefragCount( FileSystemAbstraction fileSystem, File file ) throws IOException { try ( StoreChannel channel = fileSystem.open( file, OpenMode.READ ) ) { return FreeIdKeeper.countFreeIds( new OffsetChannel( channel, HEADER_SIZE ) ); } }
/** * Initializes the id generator and performs a simple validation. Returns true if the initialization restored * properly on disk state, false otherwise (such as creating an id file from scratch). * Will throw {@link InvalidIdGeneratorException} if the id file is found to be damaged or unclean. */ public boolean init() { boolean result = true; try { if ( !fs.fileExists( file ) ) { createEmptyIdFile( fs, file, 0, false ); result = false; } fileChannel = fs.open( file, OpenMode.READ_WRITE ); initialHighId = readAndValidateHeader(); markAsSticky(); this.freeIdKeeper = new FreeIdKeeper( new OffsetChannel( fileChannel, HEADER_SIZE ), grabSize, aggressiveReuse ); closed = false; } catch ( IOException e ) { throw new UnderlyingStorageException( "Unable to init id file " + file, e ); } return result; }