Search in sources :

Example 11 with DiskAccessException

use of org.apache.geode.cache.DiskAccessException in project geode by apache.

the class DiskInitFile method writeGemfireVersion.

private void writeGemfireVersion(Version version) {
    lock.lock();
    try {
        ByteBuffer bb = getIFWriteBuffer(1 + 3 + 1);
        bb.put(IFREC_GEMFIRE_VERSION);
        Version.writeOrdinal(bb, version.ordinal(), false);
        bb.put(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(bb, false);
    } catch (IOException ex) {
        DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
        if (!this.compactInProgress) {
            this.parent.handleDiskAccessException(dae);
        }
        throw dae;
    } finally {
        lock.unlock();
    }
}
Also used : DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Example 12 with DiskAccessException

use of org.apache.geode.cache.DiskAccessException in project geode by apache.

the class DiskInitFile method bytesToPMID.

private PersistentMemberID bytesToPMID(byte[] bytes) {
    try {
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        DataInputStream dis = new DataInputStream(bais);
        PersistentMemberID result = new PersistentMemberID();
        InternalDataSerializer.invokeFromData(result, dis);
        return result;
    } catch (IOException io) {
        throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_READING_FILE_DURING_RECOVERY_FROM_0.toLocalizedString(this.ifFile.getPath()), io, this.parent);
    } catch (ClassNotFoundException cnf) {
        throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_READING_FILE_DURING_RECOVERY_FROM_0.toLocalizedString(this.ifFile.getPath()), cnf, this.parent);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) PersistentMemberID(org.apache.geode.internal.cache.persistence.PersistentMemberID)

Example 13 with DiskAccessException

use of org.apache.geode.cache.DiskAccessException in project geode by apache.

the class DiskInitFile method writeIFRecord.

private void writeIFRecord(byte b, DiskRegionView dr, long v) {
    assert lock.isHeldByCurrentThread();
    try {
        ByteBuffer bb = getIFWriteBuffer(1 + DR_ID_MAX_BYTES + 8 + 1);
        bb.put(b);
        putDiskRegionID(bb, dr.getId());
        bb.putLong(v);
        bb.put(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(bb, false);
    } catch (IOException ex) {
        DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
        if (!this.compactInProgress) {
            this.parent.handleDiskAccessException(dae);
        }
        throw dae;
    }
}
Also used : DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Example 14 with DiskAccessException

use of org.apache.geode.cache.DiskAccessException in project geode by apache.

the class DiskInitFile method writeIFRecord.

private void writeIFRecord(byte b, DiskRegionView dr) {
    assert lock.isHeldByCurrentThread();
    try {
        ByteBuffer bb = getIFWriteBuffer(1 + DR_ID_MAX_BYTES + 1);
        bb.put(b);
        putDiskRegionID(bb, dr.getId());
        bb.put(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(bb, false);
    } catch (IOException ex) {
        DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
        if (!this.compactInProgress) {
            this.parent.handleDiskAccessException(dae);
        }
        throw dae;
    }
}
Also used : DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Example 15 with DiskAccessException

use of org.apache.geode.cache.DiskAccessException in project geode by apache.

the class DiskInitFile method writeIFRecord.

private void writeIFRecord(byte b, long v) {
    assert lock.isHeldByCurrentThread();
    try {
        ByteBuffer bb = getIFWriteBuffer(OPLOG_FILE_ID_REC_SIZE);
        bb.put(b);
        bb.putLong(v);
        bb.put(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(bb, false);
    } catch (IOException ex) {
        DiskAccessException dae = new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
        if (!this.compactInProgress) {
            this.parent.handleDiskAccessException(dae);
        }
        throw dae;
    }
}
Also used : DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException) ByteBuffer(java.nio.ByteBuffer)

Aggregations

DiskAccessException (org.apache.geode.cache.DiskAccessException)76 IOException (java.io.IOException)44 InterruptedIOException (java.io.InterruptedIOException)17 StoredObject (org.apache.geode.internal.offheap.StoredObject)13 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)11 ByteBuffer (java.nio.ByteBuffer)9 Test (org.junit.Test)8 Version (org.apache.geode.internal.Version)6 File (java.io.File)5 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)5 IndexManager (org.apache.geode.cache.query.internal.index.IndexManager)5 UninterruptibleFileChannel (org.apache.geode.internal.cache.persistence.UninterruptibleFileChannel)5 VersionTag (org.apache.geode.internal.cache.versions.VersionTag)5 Released (org.apache.geode.internal.offheap.annotations.Released)5 BufferedInputStream (java.io.BufferedInputStream)4 FileInputStream (java.io.FileInputStream)4 CancelException (org.apache.geode.CancelException)4 BytesAndBits (org.apache.geode.internal.cache.persistence.BytesAndBits)4 UninterruptibleRandomAccessFile (org.apache.geode.internal.cache.persistence.UninterruptibleRandomAccessFile)4 EOFException (java.io.EOFException)3