Search in sources :

Example 1 with MetastoreDataRecord

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

the class RecordDataV1Serializer method writeRecord.

/**
 * {@inheritDoc}
 */
@Override
public void writeRecord(WALRecord rec, ByteBuffer buf) throws IgniteCheckedException {
    switch(rec.type()) {
        case PAGE_RECORD:
            PageSnapshot snap = (PageSnapshot) rec;
            buf.putInt(snap.fullPageId().groupId());
            buf.putLong(snap.fullPageId().pageId());
            buf.put(snap.pageData());
            break;
        case MEMORY_RECOVERY:
            MemoryRecoveryRecord memoryRecoveryRecord = (MemoryRecoveryRecord) rec;
            buf.putLong(memoryRecoveryRecord.time());
            break;
        case PARTITION_DESTROY:
            PartitionDestroyRecord partDestroy = (PartitionDestroyRecord) rec;
            buf.putInt(partDestroy.groupId());
            buf.putInt(partDestroy.partitionId());
            break;
        case META_PAGE_INIT:
            MetaPageInitRecord updRootsRec = (MetaPageInitRecord) rec;
            buf.putInt(updRootsRec.groupId());
            buf.putLong(updRootsRec.pageId());
            buf.putShort((short) updRootsRec.ioType());
            buf.putShort((short) updRootsRec.ioVersion());
            buf.putLong(updRootsRec.treeRoot());
            buf.putLong(updRootsRec.reuseListRoot());
            break;
        case PARTITION_META_PAGE_UPDATE_COUNTERS:
            MetaPageUpdatePartitionDataRecord partDataRec = (MetaPageUpdatePartitionDataRecord) rec;
            buf.putInt(partDataRec.groupId());
            buf.putLong(partDataRec.pageId());
            buf.putLong(partDataRec.updateCounter());
            buf.putLong(partDataRec.globalRemoveId());
            buf.putInt(partDataRec.partitionSize());
            buf.putLong(partDataRec.countersPageId());
            buf.put(partDataRec.state());
            buf.putInt(partDataRec.allocatedIndexCandidate());
            break;
        case CHECKPOINT_RECORD:
            CheckpointRecord cpRec = (CheckpointRecord) rec;
            assert cpRec.checkpointMark() == null || cpRec.checkpointMark() instanceof FileWALPointer : "Invalid WAL record: " + cpRec;
            FileWALPointer walPtr = (FileWALPointer) 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 DATA_RECORD:
            DataRecord dataRec = (DataRecord) rec;
            buf.putInt(dataRec.writeEntries().size());
            for (DataEntry dataEntry : dataRec.writeEntries()) putDataEntry(buf, dataEntry);
            break;
        case METASTORE_DATA_RECORD:
            MetastoreDataRecord metastoreDataRecord = (MetastoreDataRecord) rec;
            byte[] strBytes = metastoreDataRecord.key().getBytes();
            buf.putInt(strBytes.length);
            buf.put(strBytes);
            if (metastoreDataRecord.value() != null) {
                buf.putInt(metastoreDataRecord.value().length);
                buf.put(metastoreDataRecord.value());
            } else
                buf.putInt(0);
            break;
        case HEADER_RECORD:
            buf.putLong(HeaderRecord.REGULAR_MAGIC);
            buf.putInt(((HeaderRecord) rec).version());
            break;
        case DATA_PAGE_INSERT_RECORD:
            DataPageInsertRecord diRec = (DataPageInsertRecord) rec;
            buf.putInt(diRec.groupId());
            buf.putLong(diRec.pageId());
            buf.putShort((short) diRec.payload().length);
            buf.put(diRec.payload());
            break;
        case DATA_PAGE_UPDATE_RECORD:
            DataPageUpdateRecord uRec = (DataPageUpdateRecord) rec;
            buf.putInt(uRec.groupId());
            buf.putLong(uRec.pageId());
            buf.putInt(uRec.itemId());
            buf.putShort((short) uRec.payload().length);
            buf.put(uRec.payload());
            break;
        case DATA_PAGE_INSERT_FRAGMENT_RECORD:
            final DataPageInsertFragmentRecord difRec = (DataPageInsertFragmentRecord) rec;
            buf.putInt(difRec.groupId());
            buf.putLong(difRec.pageId());
            buf.putLong(difRec.lastLink());
            buf.putInt(difRec.payloadSize());
            buf.put(difRec.payload());
            break;
        case DATA_PAGE_REMOVE_RECORD:
            DataPageRemoveRecord drRec = (DataPageRemoveRecord) rec;
            buf.putInt(drRec.groupId());
            buf.putLong(drRec.pageId());
            buf.put((byte) drRec.itemId());
            break;
        case DATA_PAGE_SET_FREE_LIST_PAGE:
            DataPageSetFreeListPageRecord freeListRec = (DataPageSetFreeListPageRecord) rec;
            buf.putInt(freeListRec.groupId());
            buf.putLong(freeListRec.pageId());
            buf.putLong(freeListRec.freeListPage());
            break;
        case INIT_NEW_PAGE_RECORD:
            InitNewPageRecord inpRec = (InitNewPageRecord) rec;
            buf.putInt(inpRec.groupId());
            buf.putLong(inpRec.pageId());
            buf.putShort((short) inpRec.ioType());
            buf.putShort((short) inpRec.ioVersion());
            buf.putLong(inpRec.newPageId());
            break;
        case BTREE_META_PAGE_INIT_ROOT:
            MetaPageInitRootRecord imRec = (MetaPageInitRootRecord) rec;
            buf.putInt(imRec.groupId());
            buf.putLong(imRec.pageId());
            buf.putLong(imRec.rootId());
            break;
        case BTREE_META_PAGE_INIT_ROOT2:
            MetaPageInitRootInlineRecord imRec2 = (MetaPageInitRootInlineRecord) rec;
            buf.putInt(imRec2.groupId());
            buf.putLong(imRec2.pageId());
            buf.putLong(imRec2.rootId());
            buf.putShort((short) imRec2.inlineSize());
            break;
        case BTREE_META_PAGE_ADD_ROOT:
            MetaPageAddRootRecord arRec = (MetaPageAddRootRecord) rec;
            buf.putInt(arRec.groupId());
            buf.putLong(arRec.pageId());
            buf.putLong(arRec.rootId());
            break;
        case BTREE_META_PAGE_CUT_ROOT:
            MetaPageCutRootRecord crRec = (MetaPageCutRootRecord) rec;
            buf.putInt(crRec.groupId());
            buf.putLong(crRec.pageId());
            break;
        case BTREE_INIT_NEW_ROOT:
            NewRootInitRecord<?> riRec = (NewRootInitRecord<?>) rec;
            buf.putInt(riRec.groupId());
            buf.putLong(riRec.pageId());
            buf.putLong(riRec.rootId());
            buf.putShort((short) riRec.io().getType());
            buf.putShort((short) riRec.io().getVersion());
            buf.putLong(riRec.leftId());
            buf.putLong(riRec.rightId());
            putRow(buf, riRec.rowBytes());
            break;
        case BTREE_PAGE_RECYCLE:
            RecycleRecord recRec = (RecycleRecord) rec;
            buf.putInt(recRec.groupId());
            buf.putLong(recRec.pageId());
            buf.putLong(recRec.newPageId());
            break;
        case BTREE_PAGE_INSERT:
            InsertRecord<?> inRec = (InsertRecord<?>) rec;
            buf.putInt(inRec.groupId());
            buf.putLong(inRec.pageId());
            buf.putShort((short) inRec.io().getType());
            buf.putShort((short) inRec.io().getVersion());
            buf.putShort((short) inRec.index());
            buf.putLong(inRec.rightId());
            putRow(buf, inRec.rowBytes());
            break;
        case BTREE_FIX_LEFTMOST_CHILD:
            FixLeftmostChildRecord flRec = (FixLeftmostChildRecord) rec;
            buf.putInt(flRec.groupId());
            buf.putLong(flRec.pageId());
            buf.putLong(flRec.rightId());
            break;
        case BTREE_FIX_COUNT:
            FixCountRecord fcRec = (FixCountRecord) rec;
            buf.putInt(fcRec.groupId());
            buf.putLong(fcRec.pageId());
            buf.putShort((short) fcRec.count());
            break;
        case BTREE_PAGE_REPLACE:
            ReplaceRecord<?> rRec = (ReplaceRecord<?>) rec;
            buf.putInt(rRec.groupId());
            buf.putLong(rRec.pageId());
            buf.putShort((short) rRec.io().getType());
            buf.putShort((short) rRec.io().getVersion());
            buf.putShort((short) rRec.index());
            putRow(buf, rRec.rowBytes());
            break;
        case BTREE_PAGE_REMOVE:
            RemoveRecord rmRec = (RemoveRecord) rec;
            buf.putInt(rmRec.groupId());
            buf.putLong(rmRec.pageId());
            buf.putShort((short) rmRec.index());
            buf.putShort((short) rmRec.count());
            break;
        case BTREE_PAGE_INNER_REPLACE:
            InnerReplaceRecord<?> irRec = (InnerReplaceRecord<?>) rec;
            buf.putInt(irRec.groupId());
            buf.putLong(irRec.pageId());
            buf.putShort((short) irRec.destinationIndex());
            buf.putLong(irRec.sourcePageId());
            buf.putShort((short) irRec.sourceIndex());
            buf.putLong(irRec.removeId());
            break;
        case BTREE_FORWARD_PAGE_SPLIT:
            SplitForwardPageRecord sfRec = (SplitForwardPageRecord) rec;
            buf.putInt(sfRec.groupId());
            buf.putLong(sfRec.pageId());
            buf.putLong(sfRec.forwardId());
            buf.putShort((short) sfRec.ioType());
            buf.putShort((short) sfRec.ioVersion());
            buf.putLong(sfRec.sourcePageId());
            buf.putShort((short) sfRec.middleIndex());
            buf.putShort((short) sfRec.count());
            break;
        case BTREE_EXISTING_PAGE_SPLIT:
            SplitExistingPageRecord seRec = (SplitExistingPageRecord) rec;
            buf.putInt(seRec.groupId());
            buf.putLong(seRec.pageId());
            buf.putShort((short) seRec.middleIndex());
            buf.putLong(seRec.forwardId());
            break;
        case BTREE_PAGE_MERGE:
            MergeRecord<?> mRec = (MergeRecord<?>) rec;
            buf.putInt(mRec.groupId());
            buf.putLong(mRec.pageId());
            buf.putLong(mRec.parentId());
            buf.putShort((short) mRec.parentIndex());
            buf.putLong(mRec.rightId());
            buf.put((byte) (mRec.isEmptyBranch() ? 1 : 0));
            break;
        case PAGES_LIST_SET_NEXT:
            PagesListSetNextRecord plNextRec = (PagesListSetNextRecord) rec;
            buf.putInt(plNextRec.groupId());
            buf.putLong(plNextRec.pageId());
            buf.putLong(plNextRec.nextPageId());
            break;
        case PAGES_LIST_SET_PREVIOUS:
            PagesListSetPreviousRecord plPrevRec = (PagesListSetPreviousRecord) rec;
            buf.putInt(plPrevRec.groupId());
            buf.putLong(plPrevRec.pageId());
            buf.putLong(plPrevRec.previousPageId());
            break;
        case PAGES_LIST_INIT_NEW_PAGE:
            PagesListInitNewPageRecord plNewRec = (PagesListInitNewPageRecord) rec;
            buf.putInt(plNewRec.groupId());
            buf.putLong(plNewRec.pageId());
            buf.putInt(plNewRec.ioType());
            buf.putInt(plNewRec.ioVersion());
            buf.putLong(plNewRec.newPageId());
            buf.putLong(plNewRec.previousPageId());
            buf.putLong(plNewRec.dataPageId());
            break;
        case PAGES_LIST_ADD_PAGE:
            PagesListAddPageRecord plAddRec = (PagesListAddPageRecord) rec;
            buf.putInt(plAddRec.groupId());
            buf.putLong(plAddRec.pageId());
            buf.putLong(plAddRec.dataPageId());
            break;
        case PAGES_LIST_REMOVE_PAGE:
            PagesListRemovePageRecord plRmvRec = (PagesListRemovePageRecord) rec;
            buf.putInt(plRmvRec.groupId());
            buf.putLong(plRmvRec.pageId());
            buf.putLong(plRmvRec.removedPageId());
            break;
        case BTREE_FIX_REMOVE_ID:
            FixRemoveId frRec = (FixRemoveId) rec;
            buf.putInt(frRec.groupId());
            buf.putLong(frRec.pageId());
            buf.putLong(frRec.removeId());
            break;
        case TRACKING_PAGE_DELTA:
            TrackingPageDeltaRecord tpDelta = (TrackingPageDeltaRecord) rec;
            buf.putInt(tpDelta.groupId());
            buf.putLong(tpDelta.pageId());
            buf.putLong(tpDelta.pageIdToMark());
            buf.putLong(tpDelta.nextSnapshotId());
            buf.putLong(tpDelta.lastSuccessfulSnapshotId());
            break;
        case META_PAGE_UPDATE_NEXT_SNAPSHOT_ID:
            MetaPageUpdateNextSnapshotId mpUpdateNextSnapshotId = (MetaPageUpdateNextSnapshotId) rec;
            buf.putInt(mpUpdateNextSnapshotId.groupId());
            buf.putLong(mpUpdateNextSnapshotId.pageId());
            buf.putLong(mpUpdateNextSnapshotId.nextSnapshotId());
            break;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID:
            MetaPageUpdateLastSuccessfulFullSnapshotId mpUpdateLastSuccFullSnapshotId = (MetaPageUpdateLastSuccessfulFullSnapshotId) rec;
            buf.putInt(mpUpdateLastSuccFullSnapshotId.groupId());
            buf.putLong(mpUpdateLastSuccFullSnapshotId.pageId());
            buf.putLong(mpUpdateLastSuccFullSnapshotId.lastSuccessfulFullSnapshotId());
            break;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID:
            MetaPageUpdateLastSuccessfulSnapshotId mpUpdateLastSuccSnapshotId = (MetaPageUpdateLastSuccessfulSnapshotId) rec;
            buf.putInt(mpUpdateLastSuccSnapshotId.groupId());
            buf.putLong(mpUpdateLastSuccSnapshotId.pageId());
            buf.putLong(mpUpdateLastSuccSnapshotId.lastSuccessfulSnapshotId());
            buf.putLong(mpUpdateLastSuccSnapshotId.lastSuccessfulSnapshotTag());
            break;
        case META_PAGE_UPDATE_LAST_ALLOCATED_INDEX:
            MetaPageUpdateLastAllocatedIndex mpUpdateLastAllocatedIdx = (MetaPageUpdateLastAllocatedIndex) rec;
            buf.putInt(mpUpdateLastAllocatedIdx.groupId());
            buf.putLong(mpUpdateLastAllocatedIdx.pageId());
            buf.putInt(mpUpdateLastAllocatedIdx.lastAllocatedIndex());
            break;
        case PART_META_UPDATE_STATE:
            PartitionMetaStateRecord partMetaStateRecord = (PartitionMetaStateRecord) rec;
            buf.putInt(partMetaStateRecord.groupId());
            buf.putInt(partMetaStateRecord.partitionId());
            buf.put(partMetaStateRecord.state());
            buf.putLong(partMetaStateRecord.updateCounter());
            break;
        case PAGE_LIST_META_RESET_COUNT_RECORD:
            PageListMetaResetCountRecord pageListMetaResetCntRecord = (PageListMetaResetCountRecord) rec;
            buf.putInt(pageListMetaResetCntRecord.groupId());
            buf.putLong(pageListMetaResetCntRecord.pageId());
            break;
        case TX_RECORD:
            txRecordSerializer.write((TxRecord) rec, buf);
            break;
        case SWITCH_SEGMENT_RECORD:
            break;
        default:
            throw new UnsupportedOperationException("Type: " + rec.type());
    }
}
Also used : PagesListSetPreviousRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetPreviousRecord) DataPageRemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord) RecycleRecord(org.apache.ignite.internal.pagemem.wal.record.delta.RecycleRecord) MetaPageInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord) MetaPageUpdateLastSuccessfulFullSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastSuccessfulFullSnapshotId) FixLeftmostChildRecord(org.apache.ignite.internal.pagemem.wal.record.delta.FixLeftmostChildRecord) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) LazyDataEntry(org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry) SplitForwardPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.SplitForwardPageRecord) PagesListAddPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListAddPageRecord) MetaPageUpdateNextSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateNextSnapshotId) UUID(java.util.UUID) ReplaceRecord(org.apache.ignite.internal.pagemem.wal.record.delta.ReplaceRecord) InnerReplaceRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InnerReplaceRecord) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) FileWALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer) DataPageSetFreeListPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord) NewRootInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.NewRootInitRecord) MetaPageUpdateLastAllocatedIndex(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastAllocatedIndex) DataPageInsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord) InsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InsertRecord) PartitionMetaStateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord) MetaPageCutRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageCutRootRecord) MetaPageAddRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageAddRootRecord) MetaPageInitRootInlineRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRootInlineRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) InnerReplaceRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InnerReplaceRecord) DataPageUpdateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageUpdateRecord) PageListMetaResetCountRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PageListMetaResetCountRecord) PagesListRemovePageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListRemovePageRecord) TrackingPageDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageDeltaRecord) RemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.RemoveRecord) DataPageRemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord) MemoryRecoveryRecord(org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord) FixRemoveId(org.apache.ignite.internal.pagemem.wal.record.delta.FixRemoveId) PartitionDestroyRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionDestroyRecord) PagesListInitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord) InitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord) MetaPageUpdatePartitionDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord) MetaPageUpdateLastSuccessfulSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastSuccessfulSnapshotId) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) MetaPageUpdatePartitionDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord) DataPageInsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord) PagesListInitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord) SplitExistingPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.SplitExistingPageRecord) MergeRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MergeRecord) DataPageInsertFragmentRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertFragmentRecord) PagesListSetNextRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetNextRecord) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) FixCountRecord(org.apache.ignite.internal.pagemem.wal.record.delta.FixCountRecord) MetaPageInitRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRootRecord)

Example 2 with MetastoreDataRecord

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

the class RecordDataV1Serializer method readRecord.

/**
 * {@inheritDoc}
 */
@Override
public WALRecord readRecord(WALRecord.RecordType type, ByteBufferBackedDataInput in) throws IOException, IgniteCheckedException {
    WALRecord res;
    switch(type) {
        case PAGE_RECORD:
            byte[] arr = new byte[pageSize];
            int cacheId = in.readInt();
            long pageId = in.readLong();
            in.readFully(arr);
            res = new PageSnapshot(new FullPageId(pageId, cacheId), arr);
            break;
        case CHECKPOINT_RECORD:
            long msb = in.readLong();
            long lsb = in.readLong();
            boolean hasPtr = in.readByte() != 0;
            int idx = hasPtr ? in.readInt() : 0;
            int off = hasPtr ? in.readInt() : 0;
            int len = hasPtr ? in.readInt() : 0;
            Map<Integer, CacheState> states = readPartitionStates(in);
            boolean end = in.readByte() != 0;
            FileWALPointer walPtr = hasPtr ? new FileWALPointer(idx, off, len) : null;
            CheckpointRecord cpRec = new CheckpointRecord(new UUID(msb, lsb), walPtr, end);
            cpRec.cacheGroupStates(states);
            res = cpRec;
            break;
        case META_PAGE_INIT:
            cacheId = in.readInt();
            pageId = in.readLong();
            int ioType = in.readUnsignedShort();
            int ioVer = in.readUnsignedShort();
            long treeRoot = in.readLong();
            long reuseListRoot = in.readLong();
            res = new MetaPageInitRecord(cacheId, pageId, ioType, ioVer, treeRoot, reuseListRoot);
            break;
        case PARTITION_META_PAGE_UPDATE_COUNTERS:
            cacheId = in.readInt();
            pageId = in.readLong();
            long updCntr = in.readLong();
            long rmvId = in.readLong();
            int partSize = in.readInt();
            long countersPageId = in.readLong();
            byte state = in.readByte();
            int allocatedIdxCandidate = in.readInt();
            res = new MetaPageUpdatePartitionDataRecord(cacheId, pageId, updCntr, rmvId, partSize, countersPageId, state, allocatedIdxCandidate);
            break;
        case MEMORY_RECOVERY:
            long ts = in.readLong();
            res = new MemoryRecoveryRecord(ts);
            break;
        case PARTITION_DESTROY:
            cacheId = in.readInt();
            int partId = in.readInt();
            res = new PartitionDestroyRecord(cacheId, partId);
            break;
        case DATA_RECORD:
            int entryCnt = in.readInt();
            List<DataEntry> entries = new ArrayList<>(entryCnt);
            for (int i = 0; i < entryCnt; i++) entries.add(readDataEntry(in));
            res = new DataRecord(entries, 0L);
            break;
        case METASTORE_DATA_RECORD:
            int strLen = in.readInt();
            byte[] strBytes = new byte[strLen];
            in.readFully(strBytes);
            String key = new String(strBytes);
            int valLen = in.readInt();
            assert valLen >= 0;
            byte[] val;
            if (valLen > 0) {
                val = new byte[valLen];
                in.readFully(val);
            } else
                val = null;
            return new MetastoreDataRecord(key, val);
        case HEADER_RECORD:
            long magic = in.readLong();
            if (magic != HeaderRecord.REGULAR_MAGIC && magic != HeaderRecord.COMPACTED_MAGIC)
                throw new EOFException("Magic is corrupted [actual=" + U.hexLong(magic) + ']');
            int ver = in.readInt();
            res = new HeaderRecord(ver);
            break;
        case DATA_PAGE_INSERT_RECORD:
            {
                cacheId = in.readInt();
                pageId = in.readLong();
                int size = in.readUnsignedShort();
                in.ensure(size);
                byte[] payload = new byte[size];
                in.readFully(payload);
                res = new DataPageInsertRecord(cacheId, pageId, payload);
                break;
            }
        case DATA_PAGE_UPDATE_RECORD:
            {
                cacheId = in.readInt();
                pageId = in.readLong();
                int itemId = in.readInt();
                int size = in.readUnsignedShort();
                in.ensure(size);
                byte[] payload = new byte[size];
                in.readFully(payload);
                res = new DataPageUpdateRecord(cacheId, pageId, itemId, payload);
                break;
            }
        case DATA_PAGE_INSERT_FRAGMENT_RECORD:
            {
                cacheId = in.readInt();
                pageId = in.readLong();
                final long lastLink = in.readLong();
                final int payloadSize = in.readInt();
                final byte[] payload = new byte[payloadSize];
                in.readFully(payload);
                res = new DataPageInsertFragmentRecord(cacheId, pageId, payload, lastLink);
                break;
            }
        case DATA_PAGE_REMOVE_RECORD:
            cacheId = in.readInt();
            pageId = in.readLong();
            int itemId = in.readUnsignedByte();
            res = new DataPageRemoveRecord(cacheId, pageId, itemId);
            break;
        case DATA_PAGE_SET_FREE_LIST_PAGE:
            cacheId = in.readInt();
            pageId = in.readLong();
            long freeListPage = in.readLong();
            res = new DataPageSetFreeListPageRecord(cacheId, pageId, freeListPage);
            break;
        case INIT_NEW_PAGE_RECORD:
            cacheId = in.readInt();
            pageId = in.readLong();
            ioType = in.readUnsignedShort();
            ioVer = in.readUnsignedShort();
            long virtualPageId = in.readLong();
            res = new InitNewPageRecord(cacheId, pageId, ioType, ioVer, virtualPageId);
            break;
        case BTREE_META_PAGE_INIT_ROOT:
            cacheId = in.readInt();
            pageId = in.readLong();
            long rootId = in.readLong();
            res = new MetaPageInitRootRecord(cacheId, pageId, rootId);
            break;
        case BTREE_META_PAGE_INIT_ROOT2:
            cacheId = in.readInt();
            pageId = in.readLong();
            long rootId2 = in.readLong();
            int inlineSize = in.readShort();
            res = new MetaPageInitRootInlineRecord(cacheId, pageId, rootId2, inlineSize);
            break;
        case BTREE_META_PAGE_ADD_ROOT:
            cacheId = in.readInt();
            pageId = in.readLong();
            rootId = in.readLong();
            res = new MetaPageAddRootRecord(cacheId, pageId, rootId);
            break;
        case BTREE_META_PAGE_CUT_ROOT:
            cacheId = in.readInt();
            pageId = in.readLong();
            res = new MetaPageCutRootRecord(cacheId, pageId);
            break;
        case BTREE_INIT_NEW_ROOT:
            cacheId = in.readInt();
            pageId = in.readLong();
            rootId = in.readLong();
            ioType = in.readUnsignedShort();
            ioVer = in.readUnsignedShort();
            long leftId = in.readLong();
            long rightId = in.readLong();
            BPlusIO<?> io = BPlusIO.getBPlusIO(ioType, ioVer);
            byte[] rowBytes = new byte[io.getItemSize()];
            in.readFully(rowBytes);
            res = new NewRootInitRecord<>(cacheId, pageId, rootId, (BPlusInnerIO<?>) io, leftId, rowBytes, rightId);
            break;
        case BTREE_PAGE_RECYCLE:
            cacheId = in.readInt();
            pageId = in.readLong();
            long newPageId = in.readLong();
            res = new RecycleRecord(cacheId, pageId, newPageId);
            break;
        case BTREE_PAGE_INSERT:
            cacheId = in.readInt();
            pageId = in.readLong();
            ioType = in.readUnsignedShort();
            ioVer = in.readUnsignedShort();
            int itemIdx = in.readUnsignedShort();
            rightId = in.readLong();
            io = BPlusIO.getBPlusIO(ioType, ioVer);
            rowBytes = new byte[io.getItemSize()];
            in.readFully(rowBytes);
            res = new InsertRecord<>(cacheId, pageId, io, itemIdx, rowBytes, rightId);
            break;
        case BTREE_FIX_LEFTMOST_CHILD:
            cacheId = in.readInt();
            pageId = in.readLong();
            rightId = in.readLong();
            res = new FixLeftmostChildRecord(cacheId, pageId, rightId);
            break;
        case BTREE_FIX_COUNT:
            cacheId = in.readInt();
            pageId = in.readLong();
            int cnt = in.readUnsignedShort();
            res = new FixCountRecord(cacheId, pageId, cnt);
            break;
        case BTREE_PAGE_REPLACE:
            cacheId = in.readInt();
            pageId = in.readLong();
            ioType = in.readUnsignedShort();
            ioVer = in.readUnsignedShort();
            itemIdx = in.readUnsignedShort();
            io = BPlusIO.getBPlusIO(ioType, ioVer);
            rowBytes = new byte[io.getItemSize()];
            in.readFully(rowBytes);
            res = new ReplaceRecord<>(cacheId, pageId, io, rowBytes, itemIdx);
            break;
        case BTREE_PAGE_REMOVE:
            cacheId = in.readInt();
            pageId = in.readLong();
            itemIdx = in.readUnsignedShort();
            cnt = in.readUnsignedShort();
            res = new RemoveRecord(cacheId, pageId, itemIdx, cnt);
            break;
        case BTREE_PAGE_INNER_REPLACE:
            cacheId = in.readInt();
            pageId = in.readLong();
            int dstIdx = in.readUnsignedShort();
            long srcPageId = in.readLong();
            int srcIdx = in.readUnsignedShort();
            rmvId = in.readLong();
            res = new InnerReplaceRecord<>(cacheId, pageId, dstIdx, srcPageId, srcIdx, rmvId);
            break;
        case BTREE_FORWARD_PAGE_SPLIT:
            cacheId = in.readInt();
            pageId = in.readLong();
            long fwdId = in.readLong();
            ioType = in.readUnsignedShort();
            ioVer = in.readUnsignedShort();
            srcPageId = in.readLong();
            int mid = in.readUnsignedShort();
            cnt = in.readUnsignedShort();
            res = new SplitForwardPageRecord(cacheId, pageId, fwdId, ioType, ioVer, srcPageId, mid, cnt);
            break;
        case BTREE_EXISTING_PAGE_SPLIT:
            cacheId = in.readInt();
            pageId = in.readLong();
            mid = in.readUnsignedShort();
            fwdId = in.readLong();
            res = new SplitExistingPageRecord(cacheId, pageId, mid, fwdId);
            break;
        case BTREE_PAGE_MERGE:
            cacheId = in.readInt();
            pageId = in.readLong();
            long prntId = in.readLong();
            int prntIdx = in.readUnsignedShort();
            rightId = in.readLong();
            boolean emptyBranch = in.readBoolean();
            res = new MergeRecord<>(cacheId, pageId, prntId, prntIdx, rightId, emptyBranch);
            break;
        case BTREE_FIX_REMOVE_ID:
            cacheId = in.readInt();
            pageId = in.readLong();
            rmvId = in.readLong();
            res = new FixRemoveId(cacheId, pageId, rmvId);
            break;
        case PAGES_LIST_SET_NEXT:
            cacheId = in.readInt();
            pageId = in.readLong();
            long nextPageId = in.readLong();
            res = new PagesListSetNextRecord(cacheId, pageId, nextPageId);
            break;
        case PAGES_LIST_SET_PREVIOUS:
            cacheId = in.readInt();
            pageId = in.readLong();
            long prevPageId = in.readLong();
            res = new PagesListSetPreviousRecord(cacheId, pageId, prevPageId);
            break;
        case PAGES_LIST_INIT_NEW_PAGE:
            cacheId = in.readInt();
            pageId = in.readLong();
            ioType = in.readInt();
            ioVer = in.readInt();
            newPageId = in.readLong();
            prevPageId = in.readLong();
            long addDataPageId = in.readLong();
            res = new PagesListInitNewPageRecord(cacheId, pageId, ioType, ioVer, newPageId, prevPageId, addDataPageId);
            break;
        case PAGES_LIST_ADD_PAGE:
            cacheId = in.readInt();
            pageId = in.readLong();
            long dataPageId = in.readLong();
            res = new PagesListAddPageRecord(cacheId, pageId, dataPageId);
            break;
        case PAGES_LIST_REMOVE_PAGE:
            cacheId = in.readInt();
            pageId = in.readLong();
            long rmvdPageId = in.readLong();
            res = new PagesListRemovePageRecord(cacheId, pageId, rmvdPageId);
            break;
        case TRACKING_PAGE_DELTA:
            cacheId = in.readInt();
            pageId = in.readLong();
            long pageIdToMark = in.readLong();
            long nextSnapshotId0 = in.readLong();
            long lastSuccessfulSnapshotId0 = in.readLong();
            res = new TrackingPageDeltaRecord(cacheId, pageId, pageIdToMark, nextSnapshotId0, lastSuccessfulSnapshotId0);
            break;
        case META_PAGE_UPDATE_NEXT_SNAPSHOT_ID:
            cacheId = in.readInt();
            pageId = in.readLong();
            long nextSnapshotId = in.readLong();
            res = new MetaPageUpdateNextSnapshotId(cacheId, pageId, nextSnapshotId);
            break;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID:
            cacheId = in.readInt();
            pageId = in.readLong();
            long lastSuccessfulFullSnapshotId = in.readLong();
            res = new MetaPageUpdateLastSuccessfulFullSnapshotId(cacheId, pageId, lastSuccessfulFullSnapshotId);
            break;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID:
            cacheId = in.readInt();
            pageId = in.readLong();
            long lastSuccessfulSnapshotId = in.readLong();
            long lastSuccessfulSnapshotTag = in.readLong();
            res = new MetaPageUpdateLastSuccessfulSnapshotId(cacheId, pageId, lastSuccessfulSnapshotId, lastSuccessfulSnapshotTag);
            break;
        case META_PAGE_UPDATE_LAST_ALLOCATED_INDEX:
            cacheId = in.readInt();
            pageId = in.readLong();
            int lastAllocatedIdx = in.readInt();
            res = new MetaPageUpdateLastAllocatedIndex(cacheId, pageId, lastAllocatedIdx);
            break;
        case PART_META_UPDATE_STATE:
            cacheId = in.readInt();
            partId = in.readInt();
            state = in.readByte();
            long updateCntr = in.readLong();
            GridDhtPartitionState partState = GridDhtPartitionState.fromOrdinal(state);
            res = new PartitionMetaStateRecord(cacheId, partId, partState, updateCntr);
            break;
        case PAGE_LIST_META_RESET_COUNT_RECORD:
            cacheId = in.readInt();
            pageId = in.readLong();
            res = new PageListMetaResetCountRecord(cacheId, pageId);
            break;
        case SWITCH_SEGMENT_RECORD:
            throw new EOFException("END OF SEGMENT");
        case TX_RECORD:
            res = txRecordSerializer.read(in);
            break;
        default:
            throw new UnsupportedOperationException("Type: " + type);
    }
    return res;
}
Also used : PagesListSetPreviousRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetPreviousRecord) DataPageRemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord) ArrayList(java.util.ArrayList) RecycleRecord(org.apache.ignite.internal.pagemem.wal.record.delta.RecycleRecord) MetaPageInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord) MetaPageUpdateLastSuccessfulFullSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastSuccessfulFullSnapshotId) FixLeftmostChildRecord(org.apache.ignite.internal.pagemem.wal.record.delta.FixLeftmostChildRecord) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) LazyDataEntry(org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry) SplitForwardPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.SplitForwardPageRecord) HeaderRecord(org.apache.ignite.internal.processors.cache.persistence.wal.record.HeaderRecord) PagesListAddPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListAddPageRecord) EOFException(java.io.EOFException) MetaPageUpdateNextSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateNextSnapshotId) UUID(java.util.UUID) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) FileWALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer) DataPageSetFreeListPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord) MetaPageUpdateLastAllocatedIndex(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastAllocatedIndex) PartitionMetaStateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord) BPlusInnerIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusInnerIO) MetaPageCutRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageCutRootRecord) CacheState(org.apache.ignite.internal.pagemem.wal.record.CacheState) MetaPageAddRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageAddRootRecord) MetaPageInitRootInlineRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRootInlineRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) DataPageUpdateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageUpdateRecord) PageListMetaResetCountRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PageListMetaResetCountRecord) PagesListRemovePageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListRemovePageRecord) TrackingPageDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.TrackingPageDeltaRecord) RemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.RemoveRecord) DataPageRemoveRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord) MemoryRecoveryRecord(org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord) FixRemoveId(org.apache.ignite.internal.pagemem.wal.record.delta.FixRemoveId) PartitionDestroyRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionDestroyRecord) PagesListInitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord) InitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord) MetaPageUpdatePartitionDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord) MetaPageUpdateLastSuccessfulSnapshotId(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateLastSuccessfulSnapshotId) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) MetaPageUpdatePartitionDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord) DataPageInsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord) PagesListInitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord) SplitExistingPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.SplitExistingPageRecord) DataPageInsertFragmentRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertFragmentRecord) PagesListSetNextRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetNextRecord) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) FixCountRecord(org.apache.ignite.internal.pagemem.wal.record.delta.FixCountRecord) MetaPageInitRootRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRootRecord)

Example 3 with MetastoreDataRecord

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

the class MetaStorage method removeData.

/**
 */
public void removeData(String key) throws IgniteCheckedException {
    if (!readOnly) {
        WALPointer ptr = wal.log(new MetastoreDataRecord(key, null));
        wal.fsync(ptr);
        synchronized (this) {
            MetastorageDataRow row = new MetastorageDataRow(key, null);
            MetastorageDataRow oldRow = tree.findOne(row);
            if (oldRow != null) {
                tree.removex(oldRow);
                tree.rowStore().removeRow(oldRow.link());
            }
        }
    }
}
Also used : MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer)

Example 4 with MetastoreDataRecord

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

the class RecordDataV1Serializer method size.

/**
 * {@inheritDoc}
 */
@Override
public int size(WALRecord record) throws IgniteCheckedException {
    switch(record.type()) {
        case PAGE_RECORD:
            assert record instanceof PageSnapshot;
            PageSnapshot pageRec = (PageSnapshot) record;
            return pageRec.pageData().length + 12;
        case CHECKPOINT_RECORD:
            CheckpointRecord cpRec = (CheckpointRecord) record;
            assert cpRec.checkpointMark() == null || cpRec.checkpointMark() instanceof FileWALPointer : "Invalid WAL record: " + cpRec;
            int cacheStatesSize = cacheStatesSize(cpRec.cacheGroupStates());
            FileWALPointer walPtr = (FileWALPointer) cpRec.checkpointMark();
            return 18 + cacheStatesSize + (walPtr == null ? 0 : 16);
        case META_PAGE_INIT:
            return /*cache ID*/
            4 + /*page ID*/
            8 + /*ioType*/
            2 + /*ioVer*/
            2 + /*tree root*/
            8 + /*reuse root*/
            8;
        case PARTITION_META_PAGE_UPDATE_COUNTERS:
            return /*cache ID*/
            4 + /*page ID*/
            8 + /*upd cntr*/
            8 + /*rmv id*/
            8 + /*part size*/
            4 + /*counters page id*/
            8 + /*state*/
            1 + /*allocatedIdxCandidate*/
            4;
        case MEMORY_RECOVERY:
            return 8;
        case PARTITION_DESTROY:
            return /*cacheId*/
            4 + /*partId*/
            4;
        case DATA_RECORD:
            DataRecord dataRec = (DataRecord) record;
            return 4 + dataSize(dataRec);
        case METASTORE_DATA_RECORD:
            MetastoreDataRecord metastoreDataRec = (MetastoreDataRecord) record;
            return 4 + metastoreDataRec.key().getBytes().length + 4 + (metastoreDataRec.value() != null ? metastoreDataRec.value().length : 0);
        case HEADER_RECORD:
            return HEADER_RECORD_DATA_SIZE;
        case DATA_PAGE_INSERT_RECORD:
            DataPageInsertRecord diRec = (DataPageInsertRecord) record;
            return 4 + 8 + 2 + diRec.payload().length;
        case DATA_PAGE_UPDATE_RECORD:
            DataPageUpdateRecord uRec = (DataPageUpdateRecord) record;
            return 4 + 8 + 2 + 4 + uRec.payload().length;
        case DATA_PAGE_INSERT_FRAGMENT_RECORD:
            final DataPageInsertFragmentRecord difRec = (DataPageInsertFragmentRecord) record;
            return 4 + 8 + 8 + 4 + difRec.payloadSize();
        case DATA_PAGE_REMOVE_RECORD:
            return 4 + 8 + 1;
        case DATA_PAGE_SET_FREE_LIST_PAGE:
            return 4 + 8 + 8;
        case INIT_NEW_PAGE_RECORD:
            return 4 + 8 + 2 + 2 + 8;
        case BTREE_META_PAGE_INIT_ROOT:
            return 4 + 8 + 8;
        case BTREE_META_PAGE_INIT_ROOT2:
            return 4 + 8 + 8 + 2;
        case BTREE_META_PAGE_ADD_ROOT:
            return 4 + 8 + 8;
        case BTREE_META_PAGE_CUT_ROOT:
            return 4 + 8;
        case BTREE_INIT_NEW_ROOT:
            NewRootInitRecord<?> riRec = (NewRootInitRecord<?>) record;
            return 4 + 8 + 8 + 2 + 2 + 8 + 8 + riRec.io().getItemSize();
        case BTREE_PAGE_RECYCLE:
            return 4 + 8 + 8;
        case BTREE_PAGE_INSERT:
            InsertRecord<?> inRec = (InsertRecord<?>) record;
            return 4 + 8 + 2 + 2 + 2 + 8 + inRec.io().getItemSize();
        case BTREE_FIX_LEFTMOST_CHILD:
            return 4 + 8 + 8;
        case BTREE_FIX_COUNT:
            return 4 + 8 + 2;
        case BTREE_PAGE_REPLACE:
            ReplaceRecord<?> rRec = (ReplaceRecord<?>) record;
            return 4 + 8 + 2 + 2 + 2 + rRec.io().getItemSize();
        case BTREE_PAGE_REMOVE:
            return 4 + 8 + 2 + 2;
        case BTREE_PAGE_INNER_REPLACE:
            return 4 + 8 + 2 + 8 + 2 + 8;
        case BTREE_FORWARD_PAGE_SPLIT:
            return 4 + 8 + 8 + 2 + 2 + 8 + 2 + 2;
        case BTREE_EXISTING_PAGE_SPLIT:
            return 4 + 8 + 2 + 8;
        case BTREE_PAGE_MERGE:
            return 4 + 8 + 8 + 2 + 8 + 1;
        case BTREE_FIX_REMOVE_ID:
            return 4 + 8 + 8;
        case PAGES_LIST_SET_NEXT:
            return 4 + 8 + 8;
        case PAGES_LIST_SET_PREVIOUS:
            return 4 + 8 + 8;
        case PAGES_LIST_INIT_NEW_PAGE:
            return 4 + 8 + 4 + 4 + 8 + 8 + 8;
        case PAGES_LIST_ADD_PAGE:
            return 4 + 8 + 8;
        case PAGES_LIST_REMOVE_PAGE:
            return 4 + 8 + 8;
        case TRACKING_PAGE_DELTA:
            return 4 + 8 + 8 + 8 + 8;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID:
            return 4 + 8 + 8 + 8;
        case META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID:
            return 4 + 8 + 8;
        case META_PAGE_UPDATE_NEXT_SNAPSHOT_ID:
            return 4 + 8 + 8;
        case META_PAGE_UPDATE_LAST_ALLOCATED_INDEX:
            return 4 + 8 + 4;
        case PART_META_UPDATE_STATE:
            return /*cacheId*/
            4 + /*partId*/
            4 + /*State*/
            1 + /*Update Counter*/
            8;
        case PAGE_LIST_META_RESET_COUNT_RECORD:
            return /*cacheId*/
            4 + /*pageId*/
            8;
        case SWITCH_SEGMENT_RECORD:
            return 0;
        case TX_RECORD:
            return txRecordSerializer.size((TxRecord) record);
        default:
            throw new UnsupportedOperationException("Type: " + record.type());
    }
}
Also used : DataPageInsertFragmentRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertFragmentRecord) FileWALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer) NewRootInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.NewRootInitRecord) DataPageInsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord) InsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InsertRecord) DataPageUpdateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageUpdateRecord) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) MetaPageUpdatePartitionDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord) DataPageInsertRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord) ReplaceRecord(org.apache.ignite.internal.pagemem.wal.record.delta.ReplaceRecord) InnerReplaceRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InnerReplaceRecord) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)

Example 5 with MetastoreDataRecord

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

the class GridCacheDatabaseSharedManager method applyLastUpdates.

/**
 * @param status Last registered checkpoint status.
 * @throws IgniteCheckedException If failed to apply updates.
 * @throws StorageException If IO exception occurred while reading write-ahead log.
 */
private void applyLastUpdates(CheckpointStatus status, boolean metastoreOnly) throws IgniteCheckedException {
    if (log.isInfoEnabled())
        log.info("Applying lost cache updates since last checkpoint record [lastMarked=" + status.startPtr + ", lastCheckpointId=" + status.cpStartId + ']');
    if (!metastoreOnly)
        cctx.kernalContext().query().skipFieldLookup(true);
    long start = U.currentTimeMillis();
    int applied = 0;
    Collection<Integer> ignoreGrps = metastoreOnly ? Collections.emptySet() : initiallyWalDisabledGrps;
    try (WALIterator it = cctx.wal().replay(status.startPtr)) {
        Map<T2<Integer, Integer>, T2<Integer, Long>> partStates = new HashMap<>();
        while (it.hasNextX()) {
            IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();
            WALRecord rec = next.get2();
            switch(rec.type()) {
                case DATA_RECORD:
                    if (metastoreOnly)
                        continue;
                    DataRecord dataRec = (DataRecord) rec;
                    for (DataEntry dataEntry : dataRec.writeEntries()) {
                        int cacheId = dataEntry.cacheId();
                        int grpId = cctx.cache().cacheDescriptor(cacheId).groupId();
                        if (!ignoreGrps.contains(grpId)) {
                            GridCacheContext cacheCtx = cctx.cacheContext(cacheId);
                            applyUpdate(cacheCtx, dataEntry);
                            applied++;
                        }
                    }
                    break;
                case PART_META_UPDATE_STATE:
                    if (metastoreOnly)
                        continue;
                    PartitionMetaStateRecord metaStateRecord = (PartitionMetaStateRecord) rec;
                    if (!ignoreGrps.contains(metaStateRecord.groupId())) {
                        partStates.put(new T2<>(metaStateRecord.groupId(), metaStateRecord.partitionId()), new T2<>((int) metaStateRecord.state(), metaStateRecord.updateCounter()));
                    }
                    break;
                case METASTORE_DATA_RECORD:
                    MetastoreDataRecord metastoreDataRecord = (MetastoreDataRecord) rec;
                    metaStorage.applyUpdate(metastoreDataRecord.key(), metastoreDataRecord.value());
                    break;
                case META_PAGE_UPDATE_NEXT_SNAPSHOT_ID:
                case META_PAGE_UPDATE_LAST_SUCCESSFUL_SNAPSHOT_ID:
                case META_PAGE_UPDATE_LAST_SUCCESSFUL_FULL_SNAPSHOT_ID:
                    if (metastoreOnly)
                        continue;
                    PageDeltaRecord rec0 = (PageDeltaRecord) rec;
                    PageMemoryEx pageMem = getPageMemoryForCacheGroup(rec0.groupId());
                    long page = pageMem.acquirePage(rec0.groupId(), rec0.pageId(), true);
                    try {
                        long addr = pageMem.writeLock(rec0.groupId(), rec0.pageId(), page, true);
                        try {
                            rec0.applyDelta(pageMem, addr);
                        } finally {
                            pageMem.writeUnlock(rec0.groupId(), rec0.pageId(), page, null, true, true);
                        }
                    } finally {
                        pageMem.releasePage(rec0.groupId(), rec0.pageId(), page);
                    }
                    break;
                default:
            }
        }
        if (!metastoreOnly)
            restorePartitionState(partStates, ignoreGrps);
    } finally {
        if (!metastoreOnly)
            cctx.kernalContext().query().skipFieldLookup(false);
    }
    if (log.isInfoEnabled())
        log.info("Finished applying WAL changes [updatesApplied=" + applied + ", time=" + (U.currentTimeMillis() - start) + "ms]");
}
Also used : WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) PartitionMetaStateRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord) PageDeltaRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) MetastoreDataRecord(org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer) FileWALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer) T2(org.apache.ignite.internal.util.typedef.T2)

Aggregations

MetastoreDataRecord (org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord)6 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)4 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)3 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)3 PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)3 DataPageInsertFragmentRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertFragmentRecord)3 DataPageInsertRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord)3 DataPageUpdateRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageUpdateRecord)3 MetaPageUpdatePartitionDataRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdatePartitionDataRecord)3 PartitionMetaStateRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PartitionMetaStateRecord)3 UUID (java.util.UUID)2 WALPointer (org.apache.ignite.internal.pagemem.wal.WALPointer)2 LazyDataEntry (org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry)2 MemoryRecoveryRecord (org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord)2 DataPageRemoveRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord)2 DataPageSetFreeListPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord)2 FixCountRecord (org.apache.ignite.internal.pagemem.wal.record.delta.FixCountRecord)2 FixLeftmostChildRecord (org.apache.ignite.internal.pagemem.wal.record.delta.FixLeftmostChildRecord)2 FixRemoveId (org.apache.ignite.internal.pagemem.wal.record.delta.FixRemoveId)2 InitNewPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord)2