2
* Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved.
4
* This program and the accompanying materials are made available
5
* under the terms of the Eclipse Public License v1.0 which
6
* accompanies this distribution, and is available at
7
* http://www.eclipse.org/legal/epl-v10.html
9
* This program may also be available under different license terms.
10
* For more information, see www.akiban.com or contact licensing@akiban.com.
13
* Akiban Technologies, Inc.
16
package com.persistit;
20
import com.persistit.exception.InUseException;
21
import com.persistit.exception.PersistitException;
24
* Manage all details of file I/O for a special <code>Volume</code> that backs
25
* the {@link Exchange#lock()} method. The lock volume differs from a temporary
26
* volume in the following ways:
28
* <li>It has a defined name and is visible in the
29
* {@link Persistit#getVolumes()} array.</li>
30
* <li>It is threadsafe.</li>
32
* Like a temporary volume, it is intended that pages of the lock volume should
33
* seldom, if ever, need to be written to disk. And also like a temporary
34
* volume, the contents of the lock volume are not recovered during startup.
38
class VolumeStorageL2 extends VolumeStorageT2 {
40
final static String LOCK_VOLUME_FILE_PREFIX = "persistit_lockvol_";
41
private Buffer _headBuffer;
43
VolumeStorageL2(final Persistit persistit, final Volume volume, final File tempDirectory) {
44
super(persistit, volume, tempDirectory);
48
* Indicate whether this is a temporary volume. The Lock volume is not
49
* temporary, although it inherits most of the characteristics of a
52
* @return <code>true</code> if this volume is temporary
60
void truncate() throws PersistitException {
61
if (!claim(true, 0)) {
62
throw new InUseException("Unable to acquire claim on " + this);
65
_headBuffer = _volume.getStructure().getPool().get(_volume, 0, true, false);
66
_headBuffer.init(Buffer.PAGE_TYPE_HEAD);
67
_headBuffer.setFixed();
78
void claimHeadBuffer() throws PersistitException {
79
if (!_headBuffer.claim(true)) {
80
throw new InUseException("Unable to acquire claim on " + _headBuffer);
85
void releaseHeadBuffer() {
86
_headBuffer.release();