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/01/15 09:01:11 UTC

[57/60] incubator-ignite git commit: # Fixed query with portables.

# Fixed query with portables.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/eb870526
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/eb870526
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/eb870526

Branch: refs/heads/ignite-32
Commit: eb870526b910b289202b6078d95a23970d3211db
Parents: e3ec48c
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Jan 15 14:24:12 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Jan 15 14:24:12 2015 +0700

----------------------------------------------------------------------
 .../grid/kernal/visor/query/VisorQueryTask.java | 53 ++++++++++++--------
 1 file changed, 32 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eb870526/modules/core/src/main/java/org/gridgain/grid/kernal/visor/query/VisorQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/query/VisorQueryTask.java b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/query/VisorQueryTask.java
index 446406d..50f7c7a 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/query/VisorQueryTask.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/query/VisorQueryTask.java
@@ -121,6 +121,11 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTask.VisorQueryAr
         /** Flag indicating that this furure was read from last check. */
         private Boolean accessed;
 
+        /**
+         * @param fut Future.
+         * @param next Next value.
+         * @param accessed {@code true} if query was accessed before remove timeout expired.
+         */
         public VisorFutureResultSetHolder(GridCacheQueryFuture<R> fut, R next, Boolean accessed) {
             this.fut = fut;
             this.next = next;
@@ -180,15 +185,19 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTask.VisorQueryAr
             try {
                 Boolean scan = arg.queryTxt().toUpperCase().startsWith("SCAN");
 
-                String qryId = (scan ? VisorQueryUtils.SCAN_QRY_NAME : VisorQueryUtils.SQL_QRY_NAME) + "-" + UUID.randomUUID();
+                String qryId = (scan ? VisorQueryUtils.SCAN_QRY_NAME : VisorQueryUtils.SQL_QRY_NAME) + "-" +
+                    UUID.randomUUID();
 
                 GridCache<Object, Object> c = g.cachex(arg.cacheName());
 
                 if (c == null)
-                    return new IgniteBiTuple<>(new IgniteCheckedException("Cache not found: " + escapeName(arg.cacheName())), null);
+                    return new IgniteBiTuple<>(new IgniteCheckedException("Cache not found: " +
+                        escapeName(arg.cacheName())), null);
+
+                GridCacheProjection<Object, Object> cp = c.keepPortable();
 
                 if (scan) {
-                    GridCacheQueryFuture<Map.Entry<Object, Object>> fut = c.queries().createScanQuery(null)
+                    GridCacheQueryFuture<Map.Entry<Object, Object>> fut = cp.queries().createScanQuery(null)
                         .pageSize(arg.pageSize())
                         .projection(g.forNodeIds(arg.proj()))
                         .execute();
@@ -213,7 +222,7 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTask.VisorQueryAr
                         VisorQueryUtils.SCAN_COL_NAMES, rows.get1(), next != null, duration));
                 }
                 else {
-                    GridCacheQueryFuture<List<?>> fut = ((GridCacheQueriesEx<?, ?>)c.queries())
+                    GridCacheQueryFuture<List<?>> fut = ((GridCacheQueriesEx<?, ?>)cp.queries())
                         .createSqlFieldsQuery(arg.queryTxt(), true)
                         .pageSize(arg.pageSize())
                         .projection(g.forNodeIds(arg.proj()))
@@ -237,7 +246,8 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTask.VisorQueryAr
 
                         long start = U.currentTimeMillis();
 
-                        IgniteBiTuple<List<Object[]>, List<?>> rows = VisorQueryUtils.fetchSqlQueryRows(fut, firstRow, arg.pageSize());
+                        IgniteBiTuple<List<Object[]>, List<?>> rows =
+                            VisorQueryUtils.fetchSqlQueryRows(fut, firstRow, arg.pageSize());
 
                         long fetchDuration = U.currentTimeMillis() - start;
 
@@ -263,24 +273,25 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTask.VisorQueryAr
          * @param id Uniq query result id.
          */
         private void scheduleResultSetHolderRemoval(final String id) {
-            ((GridKernal)g).context().timeout().addTimeoutObject(new GridTimeoutObjectAdapter(VisorQueryUtils.RMV_DELAY) {
-                @Override public void onTimeout() {
-                    ClusterNodeLocalMap<String, VisorFutureResultSetHolder> storage = g.nodeLocalMap();
-
-                    VisorFutureResultSetHolder<?> t = storage.get(id);
-
-                    if (t != null) {
-                        // If future was accessed since last scheduling,  set access flag to false and reschedule.
-                        if (t.accessed()) {
-                            t.accessed(false);
-
-                            scheduleResultSetHolderRemoval(id);
+            ((GridKernal)g).context().timeout()
+                .addTimeoutObject(new GridTimeoutObjectAdapter(VisorQueryUtils.RMV_DELAY) {
+                    @Override public void onTimeout() {
+                        ClusterNodeLocalMap<String, VisorFutureResultSetHolder> storage = g.nodeLocalMap();
+
+                        VisorFutureResultSetHolder<?> t = storage.get(id);
+
+                        if (t != null) {
+                            // If future was accessed since last scheduling,  set access flag to false and reschedule.
+                            if (t.accessed()) {
+                                t.accessed(false);
+
+                                scheduleResultSetHolderRemoval(id);
+                            }
+                            else
+                                storage.remove(id); // Remove stored future otherwise.
                         }
-                        else
-                            storage.remove(id); // Remove stored future otherwise.
                     }
-                }
-            });
+                });
         }
 
         /** {@inheritDoc} */