TransactionManager getTxnMgr() throws IOException { if ( transactionsDisabled ) { throw new IllegalStateException( "Transactions are disabled." ); } if ( transactionManager == null ) { transactionManager = new TransactionManager( this ); } return transactionManager; }
/** * @return The TransactionManager if the transaction system is enabled. * @throws IOException If we can't create a TransactionManager */ TransactionManager getTxnMgr() throws IOException { if ( transactionsDisabled ) { throw new IllegalStateException( "Transactions are disabled." ); } if ( transactionManager == null ) { transactionManager = new TransactionManager( this ); } return transactionManager; }
/** * Creates a new object on the indicated filename. The file is * opened in read/write mode. * * @param fileName the name of the file to open or create, without * an extension. * @throws IOException whenever the creation of the underlying * RandomAccessFile throws it. */ RecordFile ( String fileName ) throws IOException { this.fileName = fileName; file = new RandomAccessFile(fileName + extension, "rw"); txnMgr = new TransactionManager( this ); }
/** * Creates a new object on the indicated filename. The file is * opened in read/write mode. * * @param fileName the name of the file to open or create, without * an extension. * @throws IOException whenever the creation of the underlying * RandomAccessFile throws it. */ RecordFile(String fileName, int blockSize) throws IOException { this.BLOCK_SIZE = blockSize; MAX_FILE_SIZE = _FILESIZE - _FILESIZE%BLOCK_SIZE; cleanData = new byte[BLOCK_SIZE]; this.fileName = fileName; // file0 = new RandomAccessFile(fileName + extension, "rw"); // file = file0.getChannel(); //make sure first file can be opened FileChannel f0 = getChannel(0); //lock it try{ f0.tryLock(); }catch(IOException e){ throw new IOException("Could not lock DB file: "+fileName,e); }catch(OverlappingFileLockException e){ throw new IOException("Could not lock DB file: "+fileName,e); } txnMgr = new TransactionManager(this); }