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/05/21 15:14:24 UTC
[34/34] incubator-ignite git commit: ignite-866 NPE during clean up
ignite-866 NPE during clean up
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/72ba3def
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/72ba3def
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/72ba3def
Branch: refs/heads/ignite-866
Commit: 72ba3def1a7bf52f3c002ce3e396d462829eeebd
Parents: 51d32fc
Author: agura <ag...@gridgain.com>
Authored: Thu May 14 14:40:38 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu May 21 16:04:34 2015 +0300
----------------------------------------------------------------------
.../processors/cache/CacheMetricsImpl.java | 62 +++++++++++++++-----
.../processors/cache/GridCacheAdapter.java | 12 +++-
.../processors/cache/GridCacheContext.java | 8 +--
3 files changed, 59 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72ba3def/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 560de97..af19077 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.configuration.*;
import org.apache.ignite.internal.processors.cache.store.*;
import org.apache.ignite.internal.util.tostring.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -118,7 +119,9 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public long getOverflowSize() {
try {
- return cctx.cache().overflowSize();
+ GridCacheAdapter<?, ?> cache = cctx.cache();
+
+ return cache != null ? cache.overflowSize() : -1;
}
catch (IgniteCheckedException ignored) {
return -1;
@@ -127,34 +130,47 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public long getOffHeapEntriesCount() {
- return cctx.cache().offHeapEntriesCount();
+ GridCacheAdapter<?, ?> cache = cctx.cache();
+
+ return cache != null ? cache.offHeapEntriesCount() : -1;
}
/** {@inheritDoc} */
@Override public long getOffHeapAllocatedSize() {
- return cctx.cache().offHeapAllocatedSize();
+ GridCacheAdapter<?, ?> cache = cctx.cache();
+
+ return cache != null ? cache.offHeapAllocatedSize() : -1;
}
/** {@inheritDoc} */
@Override public int getSize() {
- return cctx.cache().size();
+ GridCacheAdapter<?, ?> cache = cctx.cache();
+
+ return cache != null ? cache.size() : 0;
}
/** {@inheritDoc} */
@Override public int getKeySize() {
- return cctx.cache().size();
+ return getSize();
}
/** {@inheritDoc} */
@Override public boolean isEmpty() {
- return cctx.cache().isEmpty();
+ GridCacheAdapter<?, ?> cache = cctx.cache();
+
+ return cache == null || cache.isEmpty();
}
/** {@inheritDoc} */
@Override public int getDhtEvictQueueCurrentSize() {
- return cctx.isNear() ?
- dhtCtx != null ? dhtCtx.evicts().evictQueueSize() : -1
- : cctx.evicts().evictQueueSize();
+ GridCacheContext<?, ?> ctx = cctx.isNear() ? dhtCtx : cctx;
+
+ if (ctx == null)
+ return -1;
+
+ GridCacheEvictionManager evictMgr = ctx.evicts();
+
+ return evictMgr != null ? evictMgr.evictQueueSize() : -1;
}
/** {@inheritDoc} */
@@ -548,37 +564,51 @@ public class CacheMetricsImpl implements CacheMetrics {
/** {@inheritDoc} */
@Override public String getKeyType() {
- return cctx.config().getKeyType().getName();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null ? ccfg.getKeyType().getName() : null;
}
/** {@inheritDoc} */
@Override public String getValueType() {
- return cctx.config().getValueType().getName();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null ? ccfg.getValueType().getName() : null;
}
/** {@inheritDoc} */
@Override public boolean isReadThrough() {
- return cctx.config().isReadThrough();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null && ccfg.isReadThrough();
}
/** {@inheritDoc} */
@Override public boolean isWriteThrough() {
- return cctx.config().isWriteThrough();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null && ccfg.isWriteThrough();
}
/** {@inheritDoc} */
@Override public boolean isStoreByValue() {
- return cctx.config().isStoreByValue();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null && ccfg.isStoreByValue();
}
/** {@inheritDoc} */
@Override public boolean isStatisticsEnabled() {
- return cctx.config().isStatisticsEnabled();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null && ccfg.isStatisticsEnabled();
}
/** {@inheritDoc} */
@Override public boolean isManagementEnabled() {
- return cctx.config().isManagementEnabled();
+ CacheConfiguration ccfg = cctx.config();
+
+ return ccfg != null && ccfg.isManagementEnabled();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72ba3def/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 8d7b135..6ee24ca 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
@@ -3249,7 +3249,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Override public long overflowSize() throws IgniteCheckedException {
- return ctx.swap().swapSize();
+ GridCacheSwapManager swapMgr = ctx.swap();
+
+ return swapMgr != null ? swapMgr.swapSize() : -1;
}
/**
@@ -3802,12 +3804,16 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Override public long offHeapEntriesCount() {
- return ctx.swap().offHeapEntriesCount();
+ GridCacheSwapManager swapMgr = ctx.swap();
+
+ return swapMgr != null ? swapMgr.offHeapEntriesCount() : -1;
}
/** {@inheritDoc} */
@Override public long offHeapAllocatedSize() {
- return ctx.swap().offHeapAllocatedSize();
+ GridCacheSwapManager swapMgr = ctx.swap();
+
+ return swapMgr != null ? swapMgr.offHeapAllocatedSize() : -1;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72ba3def/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 2eeaed6..10b8235 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
@@ -98,7 +98,7 @@ public class GridCacheContext<K, V> implements Externalizable {
private IgniteLogger log;
/** Cache configuration. */
- private CacheConfiguration cacheCfg;
+ private volatile CacheConfiguration cacheCfg;
/** Unsafe memory object for direct memory allocation. */
private GridUnsafeMemory unsafeMemory;
@@ -116,10 +116,10 @@ public class GridCacheContext<K, V> implements Externalizable {
private CacheContinuousQueryManager contQryMgr;
/** Swap manager. */
- private GridCacheSwapManager swapMgr;
+ private volatile GridCacheSwapManager swapMgr;
/** Evictions manager. */
- private GridCacheEvictionManager evictMgr;
+ private volatile GridCacheEvictionManager evictMgr;
/** Data structures manager. */
private CacheDataStructuresManager dataStructuresMgr;
@@ -149,7 +149,7 @@ public class GridCacheContext<K, V> implements Externalizable {
private GridCacheGateway<K, V> gate;
/** Grid cache. */
- private GridCacheAdapter<K, V> cache;
+ private volatile GridCacheAdapter<K, V> cache;
/** Cached local rich node. */
private ClusterNode locNode;