Search in sources :

Example 1 with TrackingPageRepairDeltaRecord

use of org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageRepairDeltaRecord in project ignite by apache.

the class RecordDataV2Serializer method writePlainRecord.

/**
 * {@inheritDoc}
 */
@Override
protected void writePlainRecord(WALRecord rec, ByteBuffer buf) throws IgniteCheckedException {
    if (rec instanceof HeaderRecord)
        throw new UnsupportedOperationException("Writing header records is forbidden since version 2 of serializer");
    switch(rec.type()) {
        case CHECKPOINT_RECORD:
            CheckpointRecord cpRec = (CheckpointRecord) rec;
            WALPointer walPtr = cpRec.checkpointMark();
            UUID cpId = cpRec.checkpointId();
            buf.putLong(cpId.getMostSignificantBits());
            buf.putLong(cpId.getLeastSignificantBits());
            buf.put(walPtr == null ? (byte) 0 : 1);
            if (walPtr != null) {
                buf.putLong(walPtr.index());
                buf.putInt(walPtr.fileOffset());
                buf.putInt(walPtr.length());
            }
            putCacheStates(buf, cpRec.cacheGroupStates());
            buf.put(cpRec.end() ? (byte) 1 : 0);
            break;
        case MVCC_DATA_RECORD:
        case DATA_RECORD_V2:
            DataRecord dataRec = (DataRecord) rec;
            int entryCnt = dataRec.entryCount();
            buf.putInt(entryCnt);
            buf.putLong(dataRec.timestamp());
            boolean encrypted = isDataRecordEncrypted(dataRec);
            for (int i = 0; i < entryCnt; i++) {
                DataEntry dataEntry = dataRec.get(i);
                if (encrypted)
                    putEncryptedDataEntry(buf, dataEntry);
                else
                    putPlainDataEntry(buf, dataEntry);
            }
            break;
        case SNAPSHOT:
            SnapshotRecord snpRec = (SnapshotRecord) rec;
            buf.putLong(snpRec.getSnapshotId());
            buf.put(snpRec.isFull() ? (byte) 1 : 0);
            break;
        case EXCHANGE:
            ExchangeRecord r = (ExchangeRecord) rec;
            buf.putInt(r.getType().ordinal());
            buf.putShort(r.getConstId());
            buf.putLong(r.timestamp());
            break;
        case TX_RECORD:
            txRecordSerializer.write((TxRecord) rec, buf);
            break;
        case MVCC_TX_RECORD:
            txRecordSerializer.write((MvccTxRecord) rec, buf);
            break;
        case ROLLBACK_TX_RECORD:
            RollbackRecord rb = (RollbackRecord) rec;
            buf.putInt(rb.groupId());
            buf.putInt(rb.partitionId());
            buf.putLong(rb.start());
            buf.putLong(rb.range());
            break;
        case TRACKING_PAGE_REPAIR_DELTA:
            TrackingPageRepairDeltaRecord tprDelta = (TrackingPageRepairDeltaRecord) rec;
            buf.putInt(tprDelta.groupId());
            buf.putLong(tprDelta.pageId());
            break;
        default:
            super.writePlainRecord(rec, buf);
    }
}
Also used : CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) SnapshotRecord(org.apache.ignite.internal.pagemem.wal.record.SnapshotRecord) TrackingPageRepairDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageRepairDeltaRecord) MvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) LazyMvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.LazyMvccDataEntry) HeaderRecord(org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord) ExchangeRecord(org.apache.ignite.internal.pagemem.wal.record.ExchangeRecord) RollbackRecord(org.apache.ignite.internal.pagemem.wal.record.RollbackRecord) MvccDataRecord(org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) UUID(java.util.UUID) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)

Example 2 with TrackingPageRepairDeltaRecord

use of org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageRepairDeltaRecord in project ignite by apache.

the class RecordDataV2Serializer method readPlainRecord.

/**
 * {@inheritDoc}
 */
@Override
WALRecord readPlainRecord(RecordType type, ByteBufferBackedDataInput in, boolean encrypted, int recordSize) throws IOException, IgniteCheckedException {
    switch(type) {
        case PAGE_RECORD:
            int cacheId = in.readInt();
            long pageId = in.readLong();
            byte[] arr = new byte[recordSize - 4 - /* cacheId */
            8];
            in.readFully(arr);
            return new PageSnapshot(new FullPageId(pageId, cacheId), arr, encrypted ? realPageSize : pageSize);
        case CHECKPOINT_RECORD:
            long msb = in.readLong();
            long lsb = in.readLong();
            boolean hasPtr = in.readByte() != 0;
            long idx0 = hasPtr ? in.readLong() : 0;
            int off = hasPtr ? in.readInt() : 0;
            int len = hasPtr ? in.readInt() : 0;
            Map<Integer, CacheState> states = readPartitionStates(in);
            boolean end = in.readByte() != 0;
            WALPointer walPtr = hasPtr ? new WALPointer(idx0, off, len) : null;
            CheckpointRecord cpRec = new CheckpointRecord(new UUID(msb, lsb), walPtr, end);
            cpRec.cacheGroupStates(states);
            return cpRec;
        case DATA_RECORD:
        case DATA_RECORD_V2:
            int entryCnt = in.readInt();
            long timeStamp = in.readLong();
            if (entryCnt == 1)
                return new DataRecord(readPlainDataEntry(in, type), timeStamp);
            else {
                List<DataEntry> entries = new ArrayList<>(entryCnt);
                for (int i = 0; i < entryCnt; i++) entries.add(readPlainDataEntry(in, type));
                return new DataRecord(entries, timeStamp);
            }
        case MVCC_DATA_RECORD:
            entryCnt = in.readInt();
            timeStamp = in.readLong();
            List<DataEntry> entries = new ArrayList<>(entryCnt);
            for (int i = 0; i < entryCnt; i++) entries.add(readMvccDataEntry(in));
            return new MvccDataRecord(entries, timeStamp);
        case ENCRYPTED_DATA_RECORD:
        case ENCRYPTED_DATA_RECORD_V2:
        case ENCRYPTED_DATA_RECORD_V3:
            entryCnt = in.readInt();
            timeStamp = in.readLong();
            if (entryCnt == 1)
                return new DataRecord(readEncryptedDataEntry(in, type), timeStamp);
            else {
                entries = new ArrayList<>(entryCnt);
                for (int i = 0; i < entryCnt; i++) entries.add(readEncryptedDataEntry(in, type));
                return new DataRecord(entries, timeStamp);
            }
        case SNAPSHOT:
            long snpId = in.readLong();
            byte full = in.readByte();
            return new SnapshotRecord(snpId, full == 1);
        case EXCHANGE:
            int idx = in.readInt();
            short constId = in.readShort();
            long ts = in.readLong();
            return new ExchangeRecord(constId, ExchangeRecord.Type.values()[idx], ts);
        case TX_RECORD:
            return txRecordSerializer.readTx(in);
        case MVCC_TX_RECORD:
            return txRecordSerializer.readMvccTx(in);
        case ROLLBACK_TX_RECORD:
            int grpId = in.readInt();
            int partId = in.readInt();
            long start = in.readLong();
            long range = in.readLong();
            return new RollbackRecord(grpId, partId, start, range);
        case TRACKING_PAGE_REPAIR_DELTA:
            cacheId = in.readInt();
            pageId = in.readLong();
            return new TrackingPageRepairDeltaRecord(cacheId, pageId);
        default:
            return super.readPlainRecord(type, in, encrypted, recordSize);
    }
}
Also used : ArrayList(java.util.ArrayList) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) CacheState(org.apache.ignite.internal.pagemem.wal.record.CacheState) SnapshotRecord(org.apache.ignite.internal.pagemem.wal.record.SnapshotRecord) TrackingPageRepairDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageRepairDeltaRecord) MvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) LazyMvccDataEntry(org.apache.ignite.internal.pagemem.wal.record.LazyMvccDataEntry) ExchangeRecord(org.apache.ignite.internal.pagemem.wal.record.ExchangeRecord) RollbackRecord(org.apache.ignite.internal.pagemem.wal.record.RollbackRecord) MvccDataRecord(org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord) MvccDataRecord(org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) UUID(java.util.UUID) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Aggregations

UUID (java.util.UUID)2 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)2 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)2 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)2 ExchangeRecord (org.apache.ignite.internal.pagemem.wal.record.ExchangeRecord)2 LazyMvccDataEntry (org.apache.ignite.internal.pagemem.wal.record.LazyMvccDataEntry)2 MvccDataEntry (org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry)2 MvccDataRecord (org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord)2 RollbackRecord (org.apache.ignite.internal.pagemem.wal.record.RollbackRecord)2 SnapshotRecord (org.apache.ignite.internal.pagemem.wal.record.SnapshotRecord)2 TrackingPageRepairDeltaRecord (org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageRepairDeltaRecord)2 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)2 ArrayList (java.util.ArrayList)1 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)1 CacheState (org.apache.ignite.internal.pagemem.wal.record.CacheState)1 PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)1 HeaderRecord (org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord)1