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 2016/06/28 13:07:14 UTC
[27/50] [abbrv] ignite git commit: IGNITE-3340 .NET: Fix cache store
release on DestroyCache
IGNITE-3340 .NET: Fix cache store release on DestroyCache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cb0deb11
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cb0deb11
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cb0deb11
Branch: refs/heads/ignite-1232
Commit: cb0deb11eed2cb1d574f23d8668cdf1309b66070
Parents: d59e5f5
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Thu Jun 23 19:37:20 2016 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Thu Jun 23 19:37:20 2016 +0300
----------------------------------------------------------------------
.../platform/PlatformProcessorImpl.java | 35 ++------------------
.../callback/PlatformCallbackGateway.java | 3 +-
.../dotnet/PlatformDotNetCacheStore.java | 27 ++++++++-------
.../Cache/Store/CacheStoreTest.cs | 11 ++++--
4 files changed, 27 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb0deb11/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index 5830d37..8c9e205 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -75,10 +75,6 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
private final Collection<StoreInfo> pendingStores =
Collections.newSetFromMap(new ConcurrentHashMap<StoreInfo, Boolean>());
- /** Started stores. */
- private final Collection<PlatformCacheStore> stores =
- Collections.newSetFromMap(new ConcurrentHashMap<PlatformCacheStore, Boolean>());
-
/** Lock for store lifecycle operations. */
private final ReadWriteLock storeLock = new ReentrantReadWriteLock();
@@ -95,7 +91,7 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
private boolean started;
/** Whether processor if stopped (or stopping). */
- private boolean stopped;
+ private volatile boolean stopped;
/**
* Constructor.
@@ -165,34 +161,7 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
/** {@inheritDoc} */
@Override public void stop(boolean cancel) throws IgniteCheckedException {
if (platformCtx != null) {
- // Destroy cache stores.
- storeLock.writeLock().lock();
-
- try {
- for (PlatformCacheStore store : stores) {
- if (store != null) {
- if (store instanceof PlatformDotNetCacheStore) {
- PlatformDotNetCacheStore store0 = (PlatformDotNetCacheStore)store;
-
- try {
- store0.destroy(platformCtx.kernalContext());
- }
- catch (Exception e) {
- U.error(log, "Failed to destroy .Net cache store [store=" + store0 +
- ", err=" + e.getMessage() + ']');
- }
- }
- else
- assert false : "Invalid interop cache store type: " + store;
- }
- }
- }
- finally {
- stopped = true;
-
- storeLock.writeLock().unlock();
- }
-
+ stopped = true;
platformCtx.gateway().onStop();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb0deb11/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
index 5093773..3439f38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackGateway.java
@@ -88,7 +88,8 @@ public class PlatformCallbackGateway {
* @param objPtr Object pointer.
*/
public void cacheStoreDestroy(long objPtr) {
- enter();
+ if (!lock.enterBusy())
+ return; // no need to destroy stores on grid stop
try {
PlatformCallbackUtils.cacheStoreDestroy(envPtr, objPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb0deb11/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index 45d9208..1c60a42 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.platform.dotnet;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.cache.store.CacheStoreSession;
import org.apache.ignite.internal.GridKernalContext;
@@ -34,6 +35,7 @@ import org.apache.ignite.internal.util.lang.IgniteInClosureX;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lifecycle.LifecycleAware;
import org.apache.ignite.resources.CacheStoreSessionResource;
import org.jetbrains.annotations.Nullable;
@@ -57,7 +59,7 @@ import java.util.Map;
* method in .NET during node startup. Refer to its documentation for
* details.
*/
-public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, PlatformCacheStore {
+public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, PlatformCacheStore, LifecycleAware {
/** Load cache operation code. */
private static final byte OP_LOAD_CACHE = (byte)0;
@@ -309,6 +311,18 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
}
}
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+ assert platformCtx != null;
+
+ platformCtx.gateway().cacheStoreDestroy(ptr);
+ }
+
/**
* Initialize the store.
*
@@ -394,17 +408,6 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
}
/**
- * Destroys interop-aware component.
- *
- * @param ctx Context.
- */
- public void destroy(GridKernalContext ctx) {
- assert ctx != null;
-
- platformCtx.gateway().cacheStoreDestroy(ptr);
- }
-
- /**
* Load callback.
*/
private static class LoadCallback<V> extends PlatformCacheStoreCallback {
http://git-wip-us.apache.org/repos/asf/ignite/blob/cb0deb11/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index d6a7f60..8061e9f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -24,6 +24,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Impl;
using NUnit.Framework;
/// <summary>
@@ -463,15 +464,19 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[Test]
public void TestDynamicStoreStart()
{
- var cache = GetTemplateStoreCache();
+ var grid = Ignition.GetIgnite(GridName);
+ var reg = ((Ignite) grid).HandleRegistry;
+ var handleCount = reg.Count;
+ var cache = GetTemplateStoreCache();
Assert.IsNotNull(cache);
cache.Put(1, cache.Name);
-
Assert.AreEqual(cache.Name, CacheTestStore.Map[1]);
- _storeCount++;
+ Assert.AreEqual(handleCount + 1, reg.Count);
+ grid.DestroyCache(cache.Name);
+ Assert.AreEqual(handleCount, reg.Count);
}
[Test]