ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [33/33] incubator-ignite git commit: ignite-959 Avoid sending key-value class definitions to servers when starting a cache
Date Wed, 24 Jun 2015 13:05:39 GMT
ignite-959 Avoid sending key-value class definitions to servers when starting a cache


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

Branch: refs/heads/ignite-959
Commit: cb4f10d01b611c2109e4a8a211e355a9fb10c096
Parents: c270bd8
Author: agura <agura@gridgain.com>
Authored: Wed Jun 24 16:04:36 2015 +0300
Committer: agura <agura@gridgain.com>
Committed: Wed Jun 24 16:04:36 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cache/CacheTypeMetadata.java  |  30 ++
 .../configuration/CacheConfiguration.java       |   2 +-
 .../processors/cache/GridCacheProcessor.java    |  18 +-
 .../processors/query/GridQueryProcessor.java    | 375 ++++++++++++++++---
 .../CacheMetricsForClusterGroupSelfTest.java    |   2 +-
 .../processors/query/h2/IgniteH2Indexing.java   |   2 +
 6 files changed, 368 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
index 20129b7..d6b0c79 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheTypeMetadata.java
@@ -71,6 +71,10 @@ public class CacheTypeMetadata implements Serializable {
     @GridToStringInclude
     private Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>>
grps;
 
+    /** Aliases for fields. */
+    @GridToStringInclude
+    private Map<String, String> aliases;
+
     /**
      * Default constructor.
      */
@@ -88,6 +92,8 @@ public class CacheTypeMetadata implements Serializable {
         txtFlds = new LinkedHashSet<>();
 
         grps = new LinkedHashMap<>();
+
+        aliases = new HashMap<>();
     }
 
     /**
@@ -115,6 +121,8 @@ public class CacheTypeMetadata implements Serializable {
         txtFlds = new LinkedHashSet<>(src.getTextFields());
 
         grps = new LinkedHashMap<>(src.getGroups());
+
+        aliases = new HashMap<>(src.aliases);
     }
 
     /**
@@ -333,6 +341,28 @@ public class CacheTypeMetadata implements Serializable {
         this.grps = grps;
     }
 
+    /**
+     * Returns fields aliases.
+     *
+     * @return fields aliases.
+     */
+    public Map<String, String> getAliases() {
+        return aliases;
+    }
+
+    /**
+     * Adds field alias.
+     *
+     * @param alias Alias.
+     * @param fieldName Field name.
+     */
+    public void addAlias(String alias, String fieldName) {
+        A.notNull(alias, "alias");
+        A.notNull(fieldName, "fieldName");
+
+        aliases.put(alias, fieldName);
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(CacheTypeMetadata.class, this);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 7af4974..4ec3e4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -298,7 +298,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     private boolean sqlEscapeAll;
 
     /** */
-    private Class<?>[] indexedTypes;
+    private transient Class<?>[] indexedTypes;
 
     /** */
     private int sqlOnheapRowCacheSize = DFLT_SQL_ONHEAP_ROW_CACHE_SIZE;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 2f7f22c..428063b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -583,6 +583,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             // Initialize defaults.
             initialize(cfg, cacheObjCtx);
 
+            ctx.query().generateTypeMetadata(cfg);
+
             cfgs[i] = cfg; // Replace original configuration value.
 
             String masked = maskNull(cfg.getName());
@@ -594,8 +596,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     throw new IgniteCheckedException("Duplicate cache name found (check configuration
and " +
                         "assign unique name to each cache): " + U.maskName(cacheName));
                 else
-                    throw new IgniteCheckedException("Default cache has already been configured
(check configuration and " +
-                        "assign unique name to each cache).");
+                    throw new IgniteCheckedException("Default cache has already been configured
" +
+                        "(check configuration and assign unique name to each cache).");
             }
 
             CacheType cacheType;
@@ -691,7 +693,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         if (rmtCfg != null) {
                             CacheConfiguration locCfg = desc.cacheConfiguration();
 
-                            checkCache(locCfg, rmtCfg, n, desc);
+                            checkCache(locCfg, rmtCfg, n);
 
                             // Check plugin cache configurations.
                             CachePluginManager pluginMgr = desc.pluginManager();
@@ -1625,7 +1627,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         for (DynamicCacheDescriptor desc : registeredCaches.values()) {
             if (!desc.cancelled()) {
-                DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(),
null);
+                DynamicCacheChangeRequest req =
+                    new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(), null);
 
                 req.startCacheConfiguration(desc.cacheConfiguration());
 
@@ -1930,6 +1933,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 try {
                     CacheConfiguration cfg = new CacheConfiguration(ccfg);
 
+                    ctx.query().generateTypeMetadata(cfg);
+
                     CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);
 
                     initialize(cfg, cacheObjCtx);
@@ -2260,11 +2265,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param locCfg Local configuration.
      * @param rmtCfg Remote configuration.
      * @param rmtNode Remote node.
-     * @param desc Cache descriptor.
      * @throws IgniteCheckedException If check failed.
      */
-    private void checkCache(CacheConfiguration locCfg, CacheConfiguration rmtCfg, ClusterNode
rmtNode,
-        DynamicCacheDescriptor desc) throws IgniteCheckedException {
+    private void checkCache(CacheConfiguration locCfg, CacheConfiguration rmtCfg, ClusterNode
rmtNode)
+        throws IgniteCheckedException {
         ClusterNode locNode = ctx.discovery().localNode();
 
         UUID rmt = rmtNode.id();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index e080c6d..a1bb019 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -117,67 +117,304 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @param ccfg Cache configuration.
      * @throws IgniteCheckedException If failed.
      */
+    /**
+     * @param ccfg Ccfg.
+     */
     public void initializeCache(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException
{
         idx.registerCache(ccfg);
 
         try {
-            if (!F.isEmpty(ccfg.getTypeMetadata())) {
-                for (CacheTypeMetadata meta : ccfg.getTypeMetadata()) {
-                    if (F.isEmpty(meta.getValueType()))
-                        throw new IgniteCheckedException("Value type is not set: " + meta);
+            //generateTypeMetadata(ccfg);
+
+            if (!F.isEmpty(ccfg.getTypeMetadata()))
+                processTypeMetadata(ccfg);
+        }
+        catch (IgniteCheckedException | RuntimeException e) {
+            idx.unregisterCache(ccfg);
+
+            throw e;
+        }
+    }
+
+    /**
+     * Generates cache type metadata if indexed types are defined.
+     *
+     * @param ccfg Cache configuration.
+     * @throws IgniteCheckedException In case of error.
+     */
+    public void generateTypeMetadata(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException
{
+        if (ccfg.getTypeMetadata() != null)
+            throw new IgniteCheckedException("Cache type metadata already exists for cache
" + ccfg.getName());
+
+        Class<?>[] clss = ccfg.getIndexedTypes();
+
+        if (F.isEmpty(clss))
+            return;
+
+        List<CacheTypeMetadata> metadata = new ArrayList<>(clss.length / 2);
+
+        for (int i = 0; i < clss.length; i += 2) {
+            Class<?> keyCls = clss[i];
+            Class<?> valCls = clss[i + 1];
+
+            CacheTypeMetadata meta = new CacheTypeMetadata();
+
+            meta.setKeyType(keyCls);
+            meta.setValueType(valCls);
+
+            Map<String, TreeMap<Integer, T3<String, Class<?>, Boolean>>>
orderedGroups = new HashMap<>();
+
+            processClassAnnotations(keyCls, meta, null, orderedGroups);
+            processClassAnnotations(valCls, meta, null, orderedGroups);
+
+            fillOrderedGroups(meta, orderedGroups);
+
+            metadata.add(meta);
+        }
+
+        ccfg.setTypeMetadata(metadata);
+    }
+
+    /**
+     * @param meta Cache type metadata.
+     * @param orderedGroups Ordered groups.
+     * @throws IgniteCheckedException In case or error.
+     */
+    private static void fillOrderedGroups(CacheTypeMetadata meta,
+        Map<String, TreeMap<Integer, T3<String, Class<?>, Boolean>>>
orderedGroups)
+        throws IgniteCheckedException
+    {
+        for (Map.Entry<String, TreeMap<Integer, T3<String, Class<?>, Boolean>>>
ordGrp : orderedGroups.entrySet()) {
+            String grpName = ordGrp.getKey();
+
+            Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>>
groups = meta.getGroups();
+
+            LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>> fields
= groups.get(grpName);
+
+            if (fields == null)
+                groups.put(grpName, fields = new LinkedHashMap<>());
+
+            for (Map.Entry<Integer, T3<String, Class<?>, Boolean>> grpFields
: ordGrp.getValue().entrySet()) {
+                String name = grpFields.getValue().get1();
+
+                Class<?> cls = grpFields.getValue().get2();
 
-                    TypeDescriptor desc = new TypeDescriptor();
+                Boolean desc = grpFields.getValue().get3();
 
-                    Class<?> valCls = U.classForName(meta.getValueType(), null);
+                if (fields.put(name, new T2<Class<?>, Boolean>(cls, desc)) !=
null)
+                    throw new IgniteCheckedException("Field " + name + " already exists in
group " + grpName);
+            }
+        }
+    }
+
+    /**
+     * @param cls Class.
+     * @param meta Type metadata.
+     * @param parentField Parent field name.
+     */
+    private void processClassAnnotations(Class<?> cls, CacheTypeMetadata meta,
+        String parentField, Map<String, TreeMap<Integer, T3<String, Class<?>,
Boolean>>> orderedGroups)
+        throws IgniteCheckedException
+    {
+        if (U.isJdk(cls) || idx.isGeometryClass(cls))
+            return;
+
+        for (Class<?> c = cls; c != null && !c.equals(Object.class); c = c.getSuperclass())
{
+            for (Field field : c.getDeclaredFields()) {
+                QueryTextField txtAnn = field.getAnnotation(QueryTextField.class);
+
+                if (txtAnn != null) {
+                    String fieldName = parentField == null ? field.getName() : parentField
+ '.' + field.getName();
+
+                    meta.getTextFields().add(fieldName);
+
+                    meta.getQueryFields().put(fieldName, field.getType());
+                }
+
+                QuerySqlField sqlAnn = field.getAnnotation(QuerySqlField.class);
 
-                    desc.name(valCls != null ? typeName(valCls) : meta.getValueType());
+                if (sqlAnn != null) {
+                    String name = sqlAnn.name().isEmpty() ? field.getName() : sqlAnn.name();
 
-                    desc.valueClass(valCls != null ? valCls : Object.class);
-                    desc.keyClass(
-                        meta.getKeyType() == null ?
-                            Object.class :
-                            U.classForName(meta.getKeyType(), Object.class));
+                    String pathStr = parentField == null ? name : parentField + '.' + name;
 
-                    TypeId typeId;
+                    processClassAnnotations(field.getType(), meta, pathStr, orderedGroups);
 
-                    if (valCls == null || ctx.cacheObjects().isPortableEnabled()) {
-                        processPortableMeta(meta, desc);
+                    if (sqlAnn.index()) {
+                        Map<String, Class<?>> fields =
+                            sqlAnn.descending() ? meta.getDescendingFields() : meta.getAscendingFields();
 
-                        typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType()));
+                        fields.put(pathStr, field.getType());
                     }
-                    else {
-                        processClassMeta(meta, desc);
 
-                        typeId = new TypeId(ccfg.getName(), valCls);
+                    meta.getQueryFields().put(pathStr, field.getType());
+
+                    if (!sqlAnn.name().isEmpty())
+                        meta.addAlias(sqlAnn.name(), field.getName());
+
+                    if (!F.isEmpty(sqlAnn.groups())) {
+                        for (String grp : sqlAnn.groups()) {
+                            LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>
fields = meta.getGroups().get(grp);
+
+                            if (fields == null)
+                                meta.getGroups().put(grp, fields = new LinkedHashMap<>());
+
+                            if (fields.put(pathStr, new IgniteBiTuple<Class<?>,
Boolean>(field.getType(), false)) != null)
+                                throw new IgniteCheckedException("Field " + pathStr + " already
exists in group " + grp);
+                        }
                     }
 
-                    addTypeByName(ccfg, desc);
-                    types.put(typeId, desc);
+                    if (!F.isEmpty(sqlAnn.orderedGroups())) {
+                        for (QuerySqlField.Group idx : sqlAnn.orderedGroups()) {
+                            TreeMap<Integer, T3<String, Class<?>, Boolean>>
orderedFields = orderedGroups.get(idx.name());
+
+                            if (orderedFields == null)
+                                orderedGroups.put(idx.name(), orderedFields = new TreeMap<>());
+
+                            T3<String, Class<?>, Boolean> grp =
+                                new T3<String, Class<?>, Boolean>(pathStr, field.getType(),
idx.descending());
 
-                    desc.registered(idx.registerType(ccfg.getName(), desc));
+                            if (orderedFields.put(idx.order(), grp) != null)
+                                throw new IgniteCheckedException("Field " + pathStr + " has
duplicated order " +
+                                    idx.order() + " in group " + idx.name());
+                        }
+                    }
                 }
             }
 
-            Class<?>[] clss = ccfg.getIndexedTypes();
+            for (Method mtd : c.getDeclaredMethods()) {
+                String mtdName = mtd.getName().startsWith("get") && mtd.getName().length()
> 3 ?
+                    mtd.getName().substring(3) : mtd.getName();
+
+                QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
+                QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
+
+                if (sqlAnn != null || txtAnn != null) {
+                    if (mtd.getParameterTypes().length != 0)
+                        throw new IgniteCheckedException("Getter with QuerySqlField " +
+                            "annotation cannot have parameters: " + mtd);
 
-            if (!F.isEmpty(clss)) {
-                for (int i = 0; i < clss.length; i += 2) {
-                    Class<?> keyCls = clss[i];
-                    Class<?> valCls = clss[i + 1];
+                    Class<?> type = mtd.getReturnType();
 
-                    TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
+                    if (txtAnn != null) {
+                        String pathStr = parentField == null ? mtdName : parentField + '.'
+ mtdName;
 
-                    addTypeByName(ccfg, desc);
-                    types.put(new TypeId(ccfg.getName(), valCls), desc);
+                        meta.getTextFields().add(pathStr);
 
-                    desc.registered(idx.registerType(ccfg.getName(), desc));
+                        meta.getQueryFields().put(pathStr, type);
+                    }
+
+                    if (sqlAnn != null) {
+                        String name = sqlAnn.name().isEmpty() ? mtdName : sqlAnn.name();
+
+                        name = parentField == null ? name : parentField + '.' + name;
+
+                        processClassAnnotations(mtd.getReturnType(), meta, name, orderedGroups);
+
+                        if (sqlAnn.index()) {
+                            Map<String, Class<?>> fields =
+                                sqlAnn.descending() ? meta.getDescendingFields() : meta.getAscendingFields();
+
+                            fields.put(name, type);
+                        }
+
+                        meta.getQueryFields().put(name, type);
+
+                        if (!sqlAnn.name().isEmpty())
+                            meta.addAlias(sqlAnn.name(), mtdName);
+
+                        if (!F.isEmpty(sqlAnn.groups())) {
+                            for (String grp : sqlAnn.groups()) {
+                                LinkedHashMap<String, IgniteBiTuple<Class<?>,
Boolean>> fields = meta.getGroups().get(grp);
+
+                                if (fields == null) {
+                                    fields = new LinkedHashMap<>();
+
+                                    meta.getGroups().put(grp, fields);
+                                }
+
+                                if (fields.put(name, new IgniteBiTuple<Class<?>,
Boolean>(mtd.getReturnType(), false)) != null)
+                                    throw new IgniteCheckedException("Field " + name + "
already exists in group " + grp);
+                            }
+                        }
+
+                        if (!F.isEmpty(sqlAnn.orderedGroups())) {
+                            for (QuerySqlField.Group idx : sqlAnn.orderedGroups()) {
+                                TreeMap<Integer, T3<String, Class<?>, Boolean>>
orderedFields = orderedGroups.get(idx.name());
+
+                                if (orderedFields == null)
+                                    orderedGroups.put(idx.name(), orderedFields = new TreeMap<>());
+
+                                T3<String, Class<?>, Boolean> grp =
+                                    new T3<String, Class<?>, Boolean>(name, mtd.getReturnType(),
idx.descending());
+
+                                if (orderedFields.put(idx.order(), grp) != null)
+                                    throw new IgniteCheckedException("Field " + name + "
has duplicated order " +
+                                        idx.order() + " in group " + idx.name());
+                            }
+                        }
+                    }
                 }
             }
         }
-        catch (IgniteCheckedException | RuntimeException e) {
-            idx.unregisterCache(ccfg);
+    }
 
-            throw e;
+    private void processIndexedTypes(CacheConfiguration<?, ?> ccfg, Class<?>[]
clss) throws IgniteCheckedException {
+        for (int i = 0; i < clss.length; i += 2) {
+            Class<?> keyCls = clss[i];
+            Class<?> valCls = clss[i + 1];
+
+            TypeDescriptor desc = processKeyAndValueClasses(keyCls, valCls);
+
+            addTypeByName(ccfg, desc);
+            types.put(new TypeId(ccfg.getName(), valCls), desc);
+
+            desc.registered(idx.registerType(ccfg.getName(), desc));
+        }
+    }
+
+    private void processTypeMetadata(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException
{
+        for (CacheTypeMetadata meta : ccfg.getTypeMetadata()) {
+            if (F.isEmpty(meta.getValueType()))
+                throw new IgniteCheckedException("Value type is not set: " + meta);
+
+            TypeDescriptor desc = new TypeDescriptor();
+
+            Class<?> valCls = U.classForName(meta.getValueType(), null);
+
+            desc.name(valCls != null ? typeName(valCls) : meta.getValueType());
+
+            desc.valueClass(valCls != null ? valCls : Object.class);
+            desc.keyClass(
+                meta.getKeyType() == null ?
+                    Object.class :
+                    U.classForName(meta.getKeyType(), Object.class));
+
+            TypeId typeId;
+
+            if (valCls == null || ctx.cacheObjects().isPortableEnabled()) {
+                processPortableMeta(meta, desc);
+
+                typeId = new TypeId(ccfg.getName(), ctx.cacheObjects().typeId(meta.getValueType()));
+            }
+            else {
+                processClassMeta(meta, desc);
+
+                typeId = new TypeId(ccfg.getName(), valCls);
+
+                if ((U.isJdk(valCls) || idx.isGeometryClass(valCls)) && idx.isSqlType(valCls))
{ // We have to index primitive _val.
+                    String idxName = "_val_idx";
+
+                    desc.addIndex(idxName, idx.isGeometryClass(valCls) ? GEO_SPATIAL : SORTED);
+
+                    desc.addFieldToIndex(idxName, "_VAL", 0, false);
+                }
+            }
+
+            addTypeByName(ccfg, desc);
+            types.put(typeId, desc);
+
+            desc.registered(idx.registerType(ccfg.getName(), desc));
         }
     }
 
@@ -1144,12 +1381,26 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         assert keyCls != null;
         assert valCls != null;
 
-        for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet())
{
+        for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet())
{
             ClassProperty prop = buildClassProperty(
                 keyCls,
                 valCls,
                 entry.getKey(),
-                entry.getValue());
+                entry.getValue(),
+                meta.getAliases());
+
+            d.addProperty(prop, false);
+        }
+
+        for (Map.Entry<String, Class<?>> entry : meta.getAscendingFields().entrySet())
{
+            String name = entry.getKey();
+
+            ClassProperty prop = buildClassProperty(
+                keyCls,
+                valCls,
+                name,
+                entry.getValue(),
+                meta.getAliases());
 
             d.addProperty(prop, false);
 
@@ -1165,7 +1416,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 keyCls,
                 valCls,
                 entry.getKey(),
-                entry.getValue());
+                entry.getValue(),
+                meta.getAliases());
 
             d.addProperty(prop, false);
 
@@ -1181,7 +1433,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 keyCls,
                 valCls,
                 txtIdx,
-                String.class);
+                String.class,
+                meta.getAliases());
 
             d.addProperty(prop, false);
 
@@ -1203,7 +1456,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                         keyCls,
                         valCls,
                         idxField.getKey(),
-                        idxField.getValue().get1());
+                        idxField.getValue().get1(),
+                        meta.getAliases());
 
                     d.addProperty(prop, false);
 
@@ -1215,16 +1469,25 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 }
             }
         }
+    }
 
-        for (Map.Entry<String, Class<?>> entry : meta.getQueryFields().entrySet())
{
-            ClassProperty prop = buildClassProperty(
-                keyCls,
-                valCls,
-                entry.getKey(),
-                entry.getValue());
+    private String resolveAliases(String key, CacheTypeMetadata meta) {
+        Map<String, String> aliases = meta.getAliases();
 
-            d.addProperty(prop, false);
+        String[] tokens = key.split("\\.");
+
+        StringBuilder sb = new StringBuilder();
+
+        for (String token : tokens) {
+            String name = aliases.get(token);
+
+            if (sb.length() > 0)
+                sb.append('.');
+
+            sb.append(name == null ? token : name);
         }
+
+        return sb.toString();
     }
 
     /**
@@ -1327,16 +1590,17 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Class property.
      * @throws IgniteCheckedException If failed.
      */
-    private static ClassProperty buildClassProperty(Class<?> keyCls, Class<?>
valCls, String pathStr, Class<?> resType)
+    private static ClassProperty buildClassProperty(Class<?> keyCls, Class<?>
valCls, String pathStr, Class<?> resType, Map<String, String> aliases)
         throws IgniteCheckedException {
         ClassProperty res = buildClassProperty(
             true,
             keyCls,
             pathStr,
-            resType);
+            resType,
+            aliases);
 
         if (res == null) // We check key before value consistently with PortableProperty.
-            res = buildClassProperty(false, valCls, pathStr, resType);
+            res = buildClassProperty(false, valCls, pathStr, resType, aliases);
 
         if (res == null)
             throw new IgniteCheckedException("Failed to initialize property '" + pathStr
+ "' for " +
@@ -1354,7 +1618,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      * @return Property instance corresponding to the given path.
      * @throws IgniteCheckedException If property cannot be created.
      */
-    static ClassProperty buildClassProperty(boolean key, Class<?> cls, String pathStr,
Class<?> resType)
+    static ClassProperty buildClassProperty(boolean key, Class<?> cls, String pathStr,
Class<?> resType, Map<String, String> aliases)
         throws IgniteCheckedException {
         String[] path = pathStr.split("\\.");
 
@@ -1363,10 +1627,15 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         for (String prop : path) {
             ClassProperty tmp;
 
+            String fieldName = aliases.get(prop);
+
+            if (fieldName == null)
+                fieldName = prop;
+
             try {
                 StringBuilder bld = new StringBuilder("get");
 
-                bld.append(prop);
+                bld.append(fieldName);
 
                 bld.setCharAt(3, Character.toUpperCase(bld.charAt(3)));
 
@@ -1374,13 +1643,15 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             }
             catch (NoSuchMethodException ignore) {
                 try {
-                    tmp = new ClassProperty(cls.getDeclaredField(prop), key);
+                    tmp = new ClassProperty(cls.getDeclaredField(fieldName), key);
                 }
                 catch (NoSuchFieldException ignored) {
                     return null;
                 }
             }
 
+            tmp.name(prop);
+
             tmp.parent(res);
 
             cls = tmp.type();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java
index 1ba24e3..455e306 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheMetricsForClusterGroupSelfTest.java
@@ -99,7 +99,7 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest
         Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
 
         for (ClusterNode node : nodes) {
-            Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
+            Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode)node).cacheMetrics();
             assertNotNull(metrics);
             assertFalse(metrics.isEmpty());
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cb4f10d0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 06c0961..138a15a 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -632,6 +632,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         PreparedStatement stmt;
 
         try {
+//            System.out.println("!!! SQL: " + sql);
+
             stmt = conn.prepareStatement(sql);
         }
         catch (SQLException e) {


Mime
View raw message