Skip to content

Commit

Permalink
IGNITE-10558: MVCC: IgniteWalReader fixed. This closes #5583.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMashenkov authored and gvvinblade committed Dec 25, 2018
1 parent 86a815e commit 417fae5
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 71 deletions.
Expand Up @@ -31,7 +31,7 @@
* Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}. <br>
* This Data entry was not converted to key, value pair during record deserialization.
*/
public class LazyDataEntry extends DataEntry {
public class LazyDataEntry extends DataEntry implements MarshalledDataEntry {
/** */
private GridCacheSharedContext cctx;

Expand Down Expand Up @@ -124,23 +124,23 @@ public LazyDataEntry(
return val;
}

/** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */
public byte getKeyType() {
/** {@inheritDoc} */
@Override public byte getKeyType() {
return keyType;
}

/** @return Key value bytes. */
public byte[] getKeyBytes() {
/** {@inheritDoc} */
@Override public byte[] getKeyBytes() {
return keyBytes;
}

/** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */
public byte getValType() {
/** {@inheritDoc} */
@Override public byte getValType() {
return valType;
}

/** @return Value value bytes. */
public byte[] getValBytes() {
/** {@inheritDoc} */
@Override public byte[] getValBytes() {
return valBytes;
}
}
Expand Up @@ -32,7 +32,7 @@
* Represents Data Entry ({@link #key}, {@link #val value}) pair update {@link #op operation}. <br>
* This Data entry was not converted to key, value pair during record deserialization.
*/
public class LazyMvccDataEntry extends MvccDataEntry {
public class LazyMvccDataEntry extends MvccDataEntry implements MarshalledDataEntry {
/** */
private GridCacheSharedContext cctx;

Expand Down Expand Up @@ -127,23 +127,23 @@ public LazyMvccDataEntry(
return val;
}

/** @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes */
public byte getKeyType() {
/** {@inheritDoc} */
@Override public byte getKeyType() {
return keyType;
}

/** @return Key value bytes. */
public byte[] getKeyBytes() {
/** {@inheritDoc} */
@Override public byte[] getKeyBytes() {
return keyBytes;
}

/** @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes */
public byte getValType() {
/** {@inheritDoc} */
@Override public byte getValType() {
return valType;
}

/** @return Value value bytes. */
public byte[] getValBytes() {
/** {@inheritDoc} */
@Override public byte[] getValBytes() {
return valBytes;
}
}
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.pagemem.wal.record;

import org.apache.ignite.internal.processors.cache.CacheObject;

/**
* Interface for Data Entry record that was not converted to key, value pair during record deserialization.
*/
public interface MarshalledDataEntry {
/**
* @return Data Entry Key type code. See {@link CacheObject} for built-in value type codes.
*/
byte getKeyType();

/**
* @return Key value bytes.
*/
byte[] getKeyBytes();

/**
* @return Data Entry Value type code. See {@link CacheObject} for built-in value type codes.
*/
byte getValType();

/**
* @return Value value bytes.
*/
byte[] getValBytes();
}
Expand Up @@ -27,7 +27,7 @@
/**
* Data Entry for automatic unwrapping key and value from Data Entry
*/
public class UnwrapDataEntry extends DataEntry {
public class UnwrapDataEntry extends DataEntry implements UnwrappedDataEntry {
/** Cache object value context. Context is used for unwrapping objects. */
private final CacheObjectValueContext cacheObjValCtx;

Expand Down Expand Up @@ -64,13 +64,8 @@ public UnwrapDataEntry(
this.keepBinary = keepBinary;
}

/**
* Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used
* in key, call of this method requires classes to be available in classpath.
*
* @return Key which was placed into cache. Or null if failed to convert.
*/
public Object unwrappedKey() {
/** {@inheritDoc} */
@Override public Object unwrappedKey() {
try {
if (keepBinary && key instanceof BinaryObject)
return key;
Expand All @@ -93,13 +88,8 @@ public Object unwrappedKey() {
}
}

/**
* Unwraps value value from cache value object into primitive boxed type or source class. If client classes were
* used in key, call of this method requires classes to be available in classpath.
*
* @return Value which was placed into cache. Or null for delete operation or for failure.
*/
public Object unwrappedValue() {
/** {@inheritDoc} */
@Override public Object unwrappedValue() {
try {
if (val == null)
return null;
Expand Down
Expand Up @@ -28,7 +28,7 @@
/**
* Data Entry for automatic unwrapping key and value from Mvcc Data Entry
*/
public class UnwrapMvccDataEntry extends MvccDataEntry {
public class UnwrapMvccDataEntry extends MvccDataEntry implements UnwrappedDataEntry {
/** Cache object value context. Context is used for unwrapping objects. */
private final CacheObjectValueContext cacheObjValCtx;

Expand Down Expand Up @@ -68,13 +68,8 @@ public UnwrapMvccDataEntry(
this.keepBinary = keepBinary;
}

/**
* Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used
* in key, call of this method requires classes to be available in classpath.
*
* @return Key which was placed into cache. Or null if failed to convert.
*/
public Object unwrappedKey() {
/** {@inheritDoc} */
@Override public Object unwrappedKey() {
try {
if (keepBinary && key instanceof BinaryObject)
return key;
Expand All @@ -97,13 +92,8 @@ public Object unwrappedKey() {
}
}

/**
* Unwraps value value from cache value object into primitive boxed type or source class. If client classes were
* used in key, call of this method requires classes to be available in classpath.
*
* @return Value which was placed into cache. Or null for delete operation or for failure.
*/
public Object unwrappedValue() {
/** {@inheritDoc} */
@Override public Object unwrappedValue() {
try {
if (val == null)
return null;
Expand Down
@@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.pagemem.wal.record;

/**
* Interface for Data Entry for automatic unwrapping key and value from Data Entry
*/
public interface UnwrappedDataEntry {
/**
* Unwraps key value from cache key object into primitive boxed type or source class. If client classes were used in
* key, call of this method requires classes to be available in classpath.
*
* @return Key which was placed into cache. Or null if failed to convert.
*/
Object unwrappedKey();

/**
* Unwraps value value from cache value object into primitive boxed type or source class. If client classes were
* used in key, call of this method requires classes to be available in classpath.
*
* @return Value which was placed into cache. Or null for delete operation or for failure.
*/
Object unwrappedValue();
}
Expand Up @@ -29,7 +29,7 @@
import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
import org.apache.ignite.internal.pagemem.wal.record.DataRecord;
import org.apache.ignite.internal.pagemem.wal.record.FilteredRecord;
import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.MvccDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.MvccDataRecord;
import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry;
Expand Down Expand Up @@ -434,15 +434,15 @@ private boolean checkBounds(long idx) {
final IgniteCacheObjectProcessor processor,
final CacheObjectContext fakeCacheObjCtx,
final DataEntry dataEntry) throws IgniteCheckedException {
if(dataEntry instanceof EncryptedDataEntry)
if (dataEntry instanceof EncryptedDataEntry)
return dataEntry;

final KeyCacheObject key;
final CacheObject val;
boolean keepBinary = this.keepBinary || !fakeCacheObjCtx.kernalContext().marshallerContext().initialized();

if (dataEntry instanceof LazyDataEntry) {
final LazyDataEntry lazyDataEntry = (LazyDataEntry)dataEntry;
if (dataEntry instanceof MarshalledDataEntry) {
final MarshalledDataEntry lazyDataEntry = (MarshalledDataEntry)dataEntry;

key = processor.toKeyCacheObject(fakeCacheObjCtx,
lazyDataEntry.getKeyType(),
Expand Down Expand Up @@ -472,7 +472,7 @@ private boolean checkBounds(long idx) {
* @param keepBinary Don't convert non primitive types.
* @return Unwrapped entry.
*/
private @NotNull DataEntry unwrapDataEntry(CacheObjectContext coCtx, DataEntry dataEntry,
private DataEntry unwrapDataEntry(CacheObjectContext coCtx, DataEntry dataEntry,
KeyCacheObject key, CacheObject val, boolean keepBinary) {
if (dataEntry instanceof MvccDataEntry)
return new UnwrapMvccDataEntry(
Expand Down
Expand Up @@ -61,11 +61,10 @@
import org.apache.ignite.internal.pagemem.wal.WALPointer;
import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
import org.apache.ignite.internal.pagemem.wal.record.DataRecord;
import org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.LazyMvccDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.MarshalledDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.TxRecord;
import org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.UnwrapMvccDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.UnwrappedDataEntry;
import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheOperation;
Expand Down Expand Up @@ -126,9 +125,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {
/** Custom wal mode. */
private WALMode customWalMode;

/** Clear properties in afterTest() method. */
private boolean clearProps;

/** Set WAL and Archive path to same value. */
private boolean setWalAndArchiveToSameVal;

Expand Down Expand Up @@ -185,11 +181,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {

/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
if (MvccFeatureChecker.forcedMvcc())
fail("https://issues.apache.org/jira/browse/IGNITE-10558");

stopAllGrids();

cleanPersistenceDir();
}

Expand All @@ -199,8 +190,7 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest {

cleanPersistenceDir();

if (clearProps)
System.clearProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS);
System.clearProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS);
}

/**
Expand Down Expand Up @@ -1114,8 +1104,6 @@ public void testPutAllTxIntoTwoNodes() throws Exception {
*/
@Test
public void testTxRecordsReadWoBinaryMeta() throws Exception {
clearProps = true;

System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true");

Ignite ignite = startGrid("node0");
Expand Down Expand Up @@ -1383,12 +1371,12 @@ private Map<GridCacheVersion, Integer> iterateAndCountDataRecord(
Object unwrappedKeyObj;
Object unwrappedValObj;

if (entry instanceof UnwrapDataEntry || entry instanceof UnwrapMvccDataEntry) {
UnwrapDataEntry unwrapDataEntry = (UnwrapDataEntry)entry;
if (entry instanceof UnwrappedDataEntry) {
UnwrappedDataEntry unwrapDataEntry = (UnwrappedDataEntry)entry;
unwrappedKeyObj = unwrapDataEntry.unwrappedKey();
unwrappedValObj = unwrapDataEntry.unwrappedValue();
}
else if (entry instanceof LazyDataEntry || entry instanceof LazyMvccDataEntry) {
else if (entry instanceof MarshalledDataEntry) {
unwrappedKeyObj = null;
unwrappedValObj = null;
//can't check value
Expand Down

0 comments on commit 417fae5

Please sign in to comment.