Package com.sleepycat.je.log

Source Code of com.sleepycat.je.log.FileHandle

/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2002-2005
*      Sleepycat Software.  All rights reserved.
*
* $Id: FileHandle.java,v 1.14 2004/12/22 14:11:33 linda Exp $
*/

package com.sleepycat.je.log;

import java.io.IOException;
import java.io.RandomAccessFile;

import com.sleepycat.je.DatabaseException;
import com.sleepycat.je.dbi.EnvironmentImpl;
import com.sleepycat.je.latch.Latch;

/**
* A FileHandle embodies a File and its accompanying latch.
*/
class FileHandle {
    private RandomAccessFile file;
    private Latch fileLatch;
    private boolean oldHeaderVersion;

    FileHandle(RandomAccessFile file,
               String fileName,
               EnvironmentImpl env,
               boolean oldHeaderVersion) {
        this.file = file;
        this.oldHeaderVersion = oldHeaderVersion;
        fileLatch = new Latch(fileName + "_fileHandle", env);
    }

    RandomAccessFile getFile() {
        return file;
    }

    boolean isOldHeaderVersion() {
        return oldHeaderVersion;
    }

    void latch()
        throws DatabaseException {

        fileLatch.acquire();
    }

    boolean latchNoWait()
        throws DatabaseException {

        return fileLatch.acquireNoWait();
    }

    void release()
        throws DatabaseException {

        fileLatch.release();
    }

    void close()
  throws IOException {

  if (file != null) {
      file.close();
      file = null;
  }
    }
}
TOP

Related Classes of com.sleepycat.je.log.FileHandle

TOP
Copyright © 2018 www.massapi.com. 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.