You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/03/30 11:50:17 UTC
[48/50] [abbrv] ignite git commit: Merge branch master into
ignite-3477-master
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
index 32503d2,0000000..5be277a
mode 100644,000000..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteIncompleteCacheObjectSelfTest.java
@@@ -1,186 -1,0 +1,186 @@@
+/*
+ * 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.processors.cache;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+import org.junit.Assert;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Simple test for arbitrary CacheObject reading/writing.
+ */
+public class IgniteIncompleteCacheObjectSelfTest extends GridCommonAbstractTest {
+ /**
+ * Test case when requested data cut on cache object header.
+ *
+ * @throws Exception If failed.
+ */
+ public void testIncompleteObject() throws Exception {
+ final byte[] data = new byte[1024];
+
+ ThreadLocalRandom.current().nextBytes(data);
+
+ final ByteBuffer dataBuf = ByteBuffer.allocate(IncompleteCacheObject.HEAD_LEN + data.length);
+
+ int off = 0;
+ int len = 3;
+
+ final TestCacheObject obj = new TestCacheObject((byte) 1);
+
+ // Write part of the cache object and cut on header (3 bytes instead of 5)
+ assert CacheObjectAdapter.putValue(obj.cacheObjectType(), dataBuf, off, len, data, 0);
+
+ off += len;
+ len = IncompleteCacheObject.HEAD_LEN - len + data.length;
+
+ // Write rest data.
+ assert CacheObjectAdapter.putValue(obj.cacheObjectType(), dataBuf, off, len, data, 0);
+
+ assert !dataBuf.hasRemaining() : "Not all data were written.";
+
+ dataBuf.clear();
+
+ // Cut on header for reading.
+ dataBuf.limit(3);
+
+ final IncompleteCacheObject incompleteObj = new IncompleteCacheObject(dataBuf);
+
+ incompleteObj.readData(dataBuf);
+
+ assert !incompleteObj.isReady();
+
+ assert !dataBuf.hasRemaining() : "Data were read incorrectly.";
+
+ // Make rest data available.
+ dataBuf.limit(dataBuf.capacity());
+
+ incompleteObj.readData(dataBuf);
+
+ assert incompleteObj.isReady();
+
+ // Check that cache object data assembled correctly.
+ assertEquals(obj.cacheObjectType(), incompleteObj.type());
+ Assert.assertArrayEquals(data, incompleteObj.data());
+ }
+
+ /**
+ *
+ */
+ private static class TestCacheObject implements CacheObject {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final byte type;
+
+ /**
+ * @param type Cache object type.
+ */
+ private TestCacheObject(final byte type) {
+ this.type = type;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <T> T value(final CacheObjectContext ctx, final boolean cpy) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] valueBytes(final CacheObjectContext ctx) throws IgniteCheckedException {
+ return new byte[0];
+ }
+
+ /** {@inheritDoc} */
+ @Override public int valueBytesLength(final CacheObjectContext ctx) throws IgniteCheckedException {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putValue(final ByteBuffer buf) throws IgniteCheckedException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int putValue(long addr) throws IgniteCheckedException {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putValue(final ByteBuffer buf, final int off, final int len)
+ throws IgniteCheckedException {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte cacheObjectType() {
+ return type;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isPlatformType() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject prepareForCache(final CacheObjectContext ctx) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(final CacheObjectContext ctx,
+ final ClassLoader ldr) throws IgniteCheckedException {
+ // No-op
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(final CacheObjectContext ctx) throws IgniteCheckedException {
+ // No-op
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean writeTo(final ByteBuffer buf, final MessageWriter writer) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readFrom(final ByteBuffer buf, final MessageReader reader) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
- @Override public byte directType() {
++ @Override public short directType() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte fieldsCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onAckReceived() {
+ // No-op
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
index 4d018e6,8d916a7..2202339
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheEventAbstractTest.java
@@@ -356,25 -344,19 +346,20 @@@ public abstract class GridCacheEventAbs
String key = e.getKey();
Integer val = e.getValue();
- Transaction tx = cache.unwrap(Ignite.class).transactions().txStart();
+ try (Transaction tx = cache.unwrap(Ignite.class).transactions().txStart()) {
- asyncCache.getAndPut(key, val);
- assert asyncCache.future().get() == null;
- assert cache.getAndPutAsync(key, val).get() == null;
++ assert cache.getAndPutAsync(key, val).get() == null;
- assert cache.containsKey(key);
+ assert cache.containsKey(key);
- asyncCache.get(key);
-
- assert val.equals(asyncCache.future().get());
- assert val.equals(cache.getAsync(key).get());
++ assert val.equals(cache.getAsync(key).get());
- asyncCache.getAndRemove(key);
-
- assert val.equals(asyncCache.future().get());
- assert val.equals(cache.getAndRemoveAsync(key).get());
++ assert val.equals(cache.getAndRemoveAsync(key).get());
- assert !cache.containsKey(key);
+ assert !cache.containsKey(key);
- tx.commit();
+ tx.commit();
+ }
assert !cache.containsKey(key);
}
@@@ -396,31 -376,23 +379,24 @@@
String key = e.getKey();
Integer val = e.getValue();
- Transaction tx = cache.unwrap(Ignite.class).transactions().txStart();
+ try (Transaction tx = cache.unwrap(Ignite.class).transactions().txStart()) {
- asyncCache.getAndPut(key, val);
- assert asyncCache.future().get() == null;
- assert cache.getAndPutAsync(key, val).get() == null;
++ assert cache.getAndPutAsync(key, val).get() == null;
- assert cache.containsKey(key);
+ assert cache.containsKey(key);
- asyncCache.get(key);
-
- assert val.equals(asyncCache.future().get());
- assert val.equals(cache.getAsync(key).get());
++ assert val.equals(cache.getAsync(key).get());
- asyncCache.getAndRemove(key);
-
- assert val.equals(asyncCache.future().get());
- assert val.equals(cache.getAndRemoveAsync(key).get());
++ assert val.equals(cache.getAndRemoveAsync(key).get());
- assert !cache.containsKey(key);
+ assert !cache.containsKey(key);
- asyncCache.getAndPut(key, val);
-
- assert asyncCache.future().get() == null;
- assert cache.getAndPutAsync(key, val).get() == null;
++ assert cache.getAndPutAsync(key, val).get() == null;
- assert cache.containsKey(key);
+ assert cache.containsKey(key);
- tx.commit();
+ tx.commit();
+ }
assert cache.containsKey(key);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOnlyMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
index fdf0624,26574f1..7476b63
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryConcurrentTest.java
@@@ -348,15 -345,12 +348,12 @@@ public class GridCacheContinuousQueryCo
// Now must check the cache again, to make sure that we didn't miss the key insert while we
// were busy setting up the cache listener.
// Check asynchronously.
- IgniteCache<Integer, String> asyncCache = cache.withAsync();
- asyncCache.get(key);
-
// Complete the promise if the key was inserted concurrently.
- asyncCache.<String>future().listen(new IgniteInClosure<IgniteFuture<String>>() {
+ cache.getAsync(key).listen(new IgniteInClosure<IgniteFuture<String>>() {
@Override public void apply(IgniteFuture<String> f) {
- String value = f.get();
+ String val = f.get();
- if (value != null) {
+ if (val != null) {
log.info("Completed by get: " + id);
(((GridFutureAdapter)((IgniteFutureImpl)promise).internalFuture())).onDone("by get");
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/continuous/GridEventConsumeSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
index ebf4aee,0000000..471a05c
mode 100644,000000..100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
@@@ -1,545 -1,0 +1,545 @@@
+/*
+ * 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.processors.database;
+
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
+import org.apache.ignite.internal.pagemem.PageIdAllocator;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.CacheObjectContext;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.database.CacheDataRow;
+import org.apache.ignite.internal.processors.cache.database.freelist.FreeList;
+import org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.plugin.extensions.communication.MessageReader;
+import org.apache.ignite.plugin.extensions.communication.MessageWriter;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public class FreeListImplSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final int CPUS = Runtime.getRuntime().availableProcessors();
+
+ /** */
+ private static final long MB = 1024L * 1024L;
+
+ /** */
+ private PageMemory pageMem;
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ if (pageMem != null)
+ pageMem.stop();
+
+ pageMem = null;
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteSingleThreaded_1024() throws Exception {
+ checkInsertDeleteSingleThreaded(1024);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteSingleThreaded_2048() throws Exception {
+ checkInsertDeleteSingleThreaded(2048);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteSingleThreaded_4096() throws Exception {
+ checkInsertDeleteSingleThreaded(4096);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteSingleThreaded_8192() throws Exception {
+ checkInsertDeleteSingleThreaded(8192);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteSingleThreaded_16384() throws Exception {
+ checkInsertDeleteSingleThreaded(16384);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteMultiThreaded_1024() throws Exception {
+ checkInsertDeleteMultiThreaded(1024);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteMultiThreaded_2048() throws Exception {
+ checkInsertDeleteMultiThreaded(2048);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteMultiThreaded_4096() throws Exception {
+ checkInsertDeleteMultiThreaded(4096);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteMultiThreaded_8192() throws Exception {
+ checkInsertDeleteMultiThreaded(8192);
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ public void testInsertDeleteMultiThreaded_16384() throws Exception {
+ checkInsertDeleteMultiThreaded(16384);
+ }
+
+ /**
+ * @param pageSize Page size.
+ * @throws Exception
+ */
+ protected void checkInsertDeleteMultiThreaded(final int pageSize) throws Exception {
+ final FreeList list = createFreeList(pageSize);
+
+ Random rnd = new Random();
+
+ final ConcurrentMap<Long, TestDataRow> stored = new ConcurrentHashMap<>();
+
+ for (int i = 0; i < 100; i++) {
+ int keySize = rnd.nextInt(pageSize * 3 / 2) + 10;
+ int valSize = rnd.nextInt(pageSize * 5 / 2) + 10;
+
+ TestDataRow row = new TestDataRow(keySize, valSize);
+
+ list.insertDataRow(row);
+
+ assertTrue(row.link() != 0L);
+
+ TestDataRow old = stored.put(row.link(), row);
+
+ assertNull(old);
+ }
+
+ final AtomicBoolean grow = new AtomicBoolean(true);
+
+ GridTestUtils.runMultiThreaded(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ Random rnd = ThreadLocalRandom.current();
+
+ for (int i = 0; i < 1_000_000; i++) {
+ boolean grow0 = grow.get();
+
+ if (grow0) {
+ if (stored.size() > 20_000) {
+ if (grow.compareAndSet(true, false))
+ info("Shrink... [" + stored.size() + ']');
+
+ grow0 = false;
+ }
+ }
+ else {
+ if (stored.size() < 1_000) {
+ if (grow.compareAndSet(false, true))
+ info("Grow... [" + stored.size() + ']');
+
+ grow0 = true;
+ }
+ }
+
+ boolean insert = rnd.nextInt(100) < 70 == grow0;
+
+ if (insert) {
+ int keySize = rnd.nextInt(pageSize * 3 / 2) + 10;
+ int valSize = rnd.nextInt(pageSize * 3 / 2) + 10;
+
+ TestDataRow row = new TestDataRow(keySize, valSize);
+
+ list.insertDataRow(row);
+
+ assertTrue(row.link() != 0L);
+
+ TestDataRow old = stored.put(row.link(), row);
+
+ assertNull(old);
+ }
+ else {
+ while (true) {
+ Iterator<TestDataRow> it = stored.values().iterator();
+
+ if (it.hasNext()) {
+ TestDataRow row = it.next();
+
+ TestDataRow rmvd = stored.remove(row.link);
+
+ if (rmvd != null) {
+ list.removeDataRowByLink(row.link);
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+ }, 8, "runner");
+ }
+
+ /**
+ * @throws Exception if failed.
+ */
+ protected void checkInsertDeleteSingleThreaded(int pageSize) throws Exception {
+ FreeList list = createFreeList(pageSize);
+
+ Random rnd = new Random();
+
+ Map<Long, TestDataRow> stored = new HashMap<>();
+
+ for (int i = 0; i < 100; i++) {
+ int keySize = rnd.nextInt(pageSize * 3 / 2) + 10;
+ int valSize = rnd.nextInt(pageSize * 5 / 2) + 10;
+
+ TestDataRow row = new TestDataRow(keySize, valSize);
+
+ list.insertDataRow(row);
+
+ assertTrue(row.link() != 0L);
+
+ TestDataRow old = stored.put(row.link(), row);
+
+ assertNull(old);
+ }
+
+ boolean grow = true;
+
+ for (int i = 0; i < 1_000_000; i++) {
+ if (grow) {
+ if (stored.size() > 20_000) {
+ grow = false;
+
+ info("Shrink... [" + stored.size() + ']');
+ }
+ }
+ else {
+ if (stored.size() < 1_000) {
+ grow = true;
+
+ info("Grow... [" + stored.size() + ']');
+ }
+ }
+
+ boolean insert = rnd.nextInt(100) < 70 == grow;
+
+ if (insert) {
+ int keySize = rnd.nextInt(pageSize * 3 / 2) + 10;
+ int valSize = rnd.nextInt(pageSize * 3 / 2) + 10;
+
+ TestDataRow row = new TestDataRow(keySize, valSize);
+
+ list.insertDataRow(row);
+
+ assertTrue(row.link() != 0L);
+
+ TestDataRow old = stored.put(row.link(), row);
+
+ assertNull(old);
+ }
+ else {
+ Iterator<TestDataRow> it = stored.values().iterator();
+
+ if (it.hasNext()) {
+ TestDataRow row = it.next();
+
+ TestDataRow rmvd = stored.remove(row.link);
+
+ assertTrue(rmvd == row);
+
+ list.removeDataRowByLink(row.link);
+ }
+ }
+ }
+ }
+
+ /**
+ * @return Page memory.
+ */
+ protected PageMemory createPageMemory(int pageSize) throws Exception {
+ long[] sizes = new long[CPUS];
+
+ for (int i = 0; i < sizes.length; i++)
+ sizes[i] = 1024 * MB / CPUS;
+
+ PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(sizes), null, pageSize, true);
+
+ pageMem.start();
+
+ return pageMem;
+ }
+
+ /**
+ * @param pageSize Page size.
+ * @return Free list.
+ * @throws Exception If failed.
+ */
+ protected FreeList createFreeList(int pageSize) throws Exception {
+ pageMem = createPageMemory(pageSize);
+
+ long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
+
+ return new FreeListImpl(1, "freelist", pageMem, null, null, metaPageId, true);
+ }
+
+ /**
+ *
+ */
+ private static class TestDataRow implements CacheDataRow {
+ /** */
+ private long link;
+
+ /** */
+ private TestCacheObject key;
+
+ /** */
+ private TestCacheObject val;
+
+ /** */
+ private GridCacheVersion ver;
+
+ /**
+ * @param keySize Key size.
+ * @param valSize Value size.
+ */
+ private TestDataRow(int keySize, int valSize) {
+ key = new TestCacheObject(keySize);
+ val = new TestCacheObject(valSize);
+ ver = new GridCacheVersion(keySize, valSize, 0L, 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyCacheObject key() {
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void key(KeyCacheObject key) {
+ this.key = (TestCacheObject)key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject value() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheVersion version() {
+ return ver;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long expireTime() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partition() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long link() {
+ return link;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void link(long link) {
+ this.link = link;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hash() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestCacheObject implements KeyCacheObject {
+ /** */
+ private byte[] data;
+
+ /**
+ * @param size Object size.
+ */
+ private TestCacheObject(int size) {
+ data = new byte[size];
+
+ Arrays.fill(data, (byte)size);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean internal() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partition() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void partition(int part) {
+ assert false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public KeyCacheObject copy(int part) {
+ assert false;
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+ return (T)data;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] valueBytes(CacheObjectContext ctx) throws IgniteCheckedException {
+ return data;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int valueBytesLength(CacheObjectContext ctx) throws IgniteCheckedException {
+ return data.length;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putValue(ByteBuffer buf) throws IgniteCheckedException {
+ buf.put(data);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int putValue(long addr) throws IgniteCheckedException {
+ PageUtils.putBytes(addr, 0, data);
+
+ return data.length;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putValue(ByteBuffer buf, int off, int len) throws IgniteCheckedException {
+ buf.put(data, off, len);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte cacheObjectType() {
+ return 42;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isPlatformType() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+ assert false;
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
+ assert false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void prepareMarshal(CacheObjectContext ctx) throws IgniteCheckedException {
+ assert false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
+ assert false;
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
+ assert false;
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
- @Override public byte directType() {
++ @Override public short directType() {
+ assert false;
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte fieldsCount() {
+ assert false;
+
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onAckReceived() {
+ assert false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/messaging/GridMessagingSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
index 7e1fcf7,f24881e..e429c45
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/GridCacheMessageSelfTest.java
@@@ -409,7 -409,7 +409,7 @@@ public class GridCacheMessageSelfTest e
*/
static class TestMessage2 extends GridCacheMessage {
/** */
- public static final byte DIRECT_TYPE = (byte)201;
- public static final short DIRECT_TYPE = 205;
++ public static final short DIRECT_TYPE = 201;
/** Node id. */
private UUID nodeId;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index cc94cdc,475bf8e..bbed834
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@@ -97,6 -96,9 +97,8 @@@ import org.apache.ignite.internal.util.
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.plugin.extensions.communication.Message;
+ import org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage;
+ import org.apache.ignite.spi.discovery.DiscoverySpiListener;
-import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.ssl.SslContextFactory;
import org.apache.ignite.testframework.config.GridTestProperties;
import org.jetbrains.annotations.NotNull;
@@@ -110,9 -112,61 +112,67 @@@ public final class GridTestUtils
/** Default busy wait sleep interval in milliseconds. */
public static final long DFLT_BUSYWAIT_SLEEP_INTERVAL = 200;
-
+ /** */
+ static final String ALPHABETH = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890_";
+ /**
+ * Hook object intervenes to discovery message handling
+ * and thus allows to make assertions or other actions like skipping certain discovery messages.
+ */
+ public static class DiscoveryHook {
+ /**
+ * @param msg Message.
+ */
+ public void handleDiscoveryMessage(DiscoverySpiCustomMessage msg) {
+ }
+
+ /**
+ * @param ignite Ignite.
+ */
+ public void ignite(IgniteEx ignite) {
+ // No-op.
+ }
+ }
+
+ /**
+ * Injects {@link DiscoveryHook} into handling logic.
+ */
+ public static final class DiscoverySpiListenerWrapper implements DiscoverySpiListener {
+ /** */
+ private final DiscoverySpiListener delegate;
+
+ /** */
+ private final DiscoveryHook hook;
+
+ /**
+ * @param delegate Delegate.
+ * @param hook Hook.
+ */
+ private DiscoverySpiListenerWrapper(DiscoverySpiListener delegate, DiscoveryHook hook) {
+ this.hook = hook;
+ this.delegate = delegate;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode> topSnapshot, @Nullable Map<Long, Collection<ClusterNode>> topHist, @Nullable DiscoverySpiCustomMessage spiCustomMsg) {
+ hook.handleDiscoveryMessage(spiCustomMsg);
+ delegate.onDiscovery(type, topVer, node, topSnapshot, topHist, spiCustomMsg);
+ }
+
++ /** {@inheritDoc} */
++ @Override public void onLocalNodeInitialized(ClusterNode locNode) {
++ delegate.onLocalNodeInitialized(locNode);
++ }
++
+ /**
+ * @param delegate Delegate.
+ * @param discoveryHook Discovery hook.
+ */
+ public static DiscoverySpiListener wrap(DiscoverySpiListener delegate, DiscoveryHook discoveryHook) {
+ return new DiscoverySpiListenerWrapper(delegate, discoveryHook);
+ }
+ }
+
/** */
private static final Map<Class<?>, String> addrs = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index df60bf1,01207b6..29ccc29
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@@ -291,8 -348,13 +352,13 @@@ public class IgniteCacheProcessProxy<K
}
/** {@inheritDoc} */
+ @Override public IgniteFuture<Boolean> containsKeyAsync(K key) {
+ return compute.callAsync(new ContainsKeyTask<>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
- @Override public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
- throw new UnsupportedOperationException("Oparetion can't be supported automatically.");
+ @Override public void loadAll(Set<? extends K> keys, boolean replaceExistVals, CompletionListener completionLsnr) {
+ throw new UnsupportedOperationException("Operation can't be supported automatically.");
}
/** {@inheritDoc} */
@@@ -396,10 -544,17 +548,16 @@@
}
/** {@inheritDoc} */
+ @Override public <T> IgniteFuture<T> invokeAsync(K key, CacheEntryProcessor<K, V, T> processor,
+ Object... args) {
+ return compute.callAsync(new InvokeTask<>(cacheName, isAsync, key, processor, args));
+ }
+
+ /** {@inheritDoc} */
- @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
+ @Override public <T> Map<K, EntryProcessorResult<T>> invokeAll(
Set<? extends K> keys,
EntryProcessor<K, V, T> processor,
- Object... args)
- {
+ Object... args) {
return compute.call(new InvokeAllTask<>(cacheName, isAsync, keys, processor, args));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteComputeGridTestSuite.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/DmlStatementsProcessor.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index fad3de8,6d8dc14..7d255b1
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@@ -1440,48 -1418,4 +1419,29 @@@ public class GridReduceQueryExecutor
state(e, null);
}
}
+
+ /**
+ *
+ */
+ private static class Iter extends GridH2ResultSetIterator<List<?>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * @param data Data array.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected Iter(ResultSet data) throws IgniteCheckedException {
+ super(data, true, false);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected List<?> createRow() {
+ ArrayList<Object> res = new ArrayList<>(row.length);
+
+ Collections.addAll(res, row);
+
+ return res;
+ }
+ }
- /**
- *
- */
- private class ExplicitPartitionsSpecializer implements IgniteBiClosure<ClusterNode,Message,Message> {
- /** */
- private final Map<ClusterNode,IntArray> partsMap;
-
- /**
- * @param partsMap Partitions map.
- */
- private ExplicitPartitionsSpecializer(Map<ClusterNode,IntArray> partsMap) {
- this.partsMap = partsMap;
- }
-
- /** {@inheritDoc} */
- @Override public Message apply(ClusterNode n, Message msg) {
- return copy(msg, n, partsMap);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheLockPartitionOnAffinityRunTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
----------------------------------------------------------------------
diff --cc modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
index f8c9dd5,800138c..47cd98b
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSegmentedIndexSelfTest.java
@@@ -104,6 -108,28 +105,27 @@@ public class IgniteSqlSegmentedIndexSel
}
/**
+ * Run tests on single-node grid
+ * @throws Exception If failed.
+ */
+ public void testSingleNodeIndexSegmentationWithSwapEnabled() throws Exception {
+ startGridsMultiThreaded(1, true);
+
+ final IgniteCache<Object, Object> cache = ignite(0).createCache(cacheConfig("org", true, Integer.class, Organization.class)
+ .setOffHeapMaxMemory(-1)
- .setSwapEnabled(true)
+ .setEvictionPolicy(new FifoEvictionPolicy(10)));
+
+ for (int i = 0; i < 20; i++)
+ cache.put(i, new Organization("org-" + i));
+
+ String select0 = "select name from \"org\".Organization";
+
+ List<List<?>> result = cache.query(new SqlFieldsQuery(select0)).getAll();
+
+ assertEquals(20, result.size());
+ }
+
+ /**
* Run tests on multi-node grid
* @throws Exception If failed.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/h2/GridIndexingSpiAbstractSelfTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/EventsTest.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2c480b4f/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------