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/29 10:15:17 UTC
[04/50] incubator-ignite git commit: ignite-938 - value get loop
improvement
ignite-938 - value get loop improvement
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/fae83153
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/fae83153
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/fae83153
Branch: refs/heads/ignite-sprint-6
Commit: fae83153e354d477e56eec7265992f859de24137
Parents: be24c39
Author: S.Vladykin <sv...@gridgain.com>
Authored: Fri May 22 16:29:12 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Fri May 22 16:29:12 2015 +0300
----------------------------------------------------------------------
.../query/h2/opt/GridH2AbstractKeyValueRow.java | 18 +++++++++++++-----
.../query/h2/opt/GridH2KeyValueRowOffheap.java | 4 ++--
2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fae83153/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
index 2ce91cf..6e95710 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.*;
import java.lang.ref.*;
import java.sql.*;
+import java.util.concurrent.*;
/**
* Table row implementation based on {@link GridQueryTypeDescriptor}.
@@ -137,20 +138,27 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
}
/**
- * @param attempt Attempt.
+ * @param waitTime Time to await for value unswap.
* @return Synchronized value.
*/
- protected synchronized Value syncValue(int attempt) {
+ protected synchronized Value syncValue(long waitTime) {
Value v = peekValue(VAL_COL);
- if (v == null && attempt != 0) {
+ while (v == null && waitTime > 0) {
+ long start = System.nanoTime(); // This call must be quite rare, so performance is not a concern.
+
try {
- wait(attempt);
+ wait(waitTime); // Wait for value arrival to allow other threads to make a progress.
}
catch (InterruptedException e) {
throw new IgniteInterruptedException(e);
}
+ long t = System.nanoTime() - start;
+
+ if (t > 0)
+ waitTime -= TimeUnit.NANOSECONDS.toMillis(t);
+
v = peekValue(VAL_COL);
}
@@ -211,7 +219,7 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
if (start == 0)
start = U.currentTimeMillis();
- else if (U.currentTimeMillis() - start > 15_000) // Loop for at most 15 seconds.
+ else if (U.currentTimeMillis() - start > 60_000) // Loop for at most 60 seconds.
throw new IgniteException("Failed to get value for key: " + k +
". This can happen due to a long GC pause.");
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fae83153/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
index c47f122..f89591a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
@@ -272,8 +272,8 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow {
}
/** {@inheritDoc} */
- @Override protected Value syncValue(int attempt) {
- Value v = super.syncValue(attempt);
+ @Override protected Value syncValue(long waitTime) {
+ Value v = super.syncValue(waitTime);
if (v != null)
return v;