Search in sources :

Example 1 with DiskRegionFlag

use of org.apache.geode.internal.cache.DiskInitFile.DiskRegionFlag in project geode by apache.

the class DiskInitFileParser method parse.

public DiskStoreID parse() throws IOException, ClassNotFoundException {
    Version gfversion = Version.GFE_662;
    DiskStoreID result = null;
    boolean endOfFile = false;
    while (!endOfFile) {
        if (dis.atEndOfFile()) {
            endOfFile = true;
            break;
        }
        byte opCode = dis.readByte();
        if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
            logger.trace(LogMarker.PERSIST_RECOVERY, "DiskInitFile opcode={}", opCode);
        }
        switch(opCode) {
            case DiskInitFile.IF_EOF_ID:
                endOfFile = true;
                gotEOF = true;
                break;
            case DiskInitFile.IFREC_INSTANTIATOR_ID:
                {
                    int id = dis.readInt();
                    String cn = readClassName(dis);
                    String icn = readClassName(dis);
                    readEndOfRecord(dis);
                    interpreter.cmnInstantiatorId(id, cn, icn);
                }
                break;
            case DiskInitFile.IFREC_DATA_SERIALIZER_ID:
                {
                    Class<?> dsc = readClass(dis);
                    readEndOfRecord(dis);
                    interpreter.cmnDataSerializerId(dsc);
                }
                break;
            case DiskInitFile.IFREC_ONLINE_MEMBER_ID:
                {
                    long drId = readDiskRegionID(dis);
                    PersistentMemberID pmid = readPMID(dis, gfversion);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_ONLINE_MEMBER_ID drId={} omid={}", drId, pmid);
                    }
                    interpreter.cmnOnlineMemberId(drId, pmid);
                }
                break;
            case DiskInitFile.IFREC_OFFLINE_MEMBER_ID:
                {
                    long drId = readDiskRegionID(dis);
                    PersistentMemberID pmid = readPMID(dis, gfversion);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_OFFLINE_MEMBER_ID drId={} pmid={}", drId, pmid);
                    }
                    interpreter.cmnOfflineMemberId(drId, pmid);
                }
                break;
            case DiskInitFile.IFREC_RM_MEMBER_ID:
                {
                    long drId = readDiskRegionID(dis);
                    PersistentMemberID pmid = readPMID(dis, gfversion);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_RM_MEMBER_ID drId={} pmid={}", drId, pmid);
                    }
                    interpreter.cmnRmMemberId(drId, pmid);
                }
                break;
            case DiskInitFile.IFREC_MY_MEMBER_INITIALIZING_ID:
                {
                    long drId = readDiskRegionID(dis);
                    PersistentMemberID pmid = readPMID(dis, gfversion);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_MY_MEMBER_INITIALIZING_ID drId={} pmid={}", drId, pmid);
                    }
                    interpreter.cmnAddMyInitializingPMID(drId, pmid);
                }
                break;
            case DiskInitFile.IFREC_MY_MEMBER_INITIALIZED_ID:
                {
                    long drId = readDiskRegionID(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_MY_MEMBER_INITIALIZED_ID drId={}", drId);
                    }
                    interpreter.cmnMarkInitialized(drId);
                }
                break;
            case DiskInitFile.IFREC_CREATE_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    String regName = dis.readUTF();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_CREATE_REGION_ID drId= name={}", drId, regName);
                    }
                    interpreter.cmnCreateRegion(drId, regName);
                }
                break;
            case DiskInitFile.IFREC_BEGIN_DESTROY_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_BEGIN_DESTROY_REGION_ID drId={}", drId);
                    }
                    interpreter.cmnBeginDestroyRegion(drId);
                }
                break;
            case DiskInitFile.IFREC_END_DESTROY_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_END_DESTROY_REGION_ID drId={}", drId);
                    }
                    interpreter.cmnEndDestroyRegion(drId);
                }
                break;
            case DiskInitFile.IFREC_BEGIN_PARTIAL_DESTROY_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_BEGIN_PARTIAL_DESTROY_REGION_ID drId={}", drId);
                    }
                    interpreter.cmnBeginPartialDestroyRegion(drId);
                }
                break;
            case DiskInitFile.IFREC_END_PARTIAL_DESTROY_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_END_PARTIAL_DESTROY_REGION_ID drId={}", drId);
                    }
                    interpreter.cmnEndPartialDestroyRegion(drId);
                }
                break;
            case DiskInitFile.IFREC_CLEAR_REGION_ID:
                {
                    long drId = readDiskRegionID(dis);
                    long clearOplogEntryId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_CLEAR_REGION_ID drId={} oplogEntryId={}", drId, clearOplogEntryId);
                    }
                    interpreter.cmnClearRegion(drId, clearOplogEntryId);
                }
                break;
            case DiskInitFile.IFREC_CLEAR_REGION_WITH_RVV_ID:
                {
                    long drId = readDiskRegionID(dis);
                    int size = dis.readInt();
                    ConcurrentHashMap<DiskStoreID, RegionVersionHolder<DiskStoreID>> memberToVersion = new ConcurrentHashMap<DiskStoreID, RegionVersionHolder<DiskStoreID>>(size);
                    for (int i = 0; i < size; i++) {
                        DiskStoreID id = new DiskStoreID();
                        InternalDataSerializer.invokeFromData(id, dis);
                        RegionVersionHolder holder = new RegionVersionHolder(dis);
                        memberToVersion.put(id, holder);
                    }
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_CLEAR_REGION_WITH_RVV_ID drId={} memberToVersion={}", drId, memberToVersion);
                    }
                    interpreter.cmnClearRegion(drId, memberToVersion);
                }
                break;
            case DiskInitFile.IFREC_CRF_CREATE:
                {
                    long oplogId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_CRF_CREATE oplogId={}", oplogId);
                    }
                    interpreter.cmnCrfCreate(oplogId);
                }
                break;
            case DiskInitFile.IFREC_DRF_CREATE:
                {
                    long oplogId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_DRF_CREATE oplogId={}", oplogId);
                    }
                    interpreter.cmnDrfCreate(oplogId);
                }
                break;
            case DiskInitFile.IFREC_KRF_CREATE:
                {
                    long oplogId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_KRF_CREATE oplogId={}", oplogId);
                    }
                    interpreter.cmnKrfCreate(oplogId);
                }
                break;
            case DiskInitFile.IFREC_CRF_DELETE:
                {
                    long oplogId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_CRF_DELETE oplogId={}", oplogId);
                    }
                    interpreter.cmnCrfDelete(oplogId);
                }
                break;
            case DiskInitFile.IFREC_DRF_DELETE:
                {
                    long oplogId = dis.readLong();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_DRF_DELETE oplogId={}", oplogId);
                    }
                    interpreter.cmnDrfDelete(oplogId);
                }
                break;
            case DiskInitFile.IFREC_REGION_CONFIG_ID:
                {
                    long drId = readDiskRegionID(dis);
                    byte lruAlgorithm = dis.readByte();
                    byte lruAction = dis.readByte();
                    int lruLimit = dis.readInt();
                    int concurrencyLevel = dis.readInt();
                    int initialCapacity = dis.readInt();
                    float loadFactor = dis.readFloat();
                    boolean statisticsEnabled = dis.readBoolean();
                    boolean isBucket = dis.readBoolean();
                    EnumSet<DiskRegionFlag> flags = EnumSet.noneOf(DiskRegionFlag.class);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_REGION_CONFIG_ID drId={}", drId);
                    }
                    interpreter.cmnRegionConfig(drId, lruAlgorithm, lruAction, lruLimit, concurrencyLevel, initialCapacity, loadFactor, statisticsEnabled, isBucket, flags, // fixes bug 43910
                    ProxyBucketRegion.NO_FIXED_PARTITION_NAME, -1, null, false);
                }
                break;
            case DiskInitFile.IFREC_REGION_CONFIG_ID_66:
                {
                    long drId = readDiskRegionID(dis);
                    byte lruAlgorithm = dis.readByte();
                    byte lruAction = dis.readByte();
                    int lruLimit = dis.readInt();
                    int concurrencyLevel = dis.readInt();
                    int initialCapacity = dis.readInt();
                    float loadFactor = dis.readFloat();
                    boolean statisticsEnabled = dis.readBoolean();
                    boolean isBucket = dis.readBoolean();
                    EnumSet<DiskRegionFlag> flags = EnumSet.noneOf(DiskRegionFlag.class);
                    String partitionName = dis.readUTF();
                    int startingBucketId = dis.readInt();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_REGION_CONFIG_ID drId={}", drId);
                    }
                    interpreter.cmnRegionConfig(drId, lruAlgorithm, lruAction, lruLimit, concurrencyLevel, initialCapacity, loadFactor, statisticsEnabled, isBucket, flags, partitionName, startingBucketId, null, false);
                }
                break;
            case DiskInitFile.IFREC_REGION_CONFIG_ID_80:
                {
                    long drId = readDiskRegionID(dis);
                    byte lruAlgorithm = dis.readByte();
                    byte lruAction = dis.readByte();
                    int lruLimit = dis.readInt();
                    int concurrencyLevel = dis.readInt();
                    int initialCapacity = dis.readInt();
                    float loadFactor = dis.readFloat();
                    boolean statisticsEnabled = dis.readBoolean();
                    boolean isBucket = dis.readBoolean();
                    EnumSet<DiskRegionFlag> flags = EnumSet.noneOf(DiskRegionFlag.class);
                    String partitionName = dis.readUTF();
                    int startingBucketId = dis.readInt();
                    String compressorClassName = dis.readUTF();
                    if ("".equals(compressorClassName)) {
                        compressorClassName = null;
                    }
                    if (dis.readBoolean()) {
                        flags.add(DiskRegionFlag.IS_WITH_VERSIONING);
                    }
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_REGION_CONFIG_ID drId={}", drId);
                    }
                    interpreter.cmnRegionConfig(drId, lruAlgorithm, lruAction, lruLimit, concurrencyLevel, initialCapacity, loadFactor, statisticsEnabled, isBucket, flags, partitionName, startingBucketId, compressorClassName, false);
                }
                break;
            case DiskInitFile.IFREC_REGION_CONFIG_ID_90:
                {
                    long drId = readDiskRegionID(dis);
                    byte lruAlgorithm = dis.readByte();
                    byte lruAction = dis.readByte();
                    int lruLimit = dis.readInt();
                    int concurrencyLevel = dis.readInt();
                    int initialCapacity = dis.readInt();
                    float loadFactor = dis.readFloat();
                    boolean statisticsEnabled = dis.readBoolean();
                    boolean isBucket = dis.readBoolean();
                    EnumSet<DiskRegionFlag> flags = EnumSet.noneOf(DiskRegionFlag.class);
                    String partitionName = dis.readUTF();
                    int startingBucketId = dis.readInt();
                    String compressorClassName = dis.readUTF();
                    if ("".equals(compressorClassName)) {
                        compressorClassName = null;
                    }
                    if (dis.readBoolean()) {
                        flags.add(DiskRegionFlag.IS_WITH_VERSIONING);
                    }
                    boolean offHeap = dis.readBoolean();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_REGION_CONFIG_ID drId={}", drId);
                    }
                    interpreter.cmnRegionConfig(drId, lruAlgorithm, lruAction, lruLimit, concurrencyLevel, initialCapacity, loadFactor, statisticsEnabled, isBucket, flags, partitionName, startingBucketId, compressorClassName, offHeap);
                }
                break;
            case DiskInitFile.IFREC_OFFLINE_AND_EQUAL_MEMBER_ID:
                {
                    long drId = readDiskRegionID(dis);
                    PersistentMemberID pmid = readPMID(dis, gfversion);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_OFFLINE_AND_EQUAL_MEMBER_ID drId={} pmid={}", drId, pmid);
                    }
                    interpreter.cmdOfflineAndEqualMemberId(drId, pmid);
                }
                break;
            case DiskInitFile.IFREC_DISKSTORE_ID:
                {
                    long leastSigBits = dis.readLong();
                    long mostSigBits = dis.readLong();
                    readEndOfRecord(dis);
                    result = new DiskStoreID(mostSigBits, leastSigBits);
                    interpreter.cmnDiskStoreID(result);
                }
                break;
            case DiskInitFile.OPLOG_MAGIC_SEQ_ID:
                readOplogMagicSeqRecord(dis, OPLOG_TYPE.IF);
                break;
            case DiskInitFile.IFREC_PR_CREATE:
                {
                    String name = dis.readUTF();
                    int numBuckets = dis.readInt();
                    String colocatedWith = dis.readUTF();
                    readEndOfRecord(dis);
                    PRPersistentConfig config = new PRPersistentConfig(numBuckets, colocatedWith);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_PR_CREATE name={}, config={}", name, config);
                    }
                    interpreter.cmnPRCreate(name, config);
                }
                break;
            case DiskInitFile.IFREC_GEMFIRE_VERSION:
                {
                    short ver = Version.readOrdinal(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_GEMFIRE_VERSION version={}", ver);
                    }
                    try {
                        gfversion = Version.fromOrdinal(ver, false);
                    } catch (UnsupportedVersionException e) {
                        throw new DiskAccessException(LocalizedStrings.Oplog_UNEXPECTED_PRODUCT_VERSION_0.toLocalizedString(ver), e, this.interpreter.getNameForError());
                    }
                    interpreter.cmnGemfireVersion(gfversion);
                    break;
                }
            case DiskInitFile.IFREC_PR_DESTROY:
                {
                    String name = dis.readUTF();
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_PR_DESTROY name={}", name);
                    }
                    interpreter.cmnPRDestroy(name);
                }
                break;
            case DiskInitFile.IFREC_ADD_CANONICAL_MEMBER_ID:
                {
                    int id = dis.readInt();
                    Object object = DataSerializer.readObject(dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_ADD_CANONICAL_MEMBER_ID id={} name={}", id, object);
                    }
                    interpreter.cmnAddCanonicalMemberId(id, object);
                    break;
                }
            case DiskInitFile.IFREC_REVOKE_DISK_STORE_ID:
                {
                    PersistentMemberPattern pattern = new PersistentMemberPattern();
                    InternalDataSerializer.invokeFromData(pattern, dis);
                    readEndOfRecord(dis);
                    if (logger.isTraceEnabled(LogMarker.PERSIST_RECOVERY)) {
                        logger.trace(LogMarker.PERSIST_RECOVERY, "IFREC_REVOKE_DISK_STORE_ID id={}" + pattern);
                    }
                    interpreter.cmnRevokeDiskStoreId(pattern);
                }
                break;
            default:
                throw new DiskAccessException(LocalizedStrings.DiskInitFile_UNKNOWN_OPCODE_0_FOUND.toLocalizedString(opCode), this.interpreter.getNameForError());
        }
        if (interpreter.isClosing()) {
            break;
        }
    }
    return result;
}
Also used : EnumSet(java.util.EnumSet) RegionVersionHolder(org.apache.geode.internal.cache.versions.RegionVersionHolder) DiskRegionFlag(org.apache.geode.internal.cache.DiskInitFile.DiskRegionFlag) Version(org.apache.geode.internal.Version) DiskAccessException(org.apache.geode.cache.DiskAccessException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UnsupportedVersionException(org.apache.geode.cache.UnsupportedVersionException)

Aggregations

EnumSet (java.util.EnumSet)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DiskAccessException (org.apache.geode.cache.DiskAccessException)1 UnsupportedVersionException (org.apache.geode.cache.UnsupportedVersionException)1 Version (org.apache.geode.internal.Version)1 DiskRegionFlag (org.apache.geode.internal.cache.DiskInitFile.DiskRegionFlag)1 RegionVersionHolder (org.apache.geode.internal.cache.versions.RegionVersionHolder)1