IGNITE-10558: MVCC: IgniteWalReader fixed. This closes #5583.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/417fae51 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/417fae51 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/417fae51 Branch: refs/heads/ignite-601 Commit: 417fae51f79c7fbc9f17943f0df1ee15bc36dc6c Parents: 86a815e Author: Andrey V. Mashenkov <andrey.mashen...@gmail.com> Authored: Tue Dec 25 18:08:17 2018 +0300 Committer: Igor Seliverstov <gvvinbl...@gmail.com> Committed: Tue Dec 25 18:15:28 2018 +0300 ---------------------------------------------------------------------- .../pagemem/wal/record/LazyDataEntry.java | 18 ++++---- .../pagemem/wal/record/LazyMvccDataEntry.java | 18 ++++---- .../pagemem/wal/record/MarshalledDataEntry.java | 45 ++++++++++++++++++++ .../pagemem/wal/record/UnwrapDataEntry.java | 20 +++------ .../pagemem/wal/record/UnwrapMvccDataEntry.java | 20 +++------ .../pagemem/wal/record/UnwrappedDataEntry.java | 39 +++++++++++++++++ .../reader/StandaloneWalRecordsIterator.java | 10 ++--- .../db/wal/reader/IgniteWalReaderTest.java | 24 +++-------- 8 files changed, 123 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java index 403d778..ba2fabc 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyDataEntry.java @@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProces * 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; @@ -124,23 +124,23 @@ public class LazyDataEntry extends DataEntry { 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; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java index 15b1468..a7ad86f 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/LazyMvccDataEntry.java @@ -32,7 +32,7 @@ import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProces * 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; @@ -127,23 +127,23 @@ public class LazyMvccDataEntry extends MvccDataEntry { 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; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java new file mode 100644 index 0000000..c977d52 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/MarshalledDataEntry.java @@ -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(); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java index dbcc651..5dd268b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapDataEntry.java @@ -27,7 +27,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; /** * 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; @@ -64,13 +64,8 @@ public class UnwrapDataEntry extends DataEntry { 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; @@ -93,13 +88,8 @@ public class UnwrapDataEntry extends DataEntry { } } - /** - * 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; http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java index 25d7a6e..c3c12a3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrapMvccDataEntry.java @@ -28,7 +28,7 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; /** * 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; @@ -68,13 +68,8 @@ public class UnwrapMvccDataEntry extends MvccDataEntry { 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; @@ -97,13 +92,8 @@ public class UnwrapMvccDataEntry extends MvccDataEntry { } } - /** - * 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; http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java new file mode 100644 index 0000000..b3a20b9 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/wal/record/UnwrappedDataEntry.java @@ -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(); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java index 238f99a..d9e8607 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/reader/StandaloneWalRecordsIterator.java @@ -29,7 +29,7 @@ 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.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; @@ -434,15 +434,15 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator { 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(), @@ -472,7 +472,7 @@ class StandaloneWalRecordsIterator extends AbstractWalRecordsIterator { * @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( http://git-wip-us.apache.org/repos/asf/ignite/blob/417fae51/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java index 0b467d1..3ae92b7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/reader/IgniteWalReaderTest.java @@ -61,11 +61,10 @@ import org.apache.ignite.internal.pagemem.wal.WALIterator; 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; @@ -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; @@ -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(); } @@ -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); } /** @@ -1114,8 +1104,6 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { */ @Test public void testTxRecordsReadWoBinaryMeta() throws Exception { - clearProps = true; - System.setProperty(IgniteSystemProperties.IGNITE_WAL_LOG_TX_RECORDS, "true"); Ignite ignite = startGrid("node0"); @@ -1383,12 +1371,12 @@ public class IgniteWalReaderTest extends GridCommonAbstractTest { 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