You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/04/02 21:22:44 UTC
[01/30] incubator-ignite git commit: # ignite-663 Fixed build.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-366 f34dc75f7 -> b73fb49c3 (forced update)
# ignite-663 Fixed build.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/588cff34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/588cff34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/588cff34
Branch: refs/heads/ignite-366
Commit: 588cff346be3cb47e65f3aeea693c8e158001dd7
Parents: d297e06
Author: anovikov <an...@gridgain.com>
Authored: Wed Apr 1 17:12:54 2015 +0700
Committer: anovikov <an...@gridgain.com>
Committed: Wed Apr 1 17:12:54 2015 +0700
----------------------------------------------------------------------
DEVNOTES.txt | 2 ++
parent/pom.xml | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/588cff34/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index 2e8e431..3a712c7 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -8,6 +8,8 @@ With LGPL dependencies:
Look for ignite-fabric-<version>.zip in ./target directory.
+NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
+
JCache TCK compliance
======================
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/588cff34/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f408434..f475b85 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -497,7 +497,14 @@
<configuration>
<rules>
<requireJavaVersion>
- <version>[1.7,)</version>
+ <!--Detected JDK Version: 1.8.0 is not in the allowed range [1.7,1.8),[1.8.0-40,).-->
+ <message>
+[INFO] ------------------------------------------------------------------------
+[ERROR] You are trying to compile Apache Ignite with inappropriate JDK version!
+[ERROR] Detected JDK Version: ${java.runtime.version}
+[ERROR] JDK version should be 1.7.0-* or >= 1.8.0-u40.
+ </message>
+ <version>[1.7,1.8),[1.8.0-40,)</version>
</requireJavaVersion>
</rules>
</configuration>
@@ -641,6 +648,7 @@
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
+ <jdk>[1.8,)</jdk>
</activation>
<build>
<plugins>
[23/30] incubator-ignite git commit: # GG-9973: Fixed.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
deleted file mode 100644
index a3b1072..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.internal.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jsr166.*;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * This class provides basic tests for {@link GridCacheWriteBehindStore}.
- */
-public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
- /**
- * Tests correct store shutdown when underlying store fails,
- *
- * @throws Exception If failed.
- */
- public void testShutdownWithFailure() throws Exception {
- final AtomicReference<Exception> err = new AtomicReference<>();
-
- multithreadedAsync(new Runnable() {
- @Override public void run() {
- try {
- delegate.setShouldFail(true);
-
- initStore(2);
-
- try {
- store.write(new CacheEntryImpl<>(1, "val1"));
- store.write(new CacheEntryImpl<>(2, "val2"));
- }
- finally {
- shutdownStore();
-
- delegate.setShouldFail(false);
- }
- }
- catch (Exception e) {
- err.set(e);
- }
- }
- }, 1).get();
-
- if (err.get() != null)
- throw err.get();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSimpleStore() throws Exception {
- initStore(2);
-
- try {
- store.write(new CacheEntryImpl<>(1, "v1"));
- store.write(new CacheEntryImpl<>(2, "v2"));
-
- assertEquals("v1", store.load(1));
- assertEquals("v2", store.load(2));
- assertNull(store.load(3));
-
- store.delete(1);
-
- assertNull(store.load(1));
- assertEquals("v2", store.load(2));
- assertNull(store.load(3));
- }
- finally {
- shutdownStore();
- }
- }
-
- /**
- * Check that all values written to the store will be in underlying store after timeout or due to size limits.
- *
- * @throws Exception If failed.
- */
- @SuppressWarnings({"NullableProblems"})
- public void testValuePropagation() throws Exception {
- // Need to test size-based write.
- initStore(1);
-
- try {
- for (int i = 0; i < CACHE_SIZE * 2; i++)
- store.write(new CacheEntryImpl<>(i, "val" + i));
-
- U.sleep(200);
-
- for (int i = 0; i < CACHE_SIZE; i++) {
- String val = delegate.load(i);
-
- assertNotNull("Value for [key= " + i + "] was not written in store", val);
- assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
- }
-
- U.sleep(FLUSH_FREQUENCY + 300);
-
- for (int i = CACHE_SIZE; i < CACHE_SIZE * 2; i++) {
- String val = delegate.load(i);
-
- assertNotNull("Value for [key= " + i + "] was not written in store", val);
- assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
- }
- }
- finally {
- shutdownStore();
- }
- }
-
- /**
- * Tests store behaviour under continuous put of the same key with different values.
- *
- * @throws Exception If failed
- */
- public void testContinuousPut() throws Exception {
- initStore(2);
-
- try {
- final AtomicBoolean running = new AtomicBoolean(true);
-
- final AtomicInteger actualPutCnt = new AtomicInteger();
-
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @SuppressWarnings({"NullableProblems"})
- @Override public void run() {
- try {
- while (running.get()) {
- for (int i = 0; i < CACHE_SIZE; i++) {
- store.write(new CacheEntryImpl<>(i, "val-0"));
-
- actualPutCnt.incrementAndGet();
-
- store.write(new CacheEntryImpl<>(i, "val" + i));
-
- actualPutCnt.incrementAndGet();
- }
- }
- }
- catch (Exception e) {
- error("Unexpected exception in put thread", e);
-
- assert false;
- }
- }
- }, 1, "put");
-
- U.sleep(FLUSH_FREQUENCY * 2 + 500);
-
- int delegatePutCnt = delegate.getPutAllCount();
-
- running.set(false);
-
- fut.get();
-
- log().info(">>> [putCnt = " + actualPutCnt.get() + ", delegatePutCnt=" + delegatePutCnt + "]");
-
- assertTrue("No puts were made to the underlying store", delegatePutCnt > 0);
- assertTrue("Too many puts were made to the underlying store", delegatePutCnt < actualPutCnt.get() / 10);
- }
- finally {
- shutdownStore();
- }
-
- // These checks must be done after the store shut down
- assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
-
- for (int i = 0; i < CACHE_SIZE; i++)
- assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
- }
-
- /**
- * Tests that all values were put into the store will be written to the underlying store
- * after shutdown is called.
- *
- * @throws Exception If failed.
- */
- public void testShutdown() throws Exception {
- initStore(2);
-
- try {
- final AtomicBoolean running = new AtomicBoolean(true);
-
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @SuppressWarnings({"NullableProblems"})
- @Override public void run() {
- try {
- while (running.get()) {
- for (int i = 0; i < CACHE_SIZE; i++) {
- store.write(new CacheEntryImpl<>(i, "val-0"));
-
- store.write(new CacheEntryImpl<>(i, "val" + i));
- }
- }
- }
- catch (Exception e) {
- error("Unexpected exception in put thread", e);
-
- assert false;
- }
- }
- }, 1, "put");
-
- U.sleep(300);
-
- running.set(false);
-
- fut.get();
- }
- finally {
- shutdownStore();
- }
-
- // These checks must be done after the store shut down
- assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
-
- for (int i = 0; i < CACHE_SIZE; i++)
- assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
- }
-
- /**
- * Tests that all values will be written to the underlying store
- * right in the same order as they were put into the store.
- *
- * @throws Exception If failed.
- */
- public void testBatchApply() throws Exception {
- delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>());
-
- initStore(1);
-
- List<Integer> intList = new ArrayList<>(CACHE_SIZE);
-
- try {
- for (int i = 0; i < CACHE_SIZE; i++) {
- store.write(new CacheEntryImpl<>(i, "val" + i));
-
- intList.add(i);
- }
- }
- finally {
- shutdownStore();
- }
-
- Map<Integer, String> underlyingMap = delegate.getMap();
-
- assertTrue("Store map key set: " + underlyingMap.keySet(), F.eqOrdered(underlyingMap.keySet(), intList));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractSelfTest.java
new file mode 100644
index 0000000..c1dd081
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractSelfTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.store.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * Harness for {@link GridCacheWriteBehindStore} tests.
+ */
+public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridCommonAbstractTest {
+ /** Write cache size. */
+ public static final int CACHE_SIZE = 1024;
+
+ /** Value dump interval. */
+ public static final int FLUSH_FREQUENCY = 1000;
+
+ /** Underlying store. */
+ protected GridCacheTestStore delegate = new GridCacheTestStore();
+
+ /** Tested store. */
+ protected GridCacheWriteBehindStore<Integer, String> store;
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ delegate = null;
+ store = null;
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * Initializes store.
+ *
+ * @param flushThreadCnt Count of flush threads
+ * @throws Exception If failed.
+ */
+ protected void initStore(int flushThreadCnt) throws Exception {
+ store = new GridCacheWriteBehindStore<>(null, "", "", log, delegate);
+
+ store.setFlushFrequency(FLUSH_FREQUENCY);
+
+ store.setFlushSize(CACHE_SIZE);
+
+ store.setFlushThreadCount(flushThreadCnt);
+
+ delegate.reset();
+
+ store.start();
+ }
+
+ /**
+ * Shutdowns store.
+ *
+ * @throws Exception If failed.
+ */
+ protected void shutdownStore() throws Exception {
+ store.stop();
+
+ assertTrue("Store cache must be empty after shutdown", store.writeCache().isEmpty());
+ }
+
+ /**
+ * Performs multiple put, get and remove operations in several threads on a store. After
+ * all threads finished their operations, returns the total set of keys that should be
+ * in underlying store.
+ *
+ * @param threadCnt Count of threads that should update keys.
+ * @param keysPerThread Count of unique keys assigned to a thread.
+ * @return Set of keys that was totally put in store.
+ * @throws Exception If failed.
+ */
+ protected Set<Integer> runPutGetRemoveMultithreaded(int threadCnt, final int keysPerThread) throws Exception {
+ final ConcurrentMap<String, Set<Integer>> perThread = new ConcurrentHashMap<>();
+
+ final AtomicBoolean running = new AtomicBoolean(true);
+
+ final AtomicInteger cntr = new AtomicInteger();
+
+ final AtomicInteger operations = new AtomicInteger();
+
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @SuppressWarnings({"NullableProblems"})
+ @Override public void run() {
+ // Initialize key set for this thread.
+ Set<Integer> set = new HashSet<>();
+
+ Set<Integer> old = perThread.putIfAbsent(Thread.currentThread().getName(), set);
+
+ if (old != null)
+ set = old;
+
+ List<Integer> original = new ArrayList<>();
+
+ Random rnd = new Random();
+
+ for (int i = 0; i < keysPerThread; i++)
+ original.add(cntr.getAndIncrement());
+
+ try {
+ while (running.get()) {
+ int op = rnd.nextInt(3);
+ int idx = rnd.nextInt(keysPerThread);
+
+ int key = original.get(idx);
+
+ switch (op) {
+ case 0:
+ store.write(new CacheEntryImpl<>(key, "val" + key));
+ set.add(key);
+
+ operations.incrementAndGet();
+
+ break;
+
+ case 1:
+ store.delete(key);
+ set.remove(key);
+
+ operations.incrementAndGet();
+
+ break;
+
+ case 2:
+ default:
+ store.write(new CacheEntryImpl<>(key, "broken"));
+
+ String val = store.load(key);
+
+ assertEquals("Invalid intermediate value: " + val, "broken", val);
+
+ store.write(new CacheEntryImpl<>(key, "val" + key));
+
+ set.add(key);
+
+ // 2 put operations performed here.
+ operations.incrementAndGet();
+ operations.incrementAndGet();
+ operations.incrementAndGet();
+
+ break;
+ }
+ }
+ }
+ catch (Exception e) {
+ error("Unexpected exception in put thread", e);
+
+ assert false;
+ }
+ }
+ }, threadCnt, "put");
+
+ U.sleep(10000);
+
+ running.set(false);
+
+ fut.get();
+
+ log().info(">>> " + operations + " operations performed totally");
+
+ Set<Integer> total = new HashSet<>();
+
+ for (Set<Integer> threadVals : perThread.values()) {
+ total.addAll(threadVals);
+ }
+
+ return total;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractTest.java
new file mode 100644
index 0000000..d4d6f02
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreAbstractTest.java
@@ -0,0 +1,350 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.configuration.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.transactions.TransactionConcurrency.*;
+import static org.apache.ignite.transactions.TransactionIsolation.*;
+
+/**
+ * Basic store test.
+ */
+public abstract class GridCacheWriteBehindStoreAbstractTest extends GridCommonAbstractTest {
+ /** Flush frequency. */
+ private static final int WRITE_FROM_BEHIND_FLUSH_FREQUENCY = 1000;
+
+ /** Cache store. */
+ private static final GridCacheTestStore store = new GridCacheTestStore();
+
+ /**
+ *
+ */
+ protected GridCacheWriteBehindStoreAbstractTest() {
+ super(true /*start grid. */);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ store.resetTimestamp();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ IgniteCache<?, ?> cache = jcache();
+
+ if (cache != null)
+ cache.clear();
+
+ store.reset();
+ }
+
+ /** @return Caching mode. */
+ protected abstract CacheMode cacheMode();
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected final IgniteConfiguration getConfiguration() throws Exception {
+ IgniteConfiguration c = super.getConfiguration();
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+ c.setDiscoverySpi(disco);
+
+ CacheConfiguration cc = defaultCacheConfiguration();
+
+ cc.setCacheMode(cacheMode());
+ cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+ cc.setSwapEnabled(false);
+ cc.setAtomicityMode(TRANSACTIONAL);
+
+ cc.setCacheStoreFactory(singletonFactory(store));
+ cc.setReadThrough(true);
+ cc.setWriteThrough(true);
+ cc.setLoadPreviousValue(true);
+
+ cc.setWriteBehindEnabled(true);
+ cc.setWriteBehindFlushFrequency(WRITE_FROM_BEHIND_FLUSH_FREQUENCY);
+
+ c.setCacheConfiguration(cc);
+
+ return c;
+ }
+
+ /** @throws Exception If test fails. */
+ public void testWriteThrough() throws Exception {
+ IgniteCache<Integer, String> cache = jcache();
+
+ Map<Integer, String> map = store.getMap();
+
+ assert map.isEmpty();
+
+ Transaction tx = grid().transactions().txStart(OPTIMISTIC, REPEATABLE_READ);
+
+ try {
+ for (int i = 1; i <= 10; i++) {
+ cache.put(i, Integer.toString(i));
+
+ checkLastMethod(null);
+ }
+
+ tx.commit();
+ }
+ finally {
+ tx.close();
+ }
+
+ // Need to wait WFB flush timeout.
+ U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
+
+ checkLastMethod("putAll");
+
+ assert cache.size() == 10;
+
+ for (int i = 1; i <= 10; i++) {
+ String val = map.get(i);
+
+ assert val != null;
+ assert val.equals(Integer.toString(i));
+ }
+
+ store.resetLastMethod();
+
+ tx = grid().transactions().txStart();
+
+ try {
+ for (int i = 1; i <= 10; i++) {
+ String val = cache.getAndRemove(i);
+
+ checkLastMethod(null);
+
+ assert val != null;
+ assert val.equals(Integer.toString(i));
+ }
+
+ tx.commit();
+ }
+ finally {
+ tx.close();
+ }
+
+ // Need to wait WFB flush timeout.
+ U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
+
+ checkLastMethod("removeAll");
+
+ assert map.isEmpty();
+ }
+
+ /** @throws Exception If test failed. */
+ public void testReadThrough() throws Exception {
+ IgniteCache<Integer, String> cache = jcache();
+
+ Map<Integer, String> map = store.getMap();
+
+ assert map.isEmpty();
+
+ try (Transaction tx = grid().transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) {
+ for (int i = 1; i <= 10; i++)
+ cache.put(i, Integer.toString(i));
+
+ checkLastMethod(null);
+
+ tx.commit();
+ }
+
+ // Need to wait WFB flush timeout.
+ U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
+
+ checkLastMethod("putAll");
+
+ for (int i = 1; i <= 10; i++) {
+ String val = map.get(i);
+
+ assert val != null;
+ assert val.equals(Integer.toString(i));
+ }
+
+ cache.clear();
+
+ assert cache.localSize() == 0;
+ assert cache.localSize() == 0;
+
+ // Need to wait WFB flush timeout.
+ U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
+
+ assert map.size() == 10;
+
+ for (int i = 1; i <= 10; i++) {
+ // Read through.
+ String val = cache.get(i);
+
+ checkLastMethod("load");
+
+ assert val != null;
+ assert val.equals(Integer.toString(i));
+ }
+
+ assert cache.size() == 10;
+
+ cache.clear();
+
+ assert cache.localSize() == 0;
+ assert cache.localSize() == 0;
+
+ assert map.size() == 10;
+
+ Set<Integer> keys = new HashSet<>();
+
+ for (int i = 1; i <= 10; i++)
+ keys.add(i);
+
+ // Read through.
+ Map<Integer, String> vals = cache.getAll(keys);
+
+ checkLastMethod("loadAll");
+
+ assert vals != null;
+ assert vals.size() == 10;
+
+ for (int i = 1; i <= 10; i++) {
+ String val = vals.get(i);
+
+ assert val != null;
+ assert val.equals(Integer.toString(i));
+ }
+
+ // Write through.
+ cache.removeAll(keys);
+
+ // Need to wait WFB flush timeout.
+ U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
+
+ checkLastMethod("removeAll");
+
+ assert cache.localSize() == 0;
+ assert cache.localSize() == 0;
+
+ assert map.isEmpty();
+ }
+
+ /** @throws Exception If failed. */
+ public void testMultithreaded() throws Exception {
+ final ConcurrentMap<String, Set<Integer>> perThread = new ConcurrentHashMap<>();
+
+ final AtomicBoolean running = new AtomicBoolean(true);
+
+ final IgniteCache<Integer, String> cache = jcache();
+
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @SuppressWarnings({"NullableProblems"})
+ @Override public void run() {
+ // Initialize key set for this thread.
+ Set<Integer> set = new HashSet<>();
+
+ Set<Integer> old = perThread.putIfAbsent(Thread.currentThread().getName(), set);
+
+ if (old != null)
+ set = old;
+
+ Random rnd = new Random();
+
+ int keyCnt = 20000;
+
+ while (running.get()) {
+ int op = rnd.nextInt(2);
+ int key = rnd.nextInt(keyCnt);
+
+ switch (op) {
+ case 0:
+ cache.put(key, "val" + key);
+ set.add(key);
+
+ break;
+
+ case 1:
+ default:
+ cache.remove(key);
+ set.remove(key);
+
+ break;
+ }
+ }
+ }
+ }, 10, "put");
+
+ U.sleep(10000);
+
+ running.set(false);
+
+ fut.get();
+
+ U.sleep(5 * WRITE_FROM_BEHIND_FLUSH_FREQUENCY);
+
+ Map<Integer, String> stored = store.getMap();
+
+ for (Map.Entry<Integer, String> entry : stored.entrySet()) {
+ int key = entry.getKey();
+
+ assertEquals("Invalid value for key " + key, "val" + key, entry.getValue());
+
+ boolean found = false;
+
+ for (Set<Integer> threadPuts : perThread.values()) {
+ if (threadPuts.contains(key)) {
+ found = true;
+
+ break;
+ }
+ }
+
+ assert found : "No threads found that put key " + key;
+ }
+ }
+
+ /** @param mtd Expected last method value. */
+ private void checkLastMethod(@Nullable String mtd) {
+ String lastMtd = store.getLastMethod();
+
+ if (mtd == null)
+ assert lastMtd == null : "Last method must be null: " + lastMtd;
+ else {
+ assert lastMtd != null : "Last method must be not null";
+ assert lastMtd.equals(mtd) : "Last method does not match [expected=" + mtd + ", lastMtd=" + lastMtd + ']';
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
new file mode 100644
index 0000000..2325fa6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreLocalTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.cache.*;
+
+/**
+ * Tests {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore} in grid configuration.
+ */
+public class GridCacheWriteBehindStoreLocalTest extends GridCacheWriteBehindStoreAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.LOCAL;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
new file mode 100644
index 0000000..3bcebb0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreMultithreadedSelfTest.java
@@ -0,0 +1,163 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import java.util.*;
+
+/**
+ * Multithreaded tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
+ */
+public class GridCacheWriteBehindStoreMultithreadedSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
+ /**
+ * This test performs complex set of operations on store from multiple threads.
+ *
+ * @throws Exception If failed.
+ */
+ public void testPutGetRemove() throws Exception {
+ initStore(2);
+
+ Set<Integer> exp;
+
+ try {
+ exp = runPutGetRemoveMultithreaded(10, 10);
+ }
+ finally {
+ shutdownStore();
+ }
+
+ Map<Integer, String> map = delegate.getMap();
+
+ Collection<Integer> extra = new HashSet<>(map.keySet());
+
+ extra.removeAll(exp);
+
+ assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
+
+ Collection<Integer> missing = new HashSet<>(exp);
+
+ missing.removeAll(map.keySet());
+
+ assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
+
+ for (Integer key : exp)
+ assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
+ }
+
+ /**
+ * Tests that cache would keep values if underlying store fails.
+ *
+ * @throws Exception If failed.
+ */
+ public void testStoreFailure() throws Exception {
+ delegate.setShouldFail(true);
+
+ initStore(2);
+
+ Set<Integer> exp;
+
+ try {
+ exp = runPutGetRemoveMultithreaded(10, 10);
+
+ U.sleep(FLUSH_FREQUENCY);
+
+ info(">>> There are " + store.getWriteBehindErrorRetryCount() + " entries in RETRY state");
+
+ delegate.setShouldFail(false);
+
+ // Despite that we set shouldFail flag to false, flush thread may just have caught an exception.
+ // If we move store to the stopping state right away, this value will be lost. That's why this sleep
+ // is inserted here to let all exception handlers in write-behind store exit.
+ U.sleep(1000);
+ }
+ finally {
+ shutdownStore();
+ }
+
+ Map<Integer, String> map = delegate.getMap();
+
+ Collection<Integer> extra = new HashSet<>(map.keySet());
+
+ extra.removeAll(exp);
+
+ assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
+
+ Collection<Integer> missing = new HashSet<>(exp);
+
+ missing.removeAll(map.keySet());
+
+ assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
+
+ for (Integer key : exp)
+ assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
+ }
+
+ /**
+ * Tests store consistency in case of high put rate, when flush is performed from the same thread
+ * as put or remove operation.
+ *
+ * @throws Exception If failed.
+ */
+ public void testFlushFromTheSameThread() throws Exception {
+ // 50 milliseconds should be enough.
+ delegate.setOperationDelay(50);
+
+ initStore(2);
+
+ Set<Integer> exp;
+
+ int start = store.getWriteBehindTotalCriticalOverflowCount();
+
+ try {
+ //We will have in total 5 * CACHE_SIZE keys that should be enough to grow map size to critical value.
+ exp = runPutGetRemoveMultithreaded(5, CACHE_SIZE);
+ }
+ finally {
+ log.info(">>> Done inserting, shutting down the store");
+
+ shutdownStore();
+ }
+
+ // Restore delay.
+ delegate.setOperationDelay(0);
+
+ Map<Integer, String> map = delegate.getMap();
+
+ int end = store.getWriteBehindTotalCriticalOverflowCount();
+
+ log.info(">>> There are " + exp.size() + " keys in store, " + (end - start) + " overflows detected");
+
+ assertTrue("No cache overflows detected (a bug or too few keys or too few delay?)", end > start);
+
+ Collection<Integer> extra = new HashSet<>(map.keySet());
+
+ extra.removeAll(exp);
+
+ assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
+
+ Collection<Integer> missing = new HashSet<>(exp);
+
+ missing.removeAll(map.keySet());
+
+ assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
+
+ for (Integer key : exp)
+ assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
new file mode 100644
index 0000000..e9821fb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
@@ -0,0 +1,216 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+import org.apache.ignite.transactions.*;
+
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.transactions.TransactionConcurrency.*;
+import static org.apache.ignite.transactions.TransactionIsolation.*;
+
+/**
+ * Tests write-behind store with near and dht commit option.
+ */
+public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridCommonAbstractTest {
+ /** Grids to start. */
+ private static final int GRID_CNT = 5;
+
+ /** Ip finder. */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** Flush frequency. */
+ public static final int WRITE_BEHIND_FLUSH_FREQ = 1000;
+
+ /** Stores per grid. */
+ private GridCacheTestStore[] stores = new GridCacheTestStore[GRID_CNT];
+
+ /** Start grid counter. */
+ private int idx;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration c = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(ipFinder);
+
+ c.setDiscoverySpi(disco);
+
+ CacheConfiguration cc = defaultCacheConfiguration();
+
+ cc.setCacheMode(CacheMode.PARTITIONED);
+ cc.setWriteBehindEnabled(true);
+ cc.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQ);
+ cc.setAtomicityMode(TRANSACTIONAL);
+ cc.setNearConfiguration(new NearCacheConfiguration());
+
+ CacheStore store = stores[idx] = new GridCacheTestStore();
+
+ cc.setCacheStoreFactory(singletonFactory(store));
+ cc.setReadThrough(true);
+ cc.setWriteThrough(true);
+ cc.setLoadPreviousValue(true);
+
+ c.setCacheConfiguration(cc);
+
+ idx++;
+
+ return c;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stores = null;
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void prepare() throws Exception {
+ idx = 0;
+
+ startGrids(GRID_CNT);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSingleWritesOnDhtNode() throws Exception {
+ checkSingleWrites();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBatchWritesOnDhtNode() throws Exception {
+ checkBatchWrites();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxWritesOnDhtNode() throws Exception {
+ checkTxWrites();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void checkSingleWrites() throws Exception {
+ prepare();
+
+ IgniteCache<Integer, String> cache = grid(0).cache(null);
+
+ for (int i = 0; i < 100; i++)
+ cache.put(i, String.valueOf(i));
+
+ checkWrites();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void checkBatchWrites() throws Exception {
+ prepare();
+
+ Map<Integer, String> map = new HashMap<>();
+
+ for (int i = 0; i < 100; i++)
+ map.put(i, String.valueOf(i));
+
+ grid(0).cache(null).putAll(map);
+
+ checkWrites();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void checkTxWrites() throws Exception {
+ prepare();
+
+ IgniteCache<Object, Object> cache = grid(0).cache(null);
+
+ try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ for (int i = 0; i < 100; i++)
+ cache.put(i, String.valueOf(i));
+
+ tx.commit();
+ }
+
+ checkWrites();
+ }
+
+ /**
+ * @throws IgniteInterruptedCheckedException If sleep was interrupted.
+ */
+ private void checkWrites() throws IgniteInterruptedCheckedException {
+ U.sleep(WRITE_BEHIND_FLUSH_FREQ * 2);
+
+ Collection<Integer> allKeys = new ArrayList<>(100);
+
+ for (int i = 0; i < GRID_CNT; i++) {
+ Map<Integer,String> map = stores[i].getMap();
+
+ assertFalse("Missing writes for node: " + i, map.isEmpty());
+
+ allKeys.addAll(map.keySet());
+
+ // Check there is no intersection.
+ for (int j = 0; j < GRID_CNT; j++) {
+ if (i == j)
+ continue;
+
+ Collection<Integer> intersection = new HashSet<>(stores[j].getMap().keySet());
+
+ intersection.retainAll(map.keySet());
+
+ assertTrue(intersection.isEmpty());
+ }
+ }
+
+ assertEquals(100, allKeys.size());
+
+ for (int i = 0; i < 100; i++)
+ assertTrue(allKeys.contains(i));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedTest.java
new file mode 100644
index 0000000..fe589ca
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStorePartitionedTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.cache.*;
+
+/**
+ * Tests {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore} in partitioned configuration.
+ */
+public class GridCacheWriteBehindStorePartitionedTest extends GridCacheWriteBehindStoreAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.PARTITIONED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreReplicatedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreReplicatedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreReplicatedTest.java
new file mode 100644
index 0000000..26f8431
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreReplicatedTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.cache.*;
+
+/**
+ * Tests {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore} in grid configuration.
+ */
+public class GridCacheWriteBehindStoreReplicatedTest extends GridCacheWriteBehindStoreAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.REPLICATED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
new file mode 100644
index 0000000..937e597
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStoreSelfTest.java
@@ -0,0 +1,268 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jsr166.*;
+
+import java.util.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * This class provides basic tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
+ */
+public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
+ /**
+ * Tests correct store shutdown when underlying store fails,
+ *
+ * @throws Exception If failed.
+ */
+ public void testShutdownWithFailure() throws Exception {
+ final AtomicReference<Exception> err = new AtomicReference<>();
+
+ multithreadedAsync(new Runnable() {
+ @Override public void run() {
+ try {
+ delegate.setShouldFail(true);
+
+ initStore(2);
+
+ try {
+ store.write(new CacheEntryImpl<>(1, "val1"));
+ store.write(new CacheEntryImpl<>(2, "val2"));
+ }
+ finally {
+ shutdownStore();
+
+ delegate.setShouldFail(false);
+ }
+ }
+ catch (Exception e) {
+ err.set(e);
+ }
+ }
+ }, 1).get();
+
+ if (err.get() != null)
+ throw err.get();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimpleStore() throws Exception {
+ initStore(2);
+
+ try {
+ store.write(new CacheEntryImpl<>(1, "v1"));
+ store.write(new CacheEntryImpl<>(2, "v2"));
+
+ assertEquals("v1", store.load(1));
+ assertEquals("v2", store.load(2));
+ assertNull(store.load(3));
+
+ store.delete(1);
+
+ assertNull(store.load(1));
+ assertEquals("v2", store.load(2));
+ assertNull(store.load(3));
+ }
+ finally {
+ shutdownStore();
+ }
+ }
+
+ /**
+ * Check that all values written to the store will be in underlying store after timeout or due to size limits.
+ *
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings({"NullableProblems"})
+ public void testValuePropagation() throws Exception {
+ // Need to test size-based write.
+ initStore(1);
+
+ try {
+ for (int i = 0; i < CACHE_SIZE * 2; i++)
+ store.write(new CacheEntryImpl<>(i, "val" + i));
+
+ U.sleep(200);
+
+ for (int i = 0; i < CACHE_SIZE; i++) {
+ String val = delegate.load(i);
+
+ assertNotNull("Value for [key= " + i + "] was not written in store", val);
+ assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
+ }
+
+ U.sleep(FLUSH_FREQUENCY + 300);
+
+ for (int i = CACHE_SIZE; i < CACHE_SIZE * 2; i++) {
+ String val = delegate.load(i);
+
+ assertNotNull("Value for [key= " + i + "] was not written in store", val);
+ assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
+ }
+ }
+ finally {
+ shutdownStore();
+ }
+ }
+
+ /**
+ * Tests store behaviour under continuous put of the same key with different values.
+ *
+ * @throws Exception If failed
+ */
+ public void testContinuousPut() throws Exception {
+ initStore(2);
+
+ try {
+ final AtomicBoolean running = new AtomicBoolean(true);
+
+ final AtomicInteger actualPutCnt = new AtomicInteger();
+
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @SuppressWarnings({"NullableProblems"})
+ @Override public void run() {
+ try {
+ while (running.get()) {
+ for (int i = 0; i < CACHE_SIZE; i++) {
+ store.write(new CacheEntryImpl<>(i, "val-0"));
+
+ actualPutCnt.incrementAndGet();
+
+ store.write(new CacheEntryImpl<>(i, "val" + i));
+
+ actualPutCnt.incrementAndGet();
+ }
+ }
+ }
+ catch (Exception e) {
+ error("Unexpected exception in put thread", e);
+
+ assert false;
+ }
+ }
+ }, 1, "put");
+
+ U.sleep(FLUSH_FREQUENCY * 2 + 500);
+
+ int delegatePutCnt = delegate.getPutAllCount();
+
+ running.set(false);
+
+ fut.get();
+
+ log().info(">>> [putCnt = " + actualPutCnt.get() + ", delegatePutCnt=" + delegatePutCnt + "]");
+
+ assertTrue("No puts were made to the underlying store", delegatePutCnt > 0);
+ assertTrue("Too many puts were made to the underlying store", delegatePutCnt < actualPutCnt.get() / 10);
+ }
+ finally {
+ shutdownStore();
+ }
+
+ // These checks must be done after the store shut down
+ assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
+
+ for (int i = 0; i < CACHE_SIZE; i++)
+ assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
+ }
+
+ /**
+ * Tests that all values were put into the store will be written to the underlying store
+ * after shutdown is called.
+ *
+ * @throws Exception If failed.
+ */
+ public void testShutdown() throws Exception {
+ initStore(2);
+
+ try {
+ final AtomicBoolean running = new AtomicBoolean(true);
+
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @SuppressWarnings({"NullableProblems"})
+ @Override public void run() {
+ try {
+ while (running.get()) {
+ for (int i = 0; i < CACHE_SIZE; i++) {
+ store.write(new CacheEntryImpl<>(i, "val-0"));
+
+ store.write(new CacheEntryImpl<>(i, "val" + i));
+ }
+ }
+ }
+ catch (Exception e) {
+ error("Unexpected exception in put thread", e);
+
+ assert false;
+ }
+ }
+ }, 1, "put");
+
+ U.sleep(300);
+
+ running.set(false);
+
+ fut.get();
+ }
+ finally {
+ shutdownStore();
+ }
+
+ // These checks must be done after the store shut down
+ assertEquals("Invalid store size", CACHE_SIZE, delegate.getMap().size());
+
+ for (int i = 0; i < CACHE_SIZE; i++)
+ assertEquals("Invalid value stored", "val" + i, delegate.getMap().get(i));
+ }
+
+ /**
+ * Tests that all values will be written to the underlying store
+ * right in the same order as they were put into the store.
+ *
+ * @throws Exception If failed.
+ */
+ public void testBatchApply() throws Exception {
+ delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>());
+
+ initStore(1);
+
+ List<Integer> intList = new ArrayList<>(CACHE_SIZE);
+
+ try {
+ for (int i = 0; i < CACHE_SIZE; i++) {
+ store.write(new CacheEntryImpl<>(i, "val" + i));
+
+ intList.add(i);
+ }
+ }
+ finally {
+ shutdownStore();
+ }
+
+ Map<Integer, String> underlyingMap = delegate.getMap();
+
+ assertTrue("Store map key set: " + underlyingMap.keySet(), F.eqOrdered(underlyingMap.keySet(), intList));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index 20a9caf..b277d48 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.processors.cache.dr.*;
import org.apache.ignite.internal.processors.cache.jta.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.query.continuous.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.processors.plugin.*;
@@ -59,10 +60,7 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
true,
new GridCacheEventManager(),
new GridCacheSwapManager(false),
- new GridCacheStoreManager(null,
- new IdentityHashMap<CacheStore, ThreadLocal>(),
- null,
- new CacheConfiguration()),
+ new CacheOsStoreManager(null, new CacheConfiguration()),
new GridCacheEvictionManager(),
new GridCacheLocalQueryManager<K, V>(),
new CacheContinuousQueryManager(),
@@ -74,5 +72,7 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
new CacheOsConflictResolutionManager<K, V>(),
new CachePluginManager(ctx, new CacheConfiguration())
);
+
+ store().initialize(null, new IdentityHashMap<CacheStore, ThreadLocal>());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java
index 452dbf1..529b227 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheWriteBehindTestSuite.java
@@ -19,9 +19,10 @@ package org.apache.ignite.testsuites;
import junit.framework.*;
import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.store.*;
/**
- * Test suite that contains all tests for {@link GridCacheWriteBehindStore}.
+ * Test suite that contains all tests for {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore}.
*/
public class IgniteCacheWriteBehindTestSuite extends TestSuite {
/**
[29/30] incubator-ignite git commit: ignite-366 Metrics for caches
should work in clustered mode
Posted by sb...@apache.org.
ignite-366 Metrics for caches should work in clustered mode
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b4c51f47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b4c51f47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b4c51f47
Branch: refs/heads/ignite-366
Commit: b4c51f47543bbfd663b956eab124541446072eb0
Parents: 7e86251
Author: Andrey Gura <ag...@gridgain.com>
Authored: Wed Apr 1 21:02:20 2015 +0300
Committer: Andrey Gura <ag...@gridgain.com>
Committed: Thu Apr 2 22:18:39 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cluster/ClusterNode.java | 14 +++++
.../discovery/GridDiscoveryManager.java | 17 ++++++
.../processors/cache/CacheMetricsSnapshot.java | 9 ++-
.../spi/discovery/DiscoveryMetricsProvider.java | 10 ++++
.../discovery/tcp/TcpClientDiscoverySpi.java | 38 ++++++++++++-
.../tcp/internal/TcpDiscoveryNode.java | 24 ++++++++
.../messages/TcpDiscoveryHeartbeatMessage.java | 58 ++++++++++++++++++++
.../ignite/internal/GridDiscoverySelfTest.java | 5 ++
...idCachePartitionedHitsAndMissesSelfTest.java | 9 ++-
.../ignite/p2p/GridP2PClassLoadingSelfTest.java | 6 ++
.../ignite/testframework/GridTestNode.java | 8 +++
.../junits/spi/GridSpiAbstractTest.java | 7 +++
12 files changed, 199 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
index 9cb5d3d..1c2e829 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
@@ -18,6 +18,7 @@
package org.apache.ignite.cluster;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.lang.*;
import org.jetbrains.annotations.*;
@@ -148,6 +149,19 @@ public interface ClusterNode {
public ClusterMetrics metrics();
/**
+ * Gets collections of cachemetrics snapshot for this node. Note that node cache metrics are constantly updated
+ * and provide up to date information about caches. For example, you can get
+ * an idea about cache hits on remote node via {@link CacheMetrics#getCacheHits()} method.
+ * <p>
+ * Cache metrics are updated with some delay which is directly related to heartbeat
+ * frequency. For example, when used with default
+ * {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi} the update will happen every {@code 2} seconds.
+ *
+ * @return Runtime metrics snapshots for this node.
+ */
+ public Collection<CacheMetrics> cacheMetrics();
+
+ /**
* Gets all node attributes. Attributes are assigned to nodes at startup
* via {@link org.apache.ignite.configuration.IgniteConfiguration#getUserAttributes()} method.
* <p>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 04ff423..5fb8616 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.managers.discovery;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
@@ -26,6 +27,7 @@ import org.apache.ignite.internal.managers.*;
import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.managers.eventstorage.*;
import org.apache.ignite.internal.processors.affinity.*;
+import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.jobmetrics.*;
import org.apache.ignite.internal.processors.security.*;
import org.apache.ignite.internal.util.*;
@@ -644,6 +646,21 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
return nm;
}
+
+ /** {@inheritDoc} */
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ Collection<GridCache<?, ?>> caches = ctx.cache().caches();
+
+ if (F.isEmpty(caches))
+ return Collections.emptyList();
+
+ List<CacheMetrics> metrics = new ArrayList<>(caches.size());
+
+ for (GridCache<?, ?> cache : caches)
+ metrics.add(cache.metrics());
+
+ return metrics;
+ }
};
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
index 0391f4e..e20259f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
@@ -23,7 +23,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
/**
* Metrics snapshot.
*/
-class CacheMetricsSnapshot implements CacheMetrics {
+public class CacheMetricsSnapshot implements CacheMetrics {
/** Number of reads. */
private long reads = 0;
@@ -178,6 +178,13 @@ class CacheMetricsSnapshot implements CacheMetrics {
private boolean isWriteThrough;
/**
+ * Default constructor.
+ */
+ public CacheMetricsSnapshot() {
+ // No-op.
+ }
+
+ /**
* Create snapshot for given metrics.
*
* @param m Cache metrics.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
index 4a03278..f3c98de 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
@@ -17,9 +17,12 @@
package org.apache.ignite.spi.discovery;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.util.tostring.*;
+import java.util.*;
+
/**
* Provides metrics to discovery SPI. It is responsibility of discovery SPI
* to make sure that all nodes have updated metrics data about each other.
@@ -36,4 +39,11 @@ public interface DiscoveryMetricsProvider {
* @return Up to date metrics data about local node.
*/
public ClusterMetrics metrics();
+
+ /**
+ * Returns metrics data about all caches on local node.
+ *
+ * @return metrics data about all caches on local node.
+ */
+ public Collection<CacheMetrics> cacheMetrics();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
index 48125bf..a3bff02 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
@@ -18,6 +18,7 @@
package org.apache.ignite.spi.discovery.tcp;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
@@ -1068,7 +1069,10 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
Socket sock0 = sock;
if (sock0 != null) {
- msg.setMetrics(ignite.configuration().getNodeId(), metricsProvider.metrics());
+ UUID nodeId = ignite.configuration().getNodeId();
+
+ msg.setMetrics(nodeId, metricsProvider.metrics());
+ msg.setCacheMetrics(nodeId, metricsProvider.cacheMetrics());
try {
writeToSocket(sock0, msg);
@@ -1095,9 +1099,9 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
log.debug("Received heartbeat response: " + msg);
}
else {
- if (msg.hasMetrics()) {
- long tstamp = U.currentTimeMillis();
+ long tstamp = U.currentTimeMillis();
+ if (msg.hasMetrics()) {
for (Map.Entry<UUID, MetricsSet> e : msg.metrics().entrySet()) {
MetricsSet metricsSet = e.getValue();
@@ -1107,6 +1111,11 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
updateMetrics(t.get1(), t.get2(), tstamp);
}
}
+
+ if (msg.hasCacheMetrics()) {
+ for (Map.Entry<UUID,Collection<CacheMetrics>> e : msg.cacheMetrics().entrySet())
+ updateCacheMetrics(e.getKey(), e.getValue(), tstamp);
+ }
}
}
@@ -1172,6 +1181,29 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
}
/**
+ * @param nodeId Node ID.
+ * @param cacheMetrics Cache metrics.
+ * @param tstamp Timestamp.
+ */
+ private void updateCacheMetrics(UUID nodeId, Collection<CacheMetrics> cacheMetrics, long tstamp) {
+ assert nodeId != null;
+ assert cacheMetrics != null;
+
+ TcpDiscoveryNode node = nodeId.equals(ignite.configuration().getNodeId()) ? locNode : rmtNodes.get(nodeId);
+
+ if (node != null && node.visible()) {
+ node.setCacheMetrics(cacheMetrics);
+
+ node.lastUpdateTime(tstamp);
+
+ notifyDiscovery(EVT_NODE_METRICS_UPDATED, topVer, node, allNodes());
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Received cacheMetrics from unknown node: " + nodeId);
+ }
+
+
+ /**
* @param topVer New topology version.
* @return Latest topology snapshot.
*/
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
index 450dd8c..89924fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
@@ -17,6 +17,7 @@
package org.apache.ignite.spi.discovery.tcp.internal;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.lang.*;
@@ -73,6 +74,10 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
@GridToStringExclude
private volatile ClusterMetrics metrics;
+ /** Node cache metrics. */
+ @GridToStringExclude
+ private volatile Collection<CacheMetrics> cacheMetrics;
+
/** Node order in the topology. */
private volatile long order;
@@ -209,6 +214,25 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
this.metrics = metrics;
}
+ /** {@inheritDoc} */
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ if (metricsProvider != null)
+ cacheMetrics = metricsProvider.cacheMetrics();
+
+ return cacheMetrics;
+ }
+
+ /**
+ * Sets node cache metrics.
+ *
+ * @param cacheMetrics Cache metrics.
+ */
+ public void setCacheMetrics(Collection<CacheMetrics> cacheMetrics) {
+ assert cacheMetrics != null;
+
+ this.cacheMetrics = cacheMetrics;
+ }
+
/**
* @return Internal order.
*/
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
index 65eea9f..095edb7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
@@ -17,6 +17,7 @@
package org.apache.ignite.spi.discovery.tcp.messages;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.tostring.*;
@@ -52,6 +53,10 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
/** Client node IDs. */
private Collection<UUID> clientNodeIds;
+ /** Cahce metrics by node. */
+ @GridToStringExclude
+ private Map<UUID, Collection<CacheMetrics>> cacheMetrics;
+
/**
* Public default no-arg constructor for {@link Externalizable} interface.
*/
@@ -68,6 +73,7 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
super(creatorNodeId);
metrics = U.newHashMap(1);
+ cacheMetrics = U.newHashMap(1);
clientNodeIds = new HashSet<>();
}
@@ -86,6 +92,20 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * Sets cache metrics for particular node.
+ *
+ * @param nodeId Node ID.
+ * @param metrics Node cache metrics.
+ */
+ public void setCacheMetrics(UUID nodeId, Collection<CacheMetrics> metrics) {
+ assert nodeId != null;
+ assert metrics != null;
+ assert !this.cacheMetrics.containsKey(nodeId);
+
+ this.cacheMetrics.put(nodeId, metrics);
+ }
+
+ /**
* Sets metrics for a client node.
*
* @param nodeId Server node ID.
@@ -113,6 +133,17 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * Removes cache metrics for particular node from the message.
+ *
+ * @param nodeId Node ID.
+ */
+ public void removeCacheMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ cacheMetrics.remove(nodeId);
+ }
+
+ /**
* Gets metrics map.
*
* @return Metrics map.
@@ -122,6 +153,15 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * Gets cache metrics map.
+ *
+ * @return Cache metrics map.
+ */
+ public Map<UUID, Collection<CacheMetrics>> cacheMetrics() {
+ return cacheMetrics;
+ }
+
+ /**
* @return {@code True} if this message contains metrics.
*/
public boolean hasMetrics() {
@@ -129,6 +169,13 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * @return {@code True} this message contains cache metrics.
+ */
+ public boolean hasCacheMetrics() {
+ return !cacheMetrics.isEmpty();
+ }
+
+ /**
* @return {@code True} if this message contains metrics.
*/
public boolean hasMetrics(UUID nodeId) {
@@ -138,6 +185,17 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * @param nodeId Node ID.
+ *
+ * @return {@code True} if this message contains cache metrics for particular node.
+ */
+ public boolean hasCacheMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ return cacheMetrics.get(nodeId) != null;
+ }
+
+ /**
* Gets client node IDs for particular node.
*
* @return Client node IDs.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
index 4a2483d..3c2ccbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
@@ -376,6 +376,11 @@ public class GridDiscoverySelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Map<String, Object> attributes() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java
index f5eb189..0d6d30a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedHitsAndMissesSelfTest.java
@@ -115,13 +115,18 @@ public class GridCachePartitionedHitsAndMissesSelfTest extends GridCommonAbstrac
for (int i = 0; i < GRID_CNT; i++) {
CacheMetrics m = grid(i).cache(null).metrics();
- hits += m.getCacheHits();
- misses += m.getCacheMisses();
+ long cacheHits = m.getCacheHits();
+ hits += cacheHits;
+ long cacheMisses = m.getCacheMisses();
+ misses += cacheMisses;
+
+ System.out.println("!!! Grid(" + i + "): hits = " + cacheHits + ", misses = " + cacheMisses);
}
// Check that invoke and loader updated metrics
assertEquals(CNT, hits);
assertEquals(CNT, misses);
+ System.out.println("!!! Grid: hits = " + hits + ", misses = " + hits);
}
finally {
stopAllGrids();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
index 9700d94..d9ffc8e 100644
--- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.p2p;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.internal.util.lang.*;
@@ -115,6 +116,11 @@ public class GridP2PClassLoadingSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public Map<String, Object> attributes() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
index 5de1f14..e5eea88 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
@@ -17,6 +17,7 @@
package org.apache.ignite.testframework;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.lang.*;
@@ -56,6 +57,9 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
private ClusterMetrics metrics;
/** */
+ private Collection<CacheMetrics> cacheMetrics = Collections.emptyList();
+
+ /** */
private long order;
/** */
@@ -186,6 +190,10 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
return metrics;
}
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ return cacheMetrics;
+ }
+
/** {@inheritDoc} */
@Override public long order() {
return order != 0 ? order : (metrics == null ? -1 : metrics.getStartTime());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b4c51f47/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
index 7898c3d..4d65587 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
@@ -18,8 +18,10 @@
package org.apache.ignite.testframework.junits.spi;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.plugin.security.*;
@@ -348,6 +350,11 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends GridAbstr
return new DiscoveryMetricsProvider() {
/** {@inheritDoc} */
@Override public ClusterMetrics metrics() { return new ClusterMetricsSnapshot(); }
+
+ /** {@inheritDoc} */
+ @Override public Collection<CacheMetrics> cacheMetrics() {
+ return Collections.<CacheMetrics>singletonList(new CacheMetricsSnapshot());
+ }
};
}
[21/30] incubator-ignite git commit: Merge remote-tracking branch
'origin/ignite-sprint-3' into ignite-sprint-3
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/ignite-sprint-3' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/214a461e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/214a461e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/214a461e
Branch: refs/heads/ignite-366
Commit: 214a461e4da316ea92d92514327fdd6523ab451f
Parents: 71f201c ddb8e91
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 2 12:58:11 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 2 12:58:11 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 2 +
ipc/shmem/README.txt | 2 +-
.../visor/cache/VisorCacheConfiguration.java | 81 ++++++++------------
.../cache/VisorCacheNearConfiguration.java | 11 ++-
.../visor/node/VisorGridConfiguration.java | 28 ++++++-
.../internal/visor/util/VisorMimeTypes.java | 4 +-
.../resources/META-INF/classnames.properties | 79 +++++--------------
.../GridUriDeploymentFileResourceLoader.java | 2 +-
parent/pom.xml | 10 ++-
9 files changed, 102 insertions(+), 117 deletions(-)
----------------------------------------------------------------------
[12/30] incubator-ignite git commit: Merge branches 'ignite-gg-9942'
and 'ignite-sprint-3' of
https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-gg-9942
Posted by sb...@apache.org.
Merge branches 'ignite-gg-9942' and 'ignite-sprint-3' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-gg-9942
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d47b66a2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d47b66a2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d47b66a2
Branch: refs/heads/ignite-366
Commit: d47b66a2177367e3e86e1ffba9217589783d27d1
Parents: c8428a4 ed6632a
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Apr 2 08:51:46 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Apr 2 08:51:46 2015 +0700
----------------------------------------------------------------------
examples/pom.xml | 19 +-
examples/schema-import/pom.xml | 10 +-
modules/aop/pom.xml | 6 +-
modules/aws/pom.xml | 4 +-
modules/clients/pom.xml | 10 +-
modules/codegen/pom.xml | 4 +-
modules/core/pom.xml | 8 +-
.../apache/ignite/cache/CachingProvider.java | 2 +-
.../configuration/FileSystemConfiguration.java | 6 +
.../processors/cache/CacheObjectContext.java | 14 +-
.../processors/cache/CacheObjectImpl.java | 10 +-
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 16 +-
.../continuous/CacheContinuousQueryManager.java | 28 ++
.../IgniteCacheObjectProcessorImpl.java | 173 +++++++----
.../processors/igfs/IgfsDataManager.java | 11 +-
.../processors/igfs/IgfsFileAffinityRange.java | 23 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 9 +-
.../IgniteCacheAtomicLocalStoreValueTest.java | 49 +++
...iteCacheAtomicNearEnabledStoreValueTest.java | 30 ++
...maryWriteOrderNearEnabledStoreValueTest.java | 31 ++
...heAtomicPrimaryWriteOrderStoreValueTest.java | 32 ++
.../cache/IgniteCacheAtomicStoreValueTest.java | 55 ++++
.../IgniteCacheStoreValueAbstractTest.java | 311 +++++++++++++++++++
.../cache/IgniteCacheTxLocalStoreValueTest.java | 49 +++
.../IgniteCacheTxNearEnabledStoreValueTest.java | 30 ++
.../cache/IgniteCacheTxStoreValueTest.java | 49 +++
.../junits/common/GridCommonAbstractTest.java | 2 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 9 +
modules/extdata/p2p/pom.xml | 4 +-
modules/extdata/uri/pom.xml | 4 +-
modules/geospatial/pom.xml | 4 +-
modules/hadoop/pom.xml | 8 +-
modules/hibernate/pom.xml | 6 +-
modules/indexing/pom.xml | 4 +-
modules/jcl/pom.xml | 4 +-
modules/jta/pom.xml | 4 +-
modules/log4j/pom.xml | 4 +-
modules/rest-http/pom.xml | 2 +-
modules/scalar/pom.xml | 10 +-
modules/schedule/pom.xml | 4 +-
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spring/pom.xml | 8 +-
modules/ssh/pom.xml | 8 +-
modules/urideploy/pom.xml | 6 +-
modules/visor-console/pom.xml | 8 +-
.../scala/org/apache/ignite/visor/visor.scala | 2 +-
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 8 +-
modules/yardstick/pom.xml | 6 +-
pom.xml | 56 ++--
52 files changed, 947 insertions(+), 221 deletions(-)
----------------------------------------------------------------------
[22/30] incubator-ignite git commit: sprint-3 dependency fix
Posted by sb...@apache.org.
sprint-3 dependency fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/07ca9fac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/07ca9fac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/07ca9fac
Branch: refs/heads/ignite-366
Commit: 07ca9facd0bd67eba935c05b120457082ec51b5c
Parents: 214a461
Author: avinogradov <av...@gridgain.com>
Authored: Thu Apr 2 14:44:54 2015 +0300
Committer: avinogradov <av...@gridgain.com>
Committed: Thu Apr 2 14:44:54 2015 +0300
----------------------------------------------------------------------
examples/pom-standalone.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/07ca9fac/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index f07b214..996753e 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -28,7 +28,6 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <ignite.version>1.0.0</ignite.version>
</properties>
<groupId>org.apache.ignite</groupId>
[30/30] incubator-ignite git commit: ignite-366 Metrics for caches
should work in clustered mode
Posted by sb...@apache.org.
ignite-366 Metrics for caches should work in clustered mode
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b73fb49c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b73fb49c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b73fb49c
Branch: refs/heads/ignite-366
Commit: b73fb49c3ebdf1c552b12e84e492a3db21e4d52a
Parents: b4c51f4
Author: Andrey Gura <ag...@gridgain.com>
Authored: Thu Apr 2 22:10:23 2015 +0300
Committer: Andrey Gura <ag...@gridgain.com>
Committed: Thu Apr 2 22:18:39 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 8 +
.../org/apache/ignite/cluster/ClusterNode.java | 2 +-
.../discovery/GridDiscoveryManager.java | 8 +-
.../processors/cache/CacheMetricsSnapshot.java | 269 ++++++++++++++++++-
.../processors/cache/IgniteCacheProxy.java | 15 ++
.../spi/discovery/DiscoveryMetricsProvider.java | 2 +-
.../discovery/tcp/TcpClientDiscoverySpi.java | 5 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 45 +++-
.../tcp/internal/TcpDiscoveryNode.java | 6 +-
.../messages/TcpDiscoveryHeartbeatMessage.java | 41 ++-
.../ignite/internal/GridDiscoverySelfTest.java | 2 +-
...hePartitionedMetricsForClusterGroupTest.java | 72 +++++
.../ignite/p2p/GridP2PClassLoadingSelfTest.java | 2 +-
.../ignite/testframework/GridTestNode.java | 4 +-
.../junits/spi/GridSpiAbstractTest.java | 4 +-
15 files changed, 459 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 5c5bb25..d133ab7 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.affinity.*;
import org.apache.ignite.cache.affinity.rendezvous.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.cache.store.*;
+import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.mxbean.*;
@@ -514,6 +515,13 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
public CacheMetrics metrics();
/**
+ * Gets snapshot metrics for caches in cluster group.
+ * @param grp Cluster group.
+ * @return Cache metrics.
+ */
+ public CacheMetrics metrics(ClusterGroup grp);
+
+ /**
* Gets MxBean for this cache.
*
* @return MxBean.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
index 1c2e829..bc1636e 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
@@ -159,7 +159,7 @@ public interface ClusterNode {
*
* @return Runtime metrics snapshots for this node.
*/
- public Collection<CacheMetrics> cacheMetrics();
+ public Map<String, CacheMetrics> cacheMetrics();
/**
* Gets all node attributes. Attributes are assigned to nodes at startup
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index 5fb8616..76afa73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -648,16 +648,16 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
/** {@inheritDoc} */
- @Override public Collection<CacheMetrics> cacheMetrics() {
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
Collection<GridCache<?, ?>> caches = ctx.cache().caches();
if (F.isEmpty(caches))
- return Collections.emptyList();
+ return Collections.emptyMap();
- List<CacheMetrics> metrics = new ArrayList<>(caches.size());
+ Map<String, CacheMetrics> metrics = U.newHashMap(caches.size());
for (GridCache<?, ?> cache : caches)
- metrics.add(cache.metrics());
+ metrics.put(cache.name(), cache.metrics());
return metrics;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
index e20259f..4e6a256 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
@@ -20,10 +20,16 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.cache.*;
import org.apache.ignite.internal.util.typedef.internal.*;
+import java.io.*;
+import java.util.*;
+
/**
* Metrics snapshot.
*/
-public class CacheMetricsSnapshot implements CacheMetrics {
+public class CacheMetricsSnapshot implements CacheMetrics, Externalizable {
+ /** Last update time. */
+ private long lastUpdateTime = -1;
+
/** Number of reads. */
private long reads = 0;
@@ -246,6 +252,131 @@ public class CacheMetricsSnapshot implements CacheMetrics {
isWriteThrough = m.isWriteThrough();
}
+ /**
+ * Constructs merged cachemetrics.
+ *
+ * @param metrics Metrics for merge.
+ */
+ public CacheMetricsSnapshot(Collection<CacheMetrics> metrics) {
+ A.notEmpty(metrics, "metrics");
+
+ // TODO: Only once
+ /*
+ cacheName
+ isEmpty
+ isWriteBehindEnabled
+ writeBehindFlushSize
+ writeBehindFlushThreadCount
+ writeBehindFlushFrequency
+ writeBehindStoreBatchSize
+ writeBehindTotalCriticalOverflowCount
+ writeBehindCriticalOverflowCount
+ writeBehindErrorRetryCount
+ writeBehindBufferSize
+
+ keyType
+ valueType
+ isStoreByValue
+ isStatisticsEnabled
+ isManagementEnabled
+ isReadThrough
+ isWriteThrough
+ */
+
+ //TODO: How to merge?
+ /*
+ overflowSize
+ size (only once PRIMARY?)
+ */
+
+ boolean first = true;
+
+ for (CacheMetrics e : metrics) {
+
+ if (first) {
+ cacheName = e.name();
+ isEmpty = e.isEmpty();
+ isWriteBehindEnabled = e.isWriteBehindEnabled();
+ writeBehindFlushSize = e.getWriteBehindFlushSize();
+ writeBehindFlushThreadCount = e.getWriteBehindFlushThreadCount();
+ writeBehindFlushFrequency = e.getWriteBehindFlushFrequency();
+ writeBehindStoreBatchSize = e.getWriteBehindStoreBatchSize();
+ writeBehindTotalCriticalOverflowCount = e.getWriteBehindTotalCriticalOverflowCount();
+ writeBehindCriticalOverflowCount = e.getWriteBehindCriticalOverflowCount();
+ writeBehindErrorRetryCount = e.getWriteBehindErrorRetryCount();
+ writeBehindBufferSize = e.getWriteBehindBufferSize();
+
+ keyType = e.getKeyType();
+ valueType = e.getValueType();
+ isStoreByValue = e.isStoreByValue();
+ isStatisticsEnabled = e.isStatisticsEnabled();
+ isManagementEnabled = e.isManagementEnabled();
+ isReadThrough = e.isReadThrough();
+ isWriteThrough = e.isWriteThrough();
+
+ first = false;
+ }
+
+ reads += e.getCacheGets();
+ puts += e.getCachePuts();
+ hits += e.getCacheHits();
+ misses += e.getCacheHits();
+ txCommits += e.getCacheTxCommits();
+ txRollbacks += e.getCacheTxRollbacks();
+ evicts += e.getCacheEvictions();
+ removes += e.getCacheRemovals();
+
+ putAvgTimeNanos += e.getAveragePutTime();
+ getAvgTimeNanos += e.getAverageGetTime();
+ removeAvgTimeNanos += e.getAverageRemoveTime();
+ commitAvgTimeNanos += e.getAverageTxCommitTime();
+ rollbackAvgTimeNanos += e.getAverageTxRollbackTime();
+
+ offHeapEntriesCount += e.getOffHeapEntriesCount();
+ offHeapAllocatedSize += e.getOffHeapAllocatedSize();
+ keySize += e.getKeySize();
+ dhtEvictQueueCurrentSize += e.getDhtEvictQueueCurrentSize();
+ txThreadMapSize += e.getTxThreadMapSize();
+ txXidMapSize += e.getTxXidMapSize();
+ txCommitQueueSize += e.getTxCommitQueueSize();
+ txPrepareQueueSize += e.getTxPrepareQueueSize();
+ txStartVersionCountsSize += e.getTxStartVersionCountsSize();
+ txCommittedVersionsSize += e.getTxCommittedVersionsSize();
+ txRolledbackVersionsSize += e.getTxRolledbackVersionsSize();
+ txDhtThreadMapSize += e.getTxDhtThreadMapSize();
+ txDhtXidMapSize += e.getTxDhtXidMapSize();
+ txDhtCommitQueueSize += e.getTxDhtCommitQueueSize();
+ txDhtPrepareQueueSize += e.getTxDhtPrepareQueueSize();
+ txDhtStartVersionCountsSize += e.getTxDhtStartVersionCountsSize();
+ txDhtCommittedVersionsSize += e.getTxDhtCommittedVersionsSize();
+ txDhtRolledbackVersionsSize += e.getTxDhtRolledbackVersionsSize();
+ }
+
+ putAvgTimeNanos /= metrics.size();
+ getAvgTimeNanos /= metrics.size();
+ removeAvgTimeNanos /= metrics.size();
+ commitAvgTimeNanos /= metrics.size();
+ rollbackAvgTimeNanos /= metrics.size();
+ }
+
+ /**
+ * Gets last update time of this node metrics.
+ *
+ * @return Last update time.
+ */
+ public long getLastUpdateTime() {
+ return lastUpdateTime;
+ }
+
+ /**
+ * Sets last update time.
+ *
+ * @param lastUpdateTime Last update time.
+ */
+ public void setLastUpdateTime(long lastUpdateTime) {
+ this.lastUpdateTime = lastUpdateTime;
+ }
+
/** {@inheritDoc} */
@Override public long getCacheHits() {
return hits;
@@ -266,9 +397,8 @@ public class CacheMetricsSnapshot implements CacheMetrics {
/** {@inheritDoc} */
@Override public float getCacheMissPercentage() {
- if (misses == 0 || reads == 0) {
+ if (misses == 0 || reads == 0)
return 0;
- }
return (float) misses / reads * 100.0f;
}
@@ -283,6 +413,14 @@ public class CacheMetricsSnapshot implements CacheMetrics {
return puts;
}
+ /**
+ * Sets the total number of puts to the cache.
+ * @param puts The total number of puts to the cache.
+ */
+ public void setCachePuts(long puts) {
+ this.puts = puts;
+ }
+
/** {@inheritDoc} */
@Override public long getCacheRemovals() {
return removes;
@@ -303,6 +441,15 @@ public class CacheMetricsSnapshot implements CacheMetrics {
return putAvgTimeNanos;
}
+ /**
+ * Sets the mean time to execute puts.
+ *
+ * @param putAvgTimeNanos The time in µs.
+ */
+ public void setAveragePutTime(float putAvgTimeNanos) {
+ this.putAvgTimeNanos = putAvgTimeNanos;
+ }
+
/** {@inheritDoc} */
@Override public float getAverageRemoveTime() {
return removeAvgTimeNanos;
@@ -522,4 +669,120 @@ public class CacheMetricsSnapshot implements CacheMetrics {
@Override public String toString() {
return S.toString(CacheMetricsSnapshot.class, this);
}
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(reads);
+ out.writeLong(puts);
+ out.writeLong(hits);
+ out.writeLong(misses);
+ out.writeLong(txCommits);
+ out.writeLong(txRollbacks);
+ out.writeLong(evicts);
+ out.writeLong(removes);
+
+ out.writeFloat(putAvgTimeNanos);
+ out.writeFloat(getAvgTimeNanos);
+ out.writeFloat(removeAvgTimeNanos);
+ out.writeFloat(commitAvgTimeNanos);
+ out.writeFloat(rollbackAvgTimeNanos);
+
+ U.writeUTFStringNullable(out, cacheName);
+ out.writeLong(overflowSize);
+ out.writeLong(offHeapEntriesCount);
+ out.writeLong(offHeapAllocatedSize);
+ out.writeInt(size);
+ out.writeInt(keySize);
+ out.writeBoolean(isEmpty);
+ out.writeInt(dhtEvictQueueCurrentSize);
+ out.writeInt(txThreadMapSize);
+ out.writeInt(txXidMapSize);
+ out.writeInt(txCommitQueueSize);
+ out.writeInt(txPrepareQueueSize);
+ out.writeInt(txStartVersionCountsSize);
+ out.writeInt(txCommittedVersionsSize);
+ out.writeInt(txRolledbackVersionsSize);
+ out.writeInt(txDhtThreadMapSize);
+ out.writeInt(txDhtXidMapSize);
+ out.writeInt(txDhtCommitQueueSize);
+ out.writeInt(txDhtPrepareQueueSize);
+ out.writeInt(txDhtStartVersionCountsSize);
+ out.writeInt(txDhtCommittedVersionsSize);
+ out.writeInt(txDhtRolledbackVersionsSize);
+ out.writeBoolean(isWriteBehindEnabled);
+ out.writeInt(writeBehindFlushSize);
+ out.writeInt(writeBehindFlushThreadCount);
+ out.writeLong(writeBehindFlushFrequency);
+ out.writeInt(writeBehindStoreBatchSize);
+ out.writeInt(writeBehindTotalCriticalOverflowCount);
+ out.writeInt(writeBehindCriticalOverflowCount);
+ out.writeInt(writeBehindErrorRetryCount);
+ out.writeInt(writeBehindBufferSize);
+
+ out.writeUTF(keyType);
+ out.writeUTF(valueType);
+ out.writeBoolean(isStoreByValue);
+ out.writeBoolean(isStatisticsEnabled);
+ out.writeBoolean(isManagementEnabled);
+ out.writeBoolean(isReadThrough);
+ out.writeBoolean(isWriteThrough);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ reads = in.readLong();
+ puts = in.readLong();
+ hits = in.readLong();
+ misses = in.readLong();
+ txCommits = in.readLong();
+ txRollbacks = in.readLong();
+ evicts = in.readLong();
+ removes = in.readLong();
+
+ putAvgTimeNanos = in.readFloat();
+ getAvgTimeNanos = in.readFloat();
+ removeAvgTimeNanos = in.readFloat();
+ commitAvgTimeNanos = in.readFloat();
+ rollbackAvgTimeNanos = in.readFloat();
+
+ cacheName = U.readUTFStringNullable(in);
+ overflowSize = in.readLong();
+ offHeapEntriesCount = in.readLong();
+ offHeapAllocatedSize = in.readLong();
+ size = in.readInt();
+ keySize = in.readInt();
+ isEmpty = in.readBoolean();
+ dhtEvictQueueCurrentSize = in.readInt();
+ txThreadMapSize = in.readInt();
+ txXidMapSize = in.readInt();
+ txCommitQueueSize = in.readInt();
+ txPrepareQueueSize = in.readInt();
+ txStartVersionCountsSize = in.readInt();
+ txCommittedVersionsSize = in.readInt();
+ txRolledbackVersionsSize = in.readInt();
+ txDhtThreadMapSize = in.readInt();
+ txDhtXidMapSize = in.readInt();
+ txDhtCommitQueueSize = in.readInt();
+ txDhtPrepareQueueSize = in.readInt();
+ txDhtStartVersionCountsSize = in.readInt();
+ txDhtCommittedVersionsSize = in.readInt();
+ txDhtRolledbackVersionsSize = in.readInt();
+ isWriteBehindEnabled = in.readBoolean();
+ writeBehindFlushSize = in.readInt();
+ writeBehindFlushThreadCount = in.readInt();
+ writeBehindFlushFrequency = in.readLong();
+ writeBehindStoreBatchSize = in.readInt();
+ writeBehindTotalCriticalOverflowCount = in.readInt();
+ writeBehindCriticalOverflowCount = in.readInt();
+ writeBehindErrorRetryCount = in.readInt();
+ writeBehindBufferSize = in.readInt();
+
+ keyType = in.readUTF();
+ valueType = in.readUTF();
+ isStoreByValue = in.readBoolean();
+ isStatisticsEnabled = in.readBoolean();
+ isManagementEnabled = in.readBoolean();
+ isReadThrough = in.readBoolean();
+ isWriteThrough = in.readBoolean();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index dfc3ef4..6b7d709 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -140,6 +140,21 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public CacheMetrics metrics(ClusterGroup grp) {
+ List<CacheMetrics> metrics = new ArrayList<>(grp.nodes().size());
+
+ for (ClusterNode node : grp.nodes())
+ metrics.add(node.cacheMetrics().get(getName()));
+
+ if (F.isEmpty(metrics)) {
+ //TODO: what actually need to be returned?
+ return new CacheMetricsSnapshot();
+ }
+
+ return new CacheMetricsSnapshot(metrics);
+ }
+
+ /** {@inheritDoc} */
@Override public CacheMetricsMXBean mxBean() {
GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
index f3c98de..eb1deb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/DiscoveryMetricsProvider.java
@@ -45,5 +45,5 @@ public interface DiscoveryMetricsProvider {
*
* @return metrics data about all caches on local node.
*/
- public Collection<CacheMetrics> cacheMetrics();
+ public Map<String, CacheMetrics> cacheMetrics();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
index a3bff02..9cfee1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
@@ -1113,7 +1113,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
}
if (msg.hasCacheMetrics()) {
- for (Map.Entry<UUID,Collection<CacheMetrics>> e : msg.cacheMetrics().entrySet())
+ for (Map.Entry<UUID, Map<String, CacheMetrics>> e : msg.cacheMetrics().entrySet())
updateCacheMetrics(e.getKey(), e.getValue(), tstamp);
}
}
@@ -1185,7 +1185,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
* @param cacheMetrics Cache metrics.
* @param tstamp Timestamp.
*/
- private void updateCacheMetrics(UUID nodeId, Collection<CacheMetrics> cacheMetrics, long tstamp) {
+ private void updateCacheMetrics(UUID nodeId, Map<String, CacheMetrics> cacheMetrics, long tstamp) {
assert nodeId != null;
assert cacheMetrics != null;
@@ -1202,7 +1202,6 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements Tcp
log.debug("Received cacheMetrics from unknown node: " + nodeId);
}
-
/**
* @param topVer New topology version.
* @return Latest topology snapshot.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index d5c05f7..856ede2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -18,6 +18,7 @@
package org.apache.ignite.spi.discovery.tcp;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.DiscoveryEvent;
@@ -4351,7 +4352,7 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
return;
}
- if (locNodeId.equals(msg.creatorNodeId()) && !msg.hasMetrics(locNodeId) && msg.senderNodeId() != null) {
+ if (locNodeId.equals(msg.creatorNodeId()) && !hasMetrics(msg, locNodeId) && msg.senderNodeId() != null) {
if (log.isDebugEnabled())
log.debug("Discarding heartbeat message that has made two passes: " + msg);
@@ -4371,14 +4372,21 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
updateMetrics(t.get1(), t.get2(), tstamp);
}
}
+
+ if (msg.hasCacheMetrics()) {
+ for (Map.Entry<UUID, Map<String, CacheMetrics>> e : msg.cacheMetrics().entrySet())
+ updateCacheMetrics(e.getKey(), e.getValue(), tstamp);
+ }
}
if (ring.hasRemoteNodes()) {
if ((locNodeId.equals(msg.creatorNodeId()) && msg.senderNodeId() == null ||
- !msg.hasMetrics(locNodeId)) && spiStateCopy() == CONNECTED) {
+ !hasMetrics(msg, locNodeId)) && spiStateCopy() == CONNECTED) {
// Message is on its first ring or just created on coordinator.
msg.setMetrics(locNodeId, metricsProvider.metrics());
+ msg.setCacheMetrics(locNodeId, metricsProvider.cacheMetrics());
+
for (Map.Entry<UUID, ClientMessageWorker> e : clientMsgWorkers.entrySet()) {
UUID nodeId = e.getKey();
ClusterMetrics metrics = e.getValue().metrics();
@@ -4393,6 +4401,8 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
// Message is on its second ring.
msg.removeMetrics(locNodeId);
+ msg.removeCacheMetrics(locNodeId);
+
Collection<UUID> clientNodeIds = msg.clientNodeIds();
for (TcpDiscoveryNode clientNode : ring.clientNodes()) {
@@ -4444,6 +4454,35 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
}
/**
+ * @param nodeId Node ID.
+ * @param cacheMetrics Cache metrics.
+ * @param tstamp Timestamp.
+ */
+ private void updateCacheMetrics(UUID nodeId, Map<String, CacheMetrics> cacheMetrics, long tstamp) {
+ assert nodeId != null;
+ assert cacheMetrics != null;
+
+ TcpDiscoveryNode node = ring.node(nodeId);
+
+ if (node != null && node.visible()) {
+ node.setCacheMetrics(cacheMetrics);
+
+ node.lastUpdateTime(tstamp);
+
+ notifyDiscovery(EVT_NODE_METRICS_UPDATED, ring.topologyVersion(), node);
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Received cacheMetrics from unknown node: " + nodeId);
+ }
+
+ /**
+ * @param msg Message.
+ */
+ private boolean hasMetrics(TcpDiscoveryHeartbeatMessage msg, UUID nodeId) {
+ return msg.hasMetrics(nodeId) || msg.hasCacheMetrics(nodeId);
+ }
+
+ /**
* Processes discard message and discards previously registered pending messages.
*
* @param msg Discard message.
@@ -5226,8 +5265,10 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
metrics = hbMsg.metrics().get(nodeId).metrics();
hbMsg.removeMetrics(nodeId);
+ hbMsg.removeCacheMetrics(nodeId);
assert !hbMsg.hasMetrics();
+ assert !hbMsg.hasCacheMetrics();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
index 89924fb..7c4d17b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
@@ -76,7 +76,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
/** Node cache metrics. */
@GridToStringExclude
- private volatile Collection<CacheMetrics> cacheMetrics;
+ private volatile Map<String, CacheMetrics> cacheMetrics;
/** Node order in the topology. */
private volatile long order;
@@ -215,7 +215,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
}
/** {@inheritDoc} */
- @Override public Collection<CacheMetrics> cacheMetrics() {
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
if (metricsProvider != null)
cacheMetrics = metricsProvider.cacheMetrics();
@@ -227,7 +227,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
*
* @param cacheMetrics Cache metrics.
*/
- public void setCacheMetrics(Collection<CacheMetrics> cacheMetrics) {
+ public void setCacheMetrics(Map<String, CacheMetrics> cacheMetrics) {
assert cacheMetrics != null;
this.cacheMetrics = cacheMetrics;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
index 095edb7..c1e434e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.spi.discovery.tcp.messages;
import org.apache.ignite.cache.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -55,7 +56,7 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
/** Cahce metrics by node. */
@GridToStringExclude
- private Map<UUID, Collection<CacheMetrics>> cacheMetrics;
+ private Map<UUID, Map<String, CacheMetrics>> cacheMetrics;
/**
* Public default no-arg constructor for {@link Externalizable} interface.
@@ -97,7 +98,7 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
* @param nodeId Node ID.
* @param metrics Node cache metrics.
*/
- public void setCacheMetrics(UUID nodeId, Collection<CacheMetrics> metrics) {
+ public void setCacheMetrics(UUID nodeId, Map<String, CacheMetrics> metrics) {
assert nodeId != null;
assert metrics != null;
assert !this.cacheMetrics.containsKey(nodeId);
@@ -157,7 +158,7 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
*
* @return Cache metrics map.
*/
- public Map<UUID, Collection<CacheMetrics>> cacheMetrics() {
+ public Map<UUID, Map<String, CacheMetrics>> cacheMetrics() {
return cacheMetrics;
}
@@ -226,6 +227,21 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
}
}
+ out.writeInt(cacheMetrics.size());
+
+ if (!cacheMetrics.isEmpty()) {
+ for (Map.Entry<UUID, Map<String, CacheMetrics>> e : cacheMetrics.entrySet()) {
+ U.writeUuid(out, e.getKey());
+
+ Map<String, CacheMetrics> ms = e.getValue();
+
+ out.writeInt(ms == null ? 0 : ms.size());
+
+ for (Map.Entry<String, CacheMetrics> m : ms.entrySet())
+ out.writeObject(m.getValue());
+ }
+ }
+
U.writeCollection(out, clientNodeIds);
}
@@ -240,6 +256,25 @@ public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
for (int i = 0; i < metricsSize; i++)
metrics.put(U.readUuid(in), (MetricsSet)in.readObject());
+ int cacheMetricsSize = in.readInt();
+
+ cacheMetrics = U.newHashMap(cacheMetricsSize);
+
+ for (int i = 0; i < cacheMetricsSize; i++) {
+ UUID uuid = U.readUuid(in);
+
+ int size = in.readInt();
+
+ Map<String, CacheMetrics> ms = U.newHashMap(size);
+
+ for (int j = 0; j < size; j++) {
+ CacheMetricsSnapshot m = (CacheMetricsSnapshot) in.readObject();
+ ms.put(m.name(), m);
+ }
+
+ cacheMetrics.put(uuid, ms);
+ }
+
clientNodeIds = U.readCollection(in);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
index 3c2ccbb..5f47d5e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
@@ -376,7 +376,7 @@ public class GridDiscoverySelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public Collection<CacheMetrics> cacheMetrics() {
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedMetricsForClusterGroupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedMetricsForClusterGroupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedMetricsForClusterGroupTest.java
new file mode 100644
index 0000000..dce9dda
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedMetricsForClusterGroupTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.distributed.dht;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.cache.*;
+
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheRebalanceMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ *
+ */
+public class GridCachePartitionedMetricsForClusterGroupTest extends GridCacheAbstractMetricsSelfTest {
+ /** Grid count. */
+ private static final int GRID_CNT = 3;
+ public static final String CACHE_1 = "cache1";
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return GRID_CNT;
+ }
+
+ @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
+ CacheConfiguration ccfg = super.cacheConfiguration(gridName);
+
+ ccfg.setBackups(0);
+
+ return ccfg;
+ }
+
+ public void testMetrics() throws Exception {
+ IgniteCache<Integer, Integer> cache = grid(0).cache(null);
+
+ for (int i = 0; i < 1000; i++)
+ cache.put(i, i);
+
+ for (int i = 0; i < GRID_CNT; i++) {
+ IgniteCache<Integer, Integer> c = grid(i).cache(null);
+ System.out.println("!!! Grid(" + i + "), puts = " + c.metrics().getCachePuts() + ", size = " + c.size());
+ }
+
+ Thread.sleep(10000);
+
+ CacheMetrics metrics = cache.metrics(grid(0).cluster().forRemotes());
+
+ System.out.println(metrics);
+/*
+ assertEquals(1, cache.metrics().getCachePuts());
+ assertEquals(0, grid(1).cache(null).metrics().getCachePuts());
+ assertEquals(1, grid(2).cache(null).metrics().getCachePuts());
+*/
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
index d9ffc8e..6622288 100644
--- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PClassLoadingSelfTest.java
@@ -116,7 +116,7 @@ public class GridP2PClassLoadingSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public Collection<CacheMetrics> cacheMetrics() {
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
index e5eea88..aed66ad 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestNode.java
@@ -57,7 +57,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
private ClusterMetrics metrics;
/** */
- private Collection<CacheMetrics> cacheMetrics = Collections.emptyList();
+ private Map<String, CacheMetrics> cacheMetrics = Collections.emptyMap();
/** */
private long order;
@@ -190,7 +190,7 @@ public class GridTestNode extends GridMetadataAwareAdapter implements ClusterNod
return metrics;
}
- @Override public Collection<CacheMetrics> cacheMetrics() {
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
return cacheMetrics;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b73fb49c/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
index 4d65587..2655b9d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
@@ -352,8 +352,8 @@ public abstract class GridSpiAbstractTest<T extends IgniteSpi> extends GridAbstr
@Override public ClusterMetrics metrics() { return new ClusterMetricsSnapshot(); }
/** {@inheritDoc} */
- @Override public Collection<CacheMetrics> cacheMetrics() {
- return Collections.<CacheMetrics>singletonList(new CacheMetricsSnapshot());
+ @Override public Map<String, CacheMetrics> cacheMetrics() {
+ return Collections.<String, CacheMetrics>singletonMap(null, new CacheMetricsSnapshot());
}
};
}
[17/30] incubator-ignite git commit: # ignite-sprint-3 added test
Posted by sb...@apache.org.
# ignite-sprint-3 added test
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/71f201cb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/71f201cb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/71f201cb
Branch: refs/heads/ignite-366
Commit: 71f201cb203f68a497a404731091c254072fd10e
Parents: 505a7bf
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 2 12:08:36 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 2 12:08:36 2015 +0300
----------------------------------------------------------------------
.../transactions/IgniteTxLocalAdapter.java | 4 +-
.../processors/igfs/IgsfStartCacheTest.java | 115 +++++++++++++++++++
2 files changed, 117 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/71f201cb/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 9d7f332..f2407ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -3080,8 +3080,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
"(cache configurations are not compatible) [" +
"activeCaches=[" + cacheNames + "]" +
", cacheName=" + cacheCtx.name() +
- ", txSystem=" + system() +
- ", cacheSystem=" + cacheCtx.system() + ']');
+ ", cacheSystem=" + cacheCtx.system() +
+ ", txSystem=" + system() + ']');
}
else
activeCacheIds.add(cacheId);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/71f201cb/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
new file mode 100644
index 0000000..e2eedbe
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+
+import java.io.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+import static org.apache.ignite.igfs.IgfsMode.*;
+
+/**
+ *
+ */
+public class IgsfStartCacheTest extends IgfsCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /**
+ * @param igfs If {@code true} created IGFS configuration.
+ * @param idx Node index.
+ * @return Configuration
+ */
+ private IgniteConfiguration config(boolean igfs, int idx) {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ if (igfs) {
+ FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+ igfsCfg.setDataCacheName("dataCache");
+ igfsCfg.setMetaCacheName("metaCache");
+ igfsCfg.setName("igfs");
+ igfsCfg.setDefaultMode(PRIMARY);
+ igfsCfg.setFragmentizerEnabled(false);
+
+ CacheConfiguration dataCacheCfg = new CacheConfiguration();
+
+ dataCacheCfg.setName("dataCache");
+ dataCacheCfg.setCacheMode(PARTITIONED);
+ dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+ dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+ dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(1));
+
+ CacheConfiguration metaCacheCfg = new CacheConfiguration();
+
+ metaCacheCfg.setName("metaCache");
+ metaCacheCfg.setCacheMode(REPLICATED);
+ metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+ dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+ cfg.setFileSystemConfiguration(igfsCfg);
+ }
+
+ cfg.setGridName("node-" + idx);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheStart() throws Exception {
+ Ignite g0 = G.start(config(true, 0));
+
+ G.start(config(false, 1));
+
+ IgniteFileSystem igfs = g0.fileSystem("igfs");
+
+ igfs.mkdirs(new IgfsPath("/test"));
+
+ try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(
+ new IgfsPath("/test/test.file"), true)))) {
+
+ for (int i = 0; i < 1000; i++)
+ bw.write("test-" + i);
+ }
+ }
+}
[26/30] incubator-ignite git commit: # GG-9973: Fixed.
Posted by sb...@apache.org.
# GG-9973: Fixed.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c6629012
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c6629012
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c6629012
Branch: refs/heads/ignite-366
Commit: c66290121e8eaae4999ecf3104c556dfc778edc3
Parents: 07ca9fa
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Apr 2 17:29:12 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Apr 2 17:29:12 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CacheMetricsImpl.java | 1 +
.../cache/CacheStorePartialUpdateException.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 16 +-
.../processors/cache/GridCacheContext.java | 9 +-
.../processors/cache/GridCacheMapEntry.java | 28 +-
.../processors/cache/GridCacheProcessor.java | 13 +-
.../processors/cache/GridCacheStoreManager.java | 1202 ------------------
.../cache/GridCacheWriteBehindStore.java | 1015 ---------------
.../distributed/dht/GridDhtCacheAdapter.java | 6 +-
.../distributed/dht/GridDhtCacheEntry.java | 4 +-
.../distributed/dht/GridDhtLocalPartition.java | 4 +-
.../distributed/dht/GridDhtLockFuture.java | 2 +-
.../dht/atomic/GridDhtAtomicCache.java | 8 +-
.../local/atomic/GridLocalAtomicCache.java | 4 +-
.../cache/store/CacheOsStoreManager.java | 59 +
.../cache/store/CacheStoreManager.java | 182 +++
.../store/GridCacheStoreManagerAdapter.java | 1111 ++++++++++++++++
.../cache/store/GridCacheWriteBehindStore.java | 1015 +++++++++++++++
.../cache/transactions/IgniteTxAdapter.java | 5 +-
.../transactions/IgniteTxLocalAdapter.java | 39 +-
.../cacheobject/IgniteCacheObjectProcessor.java | 6 -
.../IgniteCacheObjectProcessorImpl.java | 5 -
.../processors/plugin/CachePluginManager.java | 8 +-
.../resources/META-INF/classnames.properties | 14 +-
.../cache/GridCachePartitionedWritesTest.java | 3 +-
...idCacheWriteBehindStoreAbstractSelfTest.java | 189 ---
.../GridCacheWriteBehindStoreAbstractTest.java | 349 -----
.../GridCacheWriteBehindStoreLocalTest.java | 30 -
...heWriteBehindStoreMultithreadedSelfTest.java | 163 ---
...BehindStorePartitionedMultiNodeSelfTest.java | 215 ----
...ridCacheWriteBehindStorePartitionedTest.java | 30 -
...GridCacheWriteBehindStoreReplicatedTest.java | 30 -
.../GridCacheWriteBehindStoreSelfTest.java | 267 ----
...idCacheWriteBehindStoreAbstractSelfTest.java | 191 +++
.../GridCacheWriteBehindStoreAbstractTest.java | 350 +++++
.../GridCacheWriteBehindStoreLocalTest.java | 30 +
...heWriteBehindStoreMultithreadedSelfTest.java | 163 +++
...BehindStorePartitionedMultiNodeSelfTest.java | 216 ++++
...ridCacheWriteBehindStorePartitionedTest.java | 30 +
...GridCacheWriteBehindStoreReplicatedTest.java | 30 +
.../GridCacheWriteBehindStoreSelfTest.java | 268 ++++
.../loadtests/hashmap/GridCacheTestContext.java | 8 +-
.../IgniteCacheWriteBehindTestSuite.java | 3 +-
43 files changed, 3741 insertions(+), 3582 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index 446070e..deebab4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.*;
import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStorePartialUpdateException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStorePartialUpdateException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStorePartialUpdateException.java
index 6a364da..f7fca59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStorePartialUpdateException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStorePartialUpdateException.java
@@ -36,7 +36,7 @@ public class CacheStorePartialUpdateException extends IgniteCheckedException {
* @param cause Cause.
*/
@SuppressWarnings("unchecked")
- CacheStorePartialUpdateException(Collection failedKeys, Exception cause) {
+ public CacheStorePartialUpdateException(Collection failedKeys, Exception cause) {
super(cause);
this.failedKeys = failedKeys;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index eb1a98f..ca84c1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -993,7 +993,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
* @throws IgniteCheckedException In case of any errors.
*/
@Nullable private Object peekDb(KeyCacheObject key) throws IgniteCheckedException {
- return ctx.store().loadFromStore(ctx.tm().localTxx(), key);
+ return ctx.store().load(ctx.tm().localTxx(), key);
}
/**
@@ -1581,7 +1581,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
return ctx.closures().callLocalSafe(new GPC<Object>() {
@Nullable @Override public Object call() {
try {
- ctx.store().loadAllFromStore(tx, keys, vis);
+ ctx.store().loadAll(tx, keys, vis);
}
catch (IgniteCheckedException e) {
throw new GridClosureException(e);
@@ -2096,7 +2096,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
return new GridEmbeddedFuture(
ctx.closures().callLocalSafe(ctx.projectSafe(new GPC<Map<K1, V1>>() {
@Override public Map<K1, V1> call() throws Exception {
- ctx.store().loadAllFromStore(null/*tx*/, loadKeys.keySet(), new CI2<KeyCacheObject, Object>() {
+ ctx.store().loadAll(null/*tx*/, loadKeys.keySet(), new CI2<KeyCacheObject, Object>() {
/** New version for all new entries. */
private GridCacheVersion nextVer;
@@ -3676,7 +3676,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
final ExpiryPolicy plc = plc0 != null ? plc0 : ctx.expiry();
- if (ctx.store().isLocalStore()) {
+ if (ctx.store().isLocal()) {
DataStreamerImpl ldr = ctx.kernalContext().dataStream().dataStreamer(ctx.namex());
try {
@@ -3789,7 +3789,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
ExpiryPolicy plc = prj != null ? prj.expiry() : null;
if (replaceExisting) {
- if (ctx.store().isLocalStore()) {
+ if (ctx.store().isLocal()) {
Collection<ClusterNode> nodes = ctx.grid().cluster().forDataNodes(name()).nodes();
if (nodes.isEmpty())
@@ -3837,7 +3837,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
Collection<KeyCacheObject> keys0 = ctx.cacheKeysView(keys);
- ctx.store().loadAllFromStore(null, keys0, new CIX2<KeyCacheObject, Object>() {
+ ctx.store().loadAll(null, keys0, new CIX2<KeyCacheObject, Object>() {
@Override public void applyx(KeyCacheObject key, Object val) {
col.add(new DataStreamerEntry(key, ctx.toCacheObject(val)));
@@ -3870,7 +3870,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
Collection<KeyCacheObject> keys0 = ctx.cacheKeysView(keys);
- if (ctx.store().isLocalStore()) {
+ if (ctx.store().isLocal()) {
DataStreamerImpl ldr = ctx.kernalContext().dataStream().dataStreamer(ctx.namex());
try {
@@ -3890,7 +3890,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
// Version for all loaded entries.
final GridCacheVersion ver0 = ctx.versions().nextForLoad();
- ctx.store().loadAllFromStore(null, keys0, new CI2<KeyCacheObject, Object>() {
+ ctx.store().loadAll(null, keys0, new CI2<KeyCacheObject, Object>() {
@Override public void apply(KeyCacheObject key, Object val) {
long ttl = CU.ttlForLoad(plc0);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index e7f3ad4..dfa82e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -38,6 +38,7 @@ import org.apache.ignite.internal.processors.cache.jta.*;
import org.apache.ignite.internal.processors.cache.local.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.query.continuous.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.processors.cacheobject.*;
@@ -127,7 +128,7 @@ public class GridCacheContext<K, V> implements Externalizable {
private GridCacheTtlManager ttlMgr;
/** Store manager. */
- private GridCacheStoreManager storeMgr;
+ private CacheStoreManager storeMgr;
/** Replication manager. */
private GridCacheDrManager drMgr;
@@ -233,7 +234,7 @@ public class GridCacheContext<K, V> implements Externalizable {
GridCacheEventManager evtMgr,
GridCacheSwapManager swapMgr,
- GridCacheStoreManager storeMgr,
+ CacheStoreManager storeMgr,
GridCacheEvictionManager evictMgr,
GridCacheQueryManager<K, V> qryMgr,
CacheContinuousQueryManager contQryMgr,
@@ -882,7 +883,7 @@ public class GridCacheContext<K, V> implements Externalizable {
* are set to {@code true} or the store is local.
*/
public boolean writeToStoreFromDht() {
- return store().isLocalStore() || cacheCfg.isWriteBehindEnabled();
+ return store().isLocal() || cacheCfg.isWriteBehindEnabled();
}
/**
@@ -951,7 +952,7 @@ public class GridCacheContext<K, V> implements Externalizable {
/**
* @return Store manager.
*/
- public GridCacheStoreManager store() {
+ public CacheStoreManager store() {
return storeMgr;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index d7fbde9..542d0ad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -590,7 +590,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
@SuppressWarnings({"RedundantTypeArguments"})
@Nullable protected Object readThrough(@Nullable IgniteInternalTx tx, KeyCacheObject key, boolean reload, UUID subjId,
String taskName) throws IgniteCheckedException {
- return cctx.store().loadFromStore(tx, key);
+ return cctx.store().load(tx, key);
}
/** {@inheritDoc} */
@@ -1077,7 +1077,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Persist outside of synchronization. The correctness of the
// value will be handled by current transaction.
if (writeThrough)
- cctx.store().putToStore(tx, keyValue(false), CU.value(val, cctx, false), newVer);
+ cctx.store().put(tx, keyValue(false), CU.value(val, cctx, false), newVer);
if (intercept)
cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, key, key0, val, val0));
@@ -1235,7 +1235,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Persist outside of synchronization. The correctness of the
// value will be handled by current transaction.
if (writeThrough)
- cctx.store().removeFromStore(tx, keyValue(false));
+ cctx.store().remove(tx, keyValue(false));
if (!cctx.deferredDelete()) {
boolean marked = false;
@@ -1489,7 +1489,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (writeThrough)
// Must persist inside synchronization in non-tx mode.
- cctx.store().putToStore(null, keyValue(false), CU.value(updated, cctx, false), ver);
+ cctx.store().put(null, keyValue(false), CU.value(updated, cctx, false), ver);
// Update index inside synchronization since it can be updated
// in load methods without actually holding entry lock.
@@ -1523,7 +1523,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
else {
if (writeThrough)
// Must persist inside synchronization in non-tx mode.
- cctx.store().removeFromStore(null, keyValue(false));
+ cctx.store().remove(null, keyValue(false));
boolean hasValPtr = valPtr != 0;
@@ -1724,10 +1724,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (val == null) {
assert deletedUnlocked();
- cctx.store().removeFromStore(null, keyValue(false));
+ cctx.store().remove(null, keyValue(false));
}
else
- cctx.store().putToStore(null, keyValue(false), CU.value(val, cctx, false), ver);
+ cctx.store().put(null, keyValue(false), CU.value(val, cctx, false), ver);
}
return new GridCacheUpdateAtomicResult(false,
@@ -1776,10 +1776,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (val == null) {
assert deletedUnlocked();
- cctx.store().removeFromStore(null, keyValue(false));
+ cctx.store().remove(null, keyValue(false));
}
else
- cctx.store().putToStore(null, keyValue(false), CU.value(val, cctx, false), ver);
+ cctx.store().put(null, keyValue(false), CU.value(val, cctx, false), ver);
}
else {
if (log.isDebugEnabled())
@@ -2029,7 +2029,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
// Try write-through.
if (writeThrough)
// Must persist inside synchronization in non-tx mode.
- cctx.store().putToStore(null, keyValue(false), CU.value(updated, cctx, false), newVer);
+ cctx.store().put(null, keyValue(false), CU.value(updated, cctx, false), newVer);
if (!hadVal) {
boolean new0 = isNew();
@@ -2099,7 +2099,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
if (writeThrough)
// Must persist inside synchronization in non-tx mode.
- cctx.store().removeFromStore(null, keyValue(false));
+ cctx.store().remove(null, keyValue(false));
// Update index inside synchronization since it can be updated
// in load methods without actually holding entry lock.
@@ -3085,7 +3085,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
return null;
}
- return cctx.toCacheObject(cctx.store().loadFromStore(cctx.tm().localTxx(), key));
+ return cctx.toCacheObject(cctx.store().load(cctx.tm().localTxx(), key));
}
/**
@@ -3225,9 +3225,9 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
cctx.dataStructures().onEntryUpdated(key, false);
}
- if (cctx.store().isLocalStore()) {
+ if (cctx.store().isLocal()) {
if (val != null)
- cctx.store().putToStore(null, keyValue(false), CU.value(val, cctx, false), ver);
+ cctx.store().put(null, keyValue(false), CU.value(val, cctx, false), ver);
}
return true;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 00852fc..64602c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.processors.cache.local.*;
import org.apache.ignite.internal.processors.cache.local.atomic.*;
import org.apache.ignite.internal.processors.cache.query.*;
import org.apache.ignite.internal.processors.cache.query.continuous.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.processors.plugin.*;
@@ -1020,10 +1021,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
pluginMgr.validate();
- CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(CacheConflictResolutionManager.class);
- GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
+ CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(ctx, cfg,
+ CacheConflictResolutionManager.class);
- GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, sesHolders, cfgStore, cfg);
+ GridCacheDrManager drMgr = pluginMgr.createComponent(ctx, cfg,GridCacheDrManager.class);
+
+ CacheStoreManager storeMgr = pluginMgr.createComponent(ctx, cfg, CacheStoreManager.class);
+
+ storeMgr.initialize(cfgStore, sesHolders);
GridCacheContext<?, ?> cacheCtx = new GridCacheContext(
ctx,
@@ -1150,8 +1155,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
swapMgr = new GridCacheSwapManager(true);
evictMgr = new GridCacheEvictionManager();
evtMgr = new GridCacheEventManager();
- drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
pluginMgr = new CachePluginManager(ctx, cfg);
+ drMgr = pluginMgr.createComponent(ctx, cfg, GridCacheDrManager.class);
cacheCtx = new GridCacheContext(
ctx,
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
deleted file mode 100644
index d30aa06..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
+++ /dev/null
@@ -1,1202 +0,0 @@
-/*
- * 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.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.cache.store.*;
-import org.apache.ignite.internal.processors.cache.transactions.*;
-import org.apache.ignite.internal.processors.cache.version.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.lifecycle.*;
-import org.apache.ignite.transactions.*;
-import org.jetbrains.annotations.*;
-
-import javax.cache.*;
-import javax.cache.integration.*;
-import java.util.*;
-
-/**
- * Store manager.
- */
-@SuppressWarnings("AssignmentToCatchBlockParameter")
-public class GridCacheStoreManager extends GridCacheManagerAdapter {
- /** */
- private static final UUID SES_ATTR = UUID.randomUUID();
-
- /** */
- private final CacheStore<Object, Object> store;
-
- /** */
- private final CacheStore<?, ?> cfgStore;
-
- /** */
- private final CacheStoreBalancingWrapper<Object, Object> singleThreadGate;
-
- /** */
- private final ThreadLocal<SessionData> sesHolder;
-
- /** */
- private final boolean locStore;
-
- /** */
- private final boolean writeThrough;
-
- /** */
- private boolean convertPortable;
-
- /**
- * @param ctx Kernal context.
- * @param sesHolders Session holders map to use the same session holder for different managers if they use
- * the same store instance.
- * @param cfgStore Store provided in configuration.
- * @param cfg Cache configuration.
- * @throws IgniteCheckedException In case of error.
- */
- @SuppressWarnings("unchecked")
- public GridCacheStoreManager(
- GridKernalContext ctx,
- Map<CacheStore, ThreadLocal> sesHolders,
- @Nullable CacheStore<Object, Object> cfgStore,
- CacheConfiguration cfg
- ) throws IgniteCheckedException {
- this.cfgStore = cfgStore;
-
- store = cacheStoreWrapper(ctx, cfgStore, cfg);
-
- singleThreadGate = store == null ? null : new CacheStoreBalancingWrapper<>(store);
-
- writeThrough = cfg.isWriteThrough();
-
- ThreadLocal<SessionData> sesHolder0 = null;
-
- if (cfgStore != null) {
- sesHolder0 = sesHolders.get(cfgStore);
-
- if (sesHolder0 == null) {
- ThreadLocalSession locSes = new ThreadLocalSession();
-
- if (ctx.resource().injectStoreSession(cfgStore, locSes)) {
- sesHolder0 = locSes.sesHolder;
-
- sesHolders.put(cfgStore, sesHolder0);
- }
- }
- }
-
- sesHolder = sesHolder0;
-
- locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class);
- }
-
- /**
- * @return {@code True} is write-through is enabled.
- */
- public boolean writeThrough() {
- return writeThrough;
- }
-
- /**
- * @return Unwrapped store provided in configuration.
- */
- public CacheStore<?, ?> configuredStore() {
- return cfgStore;
- }
-
- /**
- * Creates a wrapped cache store if write-behind cache is configured.
- *
- * @param ctx Kernal context.
- * @param cfgStore Store provided in configuration.
- * @param cfg Cache configuration.
- * @return Instance if {@link GridCacheWriteBehindStore} if write-behind store is configured,
- * or user-defined cache store.
- */
- @SuppressWarnings({"unchecked"})
- private CacheStore cacheStoreWrapper(GridKernalContext ctx,
- @Nullable CacheStore cfgStore,
- CacheConfiguration cfg) {
- if (cfgStore == null || !cfg.isWriteBehindEnabled())
- return cfgStore;
-
- GridCacheWriteBehindStore store = new GridCacheWriteBehindStore(this,
- ctx.gridName(),
- cfg.getName(),
- ctx.log(GridCacheWriteBehindStore.class),
- cfgStore);
-
- store.setFlushSize(cfg.getWriteBehindFlushSize());
- store.setFlushThreadCount(cfg.getWriteBehindFlushThreadCount());
- store.setFlushFrequency(cfg.getWriteBehindFlushFrequency());
- store.setBatchSize(cfg.getWriteBehindBatchSize());
-
- return store;
- }
-
- /** {@inheritDoc} */
- @Override protected void start0() throws IgniteCheckedException {
- if (store instanceof LifecycleAware) {
- try {
- // Avoid second start() call on store in case when near cache is enabled.
- if (cctx.config().isWriteBehindEnabled()) {
- if (!cctx.isNear())
- ((LifecycleAware)store).start();
- }
- }
- catch (Exception e) {
- throw new IgniteCheckedException("Failed to start cache store: " + e, e);
- }
- }
-
- convertPortable = !cctx.cacheObjects().keepPortableInStore(cctx.name());
- }
-
- /** {@inheritDoc} */
- @Override protected void stop0(boolean cancel) {
- if (store instanceof LifecycleAware) {
- try {
- // Avoid second start() call on store in case when near cache is enabled.
- if (cctx.config().isWriteBehindEnabled()) {
- if (!cctx.isNear())
- ((LifecycleAware)store).stop();
- }
- }
- catch (Exception e) {
- U.error(log(), "Failed to stop cache store.", e);
- }
- }
- }
-
- /**
- * @return Convert-portable flag.
- */
- public boolean convertPortable() {
- return convertPortable;
- }
-
- /**
- * @param convertPortable Convert-portable flag.
- */
- public void convertPortable(boolean convertPortable) {
- this.convertPortable = convertPortable;
- }
-
- /**
- * @return {@code true} If local store is configured.
- */
- public boolean isLocalStore() {
- return locStore;
- }
-
- /**
- * @return {@code true} If store configured.
- */
- public boolean configured() {
- return store != null;
- }
-
- /**
- * Loads data from persistent store.
- *
- * @param tx Cache transaction.
- * @param key Cache key.
- * @return Loaded value, possibly <tt>null</tt>.
- * @throws IgniteCheckedException If data loading failed.
- */
- @SuppressWarnings("unchecked")
- @Nullable public Object loadFromStore(@Nullable IgniteInternalTx tx, KeyCacheObject key)
- throws IgniteCheckedException {
- return loadFromStore(tx, key, true);
- }
-
- /**
- * Loads data from persistent store.
- *
- * @param tx Cache transaction.
- * @param key Cache key.
- * @param convert Convert flag.
- * @return Loaded value, possibly <tt>null</tt>.
- * @throws IgniteCheckedException If data loading failed.
- */
- @SuppressWarnings("unchecked")
- @Nullable private Object loadFromStore(@Nullable IgniteInternalTx tx,
- KeyCacheObject key,
- boolean convert)
- throws IgniteCheckedException {
- if (store != null) {
- if (key.internal())
- // Never load internal keys from store as they are never persisted.
- return null;
-
- Object storeKey = key.value(cctx.cacheObjectContext(), false);
-
- if (convertPortable)
- storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
-
- if (log.isDebugEnabled())
- log.debug("Loading value from store for key: " + storeKey);
-
- initSession(tx);
-
- boolean thewEx = true;
-
- Object val = null;
-
- try {
- val = singleThreadGate.load(storeKey);
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (CacheLoaderException e) {
- throw new IgniteCheckedException(e);
- }
- catch (Exception e) {
- throw new IgniteCheckedException(new CacheLoaderException(e));
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Loaded value from store [key=" + key + ", val=" + val + ']');
-
- if (convert) {
- val = convert(val);
-
- return val;
- }
- else
- return val;
- }
-
- return null;
- }
-
- /**
- * @param val Internal value.
- * @return User value.
- */
- @SuppressWarnings("unchecked")
- private Object convert(Object val) {
- if (val == null)
- return null;
-
- return locStore ? ((IgniteBiTuple<Object, GridCacheVersion>)val).get1() : val;
- }
-
- /**
- * @return Whether DHT transaction can write to store from DHT.
- */
- public boolean writeToStoreFromDht() {
- return cctx.config().isWriteBehindEnabled() || locStore;
- }
-
- /**
- * @param tx Cache transaction.
- * @param keys Cache keys.
- * @param vis Closure to apply for loaded elements.
- * @throws IgniteCheckedException If data loading failed.
- */
- public void localStoreLoadAll(@Nullable IgniteInternalTx tx,
- Collection<? extends KeyCacheObject> keys,
- final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> vis)
- throws IgniteCheckedException {
- assert store != null;
- assert locStore;
-
- loadAllFromStore(tx, keys, null, vis);
- }
-
- /**
- * Loads data from persistent store.
- *
- * @param tx Cache transaction.
- * @param keys Cache keys.
- * @param vis Closure.
- * @return {@code True} if there is a persistent storage.
- * @throws IgniteCheckedException If data loading failed.
- */
- @SuppressWarnings({"unchecked"})
- public boolean loadAllFromStore(@Nullable IgniteInternalTx tx,
- Collection<? extends KeyCacheObject> keys,
- final IgniteBiInClosure<KeyCacheObject, Object> vis) throws IgniteCheckedException {
- if (store != null) {
- loadAllFromStore(tx, keys, vis, null);
-
- return true;
- }
- else {
- for (KeyCacheObject key : keys)
- vis.apply(key, null);
- }
-
- return false;
- }
-
- /**
- * @param tx Cache transaction.
- * @param keys Keys to load.
- * @param vis Key/value closure (only one of vis or verVis can be specified).
- * @param verVis Key/value/version closure (only one of vis or verVis can be specified).
- * @throws IgniteCheckedException If failed.
- */
- @SuppressWarnings("unchecked")
- private void loadAllFromStore(@Nullable IgniteInternalTx tx,
- Collection<? extends KeyCacheObject> keys,
- @Nullable final IgniteBiInClosure<KeyCacheObject, Object> vis,
- @Nullable final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> verVis)
- throws IgniteCheckedException {
- assert vis != null ^ verVis != null;
- assert verVis == null || locStore;
-
- final boolean convert = verVis == null;
-
- if (!keys.isEmpty()) {
- if (keys.size() == 1) {
- KeyCacheObject key = F.first(keys);
-
- if (convert)
- vis.apply(key, loadFromStore(tx, key));
- else {
- IgniteBiTuple<Object, GridCacheVersion> t =
- (IgniteBiTuple<Object, GridCacheVersion>)loadFromStore(tx, key, false);
-
- if (t != null)
- verVis.apply(key, t.get1(), t.get2());
- }
-
- return;
- }
-
- Collection<Object> keys0;
-
- if (convertPortable) {
- keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
- @Override public Object apply(KeyCacheObject key) {
- return cctx.unwrapPortableIfNeeded(key.value(cctx.cacheObjectContext(), false), false);
- }
- });
- }
- else {
- keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
- @Override public Object apply(KeyCacheObject key) {
- return key.value(cctx.cacheObjectContext(), false);
- }
- });
- }
-
- if (log.isDebugEnabled())
- log.debug("Loading values from store for keys: " + keys0);
-
- initSession(tx);
-
- boolean thewEx = true;
-
- try {
- IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() {
- @SuppressWarnings("ConstantConditions")
- @Override public void apply(Object k, Object val) {
- if (convert) {
- Object v = convert(val);
-
- vis.apply(cctx.toCacheKeyObject(k), v);
- }
- else {
- IgniteBiTuple<Object, GridCacheVersion> v = (IgniteBiTuple<Object, GridCacheVersion>)val;
-
- if (v != null)
- verVis.apply(cctx.toCacheKeyObject(k), v.get1(), v.get2());
- }
- }
- };
-
- if (keys.size() > singleThreadGate.loadAllThreshold()) {
- Map<Object, Object> map = store.loadAll(keys0);
-
- if (map != null) {
- for (Map.Entry<Object, Object> e : map.entrySet())
- c.apply(cctx.toCacheKeyObject(e.getKey()), e.getValue());
- }
- }
- else
- singleThreadGate.loadAll(keys0, c);
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (CacheLoaderException e) {
- throw new IgniteCheckedException(e);
- }
- catch (Exception e) {
- throw new IgniteCheckedException(new CacheLoaderException(e));
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Loaded values from store for keys: " + keys0);
- }
- }
-
- /**
- * Loads data from persistent store.
- *
- * @param vis Closer to cache loaded elements.
- * @param args User arguments.
- * @return {@code True} if there is a persistent storage.
- * @throws IgniteCheckedException If data loading failed.
- */
- @SuppressWarnings({"ErrorNotRethrown", "unchecked"})
- public boolean loadCache(final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> vis, Object[] args)
- throws IgniteCheckedException {
- if (store != null) {
- if (log.isDebugEnabled())
- log.debug("Loading all values from store.");
-
- initSession(null);
-
- boolean thewEx = true;
-
- try {
- store.loadCache(new IgniteBiInClosure<Object, Object>() {
- @Override public void apply(Object k, Object o) {
- Object v;
- GridCacheVersion ver = null;
-
- if (locStore) {
- IgniteBiTuple<Object, GridCacheVersion> t = (IgniteBiTuple<Object, GridCacheVersion>)o;
-
- v = t.get1();
- ver = t.get2();
- }
- else
- v = o;
-
- KeyCacheObject cacheKey = cctx.toCacheKeyObject(k);
-
- vis.apply(cacheKey, v, ver);
- }
- }, args);
-
- thewEx = false;
- }
- catch (CacheLoaderException e) {
- throw new IgniteCheckedException(e);
- }
- catch (Exception e) {
- throw new IgniteCheckedException(new CacheLoaderException(e));
- }
- finally {
- endSession(null, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Loaded all values from store.");
-
- return true;
- }
-
- LT.warn(log, null, "Calling Cache.loadCache() method will have no effect, " +
- "CacheConfiguration.getStore() is not defined for cache: " + cctx.namexx());
-
- return false;
- }
-
- /**
- * Puts key-value pair into storage.
- *
- * @param tx Cache transaction.
- * @param key Key.
- * @param val Value.
- * @param ver Version.
- * @return {@code true} If there is a persistent storage.
- * @throws IgniteCheckedException If storage failed.
- */
- @SuppressWarnings("unchecked")
- public boolean putToStore(@Nullable IgniteInternalTx tx, Object key, Object val, GridCacheVersion ver)
- throws IgniteCheckedException {
- if (store != null) {
- // Never persist internal keys.
- if (key instanceof GridCacheInternal)
- return true;
-
- if (convertPortable) {
- key = cctx.unwrapPortableIfNeeded(key, false);
- val = cctx.unwrapPortableIfNeeded(val, false);
- }
-
- if (log.isDebugEnabled())
- log.debug("Storing value in cache store [key=" + key + ", val=" + val + ']');
-
- initSession(tx);
-
- boolean thewEx = true;
-
- try {
- store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) : val));
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (CacheWriterException e) {
- throw new IgniteCheckedException(e);
- }
- catch (Exception e) {
- throw new IgniteCheckedException(new CacheWriterException(e));
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Stored value in cache store [key=" + key + ", val=" + val + ']');
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Puts key-value pair into storage.
- *
- * @param tx Cache transaction.
- * @param map Map.
- * @return {@code True} if there is a persistent storage.
- * @throws IgniteCheckedException If storage failed.
- */
- public boolean putAllToStore(@Nullable IgniteInternalTx tx,
- Map<Object, IgniteBiTuple<Object, GridCacheVersion>> map)
- throws IgniteCheckedException
- {
- if (F.isEmpty(map))
- return true;
-
- if (map.size() == 1) {
- Map.Entry<Object, IgniteBiTuple<Object, GridCacheVersion>> e = map.entrySet().iterator().next();
-
- return putToStore(tx, e.getKey(), e.getValue().get1(), e.getValue().get2());
- }
- else {
- if (store != null) {
- EntriesView entries = new EntriesView((Map)map);
-
- if (log.isDebugEnabled())
- log.debug("Storing values in cache store [entries=" + entries + ']');
-
- initSession(tx);
-
- boolean thewEx = true;
-
- try {
- store.writeAll(entries);
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (Exception e) {
- if (!(e instanceof CacheWriterException))
- e = new CacheWriterException(e);
-
- if (!entries.isEmpty()) {
- List<Object> keys = new ArrayList<>(entries.size());
-
- for (Cache.Entry<?, ?> entry : entries)
- keys.add(entry.getKey());
-
- throw new CacheStorePartialUpdateException(keys, e);
- }
-
- throw new IgniteCheckedException(e);
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Stored value in cache store [entries=" + entries + ']');
-
- return true;
- }
-
- return false;
- }
- }
-
- /**
- * @param tx Cache transaction.
- * @param key Key.
- * @return {@code True} if there is a persistent storage.
- * @throws IgniteCheckedException If storage failed.
- */
- @SuppressWarnings("unchecked")
- public boolean removeFromStore(@Nullable IgniteInternalTx tx, Object key) throws IgniteCheckedException {
- if (store != null) {
- // Never remove internal key from store as it is never persisted.
- if (key instanceof GridCacheInternal)
- return false;
-
- if (convertPortable)
- key = cctx.unwrapPortableIfNeeded(key, false);
-
- if (log.isDebugEnabled())
- log.debug("Removing value from cache store [key=" + key + ']');
-
- initSession(tx);
-
- boolean thewEx = true;
-
- try {
- store.delete(key);
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (CacheWriterException e) {
- throw new IgniteCheckedException(e);
- }
- catch (Exception e) {
- throw new IgniteCheckedException(new CacheWriterException(e));
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Removed value from cache store [key=" + key + ']');
-
- return true;
- }
-
- return false;
- }
-
- /**
- * @param tx Cache transaction.
- * @param keys Key.
- * @return {@code True} if there is a persistent storage.
- * @throws IgniteCheckedException If storage failed.
- */
- @SuppressWarnings("unchecked")
- public boolean removeAllFromStore(@Nullable IgniteInternalTx tx, Collection<Object> keys)
- throws IgniteCheckedException {
- if (F.isEmpty(keys))
- return true;
-
- if (keys.size() == 1) {
- Object key = keys.iterator().next();
-
- return removeFromStore(tx, key);
- }
-
- if (store != null) {
- Collection<Object> keys0 = convertPortable ? cctx.unwrapPortablesIfNeeded(keys, false) : keys;
-
- if (log.isDebugEnabled())
- log.debug("Removing values from cache store [keys=" + keys0 + ']');
-
- initSession(tx);
-
- boolean thewEx = true;
-
- try {
- store.deleteAll(keys0);
-
- thewEx = false;
- }
- catch (ClassCastException e) {
- handleClassCastException(e);
- }
- catch (Exception e) {
- if (!(e instanceof CacheWriterException))
- e = new CacheWriterException(e);
-
- if (!keys0.isEmpty())
- throw new CacheStorePartialUpdateException(keys0, e);
-
- throw new IgniteCheckedException(e);
- }
- finally {
- endSession(tx, thewEx);
- }
-
- if (log.isDebugEnabled())
- log.debug("Removed values from cache store [keys=" + keys0 + ']');
-
- return true;
- }
-
- return false;
- }
-
- /**
- * @return Store.
- */
- public CacheStore<Object, Object> store() {
- return store;
- }
-
- /**
- * @throws IgniteCheckedException If failed.
- */
- public void forceFlush() throws IgniteCheckedException {
- if (store instanceof GridCacheWriteBehindStore)
- ((GridCacheWriteBehindStore)store).forceFlush();
- }
-
- /**
- * @param tx Transaction.
- * @param commit Commit.
- * @throws IgniteCheckedException If failed.
- */
- public void txEnd(IgniteInternalTx tx, boolean commit) throws IgniteCheckedException {
- assert store != null;
-
- initSession(tx);
-
- try {
- store.sessionEnd(commit);
- }
- finally {
- if (sesHolder != null) {
- sesHolder.set(null);
-
- tx.removeMeta(SES_ATTR);
- }
- }
- }
-
- /**
- * @param e Class cast exception.
- * @throws IgniteCheckedException Thrown exception.
- */
- private void handleClassCastException(ClassCastException e) throws IgniteCheckedException {
- assert e != null;
-
- if (e.getMessage() != null) {
- throw new IgniteCheckedException("Cache store must work with portable objects if portables are " +
- "enabled for cache [cacheName=" + cctx.namex() + ']', e);
- }
- else
- throw e;
- }
-
- /**
- * Clears session holder.
- */
- void endSession(@Nullable IgniteInternalTx tx, boolean threwEx) throws IgniteCheckedException {
- try {
- if (tx == null)
- store.sessionEnd(threwEx);
- }
- catch (Exception e) {
- if (!threwEx)
- throw U.cast(e);
- }
- finally {
- if (sesHolder != null)
- sesHolder.set(null);
- }
- }
-
- /**
- * @param tx Current transaction.
- */
- void initSession(@Nullable IgniteInternalTx tx) {
- if (sesHolder == null)
- return;
-
- assert sesHolder.get() == null;
-
- SessionData ses;
-
- if (tx != null) {
- ses = tx.meta(SES_ATTR);
-
- if (ses == null) {
- ses = new SessionData(tx, cctx.name());
-
- tx.addMeta(SES_ATTR, ses);
- }
- else
- // Session cache name may change in cross-cache transaction.
- ses.cacheName(cctx.name());
- }
- else
- ses = new SessionData(null, cctx.name());
-
- sesHolder.set(ses);
- }
-
- /**
- *
- */
- private static class SessionData {
- /** */
- @GridToStringExclude
- private final IgniteInternalTx tx;
-
- /** */
- private String cacheName;
-
- /** */
- @GridToStringInclude
- private Map<Object, Object> props;
-
- /**
- * @param tx Current transaction.
- * @param cacheName Cache name.
- */
- private SessionData(@Nullable IgniteInternalTx tx, @Nullable String cacheName) {
- this.tx = tx;
- this.cacheName = cacheName;
- }
-
- /**
- * @return Transaction.
- */
- @Nullable private Transaction transaction() {
- return tx != null ? tx.proxy() : null;
- }
-
- /**
- * @return Properties.
- */
- private Map<Object, Object> properties() {
- if (props == null)
- props = new GridLeanMap<>();
-
- return props;
- }
-
- /**
- * @return Cache name.
- */
- private String cacheName() {
- return cacheName;
- }
-
- /**
- * @param cacheName Cache name.
- */
- private void cacheName(String cacheName) {
- this.cacheName = cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SessionData.class, this, "tx", CU.txString(tx));
- }
- }
-
- /**
- *
- */
- private static class ThreadLocalSession implements CacheStoreSession {
- /** */
- private final ThreadLocal<SessionData> sesHolder = new ThreadLocal<>();
-
- /** {@inheritDoc} */
- @Nullable @Override public Transaction transaction() {
- SessionData ses0 = sesHolder.get();
-
- return ses0 != null ? ses0.transaction() : null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isWithinTransaction() {
- return transaction() != null;
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public <K1, V1> Map<K1, V1> properties() {
- SessionData ses0 = sesHolder.get();
-
- return ses0 != null ? (Map<K1, V1>)ses0.properties() : null;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String cacheName() {
- SessionData ses0 = sesHolder.get();
-
- return ses0 != null ? ses0.cacheName() : null;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ThreadLocalSession.class, this);
- }
- }
-
- /**
- *
- */
- @SuppressWarnings("unchecked")
- private class EntriesView extends AbstractCollection<Cache.Entry<?, ?>> {
- /** */
- private final Map<?, IgniteBiTuple<?, GridCacheVersion>> map;
-
- /** */
- private Set<Object> rmvd;
-
- /** */
- private boolean cleared;
-
- /**
- * @param map Map.
- */
- private EntriesView(Map<?, IgniteBiTuple<?, GridCacheVersion>> map) {
- assert map != null;
-
- this.map = map;
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return cleared ? 0 : (map.size() - (rmvd != null ? rmvd.size() : 0));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return cleared || !iterator().hasNext();
- }
-
- /** {@inheritDoc} */
- @Override public boolean contains(Object o) {
- if (cleared || !(o instanceof Cache.Entry))
- return false;
-
- Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
-
- return map.containsKey(e.getKey());
- }
-
- /** {@inheritDoc} */
- @NotNull @Override public Iterator<Cache.Entry<?, ?>> iterator() {
- if (cleared)
- return F.emptyIterator();
-
- final Iterator<Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>>> it0 = (Iterator)map.entrySet().iterator();
-
- return new Iterator<Cache.Entry<?, ?>>() {
- /** */
- private Cache.Entry<?, ?> cur;
-
- /** */
- private Cache.Entry<?, ?> next;
-
- /**
- *
- */
- {
- checkNext();
- }
-
- /**
- *
- */
- private void checkNext() {
- while (it0.hasNext()) {
- Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>> e = it0.next();
-
- Object k = e.getKey();
-
- if (rmvd != null && rmvd.contains(k))
- continue;
-
- Object v = locStore ? e.getValue() : e.getValue().get1();
-
- if (convertPortable) {
- k = cctx.unwrapPortableIfNeeded(k, false);
- v = cctx.unwrapPortableIfNeeded(v, false);
- }
-
- next = new CacheEntryImpl<>(k, v);
-
- break;
- }
- }
-
- @Override public boolean hasNext() {
- return next != null;
- }
-
- @Override public Cache.Entry<?, ?> next() {
- if (next == null)
- throw new NoSuchElementException();
-
- cur = next;
-
- next = null;
-
- checkNext();
-
- return cur;
- }
-
- @Override public void remove() {
- if (cur == null)
- throw new IllegalStateException();
-
- addRemoved(cur);
-
- cur = null;
- }
- };
- }
-
- /** {@inheritDoc} */
- @Override public boolean add(Cache.Entry<?, ?> entry) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean addAll(Collection<? extends Cache.Entry<?, ?>> col) {
- throw new UnsupportedOperationException();
- }
-
- /** {@inheritDoc} */
- @Override public boolean remove(Object o) {
- if (cleared || !(o instanceof Cache.Entry))
- return false;
-
- Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
-
- if (rmvd != null && rmvd.contains(e.getKey()))
- return false;
-
- if (mapContains(e)) {
- addRemoved(e);
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsAll(Collection<?> col) {
- if (cleared)
- return false;
-
- for (Object o : col) {
- if (contains(o))
- return false;
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean removeAll(Collection<?> col) {
- if (cleared)
- return false;
-
- boolean modified = false;
-
- for (Object o : col) {
- if (remove(o))
- modified = true;
- }
-
- return modified;
- }
-
- /** {@inheritDoc} */
- @Override public boolean retainAll(Collection<?> col) {
- if (cleared)
- return false;
-
- boolean modified = false;
-
- for (Cache.Entry<?, ?> e : this) {
- if (!col.contains(e)) {
- addRemoved(e);
-
- modified = true;
- }
- }
-
- return modified;
- }
-
- /** {@inheritDoc} */
- @Override public void clear() {
- cleared = true;
- }
-
- /**
- * @param e Entry.
- */
- private void addRemoved(Cache.Entry<?, ?> e) {
- if (rmvd == null)
- rmvd = new HashSet<>();
-
- rmvd.add(e.getKey());
- }
-
- /**
- * @param e Entry.
- * @return {@code True} if original map contains entry.
- */
- private boolean mapContains(Cache.Entry<?, ?> e) {
- return map.containsKey(e.getKey());
- }
-
- /** {@inheritDoc} */
- public String toString() {
- Iterator<Cache.Entry<?, ?>> it = iterator();
-
- if (!it.hasNext())
- return "[]";
-
- SB sb = new SB("[");
-
- while (true) {
- Cache.Entry<?, ?> e = it.next();
-
- sb.a(e.toString());
-
- if (!it.hasNext())
- return sb.a(']').toString();
-
- sb.a(", ");
- }
- }
- }
-}
[16/30] incubator-ignite git commit: Merge branch 'ignite-663' into
ignite-sprint-3
Posted by sb...@apache.org.
Merge branch 'ignite-663' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9b231090
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9b231090
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9b231090
Branch: refs/heads/ignite-366
Commit: 9b2310902503b05833c909d53d5099f3603665d9
Parents: 505a7bf 588cff3
Author: anovikov <an...@gridgain.com>
Authored: Thu Apr 2 14:49:28 2015 +0700
Committer: anovikov <an...@gridgain.com>
Committed: Thu Apr 2 14:49:28 2015 +0700
----------------------------------------------------------------------
DEVNOTES.txt | 2 ++
parent/pom.xml | 10 +++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[03/30] incubator-ignite git commit: # ignite-662
Posted by sb...@apache.org.
# ignite-662
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5caa1078
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5caa1078
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5caa1078
Branch: refs/heads/ignite-366
Commit: 5caa107806fde27487a15b6c8f6ca3769dbb959b
Parents: 35d05e9
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 1 13:49:48 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 1 15:33:57 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CacheObjectContext.java | 14 +-
.../processors/cache/CacheObjectImpl.java | 10 +-
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 16 +-
.../IgniteCacheObjectProcessorImpl.java | 14 +-
.../IgniteCacheAtomicLocalStoreValueTest.java | 49 ++++
...iteCacheAtomicNearEnabledStoreValueTest.java | 30 ++
...maryWriteOrderNearEnabledStoreValueTest.java | 31 +++
...heAtomicPrimaryWriteOrderStoreValueTest.java | 32 +++
.../cache/IgniteCacheAtomicStoreValueTest.java | 55 ++++
.../IgniteCacheStoreValueAbstractTest.java | 277 +++++++++++++++++++
.../cache/IgniteCacheTxLocalStoreValueTest.java | 49 ++++
.../IgniteCacheTxNearEnabledStoreValueTest.java | 30 ++
.../cache/IgniteCacheTxStoreValueTest.java | 49 ++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 9 +
15 files changed, 651 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
index 5c1b5ae..e85a04a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java
@@ -40,7 +40,7 @@ public class CacheObjectContext {
private boolean cpyOnGet;
/** */
- private boolean unmarshalVals;
+ private boolean storeVal;
/** */
private boolean p2pEnabled;
@@ -49,17 +49,17 @@ public class CacheObjectContext {
* @param kernalCtx Kernal context.
* @param dfltAffMapper Default affinity mapper.
* @param cpyOnGet Copy on get flag.
- * @param unmarshalVals Unmarshal values flag.
+ * @param storeVal {@code True} if should store unmarshalled value in cache.
*/
public CacheObjectContext(GridKernalContext kernalCtx,
AffinityKeyMapper dfltAffMapper,
boolean cpyOnGet,
- boolean unmarshalVals) {
+ boolean storeVal) {
this.kernalCtx = kernalCtx;
this.p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled();
this.dfltAffMapper = dfltAffMapper;
this.cpyOnGet = cpyOnGet;
- this.unmarshalVals = unmarshalVals;
+ this.storeVal = storeVal;
proc = kernalCtx.cacheObjects();
}
@@ -79,10 +79,10 @@ public class CacheObjectContext {
}
/**
- * @return Unmarshal values flag.
+ * @return {@code True} if should store unmarshalled value in cache.
*/
- public boolean unmarshalValues() {
- return unmarshalVals;
+ public boolean storeValue() {
+ return storeVal;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
index b131535..33a747d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectImpl.java
@@ -67,13 +67,17 @@ public class CacheObjectImpl extends CacheObjectAdapter {
assert valBytes != null;
- val = ctx.processor().unmarshal(ctx, valBytes, ctx.kernalContext().config().getClassLoader());
+ Object val = ctx.processor().unmarshal(ctx, valBytes, ctx.kernalContext().config().getClassLoader());
+
+ if (ctx.storeValue())
+ this.val = val;
+
+ return (T)val;
}
catch (IgniteCheckedException e) {
throw new IgniteException("Failed to unmarshal object.", e);
}
- return (T)val;
}
/** {@inheritDoc} */
@@ -96,7 +100,7 @@ public class CacheObjectImpl extends CacheObjectAdapter {
@Override public void finishUnmarshal(CacheObjectContext ctx, ClassLoader ldr) throws IgniteCheckedException {
assert val != null || valBytes != null;
- if (val == null && ctx.unmarshalValues())
+ if (val == null && ctx.storeValue())
val = ctx.processor().unmarshal(ctx, valBytes, ldr);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 58ff57f..d7fbde9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3674,7 +3674,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx {
try {
GridCacheQueryManager qryMgr = cctx.queries();
- if (qryMgr != null) {
+ if (qryMgr != null && qryMgr.enabled()) {
qryMgr.store(key.value(cctx.cacheObjectContext(), false),
null,
CU.value(val, cctx, false),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 145fb9c..6c8cf9a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -91,6 +91,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
/** Event listener. */
private GridLocalEventListener lsnr;
+ /** */
+ private boolean enabled;
+
/** {@inheritDoc} */
@Override public void start0() throws IgniteCheckedException {
qryProc = cctx.kernalContext().query();
@@ -135,6 +138,15 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
};
cctx.events().addListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED);
+
+ enabled = GridQueryProcessor.isEnabled(cctx.config());
+ }
+
+ /**
+ * @return {@code True} if indexing is enabled for cache.
+ */
+ public boolean enabled() {
+ return enabled;
}
/** {@inheritDoc} */
@@ -334,8 +346,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
throws IgniteCheckedException {
assert key != null;
assert val != null || valBytes != null;
+ assert enabled();
- if (!GridQueryProcessor.isEnabled(cctx.config()) && !(key instanceof GridCacheInternal))
+ if (key instanceof GridCacheInternal)
return; // No-op.
if (!enterBusy())
@@ -356,6 +369,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
/**
* @param key Key.
+ * @param val Value.
* @throws IgniteCheckedException Thrown in case of any errors.
*/
@SuppressWarnings("SimplifiableIfStatement")
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index c0be7c9..a9b7c00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -233,10 +233,14 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (ccfg != null) {
CacheMemoryMode memMode = ccfg.getMemoryMode();
+ boolean storeVal = ctx.config().isPeerClassLoadingEnabled() ||
+ GridQueryProcessor.isEnabled(ccfg) ||
+ !ccfg.isCopyOnRead();
+
return new CacheObjectContext(ctx,
new GridCacheDefaultAffinityKeyMapper(),
ccfg.isCopyOnRead() && memMode == ONHEAP_TIERED,
- ctx.config().isPeerClassLoadingEnabled() || GridQueryProcessor.isEnabled(ccfg));
+ storeVal);
}
else
return new CacheObjectContext(
@@ -323,7 +327,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
}
/**
- *
+ * @param val Value.
+ * @param valBytes Value bytes.
*/
public IgniteCacheObjectImpl(Object val, byte[] valBytes) {
super(val, valBytes);
@@ -341,7 +346,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (valBytes == null)
valBytes = ctx.processor().marshal(ctx, val);
- if (ctx.unmarshalValues()) {
+ if (ctx.storeValue()) {
ClassLoader ldr = ctx.p2pEnabled() ?
IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
@@ -355,7 +360,8 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
catch (IgniteCheckedException e) {
throw new IgniteException("Failed to marshal object: " + val, e);
}
- } else
+ }
+ else
return new CacheObjectImpl(val, valBytes);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalStoreValueTest.java
new file mode 100644
index 0000000..c547ae0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalStoreValueTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.cache.*;
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheAtomicLocalStoreValueTest extends IgniteCacheStoreValueAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return LOCAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicNearEnabledStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicNearEnabledStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicNearEnabledStoreValueTest.java
new file mode 100644
index 0000000..a86c50c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicNearEnabledStoreValueTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.configuration.*;
+
+/**
+ *
+ */
+public class IgniteCacheAtomicNearEnabledStoreValueTest extends IgniteCacheAtomicStoreValueTest {
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return new NearCacheConfiguration();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.java
new file mode 100644
index 0000000..a759ea3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.configuration.*;
+
+/**
+ *
+ */
+public class IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest
+ extends IgniteCacheAtomicPrimaryWriteOrderStoreValueTest {
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return new NearCacheConfiguration();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.java
new file mode 100644
index 0000000..17ae2bd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.cache.*;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheAtomicPrimaryWriteOrderStoreValueTest extends IgniteCacheAtomicStoreValueTest {
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+ return PRIMARY;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStoreValueTest.java
new file mode 100644
index 0000000..9b8f0b1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicStoreValueTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.cache.*;
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheAtomicStoreValueTest extends IgniteCacheStoreValueAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
+ return CLOCK;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
new file mode 100644
index 0000000..9fa24cc
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
@@ -0,0 +1,277 @@
+/*
+ * 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.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.cache.distributed.near.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.testframework.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+import javax.cache.processor.*;
+import java.io.*;
+import java.lang.ref.*;
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+
+/**
+ *
+ */
+public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
+ CacheConfiguration ccfg = super.cacheConfiguration(gridName);
+
+ if (ccfg.getCacheMode() != CacheMode.LOCAL)
+ assertEquals(1, ccfg.getBackups());
+
+ assertTrue(ccfg.isCopyOnRead());
+
+ assertEquals(FULL_SYNC, ccfg.getWriteSynchronizationMode());
+
+ ccfg.setCacheStoreFactory(singletonFactory(new CacheStoreAdapter() {
+ @Override public void loadCache(IgniteBiInClosure clo, Object... args) {
+ clo.apply(new TestKey(1), new TestValue());
+ }
+
+ @Override public Object load(Object key) throws CacheLoaderException {
+ return null;
+ }
+
+ @Override public void write(Cache.Entry entry) throws CacheWriterException {
+ // No-op.
+ }
+
+ @Override public void delete(Object key) throws CacheWriterException {
+ // No-op.
+ }
+ }));
+
+ ccfg.setInterceptor(new TestInterceptor());
+
+ return ccfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean swapEnabled() {
+ return true;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testValueNotStored() throws Exception {
+ IgniteCache<TestKey, TestValue> cache = grid(0).cache(null);
+
+ Affinity<Object> aff = grid(0).affinity(null);
+
+ final List<WeakReference<Object>> refs = new ArrayList<>();
+
+ for (int i = 0; i < 1000; i++) {
+ TestKey key = new TestKey(i);
+ TestValue val = new TestValue();
+
+ refs.add(new WeakReference<Object>(val));
+
+ cache.put(key, val);
+
+ checkNoValue(aff, key);
+
+ for (int g = 0; g < gridCount(); g++)
+ assertNotNull(grid(g).cache(null).get(key));
+
+ checkNoValue(aff, key);
+
+ cache.invoke(key, new CacheEntryProcessor<TestKey, TestValue, Object>() {
+ @Override public Object process(MutableEntry<TestKey, TestValue> entry, Object... args) {
+ assertNotNull(entry.getValue());
+
+ entry.setValue(new TestValue());
+
+ return new TestValue();
+ }
+ });
+
+ checkNoValue(aff, key);
+
+ for (int g = 0; g < gridCount(); g++)
+ assertNotNull(grid(g).cache(null).get(key));
+
+ checkNoValue(aff, key);
+
+ cache.remove(key);
+
+ for (int g = 0; g < gridCount(); g++)
+ assertNull(grid(g).cache(null).get(key));
+
+ try (IgniteDataStreamer streamer = grid(0).dataStreamer(null)) {
+ streamer.addData(key, val);
+ }
+
+ checkNoValue(aff, key);
+
+ if (aff.isPrimaryOrBackup(grid(0).localNode(), key)) {
+ cache.localEvict(Collections.singleton(key));
+
+ assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
+
+ cache.localPromote(Collections.singleton(key));
+
+ assertNotNull(cache.localPeek(key, CachePeekMode.ONHEAP));
+
+ checkNoValue(aff, key);
+ }
+ }
+
+ cache.loadCache(null); // Should load TestKey(1).
+
+ TestKey key = new TestKey(1);
+
+ checkNoValue(aff, key);
+
+ for (int g = 0; g < gridCount(); g++)
+ assertNotNull(grid(g).cache(null).get(key));
+
+ checkNoValue(aff, key);
+
+// boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
+// @Override public boolean apply() {
+// System.gc();
+//
+// boolean pass = true;
+//
+// for (Iterator<WeakReference<Object>> it = refs.iterator(); it.hasNext();) {
+// WeakReference<Object> ref = it.next();
+//
+// if (ref.get() == null)
+// it.remove();
+// else
+// pass = false;
+// }
+//
+// return pass;
+// }
+// }, 10_000);
+//
+// assertTrue("Failed to wait for when values are collected", wait);
+ }
+
+ /**
+ * @param aff Affinity.
+ * @param key Key.
+ */
+ private void checkNoValue(Affinity<Object> aff, Object key) {
+ for (int g = 0; g < gridCount(); g++) {
+ GridCacheAdapter cache0 = internalCache(grid(g), null);
+
+ GridCacheEntryEx e = cache0.peekEx(key);
+
+ if (e == null && cache0.isNear())
+ e = ((GridNearCacheAdapter)cache0).dht().peekEx(key);
+
+ if (e != null) {
+ CacheObject obj = e.rawGet();
+
+ if (obj != null) {
+ assertNotNull(obj);
+ assertEquals(CacheObjectImpl.class, obj.getClass());
+
+ assertNull("Unexpected value, node: " + g,
+ GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val"));
+
+ assertNotNull(obj.value(cache0.context().cacheObjectContext(), true));
+
+ assertNull("Unexpected value after value() requested1: " + g,
+ GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val"));
+
+ assertNotNull(obj.value(cache0.context().cacheObjectContext(), false));
+
+ assertNull("Unexpected value after value() requested2: " + g,
+ GridTestUtils.getFieldValue(obj, CacheObjectAdapter.class, "val"));
+ }
+ else
+ assertFalse(aff.isPrimaryOrBackup(grid(g).localNode(), key));
+ }
+ else
+ assertFalse("Entry not found, node: " + g, aff.isPrimaryOrBackup(grid(g).localNode(), key));
+ }
+ }
+
+ /**
+ *
+ */
+ static class TestKey implements Serializable {
+ /** */
+ private int key;
+
+ /**
+ * @param key Key.
+ */
+ public TestKey(int key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TestKey that = (TestKey)o;
+
+ return key == that.key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return key;
+ }
+ }
+
+ /**
+ *
+ */
+ static class TestValue implements Serializable {
+ // No-op.
+ }
+
+ /**
+ *
+ */
+ static class TestInterceptor extends CacheInterceptorAdapter {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java
new file mode 100644
index 0000000..c9a0cdd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxLocalStoreValueTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.cache.*;
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxLocalStoreValueTest extends IgniteCacheStoreValueAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return LOCAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java
new file mode 100644
index 0000000..29b8307
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearEnabledStoreValueTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.configuration.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxNearEnabledStoreValueTest extends IgniteCacheTxStoreValueTest {
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return new NearCacheConfiguration();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java
new file mode 100644
index 0000000..390224f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxStoreValueTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.cache.*;
+import org.apache.ignite.configuration.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheTxStoreValueTest extends IgniteCacheStoreValueAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 4;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5caa1078/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index e3fefc8..9e50565 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -415,6 +415,15 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheMarshallingNodeJoinSelfTest.class);
+ suite.addTestSuite(IgniteCacheAtomicLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class);
+
return suite;
}
}
[11/30] incubator-ignite git commit: Merge remote-tracking branch
'origin/ignite-sprint-3' into ignite-sprint-3
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/ignite-sprint-3' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ed6632ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ed6632ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ed6632ae
Branch: refs/heads/ignite-366
Commit: ed6632aed467c5dbb74eb7d235c7e062f94344ed
Parents: 3bc3b07 8a86e38
Author: Dmitiry Setrakyan <ds...@gridgain.com>
Authored: Wed Apr 1 12:34:30 2015 -0700
Committer: Dmitiry Setrakyan <ds...@gridgain.com>
Committed: Wed Apr 1 12:34:30 2015 -0700
----------------------------------------------------------------------
.../IgniteCacheObjectProcessorImpl.java | 165 ++++++++++++-------
.../IgniteCacheStoreValueAbstractTest.java | 92 +++++++----
.../junits/common/GridCommonAbstractTest.java | 2 +-
3 files changed, 167 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
[13/30] incubator-ignite git commit: # GG-9942 Fixed near cache
configuration.
Posted by sb...@apache.org.
# GG-9942 Fixed near cache configuration.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e2cbd217
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e2cbd217
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e2cbd217
Branch: refs/heads/ignite-366
Commit: e2cbd2178a9a4b7a4db171386fda0143b0a025ef
Parents: d47b66a
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Apr 2 11:38:54 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Apr 2 11:38:54 2015 +0700
----------------------------------------------------------------------
.../cache/VisorCacheNearConfiguration.java | 11 ++-
.../resources/META-INF/classnames.properties | 79 ++++++--------------
2 files changed, 29 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2cbd217/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNearConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNearConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNearConfiguration.java
index 2a5e781..a968f4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNearConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheNearConfiguration.java
@@ -53,9 +53,14 @@ public class VisorCacheNearConfiguration implements Serializable {
VisorCacheNearConfiguration cfg = new VisorCacheNearConfiguration();
cfg.nearEnabled = GridCacheUtils.isNearEnabled(ccfg);
-// cfg.nearStartSize = ccfg.getNearStartSize(); TODO IGNTIE-45
-// cfg.nearEvictPlc = compactClass(ccfg.getNearEvictionPolicy());
-// cfg.nearEvictMaxSize = evictionPolicyMaxSize(ccfg.getNearEvictionPolicy());
+
+ if (cfg.nearEnabled) {
+ NearCacheConfiguration nccfg = ccfg.getNearConfiguration();
+
+ cfg.nearStartSize = nccfg.getNearStartSize();
+ cfg.nearEvictPlc = compactClass(nccfg.getNearEvictionPolicy());
+ cfg.nearEvictMaxSize = evictionPolicyMaxSize(nccfg.getNearEvictionPolicy());
+ }
return cfg;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2cbd217/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index ccc6aae..55c1f9d 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -25,8 +25,9 @@ org.apache.ignite.IgniteState
org.apache.ignite.cache.CacheAtomicUpdateTimeoutException
org.apache.ignite.cache.CacheAtomicWriteOrderMode
org.apache.ignite.cache.CacheAtomicityMode
-org.apache.ignite.internal.processors.cache.CacheDistributionMode
+org.apache.ignite.cache.CacheEntryEventSerializableFilter
org.apache.ignite.cache.CacheEntryProcessor
+org.apache.ignite.cache.CacheExistsException
org.apache.ignite.cache.CacheInterceptor
org.apache.ignite.cache.CacheInterceptorAdapter
org.apache.ignite.cache.CacheMemoryMode
@@ -34,6 +35,9 @@ org.apache.ignite.cache.CacheMode
org.apache.ignite.cache.CachePartialUpdateException
org.apache.ignite.cache.CachePeekMode
org.apache.ignite.cache.CacheRebalanceMode
+org.apache.ignite.cache.CacheServerNotFoundException
+org.apache.ignite.cache.CacheTypeFieldMetadata
+org.apache.ignite.cache.CacheTypeMetadata
org.apache.ignite.cache.CacheWriteSynchronizationMode
org.apache.ignite.cache.affinity.AffinityFunction
org.apache.ignite.cache.affinity.AffinityKey
@@ -213,10 +217,10 @@ org.apache.ignite.internal.cluster.ClusterGroupAdapter$AttributeFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$CachesFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$DaemonFilter
org.apache.ignite.internal.cluster.ClusterGroupAdapter$OthersFilter
-org.apache.ignite.internal.cluster.ClusterGroupAdapter$StreamersFilter
org.apache.ignite.internal.cluster.ClusterGroupEmptyCheckedException
org.apache.ignite.internal.cluster.ClusterNodeLocalMapImpl
org.apache.ignite.internal.cluster.ClusterTopologyCheckedException
+org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException
org.apache.ignite.internal.cluster.IgniteClusterAsyncImpl
org.apache.ignite.internal.cluster.IgniteClusterImpl
org.apache.ignite.internal.cluster.IgniteClusterImpl$1
@@ -252,9 +256,9 @@ org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion
org.apache.ignite.internal.processors.affinity.GridAffinityAssignment
org.apache.ignite.internal.processors.affinity.GridAffinityMessage
-org.apache.ignite.internal.processors.affinity.GridAffinityProcessor$2
org.apache.ignite.internal.processors.affinity.GridAffinityUtils$AffinityJob
org.apache.ignite.internal.processors.cache.CacheAtomicUpdateTimeoutCheckedException
+org.apache.ignite.internal.processors.cache.CacheDistributionMode
org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection
org.apache.ignite.internal.processors.cache.CacheEntryPredicate
org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter
@@ -263,8 +267,6 @@ org.apache.ignite.internal.processors.cache.CacheEntryPredicateHasValue
org.apache.ignite.internal.processors.cache.CacheEntryPredicateNoValue
org.apache.ignite.internal.processors.cache.CacheEntrySerializablePredicate
org.apache.ignite.internal.processors.cache.CacheEvictionEntry
-org.apache.ignite.internal.processors.cache.CacheFlag
-org.apache.ignite.internal.processors.cache.CacheFlagException
org.apache.ignite.internal.processors.cache.CacheInvokeDirectResult
org.apache.ignite.internal.processors.cache.CacheInvokeEntry$Operation
org.apache.ignite.internal.processors.cache.CacheInvokeResult
@@ -319,7 +321,6 @@ org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdatePutAndGetTime
org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdatePutTimeStatClosure
org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdateRemoveTimeStatClosure
org.apache.ignite.internal.processors.cache.GridCacheAdapter$UpdateTimeStatClosure
-org.apache.ignite.internal.processors.cache.GridCacheAtomicVersionComparator
org.apache.ignite.internal.processors.cache.GridCacheAttributes
org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap$1
org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap$2
@@ -334,8 +335,7 @@ org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap$Set0
org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap$ValueIterator
org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap$Values
org.apache.ignite.internal.processors.cache.GridCacheContext
-org.apache.ignite.internal.processors.cache.GridCacheContext$2
-org.apache.ignite.internal.processors.cache.GridCacheContext$5
+org.apache.ignite.internal.processors.cache.GridCacheContext$4
org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper
org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper$1
org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper$2
@@ -404,6 +404,7 @@ org.apache.ignite.internal.processors.cache.GridCacheSwapManager$5
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$6
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$7
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$IteratorWrapper
+org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException
org.apache.ignite.internal.processors.cache.GridCacheUtilityKey
org.apache.ignite.internal.processors.cache.GridCacheUtils$10
org.apache.ignite.internal.processors.cache.GridCacheUtils$11
@@ -435,8 +436,6 @@ org.apache.ignite.internal.processors.cache.GridCacheValueCollection$1
org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$StatefulValue
org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$StoreOperation
org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$ValueStatus
-org.apache.ignite.internal.processors.cache.GridPartitionLockKey
-org.apache.ignite.cache.CacheExistsException
org.apache.ignite.internal.processors.cache.IgniteCacheProxy
org.apache.ignite.internal.processors.cache.IgniteCacheProxy$1
org.apache.ignite.internal.processors.cache.IgniteCacheProxy$2
@@ -483,9 +482,10 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtGetFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException
-org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition$3
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition$4
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$2
+org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockFuture$3
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLockResponse
org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState
@@ -520,7 +520,8 @@ org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtUnlockRequest
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$2
org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$1
-org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$1$1
+org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$2
+org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture$MiniFuture$2$1
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$10
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$11
@@ -656,7 +657,6 @@ org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManag
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$4
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$5
org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$6
-org.apache.ignite.internal.processors.cache.query.GridCacheQueriesImpl
org.apache.ignite.internal.processors.cache.query.GridCacheQueriesProxy
org.apache.ignite.internal.processors.cache.query.GridCacheQueryAdapter$1
org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter$1
@@ -695,6 +695,7 @@ org.apache.ignite.internal.processors.cache.query.GridCacheSqlQuery
org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEntry
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryEvent
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFilterEx
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$2
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$DeployableObject
@@ -766,9 +767,9 @@ org.apache.ignite.internal.processors.cache.version.GridCacheRawVersionedEntry
org.apache.ignite.internal.processors.cache.version.GridCacheVersion
org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext$State
org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx
-org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$1
-org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$2
-org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$IgniteCacheObjectImpl
+org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserCacheObjectByteArrayImpl
+org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserCacheObjectImpl
+org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessorImpl$UserKeyCacheObjectImpl
org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage
org.apache.ignite.internal.processors.clock.GridClockDeltaVersion
org.apache.ignite.internal.processors.closure.GridClosurePolicy
@@ -1008,21 +1009,6 @@ org.apache.ignite.internal.processors.service.GridServiceProxy
org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable
org.apache.ignite.internal.processors.service.ServiceContextImpl
org.apache.ignite.internal.processors.service.ServiceDescriptorImpl
-org.apache.ignite.internal.processors.streamer.GridStreamerAttributes
-org.apache.ignite.internal.processors.streamer.GridStreamerCancelRequest
-org.apache.ignite.internal.processors.streamer.GridStreamerExecutionBatch
-org.apache.ignite.internal.processors.streamer.GridStreamerExecutionRequest
-org.apache.ignite.internal.processors.streamer.GridStreamerResponse
-org.apache.ignite.internal.processors.streamer.GridStreamerRouteFailedException
-org.apache.ignite.internal.processors.streamer.IgniteStreamerImpl
-org.apache.ignite.internal.processors.streamer.IgniteStreamerImpl$3
-org.apache.ignite.internal.processors.streamer.IgniteStreamerImpl$StreamerPda
-org.apache.ignite.internal.processors.streamer.task.GridStreamerBroadcastTask
-org.apache.ignite.internal.processors.streamer.task.GridStreamerBroadcastTask$StreamerBroadcastJob
-org.apache.ignite.internal.processors.streamer.task.GridStreamerQueryTask
-org.apache.ignite.internal.processors.streamer.task.GridStreamerQueryTask$QueryJob
-org.apache.ignite.internal.processors.streamer.task.GridStreamerReduceTask
-org.apache.ignite.internal.processors.streamer.task.GridStreamerReduceTask$ReduceJob
org.apache.ignite.internal.processors.task.GridTaskProcessor$1
org.apache.ignite.internal.processors.task.GridTaskThreadContextKey
org.apache.ignite.internal.processors.task.GridTaskWorker$3
@@ -1420,7 +1406,6 @@ org.apache.ignite.internal.visor.event.VisorGridDiscoveryEvent
org.apache.ignite.internal.visor.event.VisorGridEvent
org.apache.ignite.internal.visor.event.VisorGridEventsLost
org.apache.ignite.internal.visor.event.VisorGridJobEvent
-org.apache.ignite.internal.visor.event.VisorGridSecuritySessionEvent
org.apache.ignite.internal.visor.event.VisorGridTaskEvent
org.apache.ignite.internal.visor.file.VisorFileBlock
org.apache.ignite.internal.visor.file.VisorFileBlockTask
@@ -1501,14 +1486,6 @@ org.apache.ignite.internal.visor.query.VisorQueryTask
org.apache.ignite.internal.visor.query.VisorQueryTask$VisorFutureResultSetHolder
org.apache.ignite.internal.visor.query.VisorQueryTask$VisorQueryArg
org.apache.ignite.internal.visor.query.VisorQueryTask$VisorQueryJob
-org.apache.ignite.internal.visor.streamer.VisorStreamer
-org.apache.ignite.internal.visor.streamer.VisorStreamerConfiguration
-org.apache.ignite.internal.visor.streamer.VisorStreamerMetrics
-org.apache.ignite.internal.visor.streamer.VisorStreamerMetricsResetTask
-org.apache.ignite.internal.visor.streamer.VisorStreamerMetricsResetTask$VisorStreamerMetricsResetJob
-org.apache.ignite.internal.visor.streamer.VisorStreamerResetTask
-org.apache.ignite.internal.visor.streamer.VisorStreamerResetTask$VisorStreamerResetJob
-org.apache.ignite.internal.visor.streamer.VisorStreamerStageMetrics
org.apache.ignite.internal.visor.util.VisorEventMapper
org.apache.ignite.internal.visor.util.VisorTaskUtils$4
org.apache.ignite.lang.IgniteBiClosure
@@ -1530,6 +1507,7 @@ org.apache.ignite.lifecycle.LifecycleEventType
org.apache.ignite.marshaller.jdk.JdkMarshallerDummySerializable
org.apache.ignite.marshaller.optimized.OptimizedFieldType
org.apache.ignite.messaging.MessagingListenActor
+org.apache.ignite.plugin.CachePluginConfiguration
org.apache.ignite.plugin.PluginNotFoundException
org.apache.ignite.plugin.PluginValidationException
org.apache.ignite.plugin.extensions.communication.Message
@@ -1600,15 +1578,9 @@ org.apache.ignite.startup.cmdline.AboutDialog
org.apache.ignite.startup.cmdline.AboutDialog$1
org.apache.ignite.stream.StreamReceiver
org.apache.ignite.stream.StreamTransformer
-org.apache.ignite.streamer.index.StreamerIndexPolicy
-org.apache.ignite.streamer.index.StreamerIndexProviderAdapter$1
-org.apache.ignite.streamer.index.StreamerIndexProviderAdapter$2
-org.apache.ignite.streamer.window.StreamerBoundedSizeBatchWindow$Batch
-org.apache.ignite.streamer.window.StreamerBoundedSizeBatchWindow$QueueHolder
-org.apache.ignite.streamer.window.StreamerBoundedSizeWindowAdapter$WindowHolder
-org.apache.ignite.streamer.window.StreamerBoundedTimeBatchWindow$Batch
-org.apache.ignite.streamer.window.StreamerBoundedTimeBatchWindow$WindowHolder
-org.apache.ignite.streamer.window.StreamerBoundedTimeWindow$WindowHolder
+org.apache.ignite.stream.StreamTransformer$1
+org.apache.ignite.stream.StreamVisitor
+org.apache.ignite.stream.StreamVisitor$1
org.apache.ignite.transactions.TransactionConcurrency
org.apache.ignite.transactions.TransactionHeuristicException
org.apache.ignite.transactions.TransactionIsolation
@@ -1617,12 +1589,3 @@ org.apache.ignite.transactions.TransactionOptimisticException
org.apache.ignite.transactions.TransactionRollbackException
org.apache.ignite.transactions.TransactionState
org.apache.ignite.transactions.TransactionTimeoutException
-org.jdk8.backport.ConcurrentHashMap8
-org.jdk8.backport.ConcurrentHashMap8$KeySetView
-org.jdk8.backport.ConcurrentHashMap8$Segment
-org.jdk8.backport.ConcurrentLinkedHashMap$QueuePolicy
-org.jdk8.backport.ConcurrentLinkedHashMap$Segment
-org.jdk8.backport.ConcurrentLinkedHashMap$WriteThroughEntry
-org.jdk8.backport.LongAdder8
-org.jdk8.backport.Striped64_8
-org.jdk8.backport.ThreadLocalRandom8
[15/30] incubator-ignite git commit: # ignite-sprint-3 fixed test
Posted by sb...@apache.org.
# ignite-sprint-3 fixed test
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/505a7bf2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/505a7bf2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/505a7bf2
Branch: refs/heads/ignite-366
Commit: 505a7bf227b1396ac3ff2f3b08258dbd58c32698
Parents: 69f5079
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 2 10:15:34 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 2 10:15:34 2015 +0300
----------------------------------------------------------------------
.../cache/GridCacheOnCopyFlagAbstractSelfTest.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/505a7bf2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
index b2906f8..538567c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOnCopyFlagAbstractSelfTest.java
@@ -93,6 +93,8 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
c.setDiscoverySpi(spi);
+ c.setPeerClassLoadingEnabled(false);
+
c.getTransactionConfiguration().setTxSerializableEnabled(true);
return c;
@@ -388,13 +390,13 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
TestImmutableValue val0 = entry.rawGet().value(cctx.cacheObjectContext(), false);
- assertSame(val0, e.getValue());
+ assertNotSame(val0, e.getValue());
TestImmutableValue val1 = entry.rawGet().value(cctx.cacheObjectContext(), true);
- assertSame(val0, val1);
+ assertNotSame(val0, val1);
- assertSame(e.getValue(), cache.get(e.getKey()));
+ assertNotSame(e.getValue(), cache.get(e.getKey()));
}
}
@@ -410,7 +412,7 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
for (int i = 0; i < ITER_CNT; i++) {
String key = String.valueOf(i);
- Long val = (long)i;
+ Long val = Long.MAX_VALUE - i;
cache.put(key, val);
@@ -436,13 +438,13 @@ public abstract class GridCacheOnCopyFlagAbstractSelfTest extends GridCacheAbstr
Long val0 = entry.rawGet().value(cctx.cacheObjectContext(), false);
- assertSame(val0, e.getValue());
+ assertNotSame(val0, e.getValue());
Long val1 = entry.rawGet().value(cctx.cacheObjectContext(), true);
- assertSame(val0, val1);
+ assertNotSame(val0, val1);
- assertSame(e.getValue(), cache.get(e.getKey()));
+ assertNotSame(e.getValue(), cache.get(e.getKey()));
}
}
[18/30] incubator-ignite git commit: # GG-8774 Review.
Posted by sb...@apache.org.
# GG-8774 Review.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0e297a6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0e297a6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0e297a6e
Branch: refs/heads/ignite-366
Commit: 0e297a6e97af1a284a1be676763bf49922e91215
Parents: 9b23109
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Apr 2 16:31:05 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Apr 2 16:31:05 2015 +0700
----------------------------------------------------------------------
ipc/shmem/README.txt | 2 +-
.../org/apache/ignite/internal/visor/util/VisorMimeTypes.java | 4 ++--
.../spi/deployment/uri/GridUriDeploymentFileResourceLoader.java | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e297a6e/ipc/shmem/README.txt
----------------------------------------------------------------------
diff --git a/ipc/shmem/README.txt b/ipc/shmem/README.txt
index 854e1d9..e11360b 100644
--- a/ipc/shmem/README.txt
+++ b/ipc/shmem/README.txt
@@ -26,7 +26,7 @@ Usage with Apache Ignite
-------------------
Copy compiled library to folder that already listed in 'java.library.path'
-with name in form: 'libigniteshmem-<ignite-version>.<extention>'.
+with name in form: 'libigniteshmem-<ignite-version>.<extension>'.
Note: Ignite should be restarted.
**************************************************************************************
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e297a6e/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java
index acd56a9..0a76f98 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/util/VisorMimeTypes.java
@@ -1009,9 +1009,9 @@ public class VisorMimeTypes {
int lastIdx = name.lastIndexOf('.');
if (lastIdx != -1) {
- String extention = name.substring(lastIdx + 1).toLowerCase();
+ String extension = name.substring(lastIdx + 1).toLowerCase();
- return mimeTypes.get(extention);
+ return mimeTypes.get(extension);
}
return null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0e297a6e/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java
index 0e065c8..a0102f6 100644
--- a/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java
+++ b/modules/urideploy/src/main/java/org/apache/ignite/spi/deployment/uri/GridUriDeploymentFileResourceLoader.java
@@ -66,7 +66,7 @@ class GridUriDeploymentFileResourceLoader {
// Replace separators.
str = str.replaceAll("\\/|\\\\", ".");
- // Strip off '.class' extention.
+ // Strip off '.class' extension.
str = str.substring(0, str.indexOf(".class"));
try {
[06/30] incubator-ignite git commit: Merge remote-tracking branch
'origin/ignite-sprint-3' into ignite-sprint-3
Posted by sb...@apache.org.
Merge remote-tracking branch 'origin/ignite-sprint-3' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/efd98ba0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/efd98ba0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/efd98ba0
Branch: refs/heads/ignite-366
Commit: efd98ba01b0d1683281cc077dfa55cee0973151d
Parents: 2268875 6333966
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 1 17:44:52 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 1 17:44:52 2015 +0300
----------------------------------------------------------------------
examples/pom.xml | 19 ++++++-------
examples/schema-import/pom.xml | 10 +++----
modules/aop/pom.xml | 6 ++--
modules/aws/pom.xml | 4 +--
modules/clients/pom.xml | 10 +++----
modules/codegen/pom.xml | 4 +--
modules/core/pom.xml | 8 +++---
modules/extdata/p2p/pom.xml | 4 +--
modules/extdata/uri/pom.xml | 4 +--
modules/geospatial/pom.xml | 4 +--
modules/hadoop/pom.xml | 8 +++---
modules/hibernate/pom.xml | 6 ++--
modules/indexing/pom.xml | 4 +--
modules/jcl/pom.xml | 4 +--
modules/jta/pom.xml | 4 +--
modules/log4j/pom.xml | 4 +--
modules/rest-http/pom.xml | 2 +-
modules/scalar/pom.xml | 10 +++----
modules/schedule/pom.xml | 4 +--
modules/schema-import/pom.xml | 2 +-
modules/slf4j/pom.xml | 2 +-
modules/spring/pom.xml | 8 +++---
modules/ssh/pom.xml | 8 +++---
modules/urideploy/pom.xml | 6 ++--
modules/visor-console/pom.xml | 8 +++---
modules/visor-plugins/pom.xml | 2 +-
modules/web/pom.xml | 8 +++---
modules/yardstick/pom.xml | 6 ++--
pom.xml | 56 ++++++++++++++++++-------------------
29 files changed, 112 insertions(+), 113 deletions(-)
----------------------------------------------------------------------
[20/30] incubator-ignite git commit: Merge branch 'ignite-gg-9942'
into ignite-sprint-3
Posted by sb...@apache.org.
Merge branch 'ignite-gg-9942' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ddb8e91a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ddb8e91a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ddb8e91a
Branch: refs/heads/ignite-366
Commit: ddb8e91ad4a7dd2dd5b6e7e8d603e8927fdae6c6
Parents: 0e297a6 624eaf4
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Apr 2 16:51:16 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Apr 2 16:51:16 2015 +0700
----------------------------------------------------------------------
.../visor/cache/VisorCacheConfiguration.java | 81 ++++++++------------
.../cache/VisorCacheNearConfiguration.java | 11 ++-
.../visor/node/VisorGridConfiguration.java | 28 ++++++-
.../resources/META-INF/classnames.properties | 79 +++++--------------
4 files changed, 87 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
[05/30] incubator-ignite git commit: sp-3
Posted by sb...@apache.org.
sp-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/22688754
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/22688754
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/22688754
Branch: refs/heads/ignite-366
Commit: 226887545372403f1042f163360e0ee9066e2a12
Parents: 6413426
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 1 17:44:38 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 1 17:44:38 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/22688754/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 74a070f..d5c05f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1060,6 +1060,13 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
}
/**
+ * @return {@code True} if node is stopping.
+ */
+ private boolean isNodeStopping() {
+ return super.getSpiContext().isStopping();
+ }
+
+ /**
* @throws IgniteSpiException If any error occurs.
* @return {@code true} if IP finder contains local address.
*/
@@ -4695,7 +4702,7 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov
// Ping.
if (msg instanceof TcpDiscoveryPingRequest) {
- if (ctxInitLatch.getCount() > 0 || !getSpiContext().isStopping()) {
+ if (!isNodeStopping()) {
TcpDiscoveryPingRequest req = (TcpDiscoveryPingRequest)msg;
TcpDiscoveryPingResponse res = new TcpDiscoveryPingResponse(locNodeId);
[09/30] incubator-ignite git commit: # ignite-sprint-3 minor (fixed
test, use static classes in CacheObjectProcessor)
Posted by sb...@apache.org.
# ignite-sprint-3 minor (fixed test, use static classes in CacheObjectProcessor)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8a86e387
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8a86e387
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8a86e387
Branch: refs/heads/ignite-366
Commit: 8a86e387be58d670acfdf06e4d9e83fe657106c9
Parents: b7659f3
Author: sboikov <se...@inria.fr>
Authored: Wed Apr 1 22:11:37 2015 +0300
Committer: sboikov <se...@inria.fr>
Committed: Wed Apr 1 22:19:58 2015 +0300
----------------------------------------------------------------------
.../IgniteCacheObjectProcessorImpl.java | 165 ++++++++++++-------
.../IgniteCacheStoreValueAbstractTest.java | 92 +++++++----
.../junits/common/GridCommonAbstractTest.java | 2 +-
3 files changed, 167 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a86e387/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index a9b7c00..f65b7bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -26,7 +26,6 @@ import org.apache.ignite.internal.processors.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.query.*;
import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.jetbrains.annotations.*;
@@ -114,34 +113,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (!userObj)
return new KeyCacheObjectImpl(obj, null);
- return new KeyCacheObjectImpl(obj, null) {
- @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
- return super.value(ctx, false); // Do not need copy since user value is not in cache.
- }
-
- @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
- try {
- if (!ctx.processor().immutable(val)) {
- if (valBytes == null)
- valBytes = ctx.processor().marshal(ctx, val);
-
- ClassLoader ldr = ctx.p2pEnabled() ?
- IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
-
- Object val = ctx.processor().unmarshal(ctx,
- valBytes,
- ldr);
-
- return new KeyCacheObjectImpl(val, valBytes);
- }
-
- return new KeyCacheObjectImpl(val, valBytes);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal object: " + val, e);
- }
- }
- };
+ return new UserKeyCacheObjectImpl(obj);
}
/** {@inheritDoc} */
@@ -208,23 +180,13 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
if (!userObj)
return new CacheObjectByteArrayImpl((byte[])obj);
- return new CacheObjectByteArrayImpl((byte[]) obj) {
- @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
- return super.value(ctx, false); // Do not need copy since user value is not in cache.
- }
-
- @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
- byte[] valCpy = Arrays.copyOf(val, val.length);
-
- return new CacheObjectByteArrayImpl(valCpy);
- }
- };
+ return new UserCacheObjectByteArrayImpl((byte[])obj);
}
if (!userObj)
return new CacheObjectImpl(obj, null);
- return new IgniteCacheObjectImpl(obj, null);
+ return new UserCacheObjectImpl(obj, null);
}
/** {@inheritDoc} */
@@ -313,16 +275,65 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
}
/**
- *
+ * Wraps key provided by user, must be serialized before stored in cache.
*/
- private static class IgniteCacheObjectImpl extends CacheObjectImpl {
+ private static class UserKeyCacheObjectImpl extends KeyCacheObjectImpl {
/** */
private static final long serialVersionUID = 0L;
/**
*
*/
- public IgniteCacheObjectImpl() {
+ public UserKeyCacheObjectImpl() {
+ //No-op.
+ }
+
+ /**
+ * @param key Key.
+ */
+ UserKeyCacheObjectImpl(Object key) {
+ super(key, null);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+ return super.value(ctx, false); // Do not need copy since user value is not in cache.
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+ try {
+ if (!ctx.processor().immutable(val)) {
+ if (valBytes == null)
+ valBytes = ctx.processor().marshal(ctx, val);
+
+ ClassLoader ldr = ctx.p2pEnabled() ?
+ IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
+
+ Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+
+ return new KeyCacheObjectImpl(val, valBytes);
+ }
+
+ return new KeyCacheObjectImpl(val, valBytes);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to marshal object: " + val, e);
+ }
+ }
+ }
+
+ /**
+ * Wraps value provided by user, must be serialized before stored in cache.
+ */
+ private static class UserCacheObjectImpl extends CacheObjectImpl {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ *
+ */
+ public UserCacheObjectImpl() {
//No-op.
}
@@ -330,7 +341,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
* @param val Value.
* @param valBytes Value bytes.
*/
- public IgniteCacheObjectImpl(Object val, byte[] valBytes) {
+ public UserCacheObjectImpl(Object val, byte[] valBytes) {
super(val, valBytes);
}
@@ -341,28 +352,58 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
/** {@inheritDoc} */
@Override public CacheObject prepareForCache(CacheObjectContext ctx) {
- if (!ctx.processor().immutable(val)) {
- try {
- if (valBytes == null)
- valBytes = ctx.processor().marshal(ctx, val);
+ try {
+ if (valBytes == null)
+ valBytes = ctx.processor().marshal(ctx, val);
- if (ctx.storeValue()) {
- ClassLoader ldr = ctx.p2pEnabled() ?
- IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
+ if (ctx.storeValue()) {
+ ClassLoader ldr = ctx.p2pEnabled() ?
+ IgniteUtils.detectClass(this.val).getClassLoader() : val.getClass().getClassLoader();
- Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+ Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
- return new CacheObjectImpl(val, valBytes);
- }
-
- return new CacheObjectImpl(null, valBytes);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to marshal object: " + val, e);
+ return new CacheObjectImpl(val, valBytes);
}
+
+ return new CacheObjectImpl(null, valBytes);
}
- else
- return new CacheObjectImpl(val, valBytes);
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to marshal object: " + val, e);
+ }
+ }
+ }
+
+ /**
+ * Wraps value provided by user, must be copied before stored in cache.
+ */
+ private static class UserCacheObjectByteArrayImpl extends CacheObjectByteArrayImpl {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ *
+ */
+ public UserCacheObjectByteArrayImpl() {
+ // No-op.
+ }
+
+ /**
+ * @param val Value.
+ */
+ public UserCacheObjectByteArrayImpl(byte[] val) {
+ super(val);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public <T> T value(CacheObjectContext ctx, boolean cpy) {
+ return super.value(ctx, false); // Do not need copy since user value is not in cache.
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheObject prepareForCache(CacheObjectContext ctx) {
+ byte[] valCpy = Arrays.copyOf(val, val.length);
+
+ return new CacheObjectByteArrayImpl(valCpy);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a86e387/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
index 9fa24cc..9552258 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheStoreValueAbstractTest.java
@@ -62,7 +62,7 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
ccfg.setCacheStoreFactory(singletonFactory(new CacheStoreAdapter() {
@Override public void loadCache(IgniteBiInClosure clo, Object... args) {
- clo.apply(new TestKey(1), new TestValue());
+ clo.apply(new TestKey(100_000), new TestValue(30_000));
}
@Override public Object load(Object key) throws CacheLoaderException {
@@ -88,6 +88,11 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
return true;
}
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 2 * 60_000;
+ }
+
/**
* @throws Exception If failed.
*/
@@ -98,9 +103,9 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
final List<WeakReference<Object>> refs = new ArrayList<>();
- for (int i = 0; i < 1000; i++) {
+ for (int i = 0; i < 100; i++) {
TestKey key = new TestKey(i);
- TestValue val = new TestValue();
+ TestValue val = new TestValue(i);
refs.add(new WeakReference<Object>(val));
@@ -117,9 +122,9 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
@Override public Object process(MutableEntry<TestKey, TestValue> entry, Object... args) {
assertNotNull(entry.getValue());
- entry.setValue(new TestValue());
+ entry.setValue(new TestValue(10_000));
- return new TestValue();
+ return new TestValue(20_000);
}
});
@@ -135,7 +140,19 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
for (int g = 0; g < gridCount(); g++)
assertNull(grid(g).cache(null).get(key));
- try (IgniteDataStreamer streamer = grid(0).dataStreamer(null)) {
+ try (IgniteDataStreamer<TestKey, TestValue> streamer = grid(0).dataStreamer(null)) {
+ streamer.addData(key, val);
+ }
+
+ checkNoValue(aff, key);
+
+ cache.remove(key);
+
+ atomicClockModeDelay(cache);
+
+ try (IgniteDataStreamer<TestKey, TestValue> streamer = grid(0).dataStreamer(null)) {
+ streamer.allowOverwrite(true);
+
streamer.addData(key, val);
}
@@ -154,9 +171,9 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
}
}
- cache.loadCache(null); // Should load TestKey(1).
+ cache.loadCache(null); // Should load TestKey(100_000).
- TestKey key = new TestKey(1);
+ TestKey key = new TestKey(100_000);
checkNoValue(aff, key);
@@ -165,26 +182,29 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
checkNoValue(aff, key);
-// boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
-// @Override public boolean apply() {
-// System.gc();
-//
-// boolean pass = true;
-//
-// for (Iterator<WeakReference<Object>> it = refs.iterator(); it.hasNext();) {
-// WeakReference<Object> ref = it.next();
-//
-// if (ref.get() == null)
-// it.remove();
-// else
-// pass = false;
-// }
-//
-// return pass;
-// }
-// }, 10_000);
-//
-// assertTrue("Failed to wait for when values are collected", wait);
+ boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ System.gc();
+
+ boolean pass = true;
+
+ for (Iterator<WeakReference<Object>> it = refs.iterator(); it.hasNext();) {
+ WeakReference<Object> ref = it.next();
+
+ if (ref.get() == null)
+ it.remove();
+ else {
+ pass = false;
+
+ log.info("Not collected value: " + ref.get());
+ }
+ }
+
+ return pass;
+ }
+ }, 60_000);
+
+ assertTrue("Failed to wait for when values are collected", wait);
}
/**
@@ -265,7 +285,21 @@ public abstract class IgniteCacheStoreValueAbstractTest extends IgniteCacheAbstr
*
*/
static class TestValue implements Serializable {
- // No-op.
+ /** */
+ private int val;
+
+ /**
+ *
+ * @param val Value.
+ */
+ public TestValue(int val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "TestValue [val=" + val + ']';
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a86e387/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 9dd40d0..be13228 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -769,6 +769,6 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
if (ccfg.getCacheMode() != LOCAL &&
ccfg.getAtomicityMode() == CacheAtomicityMode.ATOMIC &&
ccfg.getAtomicWriteOrderMode() == CacheAtomicWriteOrderMode.CLOCK)
- U.sleep(100);
+ U.sleep(50);
}
}
[19/30] incubator-ignite git commit: Merge branches 'ignite-gg-9942'
and 'ignite-sprint-3' of
https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-gg-9942
Posted by sb...@apache.org.
Merge branches 'ignite-gg-9942' and 'ignite-sprint-3' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-gg-9942
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/624eaf45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/624eaf45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/624eaf45
Branch: refs/heads/ignite-366
Commit: 624eaf454d68bb82ff3ecfedd1b2208db4a2e423
Parents: e2cbd21 9b23109
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Apr 2 16:41:11 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Apr 2 16:41:11 2015 +0700
----------------------------------------------------------------------
DEVNOTES.txt | 2 ++
.../apache/ignite/IgniteCacheAffinitySelfTest.java | 2 ++
.../cache/GridCacheOnCopyFlagAbstractSelfTest.java | 16 +++++++++-------
parent/pom.xml | 10 +++++++++-
4 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
[04/30] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-sprint-3' into ignite-662
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-sprint-3' into ignite-662
Conflicts:
modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1a9de867
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1a9de867
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1a9de867
Branch: refs/heads/ignite-366
Commit: 1a9de86780567eb99d82b7c9a08d32fd6462264e
Parents: 5caa107 dc62822
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 1 15:52:05 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 1 15:52:05 2015 +0300
----------------------------------------------------------------------
.../examples/datagrid/CacheQueryExample.java | 12 +-
.../store/jdbc/CacheAbstractJdbcStore.java | 2 +-
.../cache/store/jdbc/CacheJdbcBlobStore.java | 9 +-
.../configuration/FileSystemConfiguration.java | 6 +
.../ignite/internal/GridCachePluginContext.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 5 +-
.../cache/CacheObjectByteArrayImpl.java | 2 +-
.../cache/DynamicCacheDescriptor.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 4 +-
.../processors/cache/GridCacheProcessor.java | 66 +++++------
.../continuous/CacheContinuousQueryManager.java | 28 +++++
.../processors/igfs/IgfsDataManager.java | 11 +-
.../processors/igfs/IgfsFileAffinityRange.java | 23 +---
.../processors/igfs/IgfsHelperImpl.java | 3 +-
.../processors/plugin/CachePluginManager.java | 2 +-
.../ignite/plugin/CachePluginConfiguration.java | 5 +-
.../ignite/plugin/CachePluginContext.java | 2 +-
.../ignite/plugin/CachePluginProvider.java | 3 +-
.../ignite/startup/BasicWarmupClosure.java | 2 +-
...IgniteCacheJdbcBlobStoreNodeRestartTest.java | 52 +++++++++
...IgniteCacheStoreNodeRestartAbstractTest.java | 116 +++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../hibernate/CacheHibernateBlobStore.java | 9 +-
.../CacheHibernateBlobStoreNodeRestartTest.java | 52 +++++++++
.../testsuites/IgniteHibernateTestSuite.java | 2 +
.../processors/query/h2/IgniteH2Indexing.java | 4 +-
.../ant/beautifier/GridJavadocAntTask.java | 8 +-
27 files changed, 341 insertions(+), 93 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1a9de867/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 9e50565,6fdaa00..a4553c4
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@@ -415,15 -415,8 +415,17 @@@ public class IgniteCacheTestSuite exten
suite.addTestSuite(GridCacheMarshallingNodeJoinSelfTest.class);
+ suite.addTestSuite(IgniteCacheJdbcBlobStoreNodeRestartTest.class);
+
+ suite.addTestSuite(IgniteCacheAtomicLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheAtomicPrimaryWriteOrderNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxLocalStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxStoreValueTest.class);
+ suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class);
+
return suite;
}
}
[28/30] incubator-ignite git commit: Updated devnotes to reflect zip
name produced by parent pom.xml.
Posted by sb...@apache.org.
Updated devnotes to reflect zip name produced by parent pom.xml.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7e86251e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7e86251e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7e86251e
Branch: refs/heads/ignite-366
Commit: 7e86251e8bb5d0c610ef8414a5454c5376ef75b9
Parents: c213edc
Author: thatcoach <pp...@list.ru>
Authored: Thu Apr 2 20:58:49 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Thu Apr 2 20:58:49 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7e86251e/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index f2c885f..3726774 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -6,7 +6,7 @@ Without LGPL dependencies (default):
With LGPL dependencies:
mvn clean package -DskipTests -Prelease,lgpl
-Look for ignite-fabric-<version>.zip in ./target directory.
+Look for incubator-ignite-<version>-bin.zip in ./target directory.
NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
@@ -17,7 +17,7 @@ mvn clean package -DskipTests -Dignite.edition=hadoop [-Dhadoop.version=X.X.X]
Use 'hadoop.version' parameter to build Ignite against a specific Hadoop version.
-Look for ignite-hadoop-<version>.zip in ./target directory.
+Look for incubator-ignite-<version>-bin.zip in ./target directory.
NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
[02/30] incubator-ignite git commit: # GG-9942 Fixed Visor logic
after DR was reworked.
Posted by sb...@apache.org.
# GG-9942 Fixed Visor logic after DR was reworked.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c8428a45
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c8428a45
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c8428a45
Branch: refs/heads/ignite-366
Commit: c8428a453bdee6da2fa0a6221d53c41f157f4e45
Parents: b05b06f
Author: AKuznetsov <ak...@gridgain.com>
Authored: Wed Apr 1 18:12:43 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Wed Apr 1 18:12:43 2015 +0700
----------------------------------------------------------------------
.../visor/cache/VisorCacheConfiguration.java | 81 ++++++++------------
.../visor/node/VisorGridConfiguration.java | 28 ++++++-
2 files changed, 58 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c8428a45/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 98a8bc2..923fedd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -121,56 +121,37 @@ public class VisorCacheConfiguration implements Serializable {
* @param ccfg Cache configuration.
* @return Data transfer object for cache configuration properties.
*/
- public static VisorCacheConfiguration from(Ignite ignite, CacheConfiguration ccfg) {
- VisorCacheConfiguration cfg = new VisorCacheConfiguration();
-
- cfg.name = ccfg.getName();
- cfg.mode = ccfg.getCacheMode();
- cfg.atomicityMode = ccfg.getAtomicityMode();
- cfg.atomicWriteOrderMode = ccfg.getAtomicWriteOrderMode();
- cfg.eagerTtl = ccfg.isEagerTtl();
- cfg.writeSynchronizationMode = ccfg.getWriteSynchronizationMode();
- cfg.swapEnabled = ccfg.isSwapEnabled();
- cfg.invalidate = ccfg.isInvalidate();
- cfg.startSize = ccfg.getStartSize();
- cfg.tmLookupClsName = ccfg.getTransactionManagerLookupClassName();
- cfg.offHeapMaxMemory = ccfg.getOffHeapMaxMemory();
- cfg.maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations();
- cfg.memoryMode = ccfg.getMemoryMode();
- cfg.interceptor = compactClass(ccfg.getInterceptor());
- cfg.typeMeta = VisorCacheTypeMetadata.list(ccfg.getTypeMetadata());
- cfg.statisticsEnabled = ccfg.isStatisticsEnabled();
- cfg.mgmtEnabled = ccfg.isManagementEnabled();
- cfg.ldrFactory = compactClass(ccfg.getCacheLoaderFactory());
- cfg.writerFactory = compactClass(ccfg.getCacheWriterFactory());
- cfg.expiryPlcFactory = compactClass(ccfg.getExpiryPolicyFactory());
-
- cfg.affinityCfg = VisorCacheAffinityConfiguration.from(ccfg);
- cfg.rebalanceCfg = VisorCacheRebalanceConfiguration.from(ccfg);
- cfg.evictCfg = VisorCacheEvictionConfiguration.from(ccfg);
- cfg.nearCfg = VisorCacheNearConfiguration.from(ccfg);
- cfg.dfltCfg = VisorCacheDefaultConfiguration.from(ccfg);
- cfg.storeCfg = VisorCacheStoreConfiguration.from(ignite, ccfg);
- cfg.qryCfg = VisorCacheQueryConfiguration.from(ccfg);
-
- return cfg;
- }
-
- /**
- * @param ignite Grid.
- * @param caches Cache configurations.
- * @return Data transfer object for cache configurations properties.
- */
- public static Iterable<VisorCacheConfiguration> list(Ignite ignite, CacheConfiguration[] caches) {
- if (caches == null)
- return Collections.emptyList();
-
- final Collection<VisorCacheConfiguration> cfgs = new ArrayList<>(caches.length);
-
- for (CacheConfiguration cache : caches)
- cfgs.add(from(ignite, cache));
-
- return cfgs;
+ public VisorCacheConfiguration from(Ignite ignite, CacheConfiguration ccfg) {
+ name = ccfg.getName();
+ mode = ccfg.getCacheMode();
+ atomicityMode = ccfg.getAtomicityMode();
+ atomicWriteOrderMode = ccfg.getAtomicWriteOrderMode();
+ eagerTtl = ccfg.isEagerTtl();
+ writeSynchronizationMode = ccfg.getWriteSynchronizationMode();
+ swapEnabled = ccfg.isSwapEnabled();
+ invalidate = ccfg.isInvalidate();
+ startSize = ccfg.getStartSize();
+ tmLookupClsName = ccfg.getTransactionManagerLookupClassName();
+ offHeapMaxMemory = ccfg.getOffHeapMaxMemory();
+ maxConcurrentAsyncOps = ccfg.getMaxConcurrentAsyncOperations();
+ memoryMode = ccfg.getMemoryMode();
+ interceptor = compactClass(ccfg.getInterceptor());
+ typeMeta = VisorCacheTypeMetadata.list(ccfg.getTypeMetadata());
+ statisticsEnabled = ccfg.isStatisticsEnabled();
+ mgmtEnabled = ccfg.isManagementEnabled();
+ ldrFactory = compactClass(ccfg.getCacheLoaderFactory());
+ writerFactory = compactClass(ccfg.getCacheWriterFactory());
+ expiryPlcFactory = compactClass(ccfg.getExpiryPolicyFactory());
+
+ affinityCfg = VisorCacheAffinityConfiguration.from(ccfg);
+ rebalanceCfg = VisorCacheRebalanceConfiguration.from(ccfg);
+ evictCfg = VisorCacheEvictionConfiguration.from(ccfg);
+ nearCfg = VisorCacheNearConfiguration.from(ccfg);
+ dfltCfg = VisorCacheDefaultConfiguration.from(ccfg);
+ storeCfg = VisorCacheStoreConfiguration.from(ignite, ccfg);
+ qryCfg = VisorCacheQueryConfiguration.from(ccfg);
+
+ return this;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c8428a45/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index f6243c1..6548d07 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@ -106,7 +106,7 @@ public class VisorGridConfiguration implements Serializable {
inclEvtTypes = c.getIncludeEventTypes();
rest = VisorRestConfiguration.from(c);
userAttrs = c.getUserAttributes();
- caches = VisorCacheConfiguration.list(ignite, c.getCacheConfiguration());
+ caches = collectCaches(ignite, c.getCacheConfiguration());
igfss = VisorIgfsConfiguration.list(c.getFileSystemConfiguration());
env = new HashMap<>(System.getenv());
sysProps = IgniteSystemProperties.snapshot();
@@ -194,6 +194,32 @@ public class VisorGridConfiguration implements Serializable {
}
/**
+ * @return List of data transfer objects for caches.
+ */
+ private Iterable<VisorCacheConfiguration> collectCaches(IgniteEx ignite, CacheConfiguration[] ccfgs) {
+ if (ccfgs == null)
+ return Collections.emptyList();
+
+ final Collection<VisorCacheConfiguration> res = new ArrayList<>(ccfgs.length);
+
+ for (CacheConfiguration ccfg : ccfgs)
+ res.add(collectCache(ignite, ccfg));
+
+ return res;
+ }
+
+ /**
+ * Create data transfer object for cache configuration.
+ *
+ * @param ignite Ignite instance.
+ * @param ccfg Cache configuration.
+ * @return Data transfer objects for cache
+ */
+ protected VisorCacheConfiguration collectCache(IgniteEx ignite, CacheConfiguration ccfg) {
+ return new VisorCacheConfiguration().from(ignite, ccfg);
+ }
+
+ /**
* @return Caches.
*/
public Iterable<VisorCacheConfiguration> caches() {
[27/30] incubator-ignite git commit: Updated devnotes.
Posted by sb...@apache.org.
Updated devnotes.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c213edcd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c213edcd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c213edcd
Branch: refs/heads/ignite-366
Commit: c213edcde1bd0649a14dbf72d03a580db375cec3
Parents: c662901
Author: thatcoach <pp...@list.ru>
Authored: Thu Apr 2 20:52:16 2015 +0300
Committer: thatcoach <pp...@list.ru>
Committed: Thu Apr 2 20:52:16 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c213edcd/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index 3a712c7..f2c885f 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -1,5 +1,5 @@
-Maven Build Instructions
-========================
+Ignite Fabric Maven Build Instructions
+======================================
Without LGPL dependencies (default):
mvn clean package -DskipTests
@@ -11,6 +11,17 @@ Look for ignite-fabric-<version>.zip in ./target directory.
NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
+Ignite Hadoop Accelerator Maven Build Instructions
+============================================
+mvn clean package -DskipTests -Dignite.edition=hadoop [-Dhadoop.version=X.X.X]
+
+Use 'hadoop.version' parameter to build Ignite against a specific Hadoop version.
+
+Look for ignite-hadoop-<version>.zip in ./target directory.
+
+NOTE: JDK version should be 1.7.0-* or >= 1.8.0-u40.
+
+
JCache TCK compliance
======================
To test compliance with JCache TCK use:
[08/30] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-662' into ignite-sprint-3
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-662' into ignite-sprint-3
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b7659f39
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b7659f39
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b7659f39
Branch: refs/heads/ignite-366
Commit: b7659f39787da4fd6808a3205a05692c9518db32
Parents: 57b7549 1a9de86
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 1 18:25:11 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 1 18:25:11 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CacheObjectContext.java | 14 +-
.../processors/cache/CacheObjectImpl.java | 10 +-
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../cache/query/GridCacheQueryManager.java | 16 +-
.../IgniteCacheObjectProcessorImpl.java | 14 +-
.../IgniteCacheAtomicLocalStoreValueTest.java | 49 ++++
...iteCacheAtomicNearEnabledStoreValueTest.java | 30 ++
...maryWriteOrderNearEnabledStoreValueTest.java | 31 +++
...heAtomicPrimaryWriteOrderStoreValueTest.java | 32 +++
.../cache/IgniteCacheAtomicStoreValueTest.java | 55 ++++
.../IgniteCacheStoreValueAbstractTest.java | 277 +++++++++++++++++++
.../cache/IgniteCacheTxLocalStoreValueTest.java | 49 ++++
.../IgniteCacheTxNearEnabledStoreValueTest.java | 30 ++
.../cache/IgniteCacheTxStoreValueTest.java | 49 ++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 9 +
15 files changed, 651 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
[14/30] incubator-ignite git commit: # ignite-sprint-3 disabled
hanging test
Posted by sb...@apache.org.
# ignite-sprint-3 disabled hanging test
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/69f50791
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/69f50791
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/69f50791
Branch: refs/heads/ignite-366
Commit: 69f50791818eb21bbc99e9568c54fb27bd732956
Parents: ed6632a
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 2 10:04:28 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 2 10:04:28 2015 +0300
----------------------------------------------------------------------
.../test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/69f50791/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
index c4683fd..e5b7d68 100644
--- a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
@@ -90,6 +90,8 @@ public class IgniteCacheAffinitySelfTest extends IgniteCacheAbstractTest {
* @throws Exception if failed.
*/
public void testAffinity() throws Exception {
+ fail("Enable when https://issues.apache.org/jira/browse/IGNITE-647 is fixed.");
+
checkAffinity();
stopGrid(gridCount() - 1);
[24/30] incubator-ignite git commit: # GG-9973: Fixed.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java
new file mode 100644
index 0000000..5ce42f9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheWriteBehindStore.java
@@ -0,0 +1,1015 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.internal.util.worker.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.lifecycle.*;
+import org.apache.ignite.thread.*;
+import org.jetbrains.annotations.*;
+import org.jsr166.*;
+
+import javax.cache.integration.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+import java.util.concurrent.locks.*;
+
+import static javax.cache.Cache.*;
+
+/**
+ * Internal wrapper for a {@link CacheStore} that enables write-behind logic.
+ * <p/>
+ * The general purpose of this approach is to reduce cache store load under high
+ * store update rate. The idea is to cache all write and remove operations in a pending
+ * map and delegate these changes to the underlying store either after timeout or
+ * if size of a pending map exceeded some pre-configured value. Another performance gain
+ * is achieved due to combining a group of similar operations to a single batch update.
+ * <p/>
+ * The essential flush size for the write-behind cache should be at least the estimated
+ * count of simultaneously written keys. In case of significantly smaller value there would
+ * be triggered a lot of flush events that will result in a high cache store load.
+ * <p/>
+ * Since write operations to the cache store are deferred, transaction support is lost; no
+ * transaction objects are passed to the underlying store.
+ */
+public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, LifecycleAware {
+ /** Default write cache initial capacity. */
+ public static final int DFLT_INITIAL_CAPACITY = 1024;
+
+ /** Overflow ratio for critical cache size calculation. */
+ public static final float CACHE_OVERFLOW_RATIO = 1.5f;
+
+ /** Default concurrency level of write cache. */
+ public static final int DFLT_CONCUR_LVL = 64;
+
+ /** Write cache initial capacity. */
+ private int initCap = DFLT_INITIAL_CAPACITY;
+
+ /** Concurrency level for write cache access. */
+ private int concurLvl = DFLT_CONCUR_LVL;
+
+ /** When cache size exceeds this value eldest entry will be stored to the underlying store. */
+ private int cacheMaxSize = CacheConfiguration.DFLT_WRITE_BEHIND_FLUSH_SIZE;
+
+ /** Critical cache size. If cache size exceeds this value, data flush performed synchronously. */
+ private int cacheCriticalSize;
+
+ /** Count of worker threads performing underlying store updates. */
+ private int flushThreadCnt = CacheConfiguration.DFLT_WRITE_FROM_BEHIND_FLUSH_THREAD_CNT;
+
+ /** Cache flush frequency. All pending operations will be performed in not less then this value ms. */
+ private long cacheFlushFreq = CacheConfiguration.DFLT_WRITE_BEHIND_FLUSH_FREQUENCY;
+
+ /** Maximum batch size for put and remove operations */
+ private int batchSize = CacheConfiguration.DFLT_WRITE_BEHIND_BATCH_SIZE;
+
+ /** Grid name. */
+ private String gridName;
+
+ /** Cache name. */
+ private String cacheName;
+
+ /** Underlying store. */
+ private CacheStore<K, V> store;
+
+ /** Write cache. */
+ private ConcurrentLinkedHashMap<K, StatefulValue<K, V>> writeCache;
+
+ /** Flusher threads. */
+ private GridWorker[] flushThreads;
+
+ /** Atomic flag indicating store shutdown. */
+ private AtomicBoolean stopping = new AtomicBoolean(true);
+
+ /** Flush lock. */
+ private Lock flushLock = new ReentrantLock();
+
+ /** Condition to determine records available for flush. */
+ private Condition canFlush = flushLock.newCondition();
+
+ /** Variable for counting total cache overflows. */
+ private AtomicInteger cacheTotalOverflowCntr = new AtomicInteger();
+
+ /** Variable contains current number of overflow events. */
+ private AtomicInteger cacheOverflowCntr = new AtomicInteger();
+
+ /** Variable for counting key-value pairs that are in {@link ValueStatus#RETRY} state. */
+ private AtomicInteger retryEntriesCnt = new AtomicInteger();
+
+ /** Log. */
+ private IgniteLogger log;
+
+ /** Store manager. */
+ private CacheStoreManager storeMgr;
+
+ /**
+ * Creates a write-behind cache store for the given store.
+ *
+ * @param storeMgr Store manager.
+ * @param gridName Grid name.
+ * @param cacheName Cache name.
+ * @param log Grid logger.
+ * @param store {@code GridCacheStore} that need to be wrapped.
+ */
+ public GridCacheWriteBehindStore(
+ CacheStoreManager storeMgr,
+ String gridName,
+ String cacheName,
+ IgniteLogger log,
+ CacheStore<K, V> store) {
+ this.storeMgr = storeMgr;
+ this.gridName = gridName;
+ this.cacheName = cacheName;
+ this.log = log;
+ this.store = store;
+ }
+
+ /**
+ * Sets initial capacity for the write cache.
+ *
+ * @param initCap Initial capacity.
+ */
+ public void setInitialCapacity(int initCap) {
+ this.initCap = initCap;
+ }
+
+ /**
+ * Sets concurrency level for the write cache. Concurrency level is expected count of concurrent threads
+ * attempting to update cache.
+ *
+ * @param concurLvl Concurrency level.
+ */
+ public void setConcurrencyLevel(int concurLvl) {
+ this.concurLvl = concurLvl;
+ }
+
+ /**
+ * Sets the maximum size of the write cache. When the count of unique keys in write cache exceeds this value,
+ * the eldest entry in the cache is immediately scheduled for write to the underlying store.
+ *
+ * @param cacheMaxSize Max cache size.
+ */
+ public void setFlushSize(int cacheMaxSize) {
+ this.cacheMaxSize = cacheMaxSize;
+ }
+
+ /**
+ * Gets the maximum size of the write-behind buffer. When the count of unique keys
+ * in write buffer exceeds this value, the buffer is scheduled for write to the underlying store.
+ * <p/>
+ * If this value is {@code 0}, then flush is performed only on time-elapsing basis. However,
+ * when this value is {@code 0}, the cache critical size is set to
+ * {@link CacheConfiguration#DFLT_WRITE_BEHIND_CRITICAL_SIZE}
+ *
+ * @return Buffer size that triggers flush procedure.
+ */
+ public int getWriteBehindFlushSize() {
+ return cacheMaxSize;
+ }
+
+ /**
+ * Sets the number of threads that will perform store update operations.
+ *
+ * @param flushThreadCnt Count of worker threads.
+ */
+ public void setFlushThreadCount(int flushThreadCnt) {
+ this.flushThreadCnt = flushThreadCnt;
+ }
+
+ /**
+ * Gets the number of flush threads that will perform store update operations.
+ *
+ * @return Count of worker threads.
+ */
+ public int getWriteBehindFlushThreadCount() {
+ return flushThreadCnt;
+ }
+
+ /**
+ * Sets the cache flush frequency. All pending operations on the underlying store will be performed
+ * within time interval not less then this value.
+ *
+ * @param cacheFlushFreq Time interval value in milliseconds.
+ */
+ public void setFlushFrequency(long cacheFlushFreq) {
+ this.cacheFlushFreq = cacheFlushFreq;
+ }
+
+ /**
+ * Gets the cache flush frequency. All pending operations on the underlying store will be performed
+ * within time interval not less then this value.
+ * <p/>
+ * If this value is {@code 0}, then flush is performed only when buffer size exceeds flush size.
+ *
+ * @return Flush frequency in milliseconds.
+ */
+ public long getWriteBehindFlushFrequency() {
+ return cacheFlushFreq;
+ }
+
+ /**
+ * Sets the maximum count of similar operations that can be grouped to a single batch.
+ *
+ * @param batchSize Maximum count of batch.
+ */
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ /**
+ * Gets the maximum count of similar (put or remove) operations that can be grouped to a single batch.
+ *
+ * @return Maximum size of batch.
+ */
+ public int getWriteBehindStoreBatchSize() {
+ return batchSize;
+ }
+
+ /**
+ * Gets count of entries that were processed by the write-behind store and have not been
+ * flushed to the underlying store yet.
+ *
+ * @return Total count of entries in cache store internal buffer.
+ */
+ public int getWriteBehindBufferSize() {
+ return writeCache.sizex();
+ }
+
+ /**
+ * @return Underlying store.
+ */
+ public CacheStore<K, V> store() {
+ return store;
+ }
+
+ /**
+ * Performs all the initialization logic for write-behind cache store.
+ * This class must not be used until this method returns.
+ */
+ @Override public void start() {
+ assert cacheFlushFreq != 0 || cacheMaxSize != 0;
+
+ if (stopping.compareAndSet(true, false)) {
+ if (log.isDebugEnabled())
+ log.debug("Starting write-behind store for cache '" + cacheName + '\'');
+
+ cacheCriticalSize = (int)(cacheMaxSize * CACHE_OVERFLOW_RATIO);
+
+ if (cacheCriticalSize == 0)
+ cacheCriticalSize = CacheConfiguration.DFLT_WRITE_BEHIND_CRITICAL_SIZE;
+
+ flushThreads = new GridWorker[flushThreadCnt];
+
+ writeCache = new ConcurrentLinkedHashMap<>(initCap, 0.75f, concurLvl);
+
+ for (int i = 0; i < flushThreads.length; i++) {
+ flushThreads[i] = new Flusher(gridName, "flusher-" + i, log);
+
+ new IgniteThread(flushThreads[i]).start();
+ }
+ }
+ }
+
+ /**
+ * Gets count of write buffer overflow events since initialization. Each overflow event causes
+ * the ongoing flush operation to be performed synchronously.
+ *
+ * @return Count of cache overflow events since start.
+ */
+ public int getWriteBehindTotalCriticalOverflowCount() {
+ return cacheTotalOverflowCntr.get();
+ }
+
+ /**
+ * Gets count of write buffer overflow events in progress at the moment. Each overflow event causes
+ * the ongoing flush operation to be performed synchronously.
+ *
+ * @return Count of cache overflow events since start.
+ */
+ public int getWriteBehindCriticalOverflowCount() {
+ return cacheOverflowCntr.get();
+ }
+
+ /**
+ * Gets count of cache entries that are in a store-retry state. An entry is assigned a store-retry state
+ * when underlying store failed due some reason and cache has enough space to retain this entry till
+ * the next try.
+ *
+ * @return Count of entries in store-retry state.
+ */
+ public int getWriteBehindErrorRetryCount() {
+ return retryEntriesCnt.get();
+ }
+
+ /**
+ * Performs shutdown logic for store. No put, get and remove requests will be processed after
+ * this method is called.
+ */
+ @Override public void stop() {
+ if (stopping.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Stopping write-behind store for cache '" + cacheName + '\'');
+
+ wakeUp();
+
+ boolean graceful = true;
+
+ for (GridWorker worker : flushThreads)
+ graceful &= U.join(worker, log);
+
+ if (!graceful)
+ log.warning("Shutdown was aborted");
+ }
+ }
+
+ /**
+ * Forces all entries collected to be flushed to the underlying store.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void forceFlush() throws IgniteCheckedException {
+ wakeUp();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) {
+ store.loadCache(clo, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
+ if (log.isDebugEnabled())
+ log.debug("Store load all [keys=" + keys + ']');
+
+ Map<K, V> loaded = new HashMap<>();
+
+ Collection<K> remaining = new LinkedList<>();
+
+ for (K key : keys) {
+ StatefulValue<K, V> val = writeCache.get(key);
+
+ if (val != null) {
+ val.readLock().lock();
+
+ try {
+ if (val.operation() == StoreOperation.PUT)
+ loaded.put(key, val.entry().getValue());
+ else
+ assert val.operation() == StoreOperation.RMV : val.operation();
+ }
+ finally {
+ val.readLock().unlock();
+ }
+ }
+ else
+ remaining.add(key);
+ }
+
+ // For items that were not found in queue.
+ if (!remaining.isEmpty()) {
+ Map<K, V> loaded0 = store.loadAll(remaining);
+
+ if (loaded0 != null)
+ loaded.putAll(loaded0);
+ }
+
+ return loaded;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V load(K key) {
+ if (log.isDebugEnabled())
+ log.debug("Store load [key=" + key + ']');
+
+ StatefulValue<K, V> val = writeCache.get(key);
+
+ if (val != null) {
+ val.readLock().lock();
+
+ try {
+ switch (val.operation()) {
+ case PUT:
+ return val.entry().getValue();
+
+ case RMV:
+ return null;
+
+ default:
+ assert false : "Unexpected operation: " + val.status();
+ }
+ }
+ finally {
+ val.readLock().unlock();
+ }
+ }
+
+ return store.load(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeAll(Collection<Entry<? extends K, ? extends V>> entries) {
+ for (Entry<? extends K, ? extends V> e : entries)
+ write(e);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Entry<? extends K, ? extends V> entry) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Store put [key=" + entry.getKey() + ", val=" + entry.getValue() + ']');
+
+ updateCache(entry.getKey(), entry, StoreOperation.PUT);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new CacheWriterException(U.convertExceptionNoWrap(e));
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteAll(Collection<?> keys) {
+ for (Object key : keys)
+ delete(key);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void delete(Object key) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Store remove [key=" + key + ']');
+
+ updateCache((K)key, null, StoreOperation.RMV);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new CacheWriterException(U.convertExceptionNoWrap(e));
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sessionEnd(boolean commit) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridCacheWriteBehindStore.class, this);
+ }
+
+ /**
+ * Performs flush-consistent cache update for the given key.
+ *
+ * @param key Key for which update is performed.
+ * @param val New value, may be null for remove operation.
+ * @param operation Updated value status
+ * @throws IgniteInterruptedCheckedException If interrupted while waiting for value to be flushed.
+ */
+ private void updateCache(K key,
+ @Nullable Entry<? extends K, ? extends V> val,
+ StoreOperation operation)
+ throws IgniteInterruptedCheckedException {
+ StatefulValue<K, V> newVal = new StatefulValue<>(val, operation);
+
+ StatefulValue<K, V> prev;
+
+ while ((prev = writeCache.putIfAbsent(key, newVal)) != null) {
+ prev.writeLock().lock();
+
+ try {
+ if (prev.status() == ValueStatus.PENDING) {
+ // Flush process in progress, try again.
+ prev.waitForFlush();
+
+ continue;
+ }
+ else if (prev.status() == ValueStatus.FLUSHED)
+ // This entry was deleted from map before we acquired the lock.
+ continue;
+ else if (prev.status() == ValueStatus.RETRY)
+ // New value has come, old value is no longer in RETRY state,
+ retryEntriesCnt.decrementAndGet();
+
+ assert prev.status() == ValueStatus.NEW || prev.status() == ValueStatus.RETRY;
+
+ prev.update(val, operation, ValueStatus.NEW);
+
+ break;
+ }
+ finally {
+ prev.writeLock().unlock();
+ }
+ }
+
+ // Now check the map size
+ if (writeCache.sizex() > cacheCriticalSize)
+ // Perform single store update in the same thread.
+ flushSingleValue();
+ else if (cacheMaxSize > 0 && writeCache.sizex() > cacheMaxSize)
+ wakeUp();
+ }
+
+ /**
+ * Flushes one upcoming value to the underlying store. Called from
+ * {@link #updateCache(Object, Entry, StoreOperation)} method in case when current map size exceeds
+ * critical size.
+ */
+ private void flushSingleValue() {
+ cacheOverflowCntr.incrementAndGet();
+
+ try {
+ Map<K, StatefulValue<K, V>> batch = null;
+
+ for (Map.Entry<K, StatefulValue<K, V>> e : writeCache.entrySet()) {
+ StatefulValue<K, V> val = e.getValue();
+
+ val.writeLock().lock();
+
+ try {
+ ValueStatus status = val.status();
+
+ if (acquired(status))
+ // Another thread is helping us, continue to the next entry.
+ continue;
+
+ if (val.status() == ValueStatus.RETRY)
+ retryEntriesCnt.decrementAndGet();
+
+ assert retryEntriesCnt.get() >= 0;
+
+ val.status(ValueStatus.PENDING);
+
+ batch = Collections.singletonMap(e.getKey(), val);
+ }
+ finally {
+ val.writeLock().unlock();
+ }
+
+ if (!batch.isEmpty()) {
+ applyBatch(batch, false);
+
+ cacheTotalOverflowCntr.incrementAndGet();
+
+ return;
+ }
+ }
+ }
+ finally {
+ cacheOverflowCntr.decrementAndGet();
+ }
+ }
+
+ /**
+ * Performs batch operation on underlying store.
+ *
+ * @param valMap Batch map.
+ * @param initSes {@code True} if need to initialize session.
+ */
+ private void applyBatch(Map<K, StatefulValue<K, V>> valMap, boolean initSes) {
+ assert valMap.size() <= batchSize;
+
+ StoreOperation operation = null;
+
+ // Construct a map for underlying store
+ Map<K, Entry<? extends K, ? extends V>> batch = U.newLinkedHashMap(valMap.size());
+
+ for (Map.Entry<K, StatefulValue<K, V>> e : valMap.entrySet()) {
+ if (operation == null)
+ operation = e.getValue().operation();
+
+ assert operation == e.getValue().operation();
+
+ assert e.getValue().status() == ValueStatus.PENDING;
+
+ batch.put(e.getKey(), e.getValue().entry());
+ }
+
+ if (updateStore(operation, batch, initSes)) {
+ for (Map.Entry<K, StatefulValue<K, V>> e : valMap.entrySet()) {
+ StatefulValue<K, V> val = e.getValue();
+
+ val.writeLock().lock();
+
+ try {
+ val.status(ValueStatus.FLUSHED);
+
+ StatefulValue<K, V> prev = writeCache.remove(e.getKey());
+
+ // Additional check to ensure consistency.
+ assert prev == val : "Map value for key " + e.getKey() + " was updated during flush";
+
+ val.signalFlushed();
+ }
+ finally {
+ val.writeLock().unlock();
+ }
+ }
+ }
+ else {
+ // Exception occurred, we must set RETRY status
+ for (StatefulValue<K, V> val : valMap.values()) {
+ val.writeLock().lock();
+
+ try {
+ val.status(ValueStatus.RETRY);
+
+ retryEntriesCnt.incrementAndGet();
+
+ val.signalFlushed();
+ }
+ finally {
+ val.writeLock().unlock();
+ }
+ }
+ }
+ }
+
+ /**
+ * Tries to update store with the given values and returns {@code true} in case of success.
+ *
+ * <p/> If any exception in underlying store is occurred, this method checks the map size.
+ * If map size exceeds some critical value, then it returns {@code true} and this value will
+ * be lost. If map size does not exceed critical value, it will return false and value will
+ * be retained in write cache.
+ *
+ * @param operation Status indicating operation that should be performed.
+ * @param vals Key-Value map.
+ * @param initSes {@code True} if need to initialize session.
+ * @return {@code true} if value may be deleted from the write cache,
+ * {@code false} otherwise
+ */
+ private boolean updateStore(StoreOperation operation,
+ Map<K, Entry<? extends K, ? extends V>> vals,
+ boolean initSes) {
+
+ if (initSes && storeMgr != null)
+ storeMgr.writeBehindSessionInit();
+
+ try {
+ boolean threwEx = true;
+
+ try {
+ switch (operation) {
+ case PUT:
+ store.writeAll(vals.values());
+
+ break;
+
+ case RMV:
+ store.deleteAll(vals.keySet());
+
+ break;
+
+ default:
+ assert false : "Unexpected operation: " + operation;
+ }
+
+ threwEx = false;
+
+ return true;
+ }
+ finally {
+ if (initSes && storeMgr != null)
+ storeMgr.writeBehindSessionEnd(threwEx);
+ }
+ }
+ catch (Exception e) {
+ LT.warn(log, e, "Unable to update underlying store: " + store);
+
+ if (writeCache.sizex() > cacheCriticalSize || stopping.get()) {
+ for (Map.Entry<K, Entry<? extends K, ? extends V>> entry : vals.entrySet()) {
+ Object val = entry.getValue() != null ? entry.getValue().getValue() : null;
+
+ log.warning("Failed to update store (value will be lost as current buffer size is greater " +
+ "than 'cacheCriticalSize' or node has been stopped before store was repaired) [key=" +
+ entry.getKey() + ", val=" + val + ", op=" + operation + "]");
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * Wakes up flushing threads if map size exceeded maximum value or in case of shutdown.
+ */
+ private void wakeUp() {
+ flushLock.lock();
+
+ try {
+ canFlush.signalAll();
+ }
+ finally {
+ flushLock.unlock();
+ }
+ }
+
+ /**
+ * Thread that performs time-based flushing of written values to the underlying storage.
+ */
+ private class Flusher extends GridWorker {
+ /** {@inheritDoc */
+ protected Flusher(String gridName, String name, IgniteLogger log) {
+ super(gridName, name, log);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
+ while (!stopping.get() || writeCache.sizex() > 0) {
+ awaitOperationsAvailable();
+
+ flushCache(writeCache.entrySet().iterator());
+ }
+ }
+
+ /**
+ * This method awaits until enough elements in map are available or given timeout is over.
+ *
+ * @throws InterruptedException If awaiting was interrupted.
+ */
+ private void awaitOperationsAvailable() throws InterruptedException {
+ flushLock.lock();
+
+ try {
+ do {
+ if (writeCache.sizex() <= cacheMaxSize || cacheMaxSize == 0) {
+ if (cacheFlushFreq > 0)
+ canFlush.await(cacheFlushFreq, TimeUnit.MILLISECONDS);
+ else
+ canFlush.await();
+ }
+ }
+ while (writeCache.sizex() == 0 && !stopping.get());
+ }
+ finally {
+ flushLock.unlock();
+ }
+ }
+
+ /**
+ * Removes values from the write cache and performs corresponding operation
+ * on the underlying store.
+ *
+ * @param it Iterator for write cache.
+ */
+ private void flushCache(Iterator<Map.Entry<K,StatefulValue<K, V>>> it) {
+ StoreOperation operation = null;
+
+ Map<K, StatefulValue<K, V>> batch = null;
+ Map<K, StatefulValue<K, V>> pending = U.newLinkedHashMap(batchSize);
+
+ while (it.hasNext()) {
+ Map.Entry<K, StatefulValue<K, V>> e = it.next();
+
+ StatefulValue<K, V> val = e.getValue();
+
+ val.writeLock().lock();
+
+ try {
+ ValueStatus status = val.status();
+
+ if (acquired(status))
+ // Another thread is helping us, continue to the next entry.
+ continue;
+
+ if (status == ValueStatus.RETRY)
+ retryEntriesCnt.decrementAndGet();
+
+ assert retryEntriesCnt.get() >= 0;
+
+ val.status(ValueStatus.PENDING);
+
+ // We scan for the next operation and apply batch on operation change. Null means new batch.
+ if (operation == null)
+ operation = val.operation();
+
+ if (operation != val.operation()) {
+ // Operation is changed, so we need to perform a batch.
+ batch = pending;
+ pending = U.newLinkedHashMap(batchSize);
+
+ operation = val.operation();
+
+ pending.put(e.getKey(), val);
+ }
+ else
+ pending.put(e.getKey(), val);
+
+ if (pending.size() == batchSize) {
+ batch = pending;
+ pending = U.newLinkedHashMap(batchSize);
+
+ operation = null;
+ }
+ }
+ finally {
+ val.writeLock().unlock();
+ }
+
+ if (batch != null && !batch.isEmpty()) {
+ applyBatch(batch, true);
+ batch = null;
+ }
+ }
+
+ // Process the remainder.
+ if (!pending.isEmpty())
+ applyBatch(pending, true);
+ }
+ }
+
+ /**
+ * For test purposes only.
+ *
+ * @return Write cache for the underlying store operations.
+ */
+ Map<K, StatefulValue<K, V>> writeCache() {
+ return writeCache;
+ }
+
+ /**
+ * Enumeration that represents possible operations on the underlying store.
+ */
+ private enum StoreOperation {
+ /** Put key-value pair to the underlying store. */
+ PUT,
+
+ /** Remove key from the underlying store. */
+ RMV
+ }
+
+ /**
+ * Enumeration that represents possible states of value in the map.
+ */
+ private enum ValueStatus {
+ /** Value is scheduled for write or delete from the underlying cache but has not been captured by flusher. */
+ NEW,
+
+ /** Value is captured by flusher and store operation is performed at the moment. */
+ PENDING,
+
+ /** Store operation has failed and it will be re-tried at the next flush. */
+ RETRY,
+
+ /** Store operation succeeded and this value will be removed by flusher. */
+ FLUSHED,
+ }
+
+ /**
+ * Checks if given status indicates pending or complete flush operation.
+ *
+ * @param status Status to check.
+ * @return {@code true} if status indicates any pending or complete store update operation.
+ */
+ private boolean acquired(ValueStatus status) {
+ return status == ValueStatus.PENDING || status == ValueStatus.FLUSHED;
+ }
+
+ /**
+ * A state-value-operation trio.
+ *
+ * @param <V> Value type.
+ */
+ private static class StatefulValue<K, V> extends ReentrantReadWriteLock {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Value. */
+ @GridToStringInclude
+ private Entry<? extends K, ? extends V> val;
+
+ /** Store operation. */
+ private StoreOperation storeOperation;
+
+ /** Value status. */
+ private ValueStatus valStatus;
+
+ /** Condition to wait for flush event */
+ private Condition flushCond = writeLock().newCondition();
+
+ /**
+ * Creates a state-value pair with {@link ValueStatus#NEW} status.
+ *
+ * @param val Value.
+ * @param storeOperation Store operation.
+ */
+ private StatefulValue(Entry<? extends K, ? extends V> val, StoreOperation storeOperation) {
+ assert storeOperation == StoreOperation.PUT || storeOperation == StoreOperation.RMV;
+
+ this.val = val;
+ this.storeOperation = storeOperation;
+ valStatus = ValueStatus.NEW;
+ }
+
+ /**
+ * @return Stored value.
+ */
+ private Entry<? extends K, ? extends V> entry() {
+ return val;
+ }
+
+ /**
+ * @return Store operation.
+ */
+ private StoreOperation operation() {
+ return storeOperation;
+ }
+
+ /**
+ * @return Value status
+ */
+ private ValueStatus status() {
+ return valStatus;
+ }
+
+ /**
+ * Updates value status.
+ *
+ * @param valStatus Value status.
+ */
+ private void status(ValueStatus valStatus) {
+ this.valStatus = valStatus;
+ }
+
+ /**
+ * Updates both value and value status.
+ *
+ * @param val Value.
+ * @param storeOperation Store operation.
+ * @param valStatus Value status.
+ */
+ private void update(@Nullable Entry<? extends K, ? extends V> val,
+ StoreOperation storeOperation,
+ ValueStatus valStatus) {
+ this.val = val;
+ this.storeOperation = storeOperation;
+ this.valStatus = valStatus;
+ }
+
+ /**
+ * Awaits a signal on flush condition
+ *
+ * @throws IgniteInterruptedCheckedException If thread was interrupted.
+ */
+ private void waitForFlush() throws IgniteInterruptedCheckedException {
+ U.await(flushCond);
+ }
+
+ /**
+ * Signals flush condition.
+ */
+ @SuppressWarnings({"SignalWithoutCorrespondingAwait"})
+ private void signalFlushed() {
+ flushCond.signalAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof StatefulValue))
+ return false;
+
+ StatefulValue other = (StatefulValue)o;
+
+ return F.eq(val, other.val) && F.eq(valStatus, other.valStatus);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = val != null ? val.hashCode() : 0;
+
+ res = 31 * res + valStatus.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(StatefulValue.class, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index acd3202..1b66b4a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.near.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.transactions.*;
import org.apache.ignite.internal.util.*;
@@ -444,11 +445,11 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
*
* @return Store manager.
*/
- protected GridCacheStoreManager store() {
+ protected CacheStoreManager store() {
if (!activeCacheIds().isEmpty()) {
int cacheId = F.first(activeCacheIds());
- GridCacheStoreManager store = cctx.cacheContext(cacheId).store();
+ CacheStoreManager store = cctx.cacheContext(cacheId).store();
return store.configured() ? store : null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index f2407ce..10146a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.managers.communication.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.distributed.near.*;
import org.apache.ignite.internal.processors.cache.dr.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.processors.cache.version.*;
import org.apache.ignite.internal.processors.dr.*;
import org.apache.ignite.internal.transactions.*;
@@ -370,7 +371,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
return new GridFinishedFuture<>(
- cacheCtx.store().loadAllFromStore(this, keys, c));
+ cacheCtx.store().loadAll(this, keys, c));
}
catch (IgniteCheckedException e) {
return new GridFinishedFuture<>(e);
@@ -387,7 +388,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
return false;
}
- return cacheCtx.store().loadAllFromStore(IgniteTxLocalAdapter.this, keys, c);
+ return cacheCtx.store().loadAll(IgniteTxLocalAdapter.this, keys, c);
}
},
true);
@@ -492,17 +493,17 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
*/
@SuppressWarnings({"CatchGenericClass"})
protected void batchStoreCommit(Iterable<IgniteTxEntry> writeEntries) throws IgniteCheckedException {
- GridCacheStoreManager store = store();
+ CacheStoreManager store = store();
- if (store != null && store.writeThrough() && storeEnabled() &&
- (!internal() || groupLock()) && (near() || store.writeToStoreFromDht())) {
+ if (store != null && store.isWriteThrough() && storeEnabled() &&
+ (!internal() || groupLock()) && (near() || store.isWriteToStoreFromDht())) {
try {
if (writeEntries != null) {
Map<Object, IgniteBiTuple<Object, GridCacheVersion>> putMap = null;
List<Object> rmvCol = null;
- GridCacheStoreManager writeStore = null;
+ CacheStoreManager writeStore = null;
- boolean skipNear = near() && store.writeToStoreFromDht();
+ boolean skipNear = near() && store.isWriteToStoreFromDht();
for (IgniteTxEntry e : writeEntries) {
if (skipNear && e.cached().isNear())
@@ -527,7 +528,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (rmvCol != null && !rmvCol.isEmpty()) {
assert writeStore != null;
- writeStore.removeAllFromStore(this, rmvCol);
+ writeStore.removeAll(this, rmvCol);
// Reset.
rmvCol.clear();
@@ -537,7 +538,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// Batch-process puts if cache ID has changed.
if (writeStore != null && writeStore != cacheCtx.store() && putMap != null && !putMap.isEmpty()) {
- writeStore.putAllToStore(this, putMap);
+ writeStore.putAll(this, putMap);
// Reset.
putMap.clear();
@@ -568,7 +569,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (putMap != null && !putMap.isEmpty()) {
assert writeStore != null;
- writeStore.putAllToStore(this, putMap);
+ writeStore.putAll(this, putMap);
// Reset.
putMap.clear();
@@ -577,7 +578,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
if (writeStore != null && writeStore != cacheCtx.store() && rmvCol != null && !rmvCol.isEmpty()) {
- writeStore.removeAllFromStore(this, rmvCol);
+ writeStore.removeAll(this, rmvCol);
// Reset.
rmvCol.clear();
@@ -609,7 +610,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
assert writeStore != null;
// Batch put at the end of transaction.
- writeStore.putAllToStore(this, putMap);
+ writeStore.putAll(this, putMap);
}
if (rmvCol != null && !rmvCol.isEmpty()) {
@@ -617,12 +618,12 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
assert writeStore != null;
// Batch remove at the end of transaction.
- writeStore.removeAllFromStore(this, rmvCol);
+ writeStore.removeAll(this, rmvCol);
}
}
// Commit while locks are held.
- store.txEnd(this, true);
+ store.sessionEnd(this, true);
}
catch (IgniteCheckedException ex) {
commitError(ex);
@@ -981,11 +982,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
}
}
else {
- GridCacheStoreManager store = store();
+ CacheStoreManager store = store();
if (store != null && (!internal() || groupLock())) {
try {
- store.txEnd(this, true);
+ store.sessionEnd(this, true);
}
catch (IgniteCheckedException e) {
commitError(e);
@@ -1086,11 +1087,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
cctx.tm().rollbackTx(this);
- GridCacheStoreManager store = store();
+ CacheStoreManager store = store();
- if (store != null && (near() || store.writeToStoreFromDht())) {
+ if (store != null && (near() || store.isWriteToStoreFromDht())) {
if (!internal() || groupLock())
- store.txEnd(this, false);
+ store.sessionEnd(this, false);
}
}
catch (Error | IgniteCheckedException | RuntimeException e) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
index 42586d2..6a8117f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessor.java
@@ -156,10 +156,4 @@ public interface IgniteCacheObjectProcessor extends GridProcessor {
* with {@link IgniteImmutable} annotation.
*/
public boolean immutable(Object obj);
-
- /**
- * @param cacheName Cache name.
- * @return {@code True} if portable format should be preserved when passing values to cache store.
- */
- public boolean keepPortableInStore(@Nullable String cacheName);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index f65b7bd..6e46757 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -234,11 +234,6 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
}
/** {@inheritDoc} */
- @Override public boolean keepPortableInStore(@Nullable String cacheName) {
- return false;
- }
-
- /** {@inheritDoc} */
@Override public void onCacheProcessorStarted() {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
index 69ca1ae..580ff49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
@@ -22,6 +22,7 @@ import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.dr.*;
+import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.plugin.*;
import java.util.*;
@@ -76,10 +77,13 @@ public class CachePluginManager extends GridCacheManagerAdapter {
/**
* Creates optional component.
*
+ * @param ctx Kernal context.
+ * @param cfg Cache configuration.
* @param cls Component class.
* @return Created component.
*/
- public <T> T createComponent(Class<T> cls) {
+ @SuppressWarnings("unchecked")
+ public <T> T createComponent(GridKernalContext ctx, CacheConfiguration cfg, Class<T> cls) {
for (CachePluginProvider provider : providers) {
T res = (T)provider.createComponent(cls);
@@ -91,6 +95,8 @@ public class CachePluginManager extends GridCacheManagerAdapter {
return (T)new GridOsCacheDrManager();
else if (cls.equals(CacheConflictResolutionManager.class))
return (T)new CacheOsConflictResolutionManager<>();
+ else if (cls.equals(CacheStoreManager.class))
+ return (T)new CacheOsStoreManager(ctx, cfg);
throw new IgniteException("Unsupported component type: " + cls);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 55c1f9d..d7213a4 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -389,10 +389,10 @@ org.apache.ignite.internal.processors.cache.GridCacheProcessor$LocalAffinityFunc
org.apache.ignite.internal.processors.cache.GridCacheProjectionImpl
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl
org.apache.ignite.internal.processors.cache.GridCacheReturn
-org.apache.ignite.internal.processors.cache.GridCacheStoreManager$1
-org.apache.ignite.internal.processors.cache.GridCacheStoreManager$2
-org.apache.ignite.internal.processors.cache.GridCacheStoreManager$3
-org.apache.ignite.internal.processors.cache.GridCacheStoreManager$4
+org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$1
+org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$2
+org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3
+org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$4
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$10
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$12
org.apache.ignite.internal.processors.cache.GridCacheSwapManager$14
@@ -433,9 +433,9 @@ org.apache.ignite.internal.processors.cache.GridCacheUtils$8
org.apache.ignite.internal.processors.cache.GridCacheUtils$9
org.apache.ignite.internal.processors.cache.GridCacheValueCollection
org.apache.ignite.internal.processors.cache.GridCacheValueCollection$1
-org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$StatefulValue
-org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$StoreOperation
-org.apache.ignite.internal.processors.cache.GridCacheWriteBehindStore$ValueStatus
+org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StatefulValue
+org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StoreOperation
+org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$ValueStatus
org.apache.ignite.internal.processors.cache.IgniteCacheProxy
org.apache.ignite.internal.processors.cache.IgniteCacheProxy$1
org.apache.ignite.internal.processors.cache.IgniteCacheProxy$2
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java
index b9f9602..c4ba385 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePartitionedWritesTest.java
@@ -26,14 +26,13 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.testframework.junits.common.*;
import org.apache.ignite.transactions.*;
-import javax.cache.configuration.*;
import java.util.concurrent.atomic.*;
import static org.apache.ignite.cache.CacheAtomicityMode.*;
/**
* Test that in {@link CacheMode#PARTITIONED} mode cache writes values only to the near cache store. <p/> This check
- * is needed because in current implementation if {@link GridCacheWriteBehindStore} assumes that and user store is
+ * is needed because in current implementation if {@link org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore} assumes that and user store is
* wrapped only in near cache (see {@link GridCacheProcessor} init logic).
*/
@SuppressWarnings({"unchecked"})
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
deleted file mode 100644
index 883a216..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * Harness for {@link GridCacheWriteBehindStore} tests.
- */
-public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridCommonAbstractTest {
- /** Write cache size. */
- public static final int CACHE_SIZE = 1024;
-
- /** Value dump interval. */
- public static final int FLUSH_FREQUENCY = 1000;
-
- /** Underlying store. */
- protected GridCacheTestStore delegate = new GridCacheTestStore();
-
- /** Tested store. */
- protected GridCacheWriteBehindStore<Integer, String> store;
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- delegate = null;
- store = null;
-
- super.afterTestsStopped();
- }
-
- /**
- * Initializes store.
- *
- * @param flushThreadCnt Count of flush threads
- * @throws Exception If failed.
- */
- protected void initStore(int flushThreadCnt) throws Exception {
- store = new GridCacheWriteBehindStore<>(null, "", "", log, delegate);
-
- store.setFlushFrequency(FLUSH_FREQUENCY);
-
- store.setFlushSize(CACHE_SIZE);
-
- store.setFlushThreadCount(flushThreadCnt);
-
- delegate.reset();
-
- store.start();
- }
-
- /**
- * Shutdowns store.
- *
- * @throws Exception If failed.
- */
- protected void shutdownStore() throws Exception {
- store.stop();
-
- assertTrue("Store cache must be empty after shutdown", store.writeCache().isEmpty());
- }
-
- /**
- * Performs multiple put, get and remove operations in several threads on a store. After
- * all threads finished their operations, returns the total set of keys that should be
- * in underlying store.
- *
- * @param threadCnt Count of threads that should update keys.
- * @param keysPerThread Count of unique keys assigned to a thread.
- * @return Set of keys that was totally put in store.
- * @throws Exception If failed.
- */
- protected Set<Integer> runPutGetRemoveMultithreaded(int threadCnt, final int keysPerThread) throws Exception {
- final ConcurrentMap<String, Set<Integer>> perThread = new ConcurrentHashMap<>();
-
- final AtomicBoolean running = new AtomicBoolean(true);
-
- final AtomicInteger cntr = new AtomicInteger();
-
- final AtomicInteger operations = new AtomicInteger();
-
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @SuppressWarnings({"NullableProblems"})
- @Override public void run() {
- // Initialize key set for this thread.
- Set<Integer> set = new HashSet<>();
-
- Set<Integer> old = perThread.putIfAbsent(Thread.currentThread().getName(), set);
-
- if (old != null)
- set = old;
-
- List<Integer> original = new ArrayList<>();
-
- Random rnd = new Random();
-
- for (int i = 0; i < keysPerThread; i++)
- original.add(cntr.getAndIncrement());
-
- try {
- while (running.get()) {
- int op = rnd.nextInt(3);
- int idx = rnd.nextInt(keysPerThread);
-
- int key = original.get(idx);
-
- switch (op) {
- case 0:
- store.write(new CacheEntryImpl<>(key, "val" + key));
- set.add(key);
-
- operations.incrementAndGet();
-
- break;
-
- case 1:
- store.delete(key);
- set.remove(key);
-
- operations.incrementAndGet();
-
- break;
-
- case 2:
- default:
- store.write(new CacheEntryImpl<>(key, "broken"));
-
- String val = store.load(key);
-
- assertEquals("Invalid intermediate value: " + val, "broken", val);
-
- store.write(new CacheEntryImpl<>(key, "val" + key));
-
- set.add(key);
-
- // 2 put operations performed here.
- operations.incrementAndGet();
- operations.incrementAndGet();
- operations.incrementAndGet();
-
- break;
- }
- }
- }
- catch (Exception e) {
- error("Unexpected exception in put thread", e);
-
- assert false;
- }
- }
- }, threadCnt, "put");
-
- U.sleep(10000);
-
- running.set(false);
-
- fut.get();
-
- log().info(">>> " + operations + " operations performed totally");
-
- Set<Integer> total = new HashSet<>();
-
- for (Set<Integer> threadVals : perThread.values()) {
- total.addAll(threadVals);
- }
-
- return total;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java
deleted file mode 100644
index 305b8bb..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * 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.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-import org.apache.ignite.transactions.*;
-import org.jetbrains.annotations.*;
-
-import javax.cache.configuration.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.transactions.TransactionConcurrency.*;
-import static org.apache.ignite.transactions.TransactionIsolation.*;
-
-/**
- * Basic store test.
- */
-public abstract class GridCacheWriteBehindStoreAbstractTest extends GridCommonAbstractTest {
- /** Flush frequency. */
- private static final int WRITE_FROM_BEHIND_FLUSH_FREQUENCY = 1000;
-
- /** Cache store. */
- private static final GridCacheTestStore store = new GridCacheTestStore();
-
- /**
- *
- */
- protected GridCacheWriteBehindStoreAbstractTest() {
- super(true /*start grid. */);
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- store.resetTimestamp();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- IgniteCache<?, ?> cache = jcache();
-
- if (cache != null)
- cache.clear();
-
- store.reset();
- }
-
- /** @return Caching mode. */
- protected abstract CacheMode cacheMode();
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override protected final IgniteConfiguration getConfiguration() throws Exception {
- IgniteConfiguration c = super.getConfiguration();
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- c.setDiscoverySpi(disco);
-
- CacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setCacheMode(cacheMode());
- cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- cc.setSwapEnabled(false);
- cc.setAtomicityMode(TRANSACTIONAL);
-
- cc.setCacheStoreFactory(singletonFactory(store));
- cc.setReadThrough(true);
- cc.setWriteThrough(true);
- cc.setLoadPreviousValue(true);
-
- cc.setWriteBehindEnabled(true);
- cc.setWriteBehindFlushFrequency(WRITE_FROM_BEHIND_FLUSH_FREQUENCY);
-
- c.setCacheConfiguration(cc);
-
- return c;
- }
-
- /** @throws Exception If test fails. */
- public void testWriteThrough() throws Exception {
- IgniteCache<Integer, String> cache = jcache();
-
- Map<Integer, String> map = store.getMap();
-
- assert map.isEmpty();
-
- Transaction tx = grid().transactions().txStart(OPTIMISTIC, REPEATABLE_READ);
-
- try {
- for (int i = 1; i <= 10; i++) {
- cache.put(i, Integer.toString(i));
-
- checkLastMethod(null);
- }
-
- tx.commit();
- }
- finally {
- tx.close();
- }
-
- // Need to wait WFB flush timeout.
- U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
-
- checkLastMethod("putAll");
-
- assert cache.size() == 10;
-
- for (int i = 1; i <= 10; i++) {
- String val = map.get(i);
-
- assert val != null;
- assert val.equals(Integer.toString(i));
- }
-
- store.resetLastMethod();
-
- tx = grid().transactions().txStart();
-
- try {
- for (int i = 1; i <= 10; i++) {
- String val = cache.getAndRemove(i);
-
- checkLastMethod(null);
-
- assert val != null;
- assert val.equals(Integer.toString(i));
- }
-
- tx.commit();
- }
- finally {
- tx.close();
- }
-
- // Need to wait WFB flush timeout.
- U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
-
- checkLastMethod("removeAll");
-
- assert map.isEmpty();
- }
-
- /** @throws Exception If test failed. */
- public void testReadThrough() throws Exception {
- IgniteCache<Integer, String> cache = jcache();
-
- Map<Integer, String> map = store.getMap();
-
- assert map.isEmpty();
-
- try (Transaction tx = grid().transactions().txStart(OPTIMISTIC, REPEATABLE_READ)) {
- for (int i = 1; i <= 10; i++)
- cache.put(i, Integer.toString(i));
-
- checkLastMethod(null);
-
- tx.commit();
- }
-
- // Need to wait WFB flush timeout.
- U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
-
- checkLastMethod("putAll");
-
- for (int i = 1; i <= 10; i++) {
- String val = map.get(i);
-
- assert val != null;
- assert val.equals(Integer.toString(i));
- }
-
- cache.clear();
-
- assert cache.localSize() == 0;
- assert cache.localSize() == 0;
-
- // Need to wait WFB flush timeout.
- U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
-
- assert map.size() == 10;
-
- for (int i = 1; i <= 10; i++) {
- // Read through.
- String val = cache.get(i);
-
- checkLastMethod("load");
-
- assert val != null;
- assert val.equals(Integer.toString(i));
- }
-
- assert cache.size() == 10;
-
- cache.clear();
-
- assert cache.localSize() == 0;
- assert cache.localSize() == 0;
-
- assert map.size() == 10;
-
- Set<Integer> keys = new HashSet<>();
-
- for (int i = 1; i <= 10; i++)
- keys.add(i);
-
- // Read through.
- Map<Integer, String> vals = cache.getAll(keys);
-
- checkLastMethod("loadAll");
-
- assert vals != null;
- assert vals.size() == 10;
-
- for (int i = 1; i <= 10; i++) {
- String val = vals.get(i);
-
- assert val != null;
- assert val.equals(Integer.toString(i));
- }
-
- // Write through.
- cache.removeAll(keys);
-
- // Need to wait WFB flush timeout.
- U.sleep(WRITE_FROM_BEHIND_FLUSH_FREQUENCY + 100);
-
- checkLastMethod("removeAll");
-
- assert cache.localSize() == 0;
- assert cache.localSize() == 0;
-
- assert map.isEmpty();
- }
-
- /** @throws Exception If failed. */
- public void testMultithreaded() throws Exception {
- final ConcurrentMap<String, Set<Integer>> perThread = new ConcurrentHashMap<>();
-
- final AtomicBoolean running = new AtomicBoolean(true);
-
- final IgniteCache<Integer, String> cache = jcache();
-
- IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
- @SuppressWarnings({"NullableProblems"})
- @Override public void run() {
- // Initialize key set for this thread.
- Set<Integer> set = new HashSet<>();
-
- Set<Integer> old = perThread.putIfAbsent(Thread.currentThread().getName(), set);
-
- if (old != null)
- set = old;
-
- Random rnd = new Random();
-
- int keyCnt = 20000;
-
- while (running.get()) {
- int op = rnd.nextInt(2);
- int key = rnd.nextInt(keyCnt);
-
- switch (op) {
- case 0:
- cache.put(key, "val" + key);
- set.add(key);
-
- break;
-
- case 1:
- default:
- cache.remove(key);
- set.remove(key);
-
- break;
- }
- }
- }
- }, 10, "put");
-
- U.sleep(10000);
-
- running.set(false);
-
- fut.get();
-
- U.sleep(5 * WRITE_FROM_BEHIND_FLUSH_FREQUENCY);
-
- Map<Integer, String> stored = store.getMap();
-
- for (Map.Entry<Integer, String> entry : stored.entrySet()) {
- int key = entry.getKey();
-
- assertEquals("Invalid value for key " + key, "val" + key, entry.getValue());
-
- boolean found = false;
-
- for (Set<Integer> threadPuts : perThread.values()) {
- if (threadPuts.contains(key)) {
- found = true;
-
- break;
- }
- }
-
- assert found : "No threads found that put key " + key;
- }
- }
-
- /** @param mtd Expected last method value. */
- private void checkLastMethod(@Nullable String mtd) {
- String lastMtd = store.getLastMethod();
-
- if (mtd == null)
- assert lastMtd == null : "Last method must be null: " + lastMtd;
- else {
- assert lastMtd != null : "Last method must be not null";
- assert lastMtd.equals(mtd) : "Last method does not match [expected=" + mtd + ", lastMtd=" + lastMtd + ']';
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreLocalTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreLocalTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreLocalTest.java
deleted file mode 100644
index 6c050ca..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreLocalTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.cache.*;
-
-/**
- * Tests {@link GridCacheWriteBehindStore} in grid configuration.
- */
-public class GridCacheWriteBehindStoreLocalTest extends GridCacheWriteBehindStoreAbstractTest {
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return CacheMode.LOCAL;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreMultithreadedSelfTest.java
deleted file mode 100644
index 9607784..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreMultithreadedSelfTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * 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.internal.util.typedef.internal.*;
-
-import java.util.*;
-
-/**
- * Multithreaded tests for {@link GridCacheWriteBehindStore}.
- */
-public class GridCacheWriteBehindStoreMultithreadedSelfTest extends GridCacheWriteBehindStoreAbstractSelfTest {
- /**
- * This test performs complex set of operations on store from multiple threads.
- *
- * @throws Exception If failed.
- */
- public void testPutGetRemove() throws Exception {
- initStore(2);
-
- Set<Integer> exp;
-
- try {
- exp = runPutGetRemoveMultithreaded(10, 10);
- }
- finally {
- shutdownStore();
- }
-
- Map<Integer, String> map = delegate.getMap();
-
- Collection<Integer> extra = new HashSet<>(map.keySet());
-
- extra.removeAll(exp);
-
- assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
-
- Collection<Integer> missing = new HashSet<>(exp);
-
- missing.removeAll(map.keySet());
-
- assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
-
- for (Integer key : exp)
- assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
- }
-
- /**
- * Tests that cache would keep values if underlying store fails.
- *
- * @throws Exception If failed.
- */
- public void testStoreFailure() throws Exception {
- delegate.setShouldFail(true);
-
- initStore(2);
-
- Set<Integer> exp;
-
- try {
- exp = runPutGetRemoveMultithreaded(10, 10);
-
- U.sleep(FLUSH_FREQUENCY);
-
- info(">>> There are " + store.getWriteBehindErrorRetryCount() + " entries in RETRY state");
-
- delegate.setShouldFail(false);
-
- // Despite that we set shouldFail flag to false, flush thread may just have caught an exception.
- // If we move store to the stopping state right away, this value will be lost. That's why this sleep
- // is inserted here to let all exception handlers in write-behind store exit.
- U.sleep(1000);
- }
- finally {
- shutdownStore();
- }
-
- Map<Integer, String> map = delegate.getMap();
-
- Collection<Integer> extra = new HashSet<>(map.keySet());
-
- extra.removeAll(exp);
-
- assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
-
- Collection<Integer> missing = new HashSet<>(exp);
-
- missing.removeAll(map.keySet());
-
- assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
-
- for (Integer key : exp)
- assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
- }
-
- /**
- * Tests store consistency in case of high put rate, when flush is performed from the same thread
- * as put or remove operation.
- *
- * @throws Exception If failed.
- */
- public void testFlushFromTheSameThread() throws Exception {
- // 50 milliseconds should be enough.
- delegate.setOperationDelay(50);
-
- initStore(2);
-
- Set<Integer> exp;
-
- int start = store.getWriteBehindTotalCriticalOverflowCount();
-
- try {
- //We will have in total 5 * CACHE_SIZE keys that should be enough to grow map size to critical value.
- exp = runPutGetRemoveMultithreaded(5, CACHE_SIZE);
- }
- finally {
- log.info(">>> Done inserting, shutting down the store");
-
- shutdownStore();
- }
-
- // Restore delay.
- delegate.setOperationDelay(0);
-
- Map<Integer, String> map = delegate.getMap();
-
- int end = store.getWriteBehindTotalCriticalOverflowCount();
-
- log.info(">>> There are " + exp.size() + " keys in store, " + (end - start) + " overflows detected");
-
- assertTrue("No cache overflows detected (a bug or too few keys or too few delay?)", end > start);
-
- Collection<Integer> extra = new HashSet<>(map.keySet());
-
- extra.removeAll(exp);
-
- assertTrue("The underlying store contains extra keys: " + extra, extra.isEmpty());
-
- Collection<Integer> missing = new HashSet<>(exp);
-
- missing.removeAll(map.keySet());
-
- assertTrue("Missing keys in the underlying store: " + missing, missing.isEmpty());
-
- for (Integer key : exp)
- assertEquals("Invalid value for key " + key, "val" + key, map.get(key));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
deleted file mode 100644
index 8fb4f68..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-import org.apache.ignite.transactions.*;
-
-import java.util.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.transactions.TransactionConcurrency.*;
-import static org.apache.ignite.transactions.TransactionIsolation.*;
-
-/**
- * Tests write-behind store with near and dht commit option.
- */
-public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridCommonAbstractTest {
- /** Grids to start. */
- private static final int GRID_CNT = 5;
-
- /** Ip finder. */
- private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** Flush frequency. */
- public static final int WRITE_BEHIND_FLUSH_FREQ = 1000;
-
- /** Stores per grid. */
- private GridCacheTestStore[] stores = new GridCacheTestStore[GRID_CNT];
-
- /** Start grid counter. */
- private int idx;
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration c = super.getConfiguration(gridName);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(ipFinder);
-
- c.setDiscoverySpi(disco);
-
- CacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setCacheMode(CacheMode.PARTITIONED);
- cc.setWriteBehindEnabled(true);
- cc.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQ);
- cc.setAtomicityMode(TRANSACTIONAL);
- cc.setNearConfiguration(new NearCacheConfiguration());
-
- CacheStore store = stores[idx] = new GridCacheTestStore();
-
- cc.setCacheStoreFactory(singletonFactory(store));
- cc.setReadThrough(true);
- cc.setWriteThrough(true);
- cc.setLoadPreviousValue(true);
-
- c.setCacheConfiguration(cc);
-
- idx++;
-
- return c;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stores = null;
-
- super.afterTestsStopped();
- }
-
- /**
- * @throws Exception If failed.
- */
- private void prepare() throws Exception {
- idx = 0;
-
- startGrids(GRID_CNT);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSingleWritesOnDhtNode() throws Exception {
- checkSingleWrites();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBatchWritesOnDhtNode() throws Exception {
- checkBatchWrites();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTxWritesOnDhtNode() throws Exception {
- checkTxWrites();
- }
-
- /**
- * @throws Exception If failed.
- */
- private void checkSingleWrites() throws Exception {
- prepare();
-
- IgniteCache<Integer, String> cache = grid(0).cache(null);
-
- for (int i = 0; i < 100; i++)
- cache.put(i, String.valueOf(i));
-
- checkWrites();
- }
-
- /**
- * @throws Exception If failed.
- */
- private void checkBatchWrites() throws Exception {
- prepare();
-
- Map<Integer, String> map = new HashMap<>();
-
- for (int i = 0; i < 100; i++)
- map.put(i, String.valueOf(i));
-
- grid(0).cache(null).putAll(map);
-
- checkWrites();
- }
-
- /**
- * @throws Exception If failed.
- */
- private void checkTxWrites() throws Exception {
- prepare();
-
- IgniteCache<Object, Object> cache = grid(0).cache(null);
-
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- for (int i = 0; i < 100; i++)
- cache.put(i, String.valueOf(i));
-
- tx.commit();
- }
-
- checkWrites();
- }
-
- /**
- * @throws IgniteInterruptedCheckedException If sleep was interrupted.
- */
- private void checkWrites() throws IgniteInterruptedCheckedException {
- U.sleep(WRITE_BEHIND_FLUSH_FREQ * 2);
-
- Collection<Integer> allKeys = new ArrayList<>(100);
-
- for (int i = 0; i < GRID_CNT; i++) {
- Map<Integer,String> map = stores[i].getMap();
-
- assertFalse("Missing writes for node: " + i, map.isEmpty());
-
- allKeys.addAll(map.keySet());
-
- // Check there is no intersection.
- for (int j = 0; j < GRID_CNT; j++) {
- if (i == j)
- continue;
-
- Collection<Integer> intersection = new HashSet<>(stores[j].getMap().keySet());
-
- intersection.retainAll(map.keySet());
-
- assertTrue(intersection.isEmpty());
- }
- }
-
- assertEquals(100, allKeys.size());
-
- for (int i = 0; i < 100; i++)
- assertTrue(allKeys.contains(i));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
deleted file mode 100644
index f9e454f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.cache.*;
-
-/**
- * Tests {@link GridCacheWriteBehindStore} in partitioned configuration.
- */
-public class GridCacheWriteBehindStorePartitionedTest extends GridCacheWriteBehindStoreAbstractTest {
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return CacheMode.PARTITIONED;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
deleted file mode 100644
index c809f90..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStoreReplicatedTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.cache.*;
-
-/**
- * Tests {@link GridCacheWriteBehindStore} in grid configuration.
- */
-public class GridCacheWriteBehindStoreReplicatedTest extends GridCacheWriteBehindStoreAbstractTest {
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return CacheMode.REPLICATED;
- }
-}
[25/30] incubator-ignite git commit: # GG-9973: Fixed.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
deleted file mode 100644
index c26c34e..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
+++ /dev/null
@@ -1,1015 +0,0 @@
-/*
- * 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.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.internal.util.worker.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.lifecycle.*;
-import org.apache.ignite.thread.*;
-import org.jetbrains.annotations.*;
-import org.jsr166.*;
-
-import javax.cache.integration.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-import java.util.concurrent.locks.*;
-
-import static javax.cache.Cache.*;
-
-/**
- * Internal wrapper for a {@link CacheStore} that enables write-behind logic.
- * <p/>
- * The general purpose of this approach is to reduce cache store load under high
- * store update rate. The idea is to cache all write and remove operations in a pending
- * map and delegate these changes to the underlying store either after timeout or
- * if size of a pending map exceeded some pre-configured value. Another performance gain
- * is achieved due to combining a group of similar operations to a single batch update.
- * <p/>
- * The essential flush size for the write-behind cache should be at least the estimated
- * count of simultaneously written keys. In case of significantly smaller value there would
- * be triggered a lot of flush events that will result in a high cache store load.
- * <p/>
- * Since write operations to the cache store are deferred, transaction support is lost; no
- * transaction objects are passed to the underlying store.
- */
-public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, LifecycleAware {
- /** Default write cache initial capacity. */
- public static final int DFLT_INITIAL_CAPACITY = 1024;
-
- /** Overflow ratio for critical cache size calculation. */
- public static final float CACHE_OVERFLOW_RATIO = 1.5f;
-
- /** Default concurrency level of write cache. */
- public static final int DFLT_CONCUR_LVL = 64;
-
- /** Write cache initial capacity. */
- private int initCap = DFLT_INITIAL_CAPACITY;
-
- /** Concurrency level for write cache access. */
- private int concurLvl = DFLT_CONCUR_LVL;
-
- /** When cache size exceeds this value eldest entry will be stored to the underlying store. */
- private int cacheMaxSize = CacheConfiguration.DFLT_WRITE_BEHIND_FLUSH_SIZE;
-
- /** Critical cache size. If cache size exceeds this value, data flush performed synchronously. */
- private int cacheCriticalSize;
-
- /** Count of worker threads performing underlying store updates. */
- private int flushThreadCnt = CacheConfiguration.DFLT_WRITE_FROM_BEHIND_FLUSH_THREAD_CNT;
-
- /** Cache flush frequency. All pending operations will be performed in not less then this value ms. */
- private long cacheFlushFreq = CacheConfiguration.DFLT_WRITE_BEHIND_FLUSH_FREQUENCY;
-
- /** Maximum batch size for put and remove operations */
- private int batchSize = CacheConfiguration.DFLT_WRITE_BEHIND_BATCH_SIZE;
-
- /** Grid name. */
- private String gridName;
-
- /** Cache name. */
- private String cacheName;
-
- /** Underlying store. */
- private CacheStore<K, V> store;
-
- /** Write cache. */
- private ConcurrentLinkedHashMap<K, StatefulValue<K, V>> writeCache;
-
- /** Flusher threads. */
- private GridWorker[] flushThreads;
-
- /** Atomic flag indicating store shutdown. */
- private AtomicBoolean stopping = new AtomicBoolean(true);
-
- /** Flush lock. */
- private Lock flushLock = new ReentrantLock();
-
- /** Condition to determine records available for flush. */
- private Condition canFlush = flushLock.newCondition();
-
- /** Variable for counting total cache overflows. */
- private AtomicInteger cacheTotalOverflowCntr = new AtomicInteger();
-
- /** Variable contains current number of overflow events. */
- private AtomicInteger cacheOverflowCntr = new AtomicInteger();
-
- /** Variable for counting key-value pairs that are in {@link ValueStatus#RETRY} state. */
- private AtomicInteger retryEntriesCnt = new AtomicInteger();
-
- /** Log. */
- private IgniteLogger log;
-
- /** Store manager. */
- private GridCacheStoreManager storeMgr;
-
- /**
- * Creates a write-behind cache store for the given store.
- *
- * @param storeMgr Store manager.
- * @param gridName Grid name.
- * @param cacheName Cache name.
- * @param log Grid logger.
- * @param store {@code GridCacheStore} that need to be wrapped.
- */
- public GridCacheWriteBehindStore(
- GridCacheStoreManager storeMgr,
- String gridName,
- String cacheName,
- IgniteLogger log,
- CacheStore<K, V> store) {
- this.storeMgr = storeMgr;
- this.gridName = gridName;
- this.cacheName = cacheName;
- this.log = log;
- this.store = store;
- }
-
- /**
- * Sets initial capacity for the write cache.
- *
- * @param initCap Initial capacity.
- */
- public void setInitialCapacity(int initCap) {
- this.initCap = initCap;
- }
-
- /**
- * Sets concurrency level for the write cache. Concurrency level is expected count of concurrent threads
- * attempting to update cache.
- *
- * @param concurLvl Concurrency level.
- */
- public void setConcurrencyLevel(int concurLvl) {
- this.concurLvl = concurLvl;
- }
-
- /**
- * Sets the maximum size of the write cache. When the count of unique keys in write cache exceeds this value,
- * the eldest entry in the cache is immediately scheduled for write to the underlying store.
- *
- * @param cacheMaxSize Max cache size.
- */
- public void setFlushSize(int cacheMaxSize) {
- this.cacheMaxSize = cacheMaxSize;
- }
-
- /**
- * Gets the maximum size of the write-behind buffer. When the count of unique keys
- * in write buffer exceeds this value, the buffer is scheduled for write to the underlying store.
- * <p/>
- * If this value is {@code 0}, then flush is performed only on time-elapsing basis. However,
- * when this value is {@code 0}, the cache critical size is set to
- * {@link CacheConfiguration#DFLT_WRITE_BEHIND_CRITICAL_SIZE}
- *
- * @return Buffer size that triggers flush procedure.
- */
- public int getWriteBehindFlushSize() {
- return cacheMaxSize;
- }
-
- /**
- * Sets the number of threads that will perform store update operations.
- *
- * @param flushThreadCnt Count of worker threads.
- */
- public void setFlushThreadCount(int flushThreadCnt) {
- this.flushThreadCnt = flushThreadCnt;
- }
-
- /**
- * Gets the number of flush threads that will perform store update operations.
- *
- * @return Count of worker threads.
- */
- public int getWriteBehindFlushThreadCount() {
- return flushThreadCnt;
- }
-
- /**
- * Sets the cache flush frequency. All pending operations on the underlying store will be performed
- * within time interval not less then this value.
- *
- * @param cacheFlushFreq Time interval value in milliseconds.
- */
- public void setFlushFrequency(long cacheFlushFreq) {
- this.cacheFlushFreq = cacheFlushFreq;
- }
-
- /**
- * Gets the cache flush frequency. All pending operations on the underlying store will be performed
- * within time interval not less then this value.
- * <p/>
- * If this value is {@code 0}, then flush is performed only when buffer size exceeds flush size.
- *
- * @return Flush frequency in milliseconds.
- */
- public long getWriteBehindFlushFrequency() {
- return cacheFlushFreq;
- }
-
- /**
- * Sets the maximum count of similar operations that can be grouped to a single batch.
- *
- * @param batchSize Maximum count of batch.
- */
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- /**
- * Gets the maximum count of similar (put or remove) operations that can be grouped to a single batch.
- *
- * @return Maximum size of batch.
- */
- public int getWriteBehindStoreBatchSize() {
- return batchSize;
- }
-
- /**
- * Gets count of entries that were processed by the write-behind store and have not been
- * flushed to the underlying store yet.
- *
- * @return Total count of entries in cache store internal buffer.
- */
- public int getWriteBehindBufferSize() {
- return writeCache.sizex();
- }
-
- /**
- * @return Underlying store.
- */
- public CacheStore<K, V> store() {
- return store;
- }
-
- /**
- * Performs all the initialization logic for write-behind cache store.
- * This class must not be used until this method returns.
- */
- @Override public void start() {
- assert cacheFlushFreq != 0 || cacheMaxSize != 0;
-
- if (stopping.compareAndSet(true, false)) {
- if (log.isDebugEnabled())
- log.debug("Starting write-behind store for cache '" + cacheName + '\'');
-
- cacheCriticalSize = (int)(cacheMaxSize * CACHE_OVERFLOW_RATIO);
-
- if (cacheCriticalSize == 0)
- cacheCriticalSize = CacheConfiguration.DFLT_WRITE_BEHIND_CRITICAL_SIZE;
-
- flushThreads = new GridWorker[flushThreadCnt];
-
- writeCache = new ConcurrentLinkedHashMap<>(initCap, 0.75f, concurLvl);
-
- for (int i = 0; i < flushThreads.length; i++) {
- flushThreads[i] = new Flusher(gridName, "flusher-" + i, log);
-
- new IgniteThread(flushThreads[i]).start();
- }
- }
- }
-
- /**
- * Gets count of write buffer overflow events since initialization. Each overflow event causes
- * the ongoing flush operation to be performed synchronously.
- *
- * @return Count of cache overflow events since start.
- */
- public int getWriteBehindTotalCriticalOverflowCount() {
- return cacheTotalOverflowCntr.get();
- }
-
- /**
- * Gets count of write buffer overflow events in progress at the moment. Each overflow event causes
- * the ongoing flush operation to be performed synchronously.
- *
- * @return Count of cache overflow events since start.
- */
- public int getWriteBehindCriticalOverflowCount() {
- return cacheOverflowCntr.get();
- }
-
- /**
- * Gets count of cache entries that are in a store-retry state. An entry is assigned a store-retry state
- * when underlying store failed due some reason and cache has enough space to retain this entry till
- * the next try.
- *
- * @return Count of entries in store-retry state.
- */
- public int getWriteBehindErrorRetryCount() {
- return retryEntriesCnt.get();
- }
-
- /**
- * Performs shutdown logic for store. No put, get and remove requests will be processed after
- * this method is called.
- */
- @Override public void stop() {
- if (stopping.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Stopping write-behind store for cache '" + cacheName + '\'');
-
- wakeUp();
-
- boolean graceful = true;
-
- for (GridWorker worker : flushThreads)
- graceful &= U.join(worker, log);
-
- if (!graceful)
- log.warning("Shutdown was aborted");
- }
- }
-
- /**
- * Forces all entries collected to be flushed to the underlying store.
- * @throws IgniteCheckedException If failed.
- */
- public void forceFlush() throws IgniteCheckedException {
- wakeUp();
- }
-
- /** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) {
- store.loadCache(clo, args);
- }
-
- /** {@inheritDoc} */
- @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
- if (log.isDebugEnabled())
- log.debug("Store load all [keys=" + keys + ']');
-
- Map<K, V> loaded = new HashMap<>();
-
- Collection<K> remaining = new LinkedList<>();
-
- for (K key : keys) {
- StatefulValue<K, V> val = writeCache.get(key);
-
- if (val != null) {
- val.readLock().lock();
-
- try {
- if (val.operation() == StoreOperation.PUT)
- loaded.put(key, val.entry().getValue());
- else
- assert val.operation() == StoreOperation.RMV : val.operation();
- }
- finally {
- val.readLock().unlock();
- }
- }
- else
- remaining.add(key);
- }
-
- // For items that were not found in queue.
- if (!remaining.isEmpty()) {
- Map<K, V> loaded0 = store.loadAll(remaining);
-
- if (loaded0 != null)
- loaded.putAll(loaded0);
- }
-
- return loaded;
- }
-
- /** {@inheritDoc} */
- @Override public V load(K key) {
- if (log.isDebugEnabled())
- log.debug("Store load [key=" + key + ']');
-
- StatefulValue<K, V> val = writeCache.get(key);
-
- if (val != null) {
- val.readLock().lock();
-
- try {
- switch (val.operation()) {
- case PUT:
- return val.entry().getValue();
-
- case RMV:
- return null;
-
- default:
- assert false : "Unexpected operation: " + val.status();
- }
- }
- finally {
- val.readLock().unlock();
- }
- }
-
- return store.load(key);
- }
-
- /** {@inheritDoc} */
- @Override public void writeAll(Collection<Entry<? extends K, ? extends V>> entries) {
- for (Entry<? extends K, ? extends V> e : entries)
- write(e);
- }
-
- /** {@inheritDoc} */
- @Override public void write(Entry<? extends K, ? extends V> entry) {
- try {
- if (log.isDebugEnabled())
- log.debug("Store put [key=" + entry.getKey() + ", val=" + entry.getValue() + ']');
-
- updateCache(entry.getKey(), entry, StoreOperation.PUT);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new CacheWriterException(U.convertExceptionNoWrap(e));
- }
- }
-
- /** {@inheritDoc} */
- @Override public void deleteAll(Collection<?> keys) {
- for (Object key : keys)
- delete(key);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override public void delete(Object key) {
- try {
- if (log.isDebugEnabled())
- log.debug("Store remove [key=" + key + ']');
-
- updateCache((K)key, null, StoreOperation.RMV);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new CacheWriterException(U.convertExceptionNoWrap(e));
- }
- }
-
- /** {@inheritDoc} */
- @Override public void sessionEnd(boolean commit) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridCacheWriteBehindStore.class, this);
- }
-
- /**
- * Performs flush-consistent cache update for the given key.
- *
- * @param key Key for which update is performed.
- * @param val New value, may be null for remove operation.
- * @param operation Updated value status
- * @throws IgniteInterruptedCheckedException If interrupted while waiting for value to be flushed.
- */
- private void updateCache(K key,
- @Nullable Entry<? extends K, ? extends V> val,
- StoreOperation operation)
- throws IgniteInterruptedCheckedException {
- StatefulValue<K, V> newVal = new StatefulValue<>(val, operation);
-
- StatefulValue<K, V> prev;
-
- while ((prev = writeCache.putIfAbsent(key, newVal)) != null) {
- prev.writeLock().lock();
-
- try {
- if (prev.status() == ValueStatus.PENDING) {
- // Flush process in progress, try again.
- prev.waitForFlush();
-
- continue;
- }
- else if (prev.status() == ValueStatus.FLUSHED)
- // This entry was deleted from map before we acquired the lock.
- continue;
- else if (prev.status() == ValueStatus.RETRY)
- // New value has come, old value is no longer in RETRY state,
- retryEntriesCnt.decrementAndGet();
-
- assert prev.status() == ValueStatus.NEW || prev.status() == ValueStatus.RETRY;
-
- prev.update(val, operation, ValueStatus.NEW);
-
- break;
- }
- finally {
- prev.writeLock().unlock();
- }
- }
-
- // Now check the map size
- if (writeCache.sizex() > cacheCriticalSize)
- // Perform single store update in the same thread.
- flushSingleValue();
- else if (cacheMaxSize > 0 && writeCache.sizex() > cacheMaxSize)
- wakeUp();
- }
-
- /**
- * Flushes one upcoming value to the underlying store. Called from
- * {@link #updateCache(Object, Entry, StoreOperation)} method in case when current map size exceeds
- * critical size.
- */
- private void flushSingleValue() {
- cacheOverflowCntr.incrementAndGet();
-
- try {
- Map<K, StatefulValue<K, V>> batch = null;
-
- for (Map.Entry<K, StatefulValue<K, V>> e : writeCache.entrySet()) {
- StatefulValue<K, V> val = e.getValue();
-
- val.writeLock().lock();
-
- try {
- ValueStatus status = val.status();
-
- if (acquired(status))
- // Another thread is helping us, continue to the next entry.
- continue;
-
- if (val.status() == ValueStatus.RETRY)
- retryEntriesCnt.decrementAndGet();
-
- assert retryEntriesCnt.get() >= 0;
-
- val.status(ValueStatus.PENDING);
-
- batch = Collections.singletonMap(e.getKey(), val);
- }
- finally {
- val.writeLock().unlock();
- }
-
- if (!batch.isEmpty()) {
- applyBatch(batch, false);
-
- cacheTotalOverflowCntr.incrementAndGet();
-
- return;
- }
- }
- }
- finally {
- cacheOverflowCntr.decrementAndGet();
- }
- }
-
- /**
- * Performs batch operation on underlying store.
- *
- * @param valMap Batch map.
- * @param initSes {@code True} if need to initialize session.
- */
- private void applyBatch(Map<K, StatefulValue<K, V>> valMap, boolean initSes) {
- assert valMap.size() <= batchSize;
-
- StoreOperation operation = null;
-
- // Construct a map for underlying store
- Map<K, Entry<? extends K, ? extends V>> batch = U.newLinkedHashMap(valMap.size());
-
- for (Map.Entry<K, StatefulValue<K, V>> e : valMap.entrySet()) {
- if (operation == null)
- operation = e.getValue().operation();
-
- assert operation == e.getValue().operation();
-
- assert e.getValue().status() == ValueStatus.PENDING;
-
- batch.put(e.getKey(), e.getValue().entry());
- }
-
- if (updateStore(operation, batch, initSes)) {
- for (Map.Entry<K, StatefulValue<K, V>> e : valMap.entrySet()) {
- StatefulValue<K, V> val = e.getValue();
-
- val.writeLock().lock();
-
- try {
- val.status(ValueStatus.FLUSHED);
-
- StatefulValue<K, V> prev = writeCache.remove(e.getKey());
-
- // Additional check to ensure consistency.
- assert prev == val : "Map value for key " + e.getKey() + " was updated during flush";
-
- val.signalFlushed();
- }
- finally {
- val.writeLock().unlock();
- }
- }
- }
- else {
- // Exception occurred, we must set RETRY status
- for (StatefulValue<K, V> val : valMap.values()) {
- val.writeLock().lock();
-
- try {
- val.status(ValueStatus.RETRY);
-
- retryEntriesCnt.incrementAndGet();
-
- val.signalFlushed();
- }
- finally {
- val.writeLock().unlock();
- }
- }
- }
- }
-
- /**
- * Tries to update store with the given values and returns {@code true} in case of success.
- *
- * <p/> If any exception in underlying store is occurred, this method checks the map size.
- * If map size exceeds some critical value, then it returns {@code true} and this value will
- * be lost. If map size does not exceed critical value, it will return false and value will
- * be retained in write cache.
- *
- * @param operation Status indicating operation that should be performed.
- * @param vals Key-Value map.
- * @param initSes {@code True} if need to initialize session.
- * @return {@code true} if value may be deleted from the write cache,
- * {@code false} otherwise
- */
- private boolean updateStore(StoreOperation operation,
- Map<K, Entry<? extends K, ? extends V>> vals,
- boolean initSes) {
-
- if (initSes && storeMgr != null)
- storeMgr.initSession(null);
-
- try {
- boolean threwEx = true;
-
- try {
- switch (operation) {
- case PUT:
- store.writeAll(vals.values());
-
- break;
-
- case RMV:
- store.deleteAll(vals.keySet());
-
- break;
-
- default:
- assert false : "Unexpected operation: " + operation;
- }
-
- threwEx = false;
-
- return true;
- }
- finally {
- if (initSes && storeMgr != null)
- storeMgr.endSession(null, threwEx);
- }
- }
- catch (Exception e) {
- LT.warn(log, e, "Unable to update underlying store: " + store);
-
- if (writeCache.sizex() > cacheCriticalSize || stopping.get()) {
- for (Map.Entry<K, Entry<? extends K, ? extends V>> entry : vals.entrySet()) {
- Object val = entry.getValue() != null ? entry.getValue().getValue() : null;
-
- log.warning("Failed to update store (value will be lost as current buffer size is greater " +
- "than 'cacheCriticalSize' or node has been stopped before store was repaired) [key=" +
- entry.getKey() + ", val=" + val + ", op=" + operation + "]");
- }
-
- return true;
- }
-
- return false;
- }
- }
-
- /**
- * Wakes up flushing threads if map size exceeded maximum value or in case of shutdown.
- */
- private void wakeUp() {
- flushLock.lock();
-
- try {
- canFlush.signalAll();
- }
- finally {
- flushLock.unlock();
- }
- }
-
- /**
- * Thread that performs time-based flushing of written values to the underlying storage.
- */
- private class Flusher extends GridWorker {
- /** {@inheritDoc */
- protected Flusher(String gridName, String name, IgniteLogger log) {
- super(gridName, name, log);
- }
-
- /** {@inheritDoc} */
- @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
- while (!stopping.get() || writeCache.sizex() > 0) {
- awaitOperationsAvailable();
-
- flushCache(writeCache.entrySet().iterator());
- }
- }
-
- /**
- * This method awaits until enough elements in map are available or given timeout is over.
- *
- * @throws InterruptedException If awaiting was interrupted.
- */
- private void awaitOperationsAvailable() throws InterruptedException {
- flushLock.lock();
-
- try {
- do {
- if (writeCache.sizex() <= cacheMaxSize || cacheMaxSize == 0) {
- if (cacheFlushFreq > 0)
- canFlush.await(cacheFlushFreq, TimeUnit.MILLISECONDS);
- else
- canFlush.await();
- }
- }
- while (writeCache.sizex() == 0 && !stopping.get());
- }
- finally {
- flushLock.unlock();
- }
- }
-
- /**
- * Removes values from the write cache and performs corresponding operation
- * on the underlying store.
- *
- * @param it Iterator for write cache.
- */
- private void flushCache(Iterator<Map.Entry<K,StatefulValue<K, V>>> it) {
- StoreOperation operation = null;
-
- Map<K, StatefulValue<K, V>> batch = null;
- Map<K, StatefulValue<K, V>> pending = U.newLinkedHashMap(batchSize);
-
- while (it.hasNext()) {
- Map.Entry<K, StatefulValue<K, V>> e = it.next();
-
- StatefulValue<K, V> val = e.getValue();
-
- val.writeLock().lock();
-
- try {
- ValueStatus status = val.status();
-
- if (acquired(status))
- // Another thread is helping us, continue to the next entry.
- continue;
-
- if (status == ValueStatus.RETRY)
- retryEntriesCnt.decrementAndGet();
-
- assert retryEntriesCnt.get() >= 0;
-
- val.status(ValueStatus.PENDING);
-
- // We scan for the next operation and apply batch on operation change. Null means new batch.
- if (operation == null)
- operation = val.operation();
-
- if (operation != val.operation()) {
- // Operation is changed, so we need to perform a batch.
- batch = pending;
- pending = U.newLinkedHashMap(batchSize);
-
- operation = val.operation();
-
- pending.put(e.getKey(), val);
- }
- else
- pending.put(e.getKey(), val);
-
- if (pending.size() == batchSize) {
- batch = pending;
- pending = U.newLinkedHashMap(batchSize);
-
- operation = null;
- }
- }
- finally {
- val.writeLock().unlock();
- }
-
- if (batch != null && !batch.isEmpty()) {
- applyBatch(batch, true);
- batch = null;
- }
- }
-
- // Process the remainder.
- if (!pending.isEmpty())
- applyBatch(pending, true);
- }
- }
-
- /**
- * For test purposes only.
- *
- * @return Write cache for the underlying store operations.
- */
- Map<K, StatefulValue<K, V>> writeCache() {
- return writeCache;
- }
-
- /**
- * Enumeration that represents possible operations on the underlying store.
- */
- private enum StoreOperation {
- /** Put key-value pair to the underlying store. */
- PUT,
-
- /** Remove key from the underlying store. */
- RMV
- }
-
- /**
- * Enumeration that represents possible states of value in the map.
- */
- private enum ValueStatus {
- /** Value is scheduled for write or delete from the underlying cache but has not been captured by flusher. */
- NEW,
-
- /** Value is captured by flusher and store operation is performed at the moment. */
- PENDING,
-
- /** Store operation has failed and it will be re-tried at the next flush. */
- RETRY,
-
- /** Store operation succeeded and this value will be removed by flusher. */
- FLUSHED,
- }
-
- /**
- * Checks if given status indicates pending or complete flush operation.
- *
- * @param status Status to check.
- * @return {@code true} if status indicates any pending or complete store update operation.
- */
- private boolean acquired(ValueStatus status) {
- return status == ValueStatus.PENDING || status == ValueStatus.FLUSHED;
- }
-
- /**
- * A state-value-operation trio.
- *
- * @param <V> Value type.
- */
- private static class StatefulValue<K, V> extends ReentrantReadWriteLock {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Value. */
- @GridToStringInclude
- private Entry<? extends K, ? extends V> val;
-
- /** Store operation. */
- private StoreOperation storeOperation;
-
- /** Value status. */
- private ValueStatus valStatus;
-
- /** Condition to wait for flush event */
- private Condition flushCond = writeLock().newCondition();
-
- /**
- * Creates a state-value pair with {@link ValueStatus#NEW} status.
- *
- * @param val Value.
- * @param storeOperation Store operation.
- */
- private StatefulValue(Entry<? extends K, ? extends V> val, StoreOperation storeOperation) {
- assert storeOperation == StoreOperation.PUT || storeOperation == StoreOperation.RMV;
-
- this.val = val;
- this.storeOperation = storeOperation;
- valStatus = ValueStatus.NEW;
- }
-
- /**
- * @return Stored value.
- */
- private Entry<? extends K, ? extends V> entry() {
- return val;
- }
-
- /**
- * @return Store operation.
- */
- private StoreOperation operation() {
- return storeOperation;
- }
-
- /**
- * @return Value status
- */
- private ValueStatus status() {
- return valStatus;
- }
-
- /**
- * Updates value status.
- *
- * @param valStatus Value status.
- */
- private void status(ValueStatus valStatus) {
- this.valStatus = valStatus;
- }
-
- /**
- * Updates both value and value status.
- *
- * @param val Value.
- * @param storeOperation Store operation.
- * @param valStatus Value status.
- */
- private void update(@Nullable Entry<? extends K, ? extends V> val,
- StoreOperation storeOperation,
- ValueStatus valStatus) {
- this.val = val;
- this.storeOperation = storeOperation;
- this.valStatus = valStatus;
- }
-
- /**
- * Awaits a signal on flush condition
- *
- * @throws IgniteInterruptedCheckedException If thread was interrupted.
- */
- private void waitForFlush() throws IgniteInterruptedCheckedException {
- U.await(flushCond);
- }
-
- /**
- * Signals flush condition.
- */
- @SuppressWarnings({"SignalWithoutCorrespondingAwait"})
- private void signalFlushed() {
- flushCond.signalAll();
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (!(o instanceof StatefulValue))
- return false;
-
- StatefulValue other = (StatefulValue)o;
-
- return F.eq(val, other.val) && F.eq(valStatus, other.valStatus);
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = val != null ? val.hashCode() : 0;
-
- res = 31 * res + valStatus.hashCode();
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(StatefulValue.class, this);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 6c27566..f2dd0c4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -360,7 +360,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
/** {@inheritDoc} */
@Override public void localLoad(Collection<? extends K> keys, final ExpiryPolicy plc)
throws IgniteCheckedException {
- if (ctx.store().isLocalStore()) {
+ if (ctx.store().isLocal()) {
super.localLoad(keys, plc);
return;
@@ -377,7 +377,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
Collection<KeyCacheObject> keys0 = ctx.cacheKeysView(keys);
- ctx.store().loadAllFromStore(null, keys0, new CI2<KeyCacheObject, Object>() {
+ ctx.store().loadAll(null, keys0, new CI2<KeyCacheObject, Object>() {
@Override public void apply(KeyCacheObject key, Object val) {
loadEntry(key, val, ver0, null, topVer, replicate, plc0);
}
@@ -386,7 +386,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
/** {@inheritDoc} */
@Override public void localLoadCache(final IgniteBiPredicate<K, V> p, Object[] args) throws IgniteCheckedException {
- if (ctx.store().isLocalStore()) {
+ if (ctx.store().isLocal()) {
super.localLoadCache(p, args);
return;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
index 7195d1c..e6d5173 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
@@ -564,8 +564,8 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
log.debug("Entry has been cleared from swap storage: " + this);
}
- if (cctx.store().isLocalStore())
- cctx.store().removeFromStore(null, keyValue(false));
+ if (cctx.store().isLocal())
+ cctx.store().remove(null, keyValue(false));
rmv = true;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 4e72bd1..c433698 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -494,7 +494,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>
try {
GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> it = cctx.swap().iterator(id);
- boolean isLocStore = cctx.store().isLocalStore();
+ boolean isLocStore = cctx.store().isLocal();
if (it != null) {
// We can safely remove these values because no entries will be created for evicted partition.
@@ -508,7 +508,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>
cctx.swap().remove(key);
if (isLocStore)
- cctx.store().removeFromStore(null, key.value(cctx.cacheObjectContext(), false));
+ cctx.store().remove(null, key.value(cctx.cacheObjectContext(), false));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
index 99fb724..7e93946 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java
@@ -945,7 +945,7 @@ public final class GridDhtLockFuture<K, V> extends GridCompoundIdentityFuture<Bo
}
try {
- cctx.store().loadAllFromStore(
+ cctx.store().loadAll(
null,
loadMap.keySet(),
new CI2<KeyCacheObject, Object>() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index c376fa0..5e8a1f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1135,7 +1135,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (keys.size() > 1 && // Several keys ...
writeThrough() && // and store is enabled ...
- !ctx.store().isLocalStore() && // and this is not local store ...
+ !ctx.store().isLocal() && // and this is not local store ...
!ctx.dr().receiveEnabled() // and no DR.
) {
// This method can only be used when there are no replicated entries in the batch.
@@ -1614,7 +1614,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (needReload != null) {
final Map<KeyCacheObject, Integer> idxMap = needReload;
- ctx.store().loadAllFromStore(null, needReload.keySet(), new CI2<KeyCacheObject, Object>() {
+ ctx.store().loadAll(null, needReload.keySet(), new CI2<KeyCacheObject, Object>() {
@Override public void apply(KeyCacheObject k, Object v) {
Integer idx = idxMap.get(k);
@@ -1917,7 +1917,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
putMap;
try {
- ctx.store().putAllToStore(null, F.viewReadOnly(storeMap, new C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
+ ctx.store().putAll(null, F.viewReadOnly(storeMap, new C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
@Override public IgniteBiTuple<Object, GridCacheVersion> apply(Object v) {
return F.t(v, ver);
}
@@ -1940,7 +1940,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
rmvKeys;
try {
- ctx.store().removeAllFromStore(null, storeKeys);
+ ctx.store().removeAll(null, storeKeys);
}
catch (CacheStorePartialUpdateException e) {
storeErr = e;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index a9a6f23..98d9283 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -1306,7 +1306,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
try {
if (putMap != null) {
try {
- ctx.store().putAllToStore(null, F.viewReadOnly(putMap, new C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
+ ctx.store().putAll(null, F.viewReadOnly(putMap, new C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
@Override public IgniteBiTuple<Object, GridCacheVersion> apply(Object v) {
return F.t(v, ver);
}
@@ -1320,7 +1320,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
}
else {
try {
- ctx.store().removeAllFromStore(null, rmvKeys);
+ ctx.store().removeAll(null, rmvKeys);
}
catch (CacheStorePartialUpdateException e) {
storeErr = e;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
new file mode 100644
index 0000000..5fde622
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
@@ -0,0 +1,59 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+
+/**
+ * Default store manager implementation.
+ */
+public class CacheOsStoreManager extends GridCacheStoreManagerAdapter {
+ /** Ignite context. */
+ private final GridKernalContext ctx;
+
+ /** Cache configuration. */
+ private final CacheConfiguration cfg;
+
+ /**
+ * Constructor.
+ *
+ * @param ctx Ignite context.
+ * @param cfg Cache configuration.
+ */
+ public CacheOsStoreManager(GridKernalContext ctx, CacheConfiguration cfg) {
+ this.ctx = ctx;
+ this.cfg = cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected GridKernalContext igniteContext() {
+ return ctx;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration cacheConfiguration() {
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean convertPortable() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheStoreManager.java
new file mode 100644
index 0000000..d9f50ac
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheStoreManager.java
@@ -0,0 +1,182 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.lang.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * Cache store manager interface.
+ */
+public interface CacheStoreManager<K, V> extends GridCacheManager<K, V> {
+ /**
+ * Initialize store manager.
+ *
+ * @param cfgStore Actual store.
+ * @param sesHolders Session holders.
+ * @throws org.apache.ignite.IgniteCheckedException If failed.
+ */
+ public void initialize(@Nullable CacheStore<?, ?> cfgStore, Map<CacheStore, ThreadLocal> sesHolders)
+ throws IgniteCheckedException;
+
+ /**
+ * @return {@code true} If store configured.
+ */
+ public boolean configured();
+
+ /**
+ * @return Wrapped store.
+ */
+ public CacheStore<Object, Object> store();
+
+ /**
+ * @return Unwrapped store provided in configuration.
+ */
+ public CacheStore<?, ?> configuredStore();
+
+ /**
+ * @return {@code true} If local store is configured.
+ */
+ public boolean isLocal();
+
+ /**
+ * @return {@code True} is write-through is enabled.
+ */
+ public boolean isWriteThrough();
+
+ /**
+ * @return Whether DHT transaction can write to store from DHT.
+ */
+ public boolean isWriteToStoreFromDht();
+
+ /**
+ * Loads data from persistent store.
+ *
+ * @param tx Cache transaction.
+ * @param key Cache key.
+ * @return Loaded value, possibly <tt>null</tt>.
+ * @throws IgniteCheckedException If data loading failed.
+ */
+ @Nullable public Object load(@Nullable IgniteInternalTx tx, KeyCacheObject key) throws IgniteCheckedException;
+
+ /**
+ * Loads data from persistent store.
+ *
+ * @param tx Cache transaction.
+ * @param keys Cache keys.
+ * @param vis Closure.
+ * @return {@code True} if there is a persistent storage.
+ * @throws IgniteCheckedException If data loading failed.
+ */
+ public boolean loadAll(@Nullable IgniteInternalTx tx, Collection<? extends KeyCacheObject> keys,
+ IgniteBiInClosure<KeyCacheObject, Object> vis) throws IgniteCheckedException;
+
+ /**
+ * @param tx Cache transaction.
+ * @param keys Cache keys.
+ * @param vis Closure to apply for loaded elements.
+ * @throws IgniteCheckedException If data loading failed.
+ */
+ public void localStoreLoadAll(@Nullable IgniteInternalTx tx, Collection<? extends KeyCacheObject> keys,
+ final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> vis) throws IgniteCheckedException;
+
+ /**
+ * Loads data from persistent store.
+ *
+ * @param vis Closer to cache loaded elements.
+ * @param args User arguments.
+ * @return {@code True} if there is a persistent storage.
+ * @throws IgniteCheckedException If data loading failed.
+ */
+ public boolean loadCache(final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> vis, Object[] args)
+ throws IgniteCheckedException;
+
+ /**
+ * Puts key-value pair into storage.
+ *
+ * @param tx Cache transaction.
+ * @param key Key.
+ * @param val Value.
+ * @param ver Version.
+ * @return {@code true} If there is a persistent storage.
+ * @throws IgniteCheckedException If storage failed.
+ */
+ public boolean put(@Nullable IgniteInternalTx tx, Object key, Object val, GridCacheVersion ver)
+ throws IgniteCheckedException;
+
+ /**
+ * Puts key-value pair into storage.
+ *
+ * @param tx Cache transaction.
+ * @param map Map.
+ * @return {@code True} if there is a persistent storage.
+ * @throws IgniteCheckedException If storage failed.
+ */
+ public boolean putAll(@Nullable IgniteInternalTx tx, Map<Object, IgniteBiTuple<Object, GridCacheVersion>> map)
+ throws IgniteCheckedException;
+
+ /**
+ * @param tx Cache transaction.
+ * @param key Key.
+ * @return {@code True} if there is a persistent storage.
+ * @throws IgniteCheckedException If storage failed.
+ */
+ public boolean remove(@Nullable IgniteInternalTx tx, Object key) throws IgniteCheckedException;
+
+ /**
+ * @param tx Cache transaction.
+ * @param keys Key.
+ * @return {@code True} if there is a persistent storage.
+ * @throws IgniteCheckedException If storage failed.
+ */
+ public boolean removeAll(@Nullable IgniteInternalTx tx, Collection<Object> keys)
+ throws IgniteCheckedException;
+
+ /**
+ * @param tx Transaction.
+ * @param commit Commit.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void sessionEnd(IgniteInternalTx tx, boolean commit) throws IgniteCheckedException;
+
+ /**
+ * End session initiated by write-behind store.
+ */
+ public void writeBehindSessionInit();
+
+ /**
+ * End session initiated by write-behind store.
+ *
+ * @param threwEx If exception was thrown.
+ * @throws IgniteCheckedException If failed.
+ */
+ public void writeBehindSessionEnd(boolean threwEx) throws IgniteCheckedException;
+
+ /**
+ * @throws IgniteCheckedException If failed.
+ */
+ public void forceFlush() throws IgniteCheckedException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6629012/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
new file mode 100644
index 0000000..f9a966c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -0,0 +1,1111 @@
+/*
+ * 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.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.transactions.*;
+import org.apache.ignite.internal.processors.cache.version.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.lang.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.lifecycle.*;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+import java.util.*;
+
+/**
+ * Store manager.
+ */
+@SuppressWarnings({"AssignmentToCatchBlockParameter", "unchecked"})
+public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapter implements CacheStoreManager {
+ /** */
+ private static final UUID SES_ATTR = UUID.randomUUID();
+
+ /** */
+ protected CacheStore<Object, Object> store;
+
+ /** */
+ protected CacheStore<?, ?> cfgStore;
+
+ /** */
+ private CacheStoreBalancingWrapper<Object, Object> singleThreadGate;
+
+ /** */
+ private ThreadLocal<SessionData> sesHolder;
+
+ /** */
+ private boolean locStore;
+
+ /** */
+ private boolean writeThrough;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void initialize(@Nullable CacheStore cfgStore, Map sesHolders) throws IgniteCheckedException {
+ GridKernalContext ctx = igniteContext();
+ CacheConfiguration cfg = cacheConfiguration();
+
+ writeThrough = cfg.isWriteThrough();
+
+ this.cfgStore = cfgStore;
+
+ store = cacheStoreWrapper(ctx, cfgStore, cfg);
+
+ singleThreadGate = store == null ? null : new CacheStoreBalancingWrapper<>(store);
+
+ ThreadLocal<SessionData> sesHolder0 = null;
+
+ if (cfgStore != null) {
+ sesHolder0 = ((Map<CacheStore, ThreadLocal>)sesHolders).get(cfgStore);
+
+ if (sesHolder0 == null) {
+ ThreadLocalSession locSes = new ThreadLocalSession();
+
+ if (ctx.resource().injectStoreSession(cfgStore, locSes)) {
+ sesHolder0 = locSes.sesHolder;
+
+ sesHolders.put(cfgStore, sesHolder0);
+ }
+ }
+ }
+
+ sesHolder = sesHolder0;
+
+ locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWriteThrough() {
+ return writeThrough;
+ }
+
+ /**
+ * Creates a wrapped cache store if write-behind cache is configured.
+ *
+ * @param ctx Kernal context.
+ * @param cfgStore Store provided in configuration.
+ * @param cfg Cache configuration.
+ * @return Instance if {@link GridCacheWriteBehindStore} if write-behind store is configured,
+ * or user-defined cache store.
+ */
+ @SuppressWarnings({"unchecked"})
+ private CacheStore cacheStoreWrapper(GridKernalContext ctx,
+ @Nullable CacheStore cfgStore,
+ CacheConfiguration cfg) {
+ if (cfgStore == null || !cfg.isWriteBehindEnabled())
+ return cfgStore;
+
+ GridCacheWriteBehindStore store = new GridCacheWriteBehindStore(this,
+ ctx.gridName(),
+ cfg.getName(),
+ ctx.log(GridCacheWriteBehindStore.class),
+ cfgStore);
+
+ store.setFlushSize(cfg.getWriteBehindFlushSize());
+ store.setFlushThreadCount(cfg.getWriteBehindFlushThreadCount());
+ store.setFlushFrequency(cfg.getWriteBehindFlushFrequency());
+ store.setBatchSize(cfg.getWriteBehindBatchSize());
+
+ return store;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void start0() throws IgniteCheckedException {
+ if (store instanceof LifecycleAware) {
+ try {
+ // Avoid second start() call on store in case when near cache is enabled.
+ if (cctx.config().isWriteBehindEnabled()) {
+ if (!cctx.isNear())
+ ((LifecycleAware)store).start();
+ }
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException("Failed to start cache store: " + e, e);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void stop0(boolean cancel) {
+ if (store instanceof LifecycleAware) {
+ try {
+ // Avoid second start() call on store in case when near cache is enabled.
+ if (cctx.config().isWriteBehindEnabled()) {
+ if (!cctx.isNear())
+ ((LifecycleAware)store).stop();
+ }
+ }
+ catch (Exception e) {
+ U.error(log(), "Failed to stop cache store.", e);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isLocal() {
+ return locStore;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean configured() {
+ return store != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheStore<?, ?> configuredStore() {
+ return cfgStore;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public Object load(@Nullable IgniteInternalTx tx, KeyCacheObject key)
+ throws IgniteCheckedException {
+ return loadFromStore(tx, key, true);
+ }
+
+ /**
+ * Loads data from persistent store.
+ *
+ * @param tx Cache transaction.
+ * @param key Cache key.
+ * @param convert Convert flag.
+ * @return Loaded value, possibly <tt>null</tt>.
+ * @throws IgniteCheckedException If data loading failed.
+ */
+ @Nullable private Object loadFromStore(@Nullable IgniteInternalTx tx,
+ KeyCacheObject key,
+ boolean convert)
+ throws IgniteCheckedException {
+ if (store != null) {
+ if (key.internal())
+ // Never load internal keys from store as they are never persisted.
+ return null;
+
+ Object storeKey = key.value(cctx.cacheObjectContext(), false);
+
+ if (convertPortable())
+ storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
+
+ if (log.isDebugEnabled())
+ log.debug("Loading value from store for key: " + storeKey);
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ Object val = null;
+
+ try {
+ val = singleThreadGate.load(storeKey);
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (CacheLoaderException e) {
+ throw new IgniteCheckedException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(new CacheLoaderException(e));
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Loaded value from store [key=" + key + ", val=" + val + ']');
+
+ if (convert) {
+ val = convert(val);
+
+ return val;
+ }
+ else
+ return val;
+ }
+
+ return null;
+ }
+
+ /**
+ * @param val Internal value.
+ * @return User value.
+ */
+ private Object convert(Object val) {
+ if (val == null)
+ return null;
+
+ return locStore ? ((IgniteBiTuple<Object, GridCacheVersion>)val).get1() : val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWriteToStoreFromDht() {
+ return cctx.config().isWriteBehindEnabled() || locStore;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void localStoreLoadAll(@Nullable IgniteInternalTx tx, Collection keys, GridInClosure3 vis)
+ throws IgniteCheckedException {
+ assert store != null;
+ assert locStore;
+
+ loadAllFromStore(tx, keys, null, vis);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean loadAll(@Nullable IgniteInternalTx tx, Collection keys, IgniteBiInClosure vis)
+ throws IgniteCheckedException {
+ if (store != null) {
+ loadAllFromStore(tx, keys, vis, null);
+
+ return true;
+ }
+ else {
+ for (Object key : keys)
+ vis.apply(key, null);
+ }
+
+ return false;
+ }
+
+ /**
+ * @param tx Cache transaction.
+ * @param keys Keys to load.
+ * @param vis Key/value closure (only one of vis or verVis can be specified).
+ * @param verVis Key/value/version closure (only one of vis or verVis can be specified).
+ * @throws IgniteCheckedException If failed.
+ */
+ private void loadAllFromStore(@Nullable IgniteInternalTx tx,
+ Collection<? extends KeyCacheObject> keys,
+ @Nullable final IgniteBiInClosure<KeyCacheObject, Object> vis,
+ @Nullable final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> verVis)
+ throws IgniteCheckedException {
+ assert vis != null ^ verVis != null;
+ assert verVis == null || locStore;
+
+ final boolean convert = verVis == null;
+
+ if (!keys.isEmpty()) {
+ if (keys.size() == 1) {
+ KeyCacheObject key = F.first(keys);
+
+ if (convert)
+ vis.apply(key, load(tx, key));
+ else {
+ IgniteBiTuple<Object, GridCacheVersion> t =
+ (IgniteBiTuple<Object, GridCacheVersion>)loadFromStore(tx, key, false);
+
+ if (t != null)
+ verVis.apply(key, t.get1(), t.get2());
+ }
+
+ return;
+ }
+
+ Collection<Object> keys0;
+
+ if (convertPortable()) {
+ keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
+ @Override public Object apply(KeyCacheObject key) {
+ return cctx.unwrapPortableIfNeeded(key.value(cctx.cacheObjectContext(), false), false);
+ }
+ });
+ }
+ else {
+ keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
+ @Override public Object apply(KeyCacheObject key) {
+ return key.value(cctx.cacheObjectContext(), false);
+ }
+ });
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Loading values from store for keys: " + keys0);
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ try {
+ IgniteBiInClosure<Object, Object> c = new CI2<Object, Object>() {
+ @SuppressWarnings("ConstantConditions")
+ @Override public void apply(Object k, Object val) {
+ if (convert) {
+ Object v = convert(val);
+
+ vis.apply(cctx.toCacheKeyObject(k), v);
+ }
+ else {
+ IgniteBiTuple<Object, GridCacheVersion> v = (IgniteBiTuple<Object, GridCacheVersion>)val;
+
+ if (v != null)
+ verVis.apply(cctx.toCacheKeyObject(k), v.get1(), v.get2());
+ }
+ }
+ };
+
+ if (keys.size() > singleThreadGate.loadAllThreshold()) {
+ Map<Object, Object> map = store.loadAll(keys0);
+
+ if (map != null) {
+ for (Map.Entry<Object, Object> e : map.entrySet())
+ c.apply(cctx.toCacheKeyObject(e.getKey()), e.getValue());
+ }
+ }
+ else
+ singleThreadGate.loadAll(keys0, c);
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (CacheLoaderException e) {
+ throw new IgniteCheckedException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(new CacheLoaderException(e));
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Loaded values from store for keys: " + keys0);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean loadCache(final GridInClosure3 vis, Object[] args) throws IgniteCheckedException {
+ if (store != null) {
+ if (log.isDebugEnabled())
+ log.debug("Loading all values from store.");
+
+ sessionInit0(null);
+
+ boolean thewEx = true;
+
+ try {
+ store.loadCache(new IgniteBiInClosure<Object, Object>() {
+ @Override public void apply(Object k, Object o) {
+ Object v;
+ GridCacheVersion ver = null;
+
+ if (locStore) {
+ IgniteBiTuple<Object, GridCacheVersion> t = (IgniteBiTuple<Object, GridCacheVersion>)o;
+
+ v = t.get1();
+ ver = t.get2();
+ }
+ else
+ v = o;
+
+ KeyCacheObject cacheKey = cctx.toCacheKeyObject(k);
+
+ vis.apply(cacheKey, v, ver);
+ }
+ }, args);
+
+ thewEx = false;
+ }
+ catch (CacheLoaderException e) {
+ throw new IgniteCheckedException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(new CacheLoaderException(e));
+ }
+ finally {
+ sessionEnd0(null, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Loaded all values from store.");
+
+ return true;
+ }
+
+ LT.warn(log, null, "Calling Cache.loadCache() method will have no effect, " +
+ "CacheConfiguration.getStore() is not defined for cache: " + cctx.namexx());
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean put(@Nullable IgniteInternalTx tx, Object key, Object val, GridCacheVersion ver)
+ throws IgniteCheckedException {
+ if (store != null) {
+ // Never persist internal keys.
+ if (key instanceof GridCacheInternal)
+ return true;
+
+ if (convertPortable()) {
+ key = cctx.unwrapPortableIfNeeded(key, false);
+ val = cctx.unwrapPortableIfNeeded(val, false);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Storing value in cache store [key=" + key + ", val=" + val + ']');
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ try {
+ store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) : val));
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (CacheWriterException e) {
+ throw new IgniteCheckedException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(new CacheWriterException(e));
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Stored value in cache store [key=" + key + ", val=" + val + ']');
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putAll(@Nullable IgniteInternalTx tx, Map map) throws IgniteCheckedException {
+ if (F.isEmpty(map))
+ return true;
+
+ if (map.size() == 1) {
+ Map.Entry<Object, IgniteBiTuple<Object, GridCacheVersion>> e =
+ ((Map<Object, IgniteBiTuple<Object, GridCacheVersion>>)map).entrySet().iterator().next();
+
+ return put(tx, e.getKey(), e.getValue().get1(), e.getValue().get2());
+ }
+ else {
+ if (store != null) {
+ EntriesView entries = new EntriesView(map);
+
+ if (log.isDebugEnabled())
+ log.debug("Storing values in cache store [entries=" + entries + ']');
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ try {
+ store.writeAll(entries);
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (Exception e) {
+ if (!(e instanceof CacheWriterException))
+ e = new CacheWriterException(e);
+
+ if (!entries.isEmpty()) {
+ List<Object> keys = new ArrayList<>(entries.size());
+
+ for (Cache.Entry<?, ?> entry : entries)
+ keys.add(entry.getKey());
+
+ throw new CacheStorePartialUpdateException(keys, e);
+ }
+
+ throw new IgniteCheckedException(e);
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Stored value in cache store [entries=" + entries + ']');
+
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean remove(@Nullable IgniteInternalTx tx, Object key) throws IgniteCheckedException {
+ if (store != null) {
+ // Never remove internal key from store as it is never persisted.
+ if (key instanceof GridCacheInternal)
+ return false;
+
+ if (convertPortable())
+ key = cctx.unwrapPortableIfNeeded(key, false);
+
+ if (log.isDebugEnabled())
+ log.debug("Removing value from cache store [key=" + key + ']');
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ try {
+ store.delete(key);
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (CacheWriterException e) {
+ throw new IgniteCheckedException(e);
+ }
+ catch (Exception e) {
+ throw new IgniteCheckedException(new CacheWriterException(e));
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Removed value from cache store [key=" + key + ']');
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean removeAll(@Nullable IgniteInternalTx tx, Collection keys)
+ throws IgniteCheckedException {
+ if (F.isEmpty(keys))
+ return true;
+
+ if (keys.size() == 1) {
+ Object key = keys.iterator().next();
+
+ return remove(tx, key);
+ }
+
+ if (store != null) {
+ Collection<Object> keys0 = convertPortable() ? cctx.unwrapPortablesIfNeeded(keys, false) : keys;
+
+ if (log.isDebugEnabled())
+ log.debug("Removing values from cache store [keys=" + keys0 + ']');
+
+ sessionInit0(tx);
+
+ boolean thewEx = true;
+
+ try {
+ store.deleteAll(keys0);
+
+ thewEx = false;
+ }
+ catch (ClassCastException e) {
+ handleClassCastException(e);
+ }
+ catch (Exception e) {
+ if (!(e instanceof CacheWriterException))
+ e = new CacheWriterException(e);
+
+ if (!keys0.isEmpty())
+ throw new CacheStorePartialUpdateException(keys0, e);
+
+ throw new IgniteCheckedException(e);
+ }
+ finally {
+ sessionEnd0(tx, thewEx);
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Removed values from cache store [keys=" + keys0 + ']');
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheStore<Object, Object> store() {
+ return store;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void forceFlush() throws IgniteCheckedException {
+ if (store instanceof GridCacheWriteBehindStore)
+ ((GridCacheWriteBehindStore)store).forceFlush();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sessionEnd(IgniteInternalTx tx, boolean commit) throws IgniteCheckedException {
+ assert store != null;
+
+ sessionInit0(tx);
+
+ try {
+ store.sessionEnd(commit);
+ }
+ finally {
+ if (sesHolder != null) {
+ sesHolder.set(null);
+
+ tx.removeMeta(SES_ATTR);
+ }
+ }
+ }
+
+ /**
+ * @param e Class cast exception.
+ * @throws IgniteCheckedException Thrown exception.
+ */
+ private void handleClassCastException(ClassCastException e) throws IgniteCheckedException {
+ assert e != null;
+
+ if (e.getMessage() != null) {
+ throw new IgniteCheckedException("Cache store must work with portable objects if portables are " +
+ "enabled for cache [cacheName=" + cctx.namex() + ']', e);
+ }
+ else
+ throw e;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBehindSessionInit() {
+ sessionInit0(null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBehindSessionEnd(boolean threwEx) throws IgniteCheckedException {
+ sessionEnd0(null, threwEx);
+ }
+
+ /**
+ * @param tx Current transaction.
+ */
+ private void sessionInit0(@Nullable IgniteInternalTx tx) {
+ if (sesHolder == null)
+ return;
+
+ assert sesHolder.get() == null;
+
+ SessionData ses;
+
+ if (tx != null) {
+ ses = tx.meta(SES_ATTR);
+
+ if (ses == null) {
+ ses = new SessionData(tx, cctx.name());
+
+ tx.addMeta(SES_ATTR, ses);
+ }
+ else
+ // Session cache name may change in cross-cache transaction.
+ ses.cacheName(cctx.name());
+ }
+ else
+ ses = new SessionData(null, cctx.name());
+
+ sesHolder.set(ses);
+ }
+
+ /**
+ * Clears session holder.
+ */
+ private void sessionEnd0(@Nullable IgniteInternalTx tx, boolean threwEx) throws IgniteCheckedException {
+ try {
+ if (tx == null)
+ store.sessionEnd(threwEx);
+ }
+ catch (Exception e) {
+ if (!threwEx)
+ throw U.cast(e);
+ }
+ finally {
+ if (sesHolder != null)
+ sesHolder.set(null);
+ }
+ }
+
+ /**
+ * @return Ignite context.
+ */
+ protected abstract GridKernalContext igniteContext();
+
+ /**
+ * @return Cache configuration.
+ */
+ protected abstract CacheConfiguration cacheConfiguration();
+
+ /**
+ * @return Convert-portable flag.
+ */
+ protected abstract boolean convertPortable();
+
+ /**
+ *
+ */
+ private static class SessionData {
+ /** */
+ @GridToStringExclude
+ private final IgniteInternalTx tx;
+
+ /** */
+ private String cacheName;
+
+ /** */
+ @GridToStringInclude
+ private Map<Object, Object> props;
+
+ /**
+ * @param tx Current transaction.
+ * @param cacheName Cache name.
+ */
+ private SessionData(@Nullable IgniteInternalTx tx, @Nullable String cacheName) {
+ this.tx = tx;
+ this.cacheName = cacheName;
+ }
+
+ /**
+ * @return Transaction.
+ */
+ @Nullable private Transaction transaction() {
+ return tx != null ? tx.proxy() : null;
+ }
+
+ /**
+ * @return Properties.
+ */
+ private Map<Object, Object> properties() {
+ if (props == null)
+ props = new GridLeanMap<>();
+
+ return props;
+ }
+
+ /**
+ * @return Cache name.
+ */
+ private String cacheName() {
+ return cacheName;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ private void cacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(SessionData.class, this, "tx", CU.txString(tx));
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ThreadLocalSession implements CacheStoreSession {
+ /** */
+ private final ThreadLocal<SessionData> sesHolder = new ThreadLocal<>();
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Transaction transaction() {
+ SessionData ses0 = sesHolder.get();
+
+ return ses0 != null ? ses0.transaction() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isWithinTransaction() {
+ return transaction() != null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <K1, V1> Map<K1, V1> properties() {
+ SessionData ses0 = sesHolder.get();
+
+ return ses0 != null ? (Map<K1, V1>)ses0.properties() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public String cacheName() {
+ SessionData ses0 = sesHolder.get();
+
+ return ses0 != null ? ses0.cacheName() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ThreadLocalSession.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ private class EntriesView extends AbstractCollection<Cache.Entry<?, ?>> {
+ /** */
+ private final Map<?, IgniteBiTuple<?, GridCacheVersion>> map;
+
+ /** */
+ private Set<Object> rmvd;
+
+ /** */
+ private boolean cleared;
+
+ /**
+ * @param map Map.
+ */
+ private EntriesView(Map<?, IgniteBiTuple<?, GridCacheVersion>> map) {
+ assert map != null;
+
+ this.map = map;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int size() {
+ return cleared ? 0 : (map.size() - (rmvd != null ? rmvd.size() : 0));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isEmpty() {
+ return cleared || !iterator().hasNext();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object o) {
+ if (cleared || !(o instanceof Cache.Entry))
+ return false;
+
+ Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
+
+ return map.containsKey(e.getKey());
+ }
+
+ /** {@inheritDoc} */
+ @NotNull @Override public Iterator<Cache.Entry<?, ?>> iterator() {
+ if (cleared)
+ return F.emptyIterator();
+
+ final Iterator<Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>>> it0 = (Iterator)map.entrySet().iterator();
+
+ return new Iterator<Cache.Entry<?, ?>>() {
+ /** */
+ private Cache.Entry<?, ?> cur;
+
+ /** */
+ private Cache.Entry<?, ?> next;
+
+ /**
+ *
+ */
+ {
+ checkNext();
+ }
+
+ /**
+ *
+ */
+ private void checkNext() {
+ while (it0.hasNext()) {
+ Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>> e = it0.next();
+
+ Object k = e.getKey();
+
+ if (rmvd != null && rmvd.contains(k))
+ continue;
+
+ Object v = locStore ? e.getValue() : e.getValue().get1();
+
+ if (convertPortable()) {
+ k = cctx.unwrapPortableIfNeeded(k, false);
+ v = cctx.unwrapPortableIfNeeded(v, false);
+ }
+
+ next = new CacheEntryImpl<>(k, v);
+
+ break;
+ }
+ }
+
+ @Override public boolean hasNext() {
+ return next != null;
+ }
+
+ @Override public Cache.Entry<?, ?> next() {
+ if (next == null)
+ throw new NoSuchElementException();
+
+ cur = next;
+
+ next = null;
+
+ checkNext();
+
+ return cur;
+ }
+
+ @Override public void remove() {
+ if (cur == null)
+ throw new IllegalStateException();
+
+ addRemoved(cur);
+
+ cur = null;
+ }
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean add(Cache.Entry<?, ?> entry) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean addAll(Collection<? extends Cache.Entry<?, ?>> col) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean remove(Object o) {
+ if (cleared || !(o instanceof Cache.Entry))
+ return false;
+
+ Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
+
+ if (rmvd != null && rmvd.contains(e.getKey()))
+ return false;
+
+ if (mapContains(e)) {
+ addRemoved(e);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsAll(Collection<?> col) {
+ if (cleared)
+ return false;
+
+ for (Object o : col) {
+ if (contains(o))
+ return false;
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean removeAll(Collection<?> col) {
+ if (cleared)
+ return false;
+
+ boolean modified = false;
+
+ for (Object o : col) {
+ if (remove(o))
+ modified = true;
+ }
+
+ return modified;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean retainAll(Collection<?> col) {
+ if (cleared)
+ return false;
+
+ boolean modified = false;
+
+ for (Cache.Entry<?, ?> e : this) {
+ if (!col.contains(e)) {
+ addRemoved(e);
+
+ modified = true;
+ }
+ }
+
+ return modified;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear() {
+ cleared = true;
+ }
+
+ /**
+ * @param e Entry.
+ */
+ private void addRemoved(Cache.Entry<?, ?> e) {
+ if (rmvd == null)
+ rmvd = new HashSet<>();
+
+ rmvd.add(e.getKey());
+ }
+
+ /**
+ * @param e Entry.
+ * @return {@code True} if original map contains entry.
+ */
+ private boolean mapContains(Cache.Entry<?, ?> e) {
+ return map.containsKey(e.getKey());
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ Iterator<Cache.Entry<?, ?>> it = iterator();
+
+ if (!it.hasNext())
+ return "[]";
+
+ SB sb = new SB("[");
+
+ while (true) {
+ Cache.Entry<?, ?> e = it.next();
+
+ sb.a(e.toString());
+
+ if (!it.hasNext())
+ return sb.a(']').toString();
+
+ sb.a(", ");
+ }
+ }
+ }
+}
[07/30] incubator-ignite git commit: # GG-9989: API movement.
Posted by sb...@apache.org.
# GG-9989: API movement.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/57b75491
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/57b75491
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/57b75491
Branch: refs/heads/ignite-366
Commit: 57b754912f1722f25126a7628ca1bb5d05ecf0db
Parents: efd98ba
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Apr 1 18:09:20 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Apr 1 18:09:20 2015 +0300
----------------------------------------------------------------------
.../src/main/scala/org/apache/ignite/visor/visor.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/57b75491/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 9005cfe..7b6d1b4 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -1515,7 +1515,7 @@ object visor extends VisorTag {
try
// Cache, IGFS, streamer and DR configurations should be excluded from daemon node config.
spring.loadConfigurations(url, "cacheConfiguration", "fileSystemConfiguration",
- "streamerConfiguration", "drSenderHubConfiguration", "drReceiverHubConfiguration").get1()
+ "streamerConfiguration", "drSenderConfiguration", "drReceiverConfiguration").get1()
finally {
if (log4jTup != null)
U.removeLog4jNoOpLogger(log4jTup)
[10/30] incubator-ignite git commit: # sprint-3 - updated exception
Posted by sb...@apache.org.
# sprint-3 - updated exception
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3bc3b07b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3bc3b07b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3bc3b07b
Branch: refs/heads/ignite-366
Commit: 3bc3b07b3705d66169284b99acab6d1fea3298fa
Parents: b7659f3
Author: Dmitiry Setrakyan <ds...@gridgain.com>
Authored: Wed Apr 1 12:34:18 2015 -0700
Committer: Dmitiry Setrakyan <ds...@gridgain.com>
Committed: Wed Apr 1 12:34:18 2015 -0700
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/cache/CachingProvider.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3bc3b07b/modules/core/src/main/java/org/apache/ignite/cache/CachingProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CachingProvider.java b/modules/core/src/main/java/org/apache/ignite/cache/CachingProvider.java
index ae02792..9782bbf 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CachingProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CachingProvider.java
@@ -239,7 +239,7 @@ public class CachingProvider implements javax.cache.spi.CachingProvider {
uriMap.remove(mgr.getURI());
}
catch (IgniteCheckedException e) {
- CU.convertToCacheException(e);
+ throw CU.convertToCacheException(e);
}
}
}