You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/03/05 07:20:49 UTC

incubator-ignite git commit: # IGNITE-392 Collect cache query configuration.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-sql-tests 54d46a08a -> 47cef36d4


# IGNITE-392 Collect cache query configuration.


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

Branch: refs/heads/ignite-sql-tests
Commit: 47cef36d4b9b7b40ccfbbc0c2cb54a94136c45f2
Parents: 54d46a0
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Mar 5 13:20:45 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Mar 5 13:20:45 2015 +0700

----------------------------------------------------------------------
 .../visor/cache/VisorCacheConfiguration.java    |  11 ++
 .../cache/VisorCacheQueryConfiguration.java     | 120 +++++++++++++++++++
 .../commands/cache/VisorCacheCommand.scala      |  33 +++++
 3 files changed, 164 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/47cef36d/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 46c675a..34d8838 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -126,6 +126,9 @@ public class VisorCacheConfiguration implements Serializable {
     /** Class name of expiry policy factory. */
     private String expiryPlcFactory;
 
+    /** Query configuration. */
+    private VisorCacheQueryConfiguration qryCfg;
+
     /**
      * @param ignite Grid.
      * @param ccfg Cache configuration.
@@ -163,6 +166,7 @@ public class VisorCacheConfiguration implements Serializable {
         cfg.nearCfg = VisorCacheNearConfiguration.from(ccfg);
         cfg.dfltCfg = VisorCacheDefaultConfiguration.from(ccfg);
         cfg.storeCfg = VisorCacheStoreConfiguration.from(ignite, ccfg);
+        cfg.qryCfg = VisorCacheQueryConfiguration.from(ccfg);
 
         return cfg;
     }
@@ -401,6 +405,13 @@ public class VisorCacheConfiguration implements Serializable {
         return storeCfg;
     }
 
+    /**
+     * @return Cache query configuration.
+     */
+    public VisorCacheQueryConfiguration queryConfiguration() {
+        return qryCfg;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(VisorCacheConfiguration.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/47cef36d/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryConfiguration.java
new file mode 100644
index 0000000..d7fbce3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheQueryConfiguration.java
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.internal.visor.cache;
+
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Data transfer object for cache query configuration data.
+ */
+public class VisorCacheQueryConfiguration implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private String[] sqlFuncClss;
+
+    /** */
+    private long longQryWarnTimeout;
+
+    /** */
+    private boolean sqlEscapeAll;
+
+    /** */
+    private String[] indexedTypes;
+
+    /** */
+    private int sqlOnheapRowCacheSize;
+
+    /**
+     * @param clss Classes to compact.
+     */
+    private static String[] compactClasses(Class<?>[] clss) {
+        int len = clss.length;
+
+        String[] res = new String[len];
+
+        for (int i = 0; i < len; i++)
+            res[i] = U.compact(clss[i].getName());
+
+        return res;
+    }
+
+    /**
+     * @param ccfg Cache configuration.
+     * @return Fill data transfer object with cache query configuration data.
+     */
+    public static VisorCacheQueryConfiguration from(CacheConfiguration ccfg) {
+        VisorCacheQueryConfiguration cfg = null;
+
+        cfg.sqlFuncClss = compactClasses(ccfg.getSqlFunctionClasses());
+        cfg.longQryWarnTimeout = ccfg.getLongQueryWarningTimeout();
+        cfg.sqlEscapeAll = ccfg.isSqlEscapeAll();
+        cfg.indexedTypes = compactClasses(ccfg.getIndexedTypes());
+        cfg.sqlOnheapRowCacheSize = ccfg.getSqlOnheapRowCacheSize();
+
+        return cfg;
+    }
+
+    /**
+     * @return Classes names with SQL functions.
+     */
+    public String[] sqlFunctionClasses() {
+        return sqlFuncClss;
+    }
+
+    /**
+     * @return Timeout in milliseconds after which long query warning will be printed.
+     */
+    public long longQueryWarningTimeout() {
+        return longQryWarnTimeout;
+    }
+
+    /**
+     * @return {@code true} if SQL engine generate SQL statements with escaped names.
+     */
+    public boolean sqlEscapeAll() {
+        return sqlEscapeAll;
+    }
+
+    /**
+     * @return Array of key and value classes names to be indexed.
+     */
+    public String[] indexedTypes() {
+        return indexedTypes;
+    }
+
+    /**
+     * @return Number of SQL rows which will be cached onheap to avoid deserialization on each SQL index access.
+     */
+    public int sqlOnheapRowCacheSize() {
+        return sqlOnheapRowCacheSize;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/47cef36d/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
index 819b180..c015fb8 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/cache/VisorCacheCommand.scala
@@ -780,6 +780,7 @@ object VisorCacheCommand {
         val evictCfg = cfg.evictConfiguration()
         val defaultCfg = cfg.defaultConfiguration()
         val storeCfg = cfg.storeConfiguration()
+        val queryCfg = cfg.queryConfiguration()
 
         val cacheT = VisorTextTable()
 
@@ -864,8 +865,40 @@ object VisorCacheCommand {
         cacheT += ("Writer Factory Class Name", safe(cfg.writerFactory()))
         cacheT += ("Expiry Policy Factory Class Name", safe(cfg.expiryPolicyFactory()))
 
+        cacheT +=("Query Execution Time Threshold", queryCfg.longQueryWarningTimeout())
+        cacheT +=("Query Escaped Names", bool2Str(queryCfg.sqlEscapeAll()))
+        cacheT +=("Query Onheap Cache Size", queryCfg.sqlOnheapRowCacheSize())
+
         println(title)
 
         cacheT.render()
+
+        val sqlFxs = queryCfg.sqlFunctionClasses()
+
+        if (sqlFxs.nonEmpty) {
+            println("\nQuery SQL functions:")
+
+            val sqlFxsT = VisorTextTable()
+
+            sqlFxsT #= "Function Class Name"
+
+            sqlFxs.foreach(s => sqlFxsT += s)
+
+            sqlFxsT.render()
+        }
+
+        val indexedTypes = queryCfg.indexedTypes()
+
+        if (indexedTypes.nonEmpty) {
+            println("\nQuery Indexed Types:")
+
+            val indexedTypesT = VisorTextTable()
+
+            indexedTypesT #= ("Key Class Name", "Value Class Name")
+
+            indexedTypes.grouped(2).foreach(types => indexedTypesT += (types(0), types(1)))
+
+            indexedTypesT.render()
+        }
     }
 }