You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/04/09 10:59:22 UTC
[49/50] [abbrv] incubator-ignite git commit: GG-9829 Need examples
for IGridCache.LoadCache() and IGridCacheStore.LoadCache() in .NET - done.
GG-9829 Need examples for IGridCache.LoadCache() and IGridCacheStore.LoadCache() in .NET - done.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5fcb0729
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5fcb0729
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5fcb0729
Branch: refs/heads/ignite-sprint-4
Commit: 5fcb072927925ac2342a43bc0b81e226043439e2
Parents: bb0ce4b
Author: ptupitsyn <pt...@gridgain.com>
Authored: Thu Apr 9 11:50:42 2015 +0300
Committer: ptupitsyn <pt...@gridgain.com>
Committed: Thu Apr 9 11:50:42 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 57 +++++++++++---------
.../cache/GridLoadCacheCloseablePredicate.java | 30 +++++++++++
.../distributed/dht/GridDhtCacheAdapter.java | 22 +++++---
3 files changed, 79 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5fcb0729/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 b35dbd3..5ade136 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
@@ -3452,39 +3452,48 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
final ExpiryPolicy plc = plc0 != null ? plc0 : ctx.expiry();
- if (ctx.store().isLocal()) {
- DataStreamerImpl ldr = ctx.kernalContext().dataStream().dataStreamer(ctx.namex());
+ if (p != null)
+ ctx.kernalContext().resource().injectGeneric(p);
- try {
- ldr.receiver(new IgniteDrDataStreamerCacheUpdater());
+ try {
+ if (ctx.store().isLocal()) {
+ DataStreamerImpl ldr = ctx.kernalContext().dataStream().dataStreamer(ctx.namex());
+
+ try {
+ ldr.receiver(new IgniteDrDataStreamerCacheUpdater());
- LocalStoreLoadClosure c = new LocalStoreLoadClosure(p, ldr, plc);
+ LocalStoreLoadClosure c = new LocalStoreLoadClosure(p, ldr, plc);
- ctx.store().loadCache(c, args);
+ ctx.store().loadCache(c, args);
- c.onDone();
- }
- finally {
- ldr.closeEx(false);
+ c.onDone();
+ }
+ finally {
+ ldr.closeEx(false);
+ }
}
- }
- else {
- // Version for all loaded entries.
- final GridCacheVersion ver0 = ctx.versions().nextForLoad();
+ else {
+ // Version for all loaded entries.
+ final GridCacheVersion ver0 = ctx.versions().nextForLoad();
- ctx.store().loadCache(new CIX3<KeyCacheObject, Object, GridCacheVersion>() {
- @Override public void applyx(KeyCacheObject key, Object val, @Nullable GridCacheVersion ver)
- throws IgniteException {
- assert ver == null;
+ ctx.store().loadCache(new CIX3<KeyCacheObject, Object, GridCacheVersion>() {
+ @Override public void applyx(KeyCacheObject key, Object val, @Nullable GridCacheVersion ver)
+ throws IgniteException {
+ assert ver == null;
- long ttl = CU.ttlForLoad(plc);
+ long ttl = CU.ttlForLoad(plc);
- if (ttl == CU.TTL_ZERO)
- return;
+ if (ttl == CU.TTL_ZERO)
+ return;
- loadEntry(key, val, ver0, (IgniteBiPredicate<Object, Object>)p, topVer, replicate, ttl);
- }
- }, args);
+ loadEntry(key, val, ver0, (IgniteBiPredicate<Object, Object>) p, topVer, replicate, ttl);
+ }
+ }, args);
+ }
+ }
+ finally {
+ if (p instanceof GridLoadCacheCloseablePredicate)
+ ((GridLoadCacheCloseablePredicate)p).onClose();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5fcb0729/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLoadCacheCloseablePredicate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLoadCacheCloseablePredicate.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLoadCacheCloseablePredicate.java
new file mode 100644
index 0000000..1331a42
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridLoadCacheCloseablePredicate.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.lang.*;
+
+/**
+ * Special version of bi-predicate for LoadCache with close callback.
+ */
+public interface GridLoadCacheCloseablePredicate<K, V> extends IgniteBiPredicate<K, V> {
+ /**
+ * Callback invoked when predicate is no longer needed.
+ */
+ public void onClose();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5fcb0729/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 e19b971..a875a26 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
@@ -411,13 +411,23 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
final ExpiryPolicy plc = plc0 != null ? plc0 : ctx.expiry();
- ctx.store().loadCache(new CI3<KeyCacheObject, Object, GridCacheVersion>() {
- @Override public void apply(KeyCacheObject key, Object val, @Nullable GridCacheVersion ver) {
- assert ver == null;
+ if (p != null)
+ ctx.kernalContext().resource().injectGeneric(p);
- loadEntry(key, val, ver0, p, topVer, replicate, plc);
- }
- }, args);
+ try {
+ ctx.store().loadCache(new CI3<KeyCacheObject, Object, GridCacheVersion>() {
+ @Override public void apply(KeyCacheObject key, Object val, @Nullable GridCacheVersion ver) {
+ assert ver == null;
+
+ loadEntry(key, val, ver0, p, topVer, replicate, plc);
+ }
+ }, args);
+
+ }
+ finally {
+ if (p instanceof GridLoadCacheCloseablePredicate)
+ ((GridLoadCacheCloseablePredicate)p).onClose();
+ }
}
/**