ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [4/6] incubator-ignite git commit: # IGNITE-219 sprint-1 Fixed compilation.
Date Thu, 12 Feb 2015 15:10:44 GMT
# IGNITE-219 sprint-1 Fixed compilation.


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

Branch: refs/heads/ignite-sql-tests
Commit: cf44b520ae52462bcad78f6ed5f44c11d3b7647f
Parents: c049edb
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Feb 12 21:44:20 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Feb 12 21:44:20 2015 +0700

----------------------------------------------------------------------
 .../ignite/cache/CacheTypeFieldMetadata.java    |   2 +-
 .../ignite/internal/visor/cache/VisorCache.java |  51 ++++
 .../cache/VisorCacheTypeFieldMetadata.java      | 115 +++++++
 .../visor/cache/VisorCacheTypeMetadata.java     | 304 +++++++++++++++++++
 4 files changed, 471 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cf44b520/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java
b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java
index 7be5b4d..0041f10 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeFieldMetadata.java
@@ -29,7 +29,7 @@ public class CacheTypeFieldMetadata {
     /** Column JDBC type in database. */
     private int dbType;
 
-    /** Column name in database. */
+    /** Field name in java object. */
     private String javaName;
 
     /** Corresponding java type. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cf44b520/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index a82c943..7527a0c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.visor.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
@@ -91,6 +92,12 @@ public class VisorCache implements Serializable {
     /** Cache partitions states. */
     private GridDhtPartitionMap partsMap;
 
+    /** Collection of type metadata. */
+    private Collection<VisorCacheTypeMetadata> typeMeta;
+
+    /** Check that cache have JDBC store. */
+    private boolean jdbcStore;
+
     /**
      * @param ignite Grid.
      * @param c Actual cache.
@@ -207,6 +214,20 @@ public class VisorCache implements Serializable {
         if (cnt > 0)
             memSz = (long)((double)memSz / cnt * size);
 
+        Collection<CacheTypeMetadata> cacheMetadata = c.configuration().getTypeMetadata();
+
+        if (cacheMetadata == null)
+            cacheMetadata = Collections.emptyList();
+
+        List<VisorCacheTypeMetadata> typeMeta = new ArrayList<>(cacheMetadata!=
null ? cacheMetadata.size() : 0);
+
+        for (CacheTypeMetadata m: cacheMetadata)
+            typeMeta.add(VisorCacheTypeMetadata.from(m));
+
+        GridCacheContext cctx = ((IgniteKernal)ignite).internalCache(c.name()).context();
+
+        boolean jdbcStore = cctx.store().configuredStore() instanceof CacheAbstractJdbcStore;
+
         VisorCache cache = new VisorCache();
 
         cache.name(cacheName);
@@ -225,6 +246,8 @@ public class VisorCache implements Serializable {
         cache.backupPartitions(bps);
         cache.metrics(VisorCacheMetrics.from(ca));
         cache.partitionMap(partsMap);
+        cache.typeMeta(typeMeta);
+        cache.jdbcStore(jdbcStore);
 
         return cache;
     }
@@ -482,4 +505,32 @@ public class VisorCache implements Serializable {
     @Override public String toString() {
         return S.toString(VisorCache.class, this);
     }
+
+    /**
+     * @param typeMeta New collection of type metadata.
+     */
+    public void typeMeta(Collection<VisorCacheTypeMetadata> typeMeta) {
+        this.typeMeta = typeMeta;
+    }
+
+    /**
+     * @return Collection of type metadata.
+     */
+    public Collection<VisorCacheTypeMetadata> typeMeta() {
+        return typeMeta;
+    }
+
+    /**
+     * @return Check that cache have JDBC store.
+     */
+    public boolean jdbcStore() {
+        return jdbcStore;
+    }
+
+    /**
+     * @param jdbcStore Check that cache have JDBC store.
+     */
+    public void jdbcStore(boolean jdbcStore) {
+        this.jdbcStore = jdbcStore;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cf44b520/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java
new file mode 100644
index 0000000..0deb53b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeFieldMetadata.java
@@ -0,0 +1,115 @@
+/*
+ * 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.visor.cache;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import java.io.*;
+
+/**
+ * Data transfer object for {@link CacheTypeFieldMetadata}.
+ */
+public class VisorCacheTypeFieldMetadata implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Column name in database. */
+    private String dbName;
+
+    /** Column JDBC type in database. */
+    private int dbType;
+
+    /** Field name in java object. */
+    private String javaName;
+
+    /** Corresponding java type. */
+    private String javaType;
+
+
+    /**
+     * @param f Actual field metadata.
+     * @return Data transfer object for given cache field metadata.
+     */
+    public static VisorCacheTypeFieldMetadata from(CacheTypeFieldMetadata f) {
+        VisorCacheTypeFieldMetadata fieldMetadata = new VisorCacheTypeFieldMetadata();
+
+        fieldMetadata.dbName(f.getDatabaseName());
+        fieldMetadata.dbType(f.getDatabaseType());
+        fieldMetadata.javaName(f.getJavaName());
+        fieldMetadata.javaType(U.compact(f.getJavaType().getName()));
+
+        return fieldMetadata;
+    }
+
+    /**
+     * @param dbName New column name in database.
+     */
+    public void dbName(String dbName) {
+        this.dbName = dbName;
+    }
+
+    /**
+     * @return Column name in database.
+     */
+    public String dbName() {
+        return dbName;
+    }
+
+    /**
+     * @param dbType New column JDBC type in database.
+     */
+    public void dbType(int dbType) {
+        this.dbType = dbType;
+    }
+
+    /**
+     * @return Column JDBC type in database.
+     */
+    public int dbType() {
+        return dbType;
+    }
+
+    /**
+     * @param javaName New field name in java object.
+     */
+    public void javaName(String javaName) {
+        this.javaName = javaName;
+    }
+
+    /**
+     * @return Field name in java object.
+     */
+    public String javaName() {
+        return javaName;
+    }
+
+    /**
+     * @param javaType New corresponding java type.
+     */
+    public void javaType(String javaType) {
+        this.javaType = javaType;
+    }
+
+    /**
+     * @return Corresponding java type.
+     */
+    public String javaType() {
+        return javaType;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cf44b520/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
new file mode 100644
index 0000000..e58880c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
@@ -0,0 +1,304 @@
+/*
+ * 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.visor.cache;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Data transfer object for {@link CacheTypeMetadata}.
+ */
+public class VisorCacheTypeMetadata implements Serializable {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Schema name in database. */
+    private String dbSchema;
+
+    /** Table name in database. */
+    private String dbTbl;
+
+    /** Key class used to store key in cache. */
+    private String keyType;
+
+    /** Value class used to store value in cache. */
+    private String valType;
+
+    /** Key fields. */
+    @GridToStringInclude
+    private Collection<VisorCacheTypeFieldMetadata> keyFields;
+
+    /** Value fields. */
+    @GridToStringInclude
+    private Collection<VisorCacheTypeFieldMetadata> valFields;
+
+    /** Fields to be queried, in addition to indexed fields. */
+    @GridToStringInclude
+    private Map<String, String> qryFlds;
+
+    /** Fields to index in ascending order. */
+    @GridToStringInclude
+    private Map<String, String> ascFlds;
+
+    /** Fields to index in descending order. */
+    @GridToStringInclude
+    private Map<String, String> descFlds;
+
+    /** Fields to index as text. */
+    @GridToStringInclude
+    private Collection<String> txtFlds;
+
+    /** Fields to create group indexes for. */
+    @GridToStringInclude
+    private Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>>
grps;
+
+    /**
+     * @param m Actual cache type metadata.
+     * @return Data transfer object for given cache type metadata.
+     */
+    public static VisorCacheTypeMetadata from(CacheTypeMetadata m) {
+        assert m != null;
+
+        VisorCacheTypeMetadata metadata = new VisorCacheTypeMetadata();
+
+        metadata.dbSchema(m.getDatabaseSchema());
+        metadata.dbTbl(m.getDatabaseTable());
+        metadata.keyType(m.getKeyType());
+        metadata.valType(m.getValueType());
+
+        ArrayList<VisorCacheTypeFieldMetadata> fields = new ArrayList<>(m.getKeyFields().size());
+
+        for (CacheTypeFieldMetadata field: m.getKeyFields())
+            fields.add(VisorCacheTypeFieldMetadata.from(field));
+
+        metadata.keyFields(fields);
+
+        fields = new ArrayList<>(m.getValueFields().size());
+
+        for (CacheTypeFieldMetadata field: m.getValueFields())
+            fields.add(VisorCacheTypeFieldMetadata.from(field));
+
+        metadata.valFields(fields);
+
+        metadata.qryFlds(convertFieldsMap(m.getQueryFields()));
+        metadata.ascFlds(convertFieldsMap(m.getAscendingFields()));
+        metadata.descFlds(convertFieldsMap(m.getDescendingFields()));
+        metadata.txtFlds(m.getTextFields());
+        metadata.grps(convertGrpsMap(m.getGroups()));
+
+        return metadata;
+    }
+
+    /**
+     * Convert class object to string class name in the fields map.
+     * @param base Map with class object.
+     * @return Map with string class name.
+     */
+    private static Map<String, String> convertFieldsMap(Map<String, Class<?>>
base) {
+        Map<String, String> res = new LinkedHashMap<>(base.size());
+
+        for (Map.Entry<String, Class<?>> e: base.entrySet())
+            res.put(e.getKey(), U.compact(e.getValue().getName()));
+
+        return res;
+    }
+
+    /**
+     * Convert class object to string class name in the  groups map.
+     * @param base Map with class object.
+     * @return Map with string class name.
+     */
+    private static Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>>
convertGrpsMap(
+        Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>>
base) {
+        Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>>
res = new LinkedHashMap<>(base.size());
+
+        for (Map.Entry<String, LinkedHashMap<String, IgniteBiTuple<Class<?>,
Boolean>>> e: base.entrySet()) {
+            LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> intBase
= e.getValue();
+            LinkedHashMap<String, IgniteBiTuple<String, Boolean>> intRes = new
LinkedHashMap<>(intBase.size());
+
+            for (Map.Entry<String, IgniteBiTuple<Class<?>, Boolean>> intE:
intBase.entrySet()) {
+                IgniteBiTuple<Class<?>, Boolean> val = intE.getValue();
+
+                intRes.put(intE.getKey(), new IgniteBiTuple<>(U.compact(val.get1().getName()),
val.get2()));
+            }
+
+            res.put(e.getKey(), intRes);
+        }
+
+        return res;
+    }
+
+    /**
+     * @param dbSchema New schema name in database.
+     */
+    public void dbSchema(String dbSchema) {
+        this.dbSchema = dbSchema;
+    }
+
+    /**
+     * @return Schema name in database.
+     */
+    public String dbSchema() {
+        return dbSchema;
+    }
+
+    /**
+     * @param dbTbl New table name in database.
+     */
+    public void dbTbl(String dbTbl) {
+        this.dbTbl = dbTbl;
+    }
+
+    /**
+     * @return Table name in database.
+     */
+    public String dbTbl() {
+        return dbTbl;
+    }
+
+    /**
+     * @param keyType New key class used to store key in cache.
+     */
+    public void keyType(String keyType) {
+        this.keyType = keyType;
+    }
+
+    /**
+     * @return Key class used to store key in cache.
+     */
+    public String keyType() {
+        return keyType;
+    }
+
+    /**
+     * @param valType New value class used to store value in cache.
+     */
+    public void valType(String valType) {
+        this.valType = valType;
+    }
+
+    /**
+     * @return Value class used to store value in cache.
+     */
+    public String valType() {
+        return valType;
+    }
+
+    /**
+     * @param keyFields New key fields.
+     */
+    public void keyFields(Collection<VisorCacheTypeFieldMetadata> keyFields) {
+        this.keyFields = keyFields;
+    }
+
+    /**
+     * @return Key fields.
+     */
+    public Collection<VisorCacheTypeFieldMetadata> keyFields() {
+        return keyFields;
+    }
+
+    /**
+     * @param valFields New value fields.
+     */
+    public void valFields(Collection<VisorCacheTypeFieldMetadata> valFields) {
+        this.valFields = valFields;
+    }
+
+    /**
+     * @return Value fields.
+     */
+    public Collection<VisorCacheTypeFieldMetadata> valFields() {
+        return valFields;
+    }
+
+    /**
+     * @param qryFlds New fields to be queried, in addition to indexed fields.
+     */
+    public void qryFlds(Map<String, String> qryFlds) {
+        this.qryFlds = qryFlds;
+    }
+
+    /**
+     * @return Fields to be queried, in addition to indexed fields.
+     */
+    public Map<String, String> qryFlds() {
+        return qryFlds;
+    }
+
+    /**
+     * @param ascFlds New fields to index in ascending order.
+     */
+    public void ascFlds(Map<String, String> ascFlds) {
+        this.ascFlds = ascFlds;
+    }
+
+    /**
+     * @return Fields to index in ascending order.
+     */
+    public Map<String, String> ascFlds() {
+        return ascFlds;
+    }
+
+    /**
+     * @param descFlds New fields to index in descending order.
+     */
+    public void descFlds(Map<String, String> descFlds) {
+        this.descFlds = descFlds;
+    }
+
+    /**
+     * @return Fields to index in descending order.
+     */
+    public Map<String, String> descFlds() {
+        return descFlds;
+    }
+
+    /**
+     * @param txtFlds New fields to index as text.
+     */
+    public void txtFlds(Collection<String> txtFlds) {
+        this.txtFlds = txtFlds;
+    }
+
+    /**
+     * @return Fields to index as text.
+     */
+    public Collection<String> txtFlds() {
+        return txtFlds;
+    }
+
+    /**
+     * @param grps New fields to create group indexes for.
+     */
+    public void grps(Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>>
grps) {
+        this.grps = grps;
+    }
+
+    /**
+     * @return Fields to create group indexes for.
+     */
+    public Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>>
grps() {
+        return grps;
+    }
+}


Mime
View raw message