Search in sources :

Example 16 with DiskAccessException

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

the class DiskInitFile method writeDiskStoreId.

private void writeDiskStoreId() {
    lock.lock();
    try {
        ByteBuffer bb = getIFWriteBuffer(1 + 6 + 1);
        bb.put(OPLOG_MAGIC_SEQ_ID);
        bb.put(Oplog.OPLOG_TYPE.IF.getBytes(), 0, Oplog.OPLOG_TYPE.getLen());
        bb.put(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(bb, false);
        bb = getIFWriteBuffer(1 + 8 + 8 + 1);
        bb.put(IFREC_DISKSTORE_ID);
        bb.putLong(parent.getDiskStoreID().getLeastSignificantBits());
        bb.putLong(parent.getDiskStoreID().getMostSignificantBits());
        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 17 with DiskAccessException

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

the class DiskInitFile method writeClearRecord.

/**
   * Write a clear with an RVV record.
   */
private void writeClearRecord(DiskRegionView dr, RegionVersionVector rvv) {
    try {
        HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT);
        hdos.write(IFREC_CLEAR_REGION_WITH_RVV_ID);
        writeDiskRegionID(hdos, dr.getId());
        // We only need the memberToVersionMap for clear purposes
        Map<DiskStoreID, RegionVersionHolder> memberToVersion = rvv.getMemberToVersion();
        hdos.writeInt(memberToVersion.size());
        for (Map.Entry<DiskStoreID, RegionVersionHolder> entry : memberToVersion.entrySet()) {
            InternalDataSerializer.invokeToData(entry.getKey(), hdos);
            synchronized (entry.getValue()) {
                InternalDataSerializer.invokeToData(entry.getValue(), hdos);
            }
        }
        hdos.write(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(hdos, 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 : HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) DiskAccessException(org.apache.geode.cache.DiskAccessException) RegionVersionHolder(org.apache.geode.internal.cache.versions.RegionVersionHolder) IOException(java.io.IOException) DiskStoreID(org.apache.geode.internal.cache.persistence.DiskStoreID) Map(java.util.Map) Int2ObjectOpenHashMap(it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Int2ObjectMap(it.unimi.dsi.fastutil.ints.Int2ObjectMap)

Example 18 with DiskAccessException

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

the class DiskInitFile method writeRevokedMember.

private void writeRevokedMember(PersistentMemberPattern revoked) {
    try {
        HeapDataOutputStream hdos = new HeapDataOutputStream(32, Version.CURRENT);
        hdos.write(IFREC_REVOKE_DISK_STORE_ID);
        InternalDataSerializer.invokeToData(revoked, hdos);
        hdos.write(END_OF_RECORD_ID);
        // don't do stats for these small records
        writeIFRecord(hdos, 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 : HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException)

Example 19 with DiskAccessException

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

the class DiskInitFile method writePMIDRecord.

private void writePMIDRecord(byte opcode, DiskRegionView dr, PersistentMemberID pmid, boolean doStats) {
    assert lock.isHeldByCurrentThread();
    try {
        byte[] pmidBytes = pmidToBytes(pmid);
        ByteBuffer bb = getIFWriteBuffer(1 + DR_ID_MAX_BYTES + 4 + pmidBytes.length + 1);
        bb.put(opcode);
        putDiskRegionID(bb, dr.getId());
        bb.putInt(pmidBytes.length);
        bb.put(pmidBytes);
        bb.put(END_OF_RECORD_ID);
        writeIFRecord(bb, doStats);
    } 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 20 with DiskAccessException

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

the class DiskInitFile method pmidToBytes.

private byte[] pmidToBytes(PersistentMemberID id) {
    try {
        HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
        InternalDataSerializer.invokeToData(id, hdos);
        return hdos.toByteArray();
    } catch (IOException ex) {
        throw new DiskAccessException(LocalizedStrings.DiskInitFile_FAILED_INIT_FILE_WRITE_BECAUSE_0.toLocalizedString(ex), this.parent);
    }
}
Also used : HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) DiskAccessException(org.apache.geode.cache.DiskAccessException) IOException(java.io.IOException)

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