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 2017/10/10 12:44:05 UTC

[01/15] ignite git commit: IGNITE-5767 Web console: Use byte array type instead of java.lang.Object for binary JDBC types.

Repository: ignite
Updated Branches:
  refs/heads/ignite-5937 c1b2c03dc -> bb969db04


IGNITE-5767 Web console: Use byte array type instead of java.lang.Object for binary JDBC types.


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

Branch: refs/heads/ignite-5937
Commit: 31844374d516aea57364f716474c4a46b0098898
Parents: 90624c6
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Mon Oct 9 17:55:23 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Oct 9 17:55:23 2017 +0700

----------------------------------------------------------------------
 .../frontend/app/helpers/jade/mixins.pug            |  9 +++------
 .../generator/ConfigurationGenerator.js             |  6 +++---
 .../modules/states/configuration/caches/store.pug   |  4 ++--
 .../states/configuration/clusters/attributes.pug    |  4 ++--
 .../clusters/collision/job-stealing.pug             |  4 ++--
 .../states/configuration/domains/general.pug        |  2 +-
 .../modules/states/configuration/domains/query.pug  |  8 ++++----
 .../frontend/app/services/JavaTypes.service.js      | 15 +++++++++++++++
 .../frontend/app/services/LegacyUtils.service.js    | 16 ++++++++++++----
 .../frontend/controllers/domains-controller.js      |  7 +++++--
 10 files changed, 49 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/helpers/jade/mixins.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/helpers/jade/mixins.pug b/modules/web-console/frontend/app/helpers/jade/mixins.pug
index 9ccbde2..3e39077 100644
--- a/modules/web-console/frontend/app/helpers/jade/mixins.pug
+++ b/modules/web-console/frontend/app/helpers/jade/mixins.pug
@@ -572,7 +572,7 @@ mixin btn-remove-cond(cond, click, tip)
     i.tipField.fa.fa-remove(ng-show=cond ng-click=click bs-tooltip=tip data-trigger='hover')
 
 //- LEGACY mixin for LEGACY pair values tables.
-mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, keyJavaBuiltInTypes, valueJavaBuiltInTypes, focusId, index, divider)
+mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, valueJavaBuiltInClasses, focusId, index, divider)
     -var keyModel = `${tbl}.${prefix}Key`
     -var valModel = `${tbl}.${prefix}Value`
 
@@ -582,10 +582,7 @@ mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, keyJavaBuiltI
     .col-xs-6.col-sm-6.col-md-6
         .fieldSep !{divider}
         .input-tip
-            if keyJavaBuiltInTypes
-                input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder bs-typeahead container='body' ignite-retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' ignite-on-escape='tableReset(false)')
-            else
-                input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder ignite-on-escape='tableReset(false)')
+            input.form-control(id=keyFocusId ignite-on-enter-focus-move=valFocusId type='text' ng-model=keyModel placeholder=keyPlaceholder ignite-on-escape='tableReset(false)')
     .col-xs-6.col-sm-6.col-md-6
         -var btnVisible = 'tablePairSaveVisible(' + tbl + ', ' + index + ')'
         -var btnSave = 'tablePairSave(tablePairValid, backupItem, ' + tbl + ', ' + index + ')'
@@ -593,7 +590,7 @@ mixin table-pair-edit(tbl, prefix, keyPlaceholder, valPlaceholder, keyJavaBuiltI
 
         +btn-save(btnVisible, btnSave)
         .input-tip
-            if valueJavaBuiltInTypes
+            if valueJavaBuiltInClasses
                 input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder bs-typeahead container='body' ignite-retain-selection data-min-length='1' bs-options='javaClass for javaClass in javaBuiltInClasses' ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset(false)')
             else
                 input.form-control(id=valFocusId type='text' ng-model=valModel placeholder=valPlaceholder ignite-on-enter=btnVisibleAndSave ignite-on-escape='tableReset(false)')

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
index 9d7887a..75ee47c 100644
--- a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
+++ b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js
@@ -1681,7 +1681,7 @@ export default class IgniteConfigurationGenerator {
     static domainModelQuery(domain, available, cfg = this.domainConfigurationBean(domain)) {
         if (cfg.valueOf('queryMetadata') === 'Configuration') {
             const fields = _.filter(_.map(domain.fields,
-                (e) => ({name: e.name, className: javaTypes.fullClassName(e.className)})), (field) => {
+                (e) => ({name: e.name, className: javaTypes.stringClassName(e.className)})), (field) => {
                 return field.name !== domain.keyFieldName && field.name !== domain.valueFieldName;
             });
 
@@ -1695,10 +1695,10 @@ export default class IgniteConfigurationGenerator {
                 const valFieldName = cfg.valueOf('valueFieldName');
 
                 if (keyFieldName)
-                    fields.push({name: keyFieldName, className: javaTypes.fullClassName(domain.keyType)});
+                    fields.push({name: keyFieldName, className: javaTypes.stringClassName(domain.keyType)});
 
                 if (valFieldName)
-                    fields.push({name: valFieldName, className: javaTypes.fullClassName(domain.valueType)});
+                    fields.push({name: valFieldName, className: javaTypes.stringClassName(domain.valueType)});
             }
 
             cfg.collectionProperty('keyFields', 'keyFields', domain.queryKeyFields, 'java.lang.String', 'java.util.HashSet')

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/states/configuration/caches/store.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/caches/store.pug b/modules/web-console/frontend/app/modules/states/configuration/caches/store.pug
index d6dcbbe..0c983a2 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/caches/store.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/caches/store.pug
@@ -194,11 +194,11 @@ mixin hibernateField(name, model, items, valid, save, newItem)
                                                             a.labelFormField(ng-click='tableStartEdit(backupItem, hibernatePropsTbl, $index)') {{item.name}} = {{item.value}}
                                                             +btn-remove('tableRemove(backupItem, hibernatePropsTbl, $index)', '"Remove Property"')
                                                         td.col-sm-12(ng-if='tableEditing(hibernatePropsTbl, $index)')
-                                                            +table-pair-edit('hibernatePropsTbl', 'cur', 'Property name', 'Property value', false, false, '{{::hibernatePropsTbl.focusId + $index}}', '$index', '=')
+                                                            +table-pair-edit('hibernatePropsTbl', 'cur', 'Property name', 'Property value', false, '{{::hibernatePropsTbl.focusId + $index}}', '$index', '=')
                                                 tfoot(ng-show='tableNewItemActive(hibernatePropsTbl)')
                                                     tr
                                                         td.col-sm-12
-                                                            +table-pair-edit('hibernatePropsTbl', 'new', 'Property name', 'Property value', false, false, '{{::hibernatePropsTbl.focusId + $index}}', '-1', '=')
+                                                            +table-pair-edit('hibernatePropsTbl', 'new', 'Property name', 'Property value', false, '{{::hibernatePropsTbl.focusId + $index}}', '-1', '=')
 
 
                 .settings-row

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/states/configuration/clusters/attributes.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/clusters/attributes.pug b/modules/web-console/frontend/app/modules/states/configuration/clusters/attributes.pug
index cac122b..beb0739 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/clusters/attributes.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/clusters/attributes.pug
@@ -48,10 +48,10 @@ include /app/helpers/jade/mixins
                                             a.labelFormField(ng-click='tableStartEdit(backupItem, attributesTbl, $index)') {{item.name}} = {{item.value}}
                                             +btn-remove('tableRemove(backupItem, attributesTbl, $index)', '"Remove attribute"')
                                         td.col-sm-12(ng-show='tableEditing(attributesTbl, $index)')
-                                            +table-pair-edit('attributesTbl', 'cur', 'Attribute name', 'Attribute value', false, false, '{{::attributesTbl.focusId + $index}}', '$index', '=')
+                                            +table-pair-edit('attributesTbl', 'cur', 'Attribute name', 'Attribute value', false, '{{::attributesTbl.focusId + $index}}', '$index', '=')
                                 tfoot(ng-show='tableNewItemActive(attributesTbl)')
                                     tr
                                         td.col-sm-12
-                                            +table-pair-edit('attributesTbl', 'new', 'Attribute name', 'Attribute value', false, false, '{{::attributesTbl.focusId + $index}}', '-1', '=')
+                                            +table-pair-edit('attributesTbl', 'new', 'Attribute name', 'Attribute value', false, '{{::attributesTbl.focusId + $index}}', '-1', '=')
             .col-sm-6
                 +preview-xml-java(model, 'clusterUserAttributes')

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/states/configuration/clusters/collision/job-stealing.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/clusters/collision/job-stealing.pug b/modules/web-console/frontend/app/modules/states/configuration/clusters/collision/job-stealing.pug
index d10a02e..eeb6114 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/clusters/collision/job-stealing.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/clusters/collision/job-stealing.pug
@@ -56,8 +56,8 @@ div
                                 a.labelFormField(ng-click='tableStartEdit(backupItem, stealingAttributesTbl, $index)') {{item.name}} = {{item.value}}
                                 +btn-remove('tableRemove(backupItem, stealingAttributesTbl, $index)', '"Remove attribute"')
                             td.col-sm-12(ng-show='tableEditing(stealingAttributesTbl, $index)')
-                                +table-pair-edit('stealingAttributesTbl', 'cur', 'Attribute name', 'Attribute value', false, false, '{{::stealingAttributesTbl.focusId + $index}}', '$index', '=')
+                                +table-pair-edit('stealingAttributesTbl', 'cur', 'Attribute name', 'Attribute value', false, '{{::stealingAttributesTbl.focusId + $index}}', '$index', '=')
                     tfoot(ng-show='tableNewItemActive(stealingAttributesTbl)')
                         tr
                             td.col-sm-12
-                                +table-pair-edit('stealingAttributesTbl', 'new', 'Attribute name', 'Attribute value', false, false, '{{::stealingAttributesTbl.focusId + $index}}', '-1', '=')
+                                +table-pair-edit('stealingAttributesTbl', 'new', 'Attribute name', 'Attribute value', false, '{{::stealingAttributesTbl.focusId + $index}}', '-1', '=')

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/states/configuration/domains/general.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/domains/general.pug b/modules/web-console/frontend/app/modules/states/configuration/domains/general.pug
index f6f4e72..7c8de9a 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/domains/general.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/domains/general.pug
@@ -44,7 +44,7 @@ include /app/helpers/jade/mixins
                             <li>Configuration via QueryEntity class</li>\
                         </ul>')
                 .settings-row
-                    +java-class-typeahead('Key type:', `${model}.keyType`, '"keyType"', 'javaBuiltInClasses', 'true', 'true', '{{ ' + generatePojo + ' ? "Full class name for Key" : "Key type name" }}', 'Key class used to store key in cache', generatePojo)
+                    +java-class-typeahead('Key type:', `${model}.keyType`, '"keyType"', 'javaBuiltInClassesBase', 'true', 'true', '{{ ' + generatePojo + ' ? "Full class name for Key" : "Key type name" }}', 'Key class used to store key in cache', generatePojo)
                 .settings-row
                     +java-class-autofocus-placholder('Value type:', `${model}.valueType`, '"valueType"', 'true', 'true', 'false', '{{ ' + generatePojo +' ? "Enter fully qualified class name" : "Value type name" }}', 'Value class used to store value in cache', generatePojo)
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug b/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
index e8eceac..b4b5abe 100644
--- a/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
+++ b/modules/web-console/frontend/app/modules/states/configuration/domains/query.pug
@@ -95,11 +95,11 @@ mixin table-index-item-edit(prefix, index, sortAvailable, idAddition)
                                                 a.labelFormField(ng-click='tableStartEdit(backupItem, queryFieldsTbl, $index)') {{item.name}}  / {{item.className}}
                                                 +btn-remove('tableRemove(backupItem, queryFieldsTbl, $index)', '"Remove path"')
                                             td.col-sm-12(ng-show='tableEditing(queryFieldsTbl, $index)')
-                                                +table-pair-edit('queryFieldsTbl', 'cur', 'Field name', 'Field full class name', false, true, '{{::queryFieldsTbl.focusId + $index}}', '$index', '/')
+                                                +table-pair-edit('queryFieldsTbl', 'cur', 'Field name', 'Field full class name', true, '{{::queryFieldsTbl.focusId + $index}}', '$index', '/')
                                     tfoot(ng-show='tableNewItemActive(queryFieldsTbl)')
                                         tr
                                             td.col-sm-12
-                                                +table-pair-edit('queryFieldsTbl', 'new', 'Field name', 'Field full class name', false, true, '{{::queryFieldsTbl.focusId + $index}}', '-1', '/')
+                                                +table-pair-edit('queryFieldsTbl', 'new', 'Field name', 'Field full class name', true, '{{::queryFieldsTbl.focusId + $index}}', '-1', '/')
                     .settings-row
                         +ignite-form-field-dropdown('Key fields:', queryKeyFields, '"queryKeyFields"', false, false, true,
                             'Select key fields', 'Configure available fields', 'fields(\'cur\', ' + queryKeyFields + ')',
@@ -125,11 +125,11 @@ mixin table-index-item-edit(prefix, index, sortAvailable, idAddition)
                                                 a.labelFormField(ng-click='tableStartEdit(backupItem, aliasesTbl, $index)') {{item.field}} &rarr; {{item.alias}}
                                                 +btn-remove('tableRemove(backupItem, aliasesTbl, $index)', '"Remove alias"')
                                             td.col-sm-12(ng-show='tableEditing(aliasesTbl, $index)')
-                                                +table-pair-edit('aliasesTbl', 'cur', 'Field name', 'Field Alias', false, false, '{{::aliasesTbl.focusId + $index}}', '$index', '&rarr;')
+                                                +table-pair-edit('aliasesTbl', 'cur', 'Field name', 'Field Alias', false, '{{::aliasesTbl.focusId + $index}}', '$index', '&rarr;')
                                     tfoot(ng-show='tableNewItemActive(aliasesTbl)')
                                         tr
                                             td.col-sm-12
-                                                +table-pair-edit('aliasesTbl', 'new', 'Field name', 'Field Alias', false, false, '{{::aliasesTbl.focusId + $index}}', '-1', '&rarr;')
+                                                +table-pair-edit('aliasesTbl', 'new', 'Field name', 'Field Alias', false, '{{::aliasesTbl.focusId + $index}}', '-1', '&rarr;')
                     .settings-row(ng-init='indexesTbl={type: "table-indexes", model: "indexes", focusId: "IndexName", ui: "table-indexes"}')
                         +ignite-form-group(ng-model=queryIndexes ng-form=queryIndexesForm)
                             ignite-form-field-label

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/services/JavaTypes.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/JavaTypes.service.js b/modules/web-console/frontend/app/services/JavaTypes.service.js
index 944fea5..dff73a4 100644
--- a/modules/web-console/frontend/app/services/JavaTypes.service.js
+++ b/modules/web-console/frontend/app/services/JavaTypes.service.js
@@ -36,6 +36,9 @@ const VALID_PACKAGE = /^(([a-zA-Z_$][a-zA-Z0-9_$]*)\.)*([a-zA-Z_$][a-zA-Z0-9_$]*
 // Regular expression to check UUID string representation.
 const VALID_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/im;
 
+// Extended list of Java built-in class names.
+const JAVA_CLASS_STRINGS = JAVA_CLASSES.slice();
+
 /**
  * Utility service for various check on java types.
  */
@@ -45,6 +48,8 @@ export default class JavaTypes {
     constructor(clusterDflts, cacheDflts, igfsDflts) {
         this.enumClasses = _.uniq(this._enumClassesAcc(_.merge(clusterDflts, cacheDflts, igfsDflts), []));
         this.shortEnumClasses = _.map(this.enumClasses, (cls) => this.shortClassName(cls));
+
+        JAVA_CLASS_STRINGS.push({short: 'byte[]', full: 'byte[]', stringValue: '[B'});
     }
 
     /**
@@ -95,6 +100,16 @@ export default class JavaTypes {
     }
 
     /**
+     * @param clsName Class name to check.
+     * @returns {String} Full class name string presentation for java build-in types or source class otherwise.
+     */
+    stringClassName(clsName) {
+        const type = _.find(JAVA_CLASS_STRINGS, (clazz) => clsName === clazz.short);
+
+        return type ? type.stringValue || type.full : clsName;
+    }
+
+    /**
      * Extract class name from full class name.
      *
      * @param clsName full class name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/app/services/LegacyUtils.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/LegacyUtils.service.js b/modules/web-console/frontend/app/services/LegacyUtils.service.js
index e7c064b..be593b0 100644
--- a/modules/web-console/frontend/app/services/LegacyUtils.service.js
+++ b/modules/web-console/frontend/app/services/LegacyUtils.service.js
@@ -50,6 +50,7 @@ export default ['IgniteLegacyUtils', ['IgniteErrorPopover', (ErrorPopover) => {
         'boolean',
         'Boolean',
         'byte',
+        'byte[]',
         'Byte',
         'Date',
         'double',
@@ -88,13 +89,15 @@ export default ['IgniteLegacyUtils', ['IgniteErrorPopover', (ErrorPopover) => {
 
     /**
      * @param clsName Class name to check.
+     * @param additionalClasses List of classes to check as builtin.
      * @returns {Boolean} 'true' if given class name is a java build-in type.
      */
-    function isJavaBuiltInClass(clsName) {
+    function isJavaBuiltInClass(clsName, additionalClasses) {
         if (isEmptyString(clsName))
             return false;
 
-        return _.includes(javaBuiltInClasses, clsName) || _.includes(javaBuiltInFullNameClasses, clsName);
+        return _.includes(javaBuiltInClasses, clsName) || _.includes(javaBuiltInFullNameClasses, clsName)
+            || (_.isArray(additionalClasses) && _.includes(additionalClasses, clsName));
     }
 
     const SUPPORTED_JDBC_TYPES = [
@@ -323,8 +326,13 @@ export default ['IgniteLegacyUtils', ['IgniteErrorPopover', (ErrorPopover) => {
             if (!allowBuiltInClass && isJavaBuiltInClass(ident))
                 return !stopEdit && ErrorPopover.show(elemId, msg + ' should not be the Java build-in class!', panels, panelId);
 
-            if (len < 2 && !isJavaBuiltInClass(ident) && !packageOnly)
-                return !stopEdit && ErrorPopover.show(elemId, msg + ' does not have package specified!', panels, panelId);
+            if (len < 2) {
+                if (isJavaBuiltInClass(ident, allowBuiltInClass))
+                    return true;
+
+                if (!packageOnly)
+                    return !stopEdit && ErrorPopover.show(elemId, msg + ' does not have package specified!', panels, panelId);
+            }
 
             for (let i = 0; i < parts.length; i++) {
                 const part = parts[i];

http://git-wip-us.apache.org/repos/asf/ignite/blob/31844374/modules/web-console/frontend/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/controllers/domains-controller.js b/modules/web-console/frontend/controllers/domains-controller.js
index 840086e..646f8e5 100644
--- a/modules/web-console/frontend/controllers/domains-controller.js
+++ b/modules/web-console/frontend/controllers/domains-controller.js
@@ -81,7 +81,10 @@ export default ['$rootScope', '$scope', '$http', '$state', '$filter', '$timeout'
             return !item.empty && (!item._id || _.find($scope.displayedRows, {_id: item._id}));
         };
 
-        $scope.javaBuiltInClasses = LegacyUtils.javaBuiltInClasses;
+        $scope.javaBuiltInClassesBase = LegacyUtils.javaBuiltInClasses;
+        $scope.javaBuiltInClasses = $scope.javaBuiltInClassesBase.slice();
+        $scope.javaBuiltInClasses.splice(3, 0, 'byte[]');
+
         $scope.compactJavaName = FormUtils.compactJavaName;
         $scope.widthIsSufficient = FormUtils.widthIsSufficient;
         $scope.saveBtnTipText = FormUtils.saveBtnTipText;
@@ -1600,7 +1603,7 @@ export default ['$rootScope', '$scope', '$http', '$state', '$filter', '$timeout'
                         return !stopEdit && ErrorPopover.show(LegacyTable.tableFieldId(index, pairField.idPrefix + pairField.id), 'Field with such ' + pairField.dupObjName + ' already exists!', $scope.ui, 'query');
                 }
 
-                if (pairField.classValidation && !LegacyUtils.isValidJavaClass(pairField.msg, pairValue.value, true, LegacyTable.tableFieldId(index, 'Value' + pairField.id), false, $scope.ui, 'query', stopEdit)) {
+                if (pairField.classValidation && !LegacyUtils.isValidJavaClass(pairField.msg, pairValue.value, ['byte[]'], LegacyTable.tableFieldId(index, 'Value' + pairField.id), false, $scope.ui, 'query', stopEdit)) {
                     if (stopEdit)
                         return false;
 


[07/15] ignite git commit: ignite-6305 Ignite update checker enabled

Posted by sb...@apache.org.
ignite-6305 Ignite update checker enabled


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

Branch: refs/heads/ignite-5937
Commit: a8ac4438fd0a0a5d086c5df8872fa0aa97a1360c
Parents: 97b91e9
Author: Andrey Gura <ag...@apache.org>
Authored: Wed Sep 27 13:50:26 2017 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Mon Oct 9 17:51:31 2017 +0300

----------------------------------------------------------------------
 .../processors/cluster/ClusterProcessor.java    |  39 ++--
 .../processors/cluster/GridUpdateNotifier.java  | 224 ++++++++-----------
 .../cluster/HttpIgniteUpdatesChecker.java       |  29 ++-
 .../cluster/GridUpdateNotifierSelfTest.java     |  50 +----
 4 files changed, 130 insertions(+), 212 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a8ac4438/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
index dc503fb..5f2c66c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/ClusterProcessor.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cluster;
 
 import java.io.Serializable;
-import java.lang.ref.WeakReference;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -30,6 +29,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.events.DiscoveryEvent;
 import org.apache.ignite.events.Event;
@@ -60,6 +60,7 @@ import org.apache.ignite.spi.discovery.DiscoveryDataBag.GridDiscoveryData;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_DIAGNOSTIC_ENABLED;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER;
 import static org.apache.ignite.IgniteSystemProperties.getBoolean;
 import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
 import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -84,7 +85,7 @@ public class ClusterProcessor extends GridProcessorAdapter {
     private IgniteClusterImpl cluster;
 
     /** */
-    private final AtomicBoolean notifyEnabled = new AtomicBoolean(false);
+    private final AtomicBoolean notifyEnabled = new AtomicBoolean();
 
     /** */
     @GridToStringExclude
@@ -107,6 +108,8 @@ public class ClusterProcessor extends GridProcessorAdapter {
     public ClusterProcessor(GridKernalContext ctx) {
         super(ctx);
 
+        notifyEnabled.set(IgniteSystemProperties.getBoolean(IGNITE_UPDATE_NOTIFIER, true));
+
         cluster = new IgniteClusterImpl(ctx);
     }
 
@@ -297,12 +300,13 @@ public class ClusterProcessor extends GridProcessorAdapter {
     /**
      * @param vals collection to seek through.
      */
+    @SuppressWarnings("unchecked")
     private Boolean findLastFlag(Collection<Serializable> vals) {
         Boolean flag = null;
 
         for (Serializable ser : vals) {
             if (ser != null) {
-                Map<String, Object> map = (Map<String, Object>) ser;
+                Map<String, Object> map = (Map<String, Object>)ser;
 
                 if (map.containsKey(ATTR_UPDATE_NOTIFIER_STATUS))
                     flag = (Boolean) map.get(ATTR_UPDATE_NOTIFIER_STATUS);
@@ -316,11 +320,7 @@ public class ClusterProcessor extends GridProcessorAdapter {
     @Override public void onKernalStart(boolean active) throws IgniteCheckedException {
         if (notifyEnabled.get()) {
             try {
-                verChecker = new GridUpdateNotifier(ctx.igniteInstanceName(),
-                    VER_STR,
-                    ctx.gateway(),
-                    ctx.plugins().allProviders(),
-                    false);
+                verChecker = new GridUpdateNotifier(ctx.igniteInstanceName(), VER_STR, false);
 
                 updateNtfTimer = new Timer("ignite-update-notifier-timer", true);
 
@@ -473,9 +473,6 @@ public class ClusterProcessor extends GridProcessorAdapter {
      * Update notifier timer task.
      */
     private static class UpdateNotifierTimerTask extends GridTimerTask {
-        /** Reference to kernal. */
-        private final WeakReference<IgniteKernal> kernalRef;
-
         /** Logger. */
         private final IgniteLogger log;
 
@@ -494,10 +491,11 @@ public class ClusterProcessor extends GridProcessorAdapter {
          * @param kernal Kernal.
          * @param verChecker Version checker.
          */
-        private UpdateNotifierTimerTask(IgniteKernal kernal, GridUpdateNotifier verChecker,
-            AtomicBoolean notifyEnabled) {
-            kernalRef = new WeakReference<>(kernal);
-
+        private UpdateNotifierTimerTask(
+            IgniteKernal kernal,
+            GridUpdateNotifier verChecker,
+            AtomicBoolean notifyEnabled
+        ) {
             log = kernal.context().log(UpdateNotifierTimerTask.class);
 
             this.verChecker = verChecker;
@@ -509,14 +507,7 @@ public class ClusterProcessor extends GridProcessorAdapter {
             if (!notifyEnabled.get())
                 return;
 
-            if (!first) {
-                IgniteKernal kernal = kernalRef.get();
-
-                if (kernal != null)
-                    verChecker.topologySize(kernal.cluster().nodes().size());
-            }
-
-            verChecker.checkForNewVersion(log);
+            verChecker.checkForNewVersion(log, first);
 
             // Just wait for 10 secs.
             Thread.sleep(PERIODIC_VER_CHECK_CONN_TIMEOUT);
@@ -530,7 +521,7 @@ public class ClusterProcessor extends GridProcessorAdapter {
             // No-op if status is NOT available.
             verChecker.reportStatus(log);
 
-            if (first) {
+            if (first && verChecker.error() == null) {
                 first = false;
 
                 verChecker.reportOnlyNew(true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a8ac4438/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
index eacc42f..ff834f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifier.java
@@ -17,34 +17,17 @@
 
 package org.apache.ignite.internal.processors.cluster;
 
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Collection;
+import java.util.Comparator;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.GridKernalGateway;
 import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.IgniteProperties;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.internal.util.worker.GridWorker;
-import org.apache.ignite.plugin.PluginProvider;
 import org.jetbrains.annotations.Nullable;
 
-import static java.net.URLEncoder.encode;
-
 /**
  * This class is responsible for notification about new version availability.
  * <p>
@@ -55,8 +38,8 @@ class GridUpdateNotifier {
     /** Default encoding. */
     private static final String CHARSET = "UTF-8";
 
-    /** Access URL to be used to access latest version data. */
-    private final String UPD_STATUS_PARAMS = IgniteProperties.get("ignite.update.status.params");
+    /** Version comparator. */
+    private static final VersionComparator VER_COMPARATOR = new VersionComparator();
 
     /** Throttling for logging out. */
     private static final long THROTTLE_PERIOD = 24 * 60 * 60 * 1000; // 1 day.
@@ -64,12 +47,18 @@ class GridUpdateNotifier {
     /** Sleep milliseconds time for worker thread. */
     private static final int WORKER_THREAD_SLEEP_TIME = 5000;
 
-    /** Default url for request Ignite updates. */
-    private final static String DEFAULT_IGNITE_UPDATES_URL = "https://ignite.run/update_status_ignite-plain-text.php";
+    /** Default URL for request Ignite updates. */
+    private final static String DEFAULT_IGNITE_UPDATES_URL = "https://ignite.apache.org/latest";
+
+    /** Default HTTP parameter for request Ignite updates. */
+    private final static String DEFAULT_IGNITE_UPDATES_PARAMS = "?ver=";
 
     /** Grid version. */
     private final String ver;
 
+    /** Error during obtaining data. */
+    private volatile Exception err;
+
     /** Latest version. */
     private volatile String latestVer;
 
@@ -83,18 +72,6 @@ class GridUpdateNotifier {
     private volatile boolean reportOnlyNew;
 
     /** */
-    private volatile int topSize;
-
-    /** System properties */
-    private final String vmProps;
-
-    /** Plugins information for request */
-    private final String pluginsVers;
-
-    /** Kernal gateway */
-    private final GridKernalGateway gw;
-
-    /** */
     private long lastLog = -1;
 
     /** Command for worker thread. */
@@ -111,88 +88,50 @@ class GridUpdateNotifier {
      *
      * @param igniteInstanceName igniteInstanceName
      * @param ver Compound Ignite version.
-     * @param gw Kernal gateway.
-     * @param pluginProviders Kernal gateway.
      * @param reportOnlyNew Whether or not to report only new version.
      * @param updatesChecker Service for getting Ignite updates
      * @throws IgniteCheckedException If failed.
      */
-    GridUpdateNotifier(String igniteInstanceName, String ver, GridKernalGateway gw, Collection<PluginProvider> pluginProviders,
-                       boolean reportOnlyNew, HttpIgniteUpdatesChecker updatesChecker) throws IgniteCheckedException {
-        try {
-            this.ver = ver;
-            this.igniteInstanceName = igniteInstanceName == null ? "null" : igniteInstanceName;
-            this.gw = gw;
-            this.updatesChecker = updatesChecker;
-
-            SB pluginsBuilder = new SB();
-
-            for (PluginProvider provider : pluginProviders)
-                pluginsBuilder.a("&").a(provider.name() + "-plugin-version").a("=").
-                    a(encode(provider.version(), CHARSET));
-
-            pluginsVers = pluginsBuilder.toString();
-
-            this.reportOnlyNew = reportOnlyNew;
-
-            vmProps = getSystemProperties();
+    GridUpdateNotifier(
+        String igniteInstanceName,
+        String ver,
+        boolean reportOnlyNew,
+        HttpIgniteUpdatesChecker updatesChecker
+    ) throws IgniteCheckedException {
+        this.ver = ver;
+        this.igniteInstanceName = igniteInstanceName == null ? "null" : igniteInstanceName;
+        this.updatesChecker = updatesChecker;
+        this.reportOnlyNew = reportOnlyNew;
 
-            workerThread = new Thread(new Runnable() {
-                @Override public void run() {
-                    try {
-                        while(!Thread.currentThread().isInterrupted()) {
-                            Runnable cmd0 = cmd.getAndSet(null);
+        workerThread = new Thread(new Runnable() {
+            @Override public void run() {
+                try {
+                    while(!Thread.currentThread().isInterrupted()) {
+                        Runnable cmd0 = cmd.getAndSet(null);
 
-                            if (cmd0 != null)
-                                cmd0.run();
-                            else
-                                Thread.sleep(WORKER_THREAD_SLEEP_TIME);
-                        }
-                    }
-                    catch (InterruptedException ignore) {
-                        // No-op.
+                        if (cmd0 != null)
+                            cmd0.run();
+                        else
+                            Thread.sleep(WORKER_THREAD_SLEEP_TIME);
                     }
                 }
-            }, "upd-ver-checker");
+                catch (InterruptedException ignore) {
+                    // No-op.
+                }
+            }
+        }, "upd-ver-checker");
 
-            workerThread.setDaemon(true);
+        workerThread.setDaemon(true);
 
-            workerThread.start();
-        }
-        catch (UnsupportedEncodingException e) {
-            throw new IgniteCheckedException("Failed to encode.", e);
-        }
+        workerThread.start();
     }
 
     /**
      * Creates new notifier with default Ignite updates URL
      */
-    GridUpdateNotifier(String igniteInstanceName, String ver, GridKernalGateway gw, Collection<PluginProvider> pluginProviders,
-                       boolean reportOnlyNew) throws IgniteCheckedException {
-        this(igniteInstanceName, ver, gw, pluginProviders, reportOnlyNew, new HttpIgniteUpdatesChecker(DEFAULT_IGNITE_UPDATES_URL, CHARSET));
-    }
-
-    /**
-     * Gets system properties.
-     *
-     * @return System properties.
-     */
-    private static String getSystemProperties() {
-        try {
-            StringWriter sw = new StringWriter();
-
-            try {
-                IgniteSystemProperties.safeSnapshot().store(new PrintWriter(sw), "");
-            }
-            catch (IOException ignore) {
-                return null;
-            }
-
-            return sw.toString();
-        }
-        catch (SecurityException ignore) {
-            return null;
-        }
+    GridUpdateNotifier(String igniteInstanceName, String ver, boolean reportOnlyNew) throws IgniteCheckedException {
+        this(igniteInstanceName, ver, reportOnlyNew,
+            new HttpIgniteUpdatesChecker(DEFAULT_IGNITE_UPDATES_URL, DEFAULT_IGNITE_UPDATES_PARAMS + ver, CHARSET));
     }
 
     /**
@@ -203,31 +142,32 @@ class GridUpdateNotifier {
     }
 
     /**
-     * @param topSize Size of topology for license verification purpose.
+     * @return Latest version.
      */
-    void topologySize(int topSize) {
-        this.topSize = topSize;
+    String latestVersion() {
+        return latestVer;
     }
 
     /**
-     * @return Latest version.
+     * @return Error.
      */
-    String latestVersion() {
-        return latestVer;
+    Exception error() {
+        return err;
     }
 
     /**
      * Starts asynchronous process for retrieving latest version data.
      *
      * @param log Logger.
+     * @param first First checking.
      */
-    void checkForNewVersion(IgniteLogger log) {
+    void checkForNewVersion(IgniteLogger log, boolean first) {
         assert log != null;
 
         log = log.getLogger(getClass());
 
         try {
-            cmd.set(new UpdateChecker(log));
+            cmd.set(new UpdateChecker(log, first));
         }
         catch (RejectedExecutionException e) {
             U.error(log, "Failed to schedule a thread due to execution rejection (safely ignoring): " +
@@ -250,13 +190,16 @@ class GridUpdateNotifier {
 
         downloadUrl = downloadUrl != null ? downloadUrl : IgniteKernal.SITE;
 
-        if (latestVer != null)
-            if (latestVer.equals(ver)) {
+        if (latestVer != null) {
+            int cmp = VER_COMPARATOR.compare(latestVer, ver);
+
+            if (cmp == 0) {
                 if (!reportOnlyNew)
                     throttle(log, false, "Your version is up to date.");
             }
-            else
+            else if (cmp > 0)
                 throttle(log, true, "New version is available at " + downloadUrl + ": " + latestVer);
+        }
         else
             if (!reportOnlyNew)
                 throttle(log, false, "Update status is not available.");
@@ -302,35 +245,29 @@ class GridUpdateNotifier {
         /** Logger. */
         private final IgniteLogger log;
 
+        /** First. */
+        private final boolean first;
+
         /**
          * Creates checked with given logger.
          *
          * @param log Logger.
          */
-        UpdateChecker(IgniteLogger log) {
+        UpdateChecker(IgniteLogger log, boolean first) {
             super(igniteInstanceName, "grid-version-checker", log);
 
             this.log = log.getLogger(getClass());
+            this.first = first;
         }
 
         /** {@inheritDoc} */
         @Override protected void body() throws InterruptedException {
             try {
-                String stackTrace = gw != null ? gw.userStackTrace() : null;
-
-                String postParams =
-                    "igniteInstanceName=" + encode(igniteInstanceName, CHARSET) +
-                    (!F.isEmpty(UPD_STATUS_PARAMS) ? "&" + UPD_STATUS_PARAMS : "") +
-                    (topSize > 0 ? "&topSize=" + topSize : "") +
-                    (!F.isEmpty(stackTrace) ? "&stackTrace=" + encode(stackTrace, CHARSET) : "") +
-                    (!F.isEmpty(vmProps) ? "&vmProps=" + encode(vmProps, CHARSET) : "") +
-                        pluginsVers;
-
                 if (!isCancelled()) {
                     try {
-                        String updatesResponse = updatesChecker.getUpdates(postParams);
+                        String updatesRes = updatesChecker.getUpdates(first);
 
-                        String[] lines = updatesResponse.split("\n");
+                        String[] lines = updatesRes.split("\n");
 
                         for (String line : lines) {
                             if (line.contains("version"))
@@ -338,14 +275,20 @@ class GridUpdateNotifier {
                             else if (line.contains("downloadUrl"))
                                 downloadUrl = obtainDownloadUrlFrom(line);
                         }
+
+                        err = null;
                     }
                     catch (IOException e) {
+                        err = e;
+
                         if (log.isDebugEnabled())
                             log.debug("Failed to connect to Ignite update server. " + e.getMessage());
                     }
                 }
             }
             catch (Exception e) {
+                err = e;
+
                 if (log.isDebugEnabled())
                     log.debug("Unexpected exception in update checker. " + e.getMessage());
             }
@@ -385,4 +328,35 @@ class GridUpdateNotifier {
             return obtainMeta("downloadUrl=", line);
         }
     }
+
+    /**
+     * Ignite version comparator.
+     */
+    private static final class VersionComparator implements Comparator<String> {
+        /** Dot pattern. */
+        private static final String DOT_PATTERN = "\\.";
+
+        /** Dash pattern. */
+        private static final String DASH_PATTERN = "-";
+
+        /** {@inheritDoc} */
+        @Override public int compare(String o1, String o2) {
+            if (o1.equals(o2))
+                return 0;
+
+            String[] ver1 = o1.split(DOT_PATTERN, 3);
+            String[] ver2 = o2.split(DOT_PATTERN, 3);
+
+            assert ver1.length == 3;
+            assert ver2.length == 3;
+
+            if (Integer.valueOf(ver1[0]) >= Integer.valueOf(ver2[0]) &&
+                Integer.valueOf(ver1[1]) >= Integer.valueOf(ver2[1]) &&
+                Integer.valueOf(ver1[2].split(DASH_PATTERN)[0]) >= Integer.valueOf(ver2[2].split(DASH_PATTERN)[0]))
+
+                return 1;
+            else
+                return -1;
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a8ac4438/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/HttpIgniteUpdatesChecker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/HttpIgniteUpdatesChecker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/HttpIgniteUpdatesChecker.java
index 2b93ceb..5d6732e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/HttpIgniteUpdatesChecker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cluster/HttpIgniteUpdatesChecker.java
@@ -21,7 +21,6 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.OutputStream;
 import java.net.URL;
 import java.net.URLConnection;
 
@@ -32,6 +31,9 @@ public class HttpIgniteUpdatesChecker {
     /** Url for request updates. */
     private final String url;
 
+    /** Params. */
+    private final String params;
+
     /** Charset for encoding requests/responses */
     private final String charset;
 
@@ -40,43 +42,38 @@ public class HttpIgniteUpdatesChecker {
      * @param url URL for getting Ignite updates information
      * @param charset Charset for encoding
      */
-    HttpIgniteUpdatesChecker(String url, String charset) {
+    HttpIgniteUpdatesChecker(String url, String params, String charset) {
         this.url = url;
+        this.params = params;
         this.charset = charset;
     }
 
     /**
      * Gets information about Ignite updates via HTTP
-     * @param updateRequest HTTP Request parameters
      * @return Information about Ignite updates separated by line endings
      * @throws IOException If HTTP request was failed
      */
-    public String getUpdates(String updateRequest) throws IOException {
-        URLConnection conn = new URL(url).openConnection();
-        conn.setDoOutput(true);
+    public String getUpdates(boolean first) throws IOException {
+        String addr = first ? url + params : url;
+
+        URLConnection conn = new URL(addr).openConnection();
         conn.setRequestProperty("Accept-Charset", charset);
-        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=" + charset);
 
         conn.setConnectTimeout(3000);
         conn.setReadTimeout(3000);
 
-        try (OutputStream os = conn.getOutputStream()) {
-            os.write(updateRequest.getBytes(charset));
-        }
-
         try (InputStream in = conn.getInputStream()) {
             if (in == null)
                 return null;
 
             BufferedReader reader = new BufferedReader(new InputStreamReader(in, charset));
 
-            StringBuilder response = new StringBuilder();
+            StringBuilder res = new StringBuilder();
 
-            for (String line; (line = reader.readLine()) != null; ) {
-                response.append(line).append('\n');
-            }
+            for (String line; (line = reader.readLine()) != null; )
+                res.append(line).append('\n');
 
-            return response.toString();
+            return res.toString();
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a8ac4438/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
index 1a20f26..f295b2b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cluster/GridUpdateNotifierSelfTest.java
@@ -17,19 +17,13 @@
 
 package org.apache.ignite.internal.processors.cluster;
 
-import java.util.Collections;
 import java.util.Properties;
 import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.GridKernalGateway;
-import org.apache.ignite.internal.GridKernalState;
 import org.apache.ignite.internal.IgniteProperties;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.lang.IgniteProductVersion;
-import org.apache.ignite.plugin.PluginProvider;
 import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.apache.ignite.testframework.junits.common.GridCommonTest;
-import org.mockito.Matchers;
 import org.mockito.Mockito;
 
 /**
@@ -78,13 +72,12 @@ public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
         HttpIgniteUpdatesChecker updatesCheckerMock = Mockito.mock(HttpIgniteUpdatesChecker.class);
 
         // Return current node version and some other info
-        Mockito.when(updatesCheckerMock.getUpdates(Matchers.anyString()))
+        Mockito.when(updatesCheckerMock.getUpdates(true))
                 .thenReturn("meta=meta" + "\n" + "version=" + nodeVer + "\n" + "downloadUrl=url");
 
-        GridUpdateNotifier ntf = new GridUpdateNotifier(null, nodeVer,
-            TEST_GATEWAY, Collections.<PluginProvider>emptyList(), false, updatesCheckerMock);
+        GridUpdateNotifier ntf = new GridUpdateNotifier(null, nodeVer, false, updatesCheckerMock);
 
-        ntf.checkForNewVersion(log);
+        ntf.checkForNewVersion(log, true);
 
         String ver = ntf.latestVersion();
 
@@ -108,41 +101,4 @@ public class GridUpdateNotifierSelfTest extends GridCommonAbstractTest {
 
         ntf.reportStatus(log);
     }
-
-    /**
-     * Test kernal gateway that always return uninitialized user stack trace.
-     */
-    private static final GridKernalGateway TEST_GATEWAY = new GridKernalGateway() {
-        @Override public void readLock() throws IllegalStateException {}
-
-        @Override public void readLockAnyway() {}
-
-        @Override public void setState(GridKernalState state) {}
-
-        @Override public GridKernalState getState() {
-            return null;
-        }
-
-        @Override public void readUnlock() {}
-
-        @Override public void writeLock() {}
-
-        @Override public void writeUnlock() {}
-
-        @Override public String userStackTrace() {
-            return null;
-        }
-
-        @Override public boolean tryWriteLock(long timeout) {
-            return false;
-        }
-
-        @Override public GridFutureAdapter<?> onDisconnected() {
-            return null;
-        }
-
-        @Override public void onReconnected() {
-            // No-op.
-        }
-    };
 }


[06/15] ignite git commit: IGNITE-6397 .NET thin client: basic cache operations. This closes #2725.

Posted by sb...@apache.org.
IGNITE-6397 .NET thin client: basic cache operations. This closes #2725.


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

Branch: refs/heads/ignite-5937
Commit: 97b91e9c18ef89feef8ecc68f3d26f5e3727eff6
Parents: 218416c
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Oct 9 17:33:46 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Oct 9 17:33:46 2017 +0300

----------------------------------------------------------------------
 .../platform/client/ClientIntResponse.java      |  46 ++
 .../platform/client/ClientLongResponse.java     |  46 ++
 .../platform/client/ClientMessageParser.java    | 133 ++++
 .../cache/ClientCacheClearKeyRequest.java       |  44 ++
 .../cache/ClientCacheClearKeysRequest.java      |  44 ++
 .../client/cache/ClientCacheClearRequest.java   |  44 ++
 .../cache/ClientCacheContainsKeyRequest.java    |  45 ++
 .../cache/ClientCacheContainsKeysRequest.java   |  45 ++
 .../client/cache/ClientCacheGetAllRequest.java  |  46 ++
 .../client/cache/ClientCacheGetAllResponse.java |  57 ++
 .../ClientCacheGetAndPutIfAbsentRequest.java    |  45 ++
 .../cache/ClientCacheGetAndPutRequest.java      |  45 ++
 .../cache/ClientCacheGetAndRemoveRequest.java   |  45 ++
 .../cache/ClientCacheGetAndReplaceRequest.java  |  45 ++
 .../client/cache/ClientCacheGetRequest.java     |   9 +-
 .../client/cache/ClientCacheGetSizeRequest.java |  57 ++
 .../client/cache/ClientCacheKeyRequest.java     |  48 ++
 .../cache/ClientCacheKeyValueRequest.java       |  48 ++
 .../client/cache/ClientCacheKeysRequest.java    |  68 +++
 .../client/cache/ClientCachePutAllRequest.java  |  57 ++
 .../cache/ClientCachePutIfAbsentRequest.java    |  45 ++
 .../client/cache/ClientCachePutRequest.java     |  13 +-
 .../cache/ClientCacheRemoveAllRequest.java      |  44 ++
 .../cache/ClientCacheRemoveIfEqualsRequest.java |  45 ++
 .../cache/ClientCacheRemoveKeyRequest.java      |  45 ++
 .../cache/ClientCacheRemoveKeysRequest.java     |  44 ++
 .../ClientCacheReplaceIfEqualsRequest.java      |  50 ++
 .../client/cache/ClientCacheReplaceRequest.java |  45 ++
 .../client/cache/ClientCacheRequest.java        |   2 +-
 .../Client/Cache/CacheTest.cs                   | 611 ++++++++++++++++++-
 .../Client/Cache/CacheTestNoMeta.cs             |   4 +-
 .../Client/ClientTestBase.cs                    |   9 +
 .../Client/Cache/ICacheClient.cs                | 155 +++++
 .../Client/IgniteClientException.cs             |   8 +
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  24 +-
 .../Impl/Client/Cache/CacheClient.cs            | 260 +++++++-
 .../Apache.Ignite.Core/Impl/Client/ClientOp.cs  |  21 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  21 +
 38 files changed, 2418 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java
new file mode 100644
index 0000000..b8debf1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientIntResponse.java
@@ -0,0 +1,46 @@
+/*
+ * 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.processors.platform.client;
+
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+
+/**
+ * Int response.
+ */
+public class ClientIntResponse extends ClientResponse {
+    /** */
+    private final int val;
+
+    /**
+     * Constructor.
+     *
+     * @param reqId Request id.
+     */
+    public ClientIntResponse(long reqId, int val) {
+        super(reqId);
+
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void encode(BinaryRawWriterEx writer) {
+        super.encode(writer);
+
+        writer.writeInt(val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java
new file mode 100644
index 0000000..a116157
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientLongResponse.java
@@ -0,0 +1,46 @@
+/*
+ * 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.processors.platform.client;
+
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+
+/**
+ * Long response.
+ */
+public class ClientLongResponse extends ClientResponse {
+    /** */
+    private final long val;
+
+    /**
+     * Constructor.
+     *
+     * @param reqId Request id.
+     */
+    public ClientLongResponse(long reqId, long val) {
+        super(reqId);
+
+        this.val = val;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void encode(BinaryRawWriterEx writer) {
+        super.encode(writer);
+
+        writer.writeLong(val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
index 84d3eee..f0f0f4c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
@@ -32,8 +32,27 @@ import org.apache.ignite.internal.processors.platform.client.binary.ClientBinary
 import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeNameGetRequest;
 import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypeNamePutRequest;
 import org.apache.ignite.internal.processors.platform.client.binary.ClientBinaryTypePutRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearKeyRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearKeysRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheClearRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheContainsKeyRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheContainsKeysRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAllRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndPutIfAbsentRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndPutRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndRemoveRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetAndReplaceRequest;
 import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheGetSizeRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutAllRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutIfAbsentRequest;
 import org.apache.ignite.internal.processors.platform.client.cache.ClientCachePutRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveIfEqualsRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveAllRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveKeysRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheRemoveKeyRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheReplaceIfEqualsRequest;
+import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheReplaceRequest;
 import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheScanQueryNextPageRequest;
 import org.apache.ignite.internal.processors.platform.client.cache.ClientCacheScanQueryRequest;
 
@@ -68,6 +87,63 @@ public class ClientMessageParser implements ClientListenerMessageParser {
     /** */
     private static final short OP_RESOURCE_CLOSE = 9;
 
+    /** */
+    private static final short OP_CACHE_CONTAINS_KEY = 10;
+
+    /** */
+    private static final short OP_CACHE_CONTAINS_KEYS = 11;
+
+    /** */
+    private static final short OP_CACHE_GET_ALL = 12;
+
+    /** */
+    private static final short OP_CACHE_GET_AND_PUT = 13;
+
+    /** */
+    private static final short OP_CACHE_GET_AND_REPLACE = 14;
+
+    /** */
+    private static final short OP_CACHE_GET_AND_REMOVE = 15;
+
+    /** */
+    private static final short OP_CACHE_PUT_IF_ABSENT = 16;
+
+    /** */
+    private static final short OP_CACHE_GET_AND_PUT_IF_ABSENT = 17;
+
+    /** */
+    private static final short OP_CACHE_REPLACE = 18;
+
+    /** */
+    private static final short OP_CACHE_REPLACE_IF_EQUALS = 19;
+
+    /** */
+    private static final short OP_CACHE_PUT_ALL = 20;
+
+    /** */
+    private static final short OP_CACHE_CLEAR = 21;
+
+    /** */
+    private static final short OP_CACHE_CLEAR_KEY = 22;
+
+    /** */
+    private static final short OP_CACHE_CLEAR_KEYS = 23;
+
+    /** */
+    private static final short OP_CACHE_REMOVE_KEY = 24;
+
+    /** */
+    private static final short OP_CACHE_REMOVE_IF_EQUALS = 25;
+
+    /** */
+    private static final short OP_CACHE_GET_SIZE = 26;
+
+    /** */
+    private static final short OP_CACHE_REMOVE_KEYS = 27;
+
+    /** */
+    private static final short OP_CACHE_REMOVE_ALL = 28;
+
     /** Marshaller. */
     private final GridBinaryMarshaller marsh;
 
@@ -129,6 +205,63 @@ public class ClientMessageParser implements ClientListenerMessageParser {
 
             case OP_RESOURCE_CLOSE:
                 return new ClientResourceCloseRequest(reader);
+
+            case OP_CACHE_CONTAINS_KEY:
+                return new ClientCacheContainsKeyRequest(reader);
+
+            case OP_CACHE_CONTAINS_KEYS:
+                return new ClientCacheContainsKeysRequest(reader);
+
+            case OP_CACHE_GET_ALL:
+                return new ClientCacheGetAllRequest(reader);
+
+            case OP_CACHE_GET_AND_PUT:
+                return new ClientCacheGetAndPutRequest(reader);
+
+            case OP_CACHE_GET_AND_REPLACE:
+                return new ClientCacheGetAndReplaceRequest(reader);
+
+            case OP_CACHE_GET_AND_REMOVE:
+                return new ClientCacheGetAndRemoveRequest(reader);
+
+            case OP_CACHE_PUT_IF_ABSENT:
+                return new ClientCachePutIfAbsentRequest(reader);
+
+            case OP_CACHE_GET_AND_PUT_IF_ABSENT:
+                return new ClientCacheGetAndPutIfAbsentRequest(reader);
+
+            case OP_CACHE_REPLACE:
+                return new ClientCacheReplaceRequest(reader);
+
+            case OP_CACHE_REPLACE_IF_EQUALS:
+                return new ClientCacheReplaceIfEqualsRequest(reader);
+
+            case OP_CACHE_PUT_ALL:
+                return new ClientCachePutAllRequest(reader);
+
+            case OP_CACHE_CLEAR:
+                return new ClientCacheClearRequest(reader);
+
+            case OP_CACHE_CLEAR_KEY:
+                return new ClientCacheClearKeyRequest(reader);
+
+            case OP_CACHE_CLEAR_KEYS:
+                return new ClientCacheClearKeysRequest(reader);
+
+            case OP_CACHE_REMOVE_KEY:
+                return new ClientCacheRemoveKeyRequest(reader);
+
+            case OP_CACHE_REMOVE_IF_EQUALS:
+                return new ClientCacheRemoveIfEqualsRequest(reader);
+
+            case OP_CACHE_GET_SIZE:
+                return new ClientCacheGetSizeRequest(reader);
+
+            case OP_CACHE_REMOVE_KEYS:
+                return new ClientCacheRemoveKeysRequest(reader);
+
+            case OP_CACHE_REMOVE_ALL:
+                return new ClientCacheRemoveAllRequest(reader);
         }
 
         return new ClientRawRequest(reader.readLong(), ClientStatus.INVALID_OP_CODE,

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java
new file mode 100644
index 0000000..6bcbbe8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeyRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Clear key request.
+ */
+public class ClientCacheClearKeyRequest extends ClientCacheKeyRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheClearKeyRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).clear(key());
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java
new file mode 100644
index 0000000..04eb7f6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearKeysRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Clear keys request.
+ */
+public class ClientCacheClearKeysRequest extends ClientCacheKeysRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheClearKeysRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).clearAll(keys());
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java
new file mode 100644
index 0000000..0e5f20d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheClearRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache clear request.
+ */
+public class ClientCacheClearRequest extends ClientCacheRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheClearRequest(BinaryRawReader reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).clear();
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java
new file mode 100644
index 0000000..8470828
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeyRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * ContainsKey request.
+ */
+public class ClientCacheContainsKeyRequest extends ClientCacheKeyRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheContainsKeyRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean val = cache(ctx).containsKey(key());
+
+        return new ClientBooleanResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java
new file mode 100644
index 0000000..41e1306
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheContainsKeysRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * ContainsKeys request.
+ */
+public class ClientCacheContainsKeysRequest extends ClientCacheKeysRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheContainsKeysRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean val = cache(ctx).containsKeys(keys());
+
+        return new ClientBooleanResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java
new file mode 100644
index 0000000..2b33af1
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllRequest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+import java.util.Map;
+
+/**
+ * GetAll request.
+ */
+public class ClientCacheGetAllRequest extends ClientCacheKeysRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetAllRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        Map val = cache(ctx).getAll(keys());
+
+        return new ClientCacheGetAllResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java
new file mode 100644
index 0000000..2ee2d5b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAllResponse.java
@@ -0,0 +1,57 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+import java.util.Map;
+
+/**
+ * GetAll response.
+ */
+class ClientCacheGetAllResponse extends ClientResponse {
+    /** Result. */
+    private final Map<Object, Object> res;
+
+    /**
+     * Ctor.
+     *
+     * @param requestId Request id.
+     * @param res Result.
+     */
+    ClientCacheGetAllResponse(long requestId, Map<Object, Object> res) {
+        super(requestId);
+
+        assert res != null;
+
+        this.res = res;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void encode(BinaryRawWriterEx writer) {
+        super.encode(writer);
+
+        writer.writeInt(res.size());
+
+        for (Map.Entry e : res.entrySet()) {
+            writer.writeObjectDetached(e.getKey());
+            writer.writeObjectDetached(e.getValue());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java
new file mode 100644
index 0000000..8360213
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutIfAbsentRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache get and put if absent request.
+ */
+public class ClientCacheGetAndPutIfAbsentRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetAndPutIfAbsentRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        Object res = cache(ctx).getAndPutIfAbsent(key(), val());
+
+        return new ClientObjectResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java
new file mode 100644
index 0000000..7a540e8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndPutRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache get and put request.
+ */
+public class ClientCacheGetAndPutRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetAndPutRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        Object res = cache(ctx).getAndPut(key(), val());
+
+        return new ClientObjectResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java
new file mode 100644
index 0000000..e4fd735
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndRemoveRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache get and remove request.
+ */
+public class ClientCacheGetAndRemoveRequest extends ClientCacheKeyRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetAndRemoveRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        Object val = cache(ctx).getAndRemove(key());
+
+        return new ClientObjectResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java
new file mode 100644
index 0000000..dba8639
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetAndReplaceRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache get and replace request.
+ */
+public class ClientCacheGetAndReplaceRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetAndReplaceRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        Object res = cache(ctx).getAndReplace(key(), val());
+
+        return new ClientObjectResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java
index e2d261a..41558c2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetRequest.java
@@ -25,10 +25,7 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse;
 /**
  * Cache get request.
  */
-public class ClientCacheGetRequest extends ClientCacheRequest {
-    /** Key. */
-    private final Object key;
-
+public class ClientCacheGetRequest extends ClientCacheKeyRequest {
     /**
      * Constructor.
      *
@@ -36,14 +33,12 @@ public class ClientCacheGetRequest extends ClientCacheRequest {
      */
     public ClientCacheGetRequest(BinaryRawReaderEx reader) {
         super(reader);
-
-        key = reader.readObjectDetached();
     }
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public ClientResponse process(ClientConnectionContext ctx) {
-        Object val = cache(ctx).get(key);
+        Object val = cache(ctx).get(key());
 
         return new ClientObjectResponse(requestId(), val);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java
new file mode 100644
index 0000000..ba185bf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheGetSizeRequest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientLongResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache size request.
+ */
+public class ClientCacheGetSizeRequest extends ClientCacheRequest {
+    /** Peek modes. */
+    private final CachePeekMode[] modes;
+
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheGetSizeRequest(BinaryRawReader reader) {
+        super(reader);
+
+        int cnt = reader.readInt();
+
+        modes = new CachePeekMode[cnt];
+
+        for (int i = 0; i < cnt; i++) {
+            modes[i] = CachePeekMode.fromOrdinal(reader.readByte());
+        }
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        long res = cache(ctx).sizeLong(modes);
+
+        return new ClientLongResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java
new file mode 100644
index 0000000..e888236
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyRequest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+
+/**
+ * Cache request involving key.
+ */
+public abstract class ClientCacheKeyRequest extends ClientCacheRequest {
+    /** Key. */
+    private final Object key;
+
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    ClientCacheKeyRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        key = reader.readObjectDetached();
+    }
+
+    /**
+     * Gets the key.
+     *
+     * @return Key.
+     */
+    public Object key() {
+        return key;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java
new file mode 100644
index 0000000..03b85d6
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeyValueRequest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+
+/**
+ * Cache request involving key and value.
+ */
+public class ClientCacheKeyValueRequest extends ClientCacheKeyRequest {
+    /** Value. */
+    private final Object val;
+
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    ClientCacheKeyValueRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        val = reader.readObjectDetached();
+    }
+
+    /**
+     * Gets the value.
+     *
+     * @return Value.
+     */
+    public Object val() {
+        return val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java
new file mode 100644
index 0000000..526ee5b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheKeysRequest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Key set request.
+ */
+public class ClientCacheKeysRequest extends ClientCacheRequest {
+    /** Keys. */
+    private final Set<Object> keys;
+
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    ClientCacheKeysRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        keys = readSet(reader);
+    }
+
+    /**
+     * Gets the set of keys.
+     *
+     * @return Keys.
+     */
+    public Set<Object> keys() {
+        return keys;
+    }
+
+    /**
+     * Reads a set of objects.
+     *
+     * @param reader Reader.
+     * @return Set of objects.
+     */
+    private static Set<Object> readSet(BinaryRawReaderEx reader) {
+        int cnt = reader.readInt();
+
+        Set<Object> keys = new LinkedHashSet<>(cnt);
+
+        for (int i = 0; i < cnt; i++)
+            keys.add(reader.readObjectDetached());
+
+        return keys;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java
new file mode 100644
index 0000000..28a7fa5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutAllRequest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * PutAll request.
+ */
+public class ClientCachePutAllRequest extends ClientCacheRequest {
+    /** Map. */
+    private final Map<Object, Object> map;
+
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCachePutAllRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        int cnt = reader.readInt();
+
+        map = new LinkedHashMap<>(cnt);
+
+        for (int i = 0; i < cnt; i++)
+            map.put(reader.readObjectDetached(), reader.readObjectDetached());
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).putAll(map);
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java
new file mode 100644
index 0000000..4dd2cde
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutIfAbsentRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache put if absent request.
+ */
+public class ClientCachePutIfAbsentRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCachePutIfAbsentRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean res = cache(ctx).putIfAbsent(key(), val());
+
+        return new ClientBooleanResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
index 04e3961..94c2b25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCachePutRequest.java
@@ -24,13 +24,7 @@ import org.apache.ignite.internal.processors.platform.client.ClientResponse;
 /**
  * Cache put request.
  */
-public class ClientCachePutRequest extends ClientCacheRequest {
-    /** Key. */
-    private final Object key;
-
-    /** Value. */
-    private final Object val;
-
+public class ClientCachePutRequest extends ClientCacheKeyValueRequest {
     /**
      * Ctor.
      *
@@ -38,15 +32,12 @@ public class ClientCachePutRequest extends ClientCacheRequest {
      */
     public ClientCachePutRequest(BinaryRawReaderEx reader) {
         super(reader);
-
-        key = reader.readObjectDetached();
-        val = reader.readObjectDetached();
     }
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public ClientResponse process(ClientConnectionContext ctx) {
-        cache(ctx).put(key, val);
+        cache(ctx).put(key(), val());
 
         return super.process(ctx);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java
new file mode 100644
index 0000000..f5adc63
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveAllRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache removeAll request.
+ */
+public class ClientCacheRemoveAllRequest extends ClientCacheRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheRemoveAllRequest(BinaryRawReader reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).removeAll();
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java
new file mode 100644
index 0000000..b86f2f8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveIfEqualsRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache remove request with value.
+ */
+public class ClientCacheRemoveIfEqualsRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheRemoveIfEqualsRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean res = cache(ctx).remove(key(), val());
+
+        return new ClientBooleanResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java
new file mode 100644
index 0000000..a68c327
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeyRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Remove request.
+ */
+public class ClientCacheRemoveKeyRequest extends ClientCacheKeyRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheRemoveKeyRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean val = cache(ctx).remove(key());
+
+        return new ClientBooleanResponse(requestId(), val);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java
new file mode 100644
index 0000000..043b568
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRemoveKeysRequest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Remove keys request.
+ */
+public class ClientCacheRemoveKeysRequest extends ClientCacheKeysRequest {
+    /**
+     * Constructor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheRemoveKeysRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        cache(ctx).removeAll(keys());
+
+        return super.process(ctx);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java
new file mode 100644
index 0000000..8645fbb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceIfEqualsRequest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache replace request.
+ */
+public class ClientCacheReplaceIfEqualsRequest extends ClientCacheKeyValueRequest {
+    /** New value. */
+    private final Object newVal;
+
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheReplaceIfEqualsRequest(BinaryRawReaderEx reader) {
+        super(reader);
+
+        newVal = reader.readObjectDetached();
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean res = cache(ctx).replace(key(), val(), newVal);
+
+        return new ClientBooleanResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java
new file mode 100644
index 0000000..bd7a642
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheReplaceRequest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.processors.platform.client.cache;
+
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.processors.platform.client.ClientBooleanResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+/**
+ * Cache replace request.
+ */
+public class ClientCacheReplaceRequest extends ClientCacheKeyValueRequest {
+    /**
+     * Ctor.
+     *
+     * @param reader Reader.
+     */
+    public ClientCacheReplaceRequest(BinaryRawReaderEx reader) {
+        super(reader);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public ClientResponse process(ClientConnectionContext ctx) {
+        boolean res = cache(ctx).replace(key(), val());
+
+        return new ClientBooleanResponse(requestId(), res);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
index 8f81e94..1aaa22c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cache/ClientCacheRequest.java
@@ -21,9 +21,9 @@ import org.apache.ignite.IgniteCache;
 import org.apache.ignite.binary.BinaryRawReader;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
-import org.apache.ignite.internal.processors.platform.client.IgniteClientException;
 import org.apache.ignite.internal.processors.platform.client.ClientRequest;
 import org.apache.ignite.internal.processors.platform.client.ClientStatus;
+import org.apache.ignite.internal.processors.platform.client.IgniteClientException;
 
 /**
  * Cache get request.


[03/15] ignite git commit: IGNITE-6287 Web Console: Improved DDL support: added checkbox "Use selected cache as default schema name".

Posted by sb...@apache.org.
IGNITE-6287 Web Console: Improved DDL support: added checkbox "Use selected cache as default schema name".


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

Branch: refs/heads/ignite-5937
Commit: a45677cf0b6b6ffa524fc10932c002d3b879f943
Parents: dc514c7
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Mon Oct 9 19:23:23 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Oct 9 19:23:23 2017 +0700

----------------------------------------------------------------------
 .../ignite/internal/visor/query/VisorQueryTask.java  | 15 +--------------
 modules/web-console/backend/app/mongo.js             |  1 +
 .../frontend/app/modules/sql/sql.controller.js       | 14 +++++++++++++-
 .../frontend/public/stylesheets/style.scss           |  8 ++++++++
 modules/web-console/frontend/views/sql/sql.tpl.pug   | 10 ++++++++++
 5 files changed, 33 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a45677cf/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
index a3668c8..933bacc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/query/VisorQueryTask.java
@@ -99,20 +99,7 @@ public class VisorQueryTask extends VisorOneNodeTask<VisorQueryTaskArg, VisorEit
                     if (c == null)
                         throw new SQLException("Fail to execute query. Cache not found: " + cacheName);
 
-                    try {
-                        qryCursor = c.withKeepBinary().query(qry);
-                    }
-                    catch (CacheException e) {
-                        // Work around for DDL without explicit schema name.
-                        if (X.hasCause(e, IgniteSQLException.class)
-                            && e.getMessage().contains("can only be executed on PUBLIC schema")) {
-                            qry.setSchema("PUBLIC");
-
-                            qryCursor = c.withKeepBinary().query(qry);
-                        }
-                        else
-                            throw e;
-                    }
+                    qryCursor = c.withKeepBinary().query(qry);
                 }
 
                 VisorQueryCursor<List<?>> cur = new VisorQueryCursor<>(qryCursor);

http://git-wip-us.apache.org/repos/asf/ignite/blob/a45677cf/modules/web-console/backend/app/mongo.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/app/mongo.js b/modules/web-console/backend/app/mongo.js
index ecc833f..a07f979 100644
--- a/modules/web-console/backend/app/mongo.js
+++ b/modules/web-console/backend/app/mongo.js
@@ -1036,6 +1036,7 @@ module.exports.factory = function(passportMongo, settings, pluginMongo, mongoose
             maxPages: Number,
             hideSystemColumns: Boolean,
             cacheName: String,
+            useAsDefaultSchema: Boolean,
             chartsOptions: {barChart: {stacked: Boolean}, areaChart: {style: String}},
             rate: {
                 value: Number,

http://git-wip-us.apache.org/repos/asf/ignite/blob/a45677cf/modules/web-console/frontend/app/modules/sql/sql.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/sql/sql.controller.js b/modules/web-console/frontend/app/modules/sql/sql.controller.js
index 8011b0f..a3fc0ca 100644
--- a/modules/web-console/frontend/app/modules/sql/sql.controller.js
+++ b/modules/web-console/frontend/app/modules/sql/sql.controller.js
@@ -32,6 +32,8 @@ const ENFORCE_JOIN_SINCE = [['1.7.9', '1.8.0'], ['1.8.4', '1.9.0'], '1.9.1'];
 
 const LAZY_QUERY_SINCE = [['2.1.4-p1', '2.2.0'], '2.2.1'];
 
+const DDL_SINCE = [['2.1.6', '2.2.0'], '2.3.0'];
+
 const _fullColName = (col) => {
     const res = [];
 
@@ -56,6 +58,7 @@ class Paragraph {
         self.qryType = paragraph.qryType || 'query';
         self.maxPages = 0;
         self.filter = '';
+        self.useAsDefaultSchema = false;
 
         _.assign(this, paragraph);
 
@@ -1381,6 +1384,15 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
             return false;
         };
 
+        $scope.ddlAvailable = (paragraph) => {
+            const cache = _.find($scope.caches, {name: paragraph.cacheName});
+
+            if (cache)
+                return !!_.find(cache.nodes, (node) => Version.since(node.version, ...DDL_SINCE));
+
+            return false;
+        };
+
         $scope.execute = (paragraph, local = false) => {
             const nonCollocatedJoins = !!paragraph.nonCollocatedJoins;
             const enforceJoinOrder = !!paragraph.enforceJoinOrder;
@@ -1399,7 +1411,7 @@ export default ['$rootScope', '$scope', '$http', '$q', '$timeout', '$interval',
                         .then(() => {
                             const args = paragraph.queryArgs = {
                                 type: 'QUERY',
-                                cacheName: paragraph.cacheName,
+                                cacheName: ($scope.ddlAvailable(paragraph) && !paragraph.useAsDefaultSchema) ? null : paragraph.cacheName,
                                 query: paragraph.query,
                                 pageSize: paragraph.pageSize,
                                 maxPages: paragraph.maxPages,

http://git-wip-us.apache.org/repos/asf/ignite/blob/a45677cf/modules/web-console/frontend/public/stylesheets/style.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/stylesheets/style.scss b/modules/web-console/frontend/public/stylesheets/style.scss
index eeb3a55..b259f1d 100644
--- a/modules/web-console/frontend/public/stylesheets/style.scss
+++ b/modules/web-console/frontend/public/stylesheets/style.scss
@@ -304,6 +304,14 @@ body > .wrapper > ui-view {
     }
 }
 
+.use-cache {
+    display: flex;
+
+    input[type="checkbox"] {
+        width: 20px;
+    }
+}
+
 .group-section {
     margin-top: 20px;
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a45677cf/modules/web-console/frontend/views/sql/sql.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/sql/sql.tpl.pug b/modules/web-console/frontend/views/sql/sql.tpl.pug
index 724c53c..7ee966d 100644
--- a/modules/web-console/frontend/views/sql/sql.tpl.pug
+++ b/modules/web-console/frontend/views/sql/sql.tpl.pug
@@ -240,6 +240,16 @@ mixin paragraph-query
                                 td(style='width: 100%')
                                     input.labelField(id='cache_{{ [paragraph.id, $index].join("_") }}' type='radio' value='{{cache.name}}' ng-model='paragraph.cacheName')
                                     label(for='cache_{{ [paragraph.id, $index].join("_") }} ' ng-bind-html='cache.label')
+                    .settings-row
+                        .row(ng-if='ddlAvailable(paragraph)')
+                            label.tipLabel.use-cache(bs-tooltip data-placement='bottom'
+                                data-title=
+                                    'Use selected cache as default schema name.<br/>\
+                                    This will allow to execute query on specified cache without specify schema name.<br/>\
+                                    <b>NOTE:</b> In future version of Ignite this feature will be removed.'
+                                data-trigger='hover')
+                                input(type='checkbox' ng-model='paragraph.useAsDefaultSchema')
+                                span Use selected cache as default schema name
                 .empty-caches(ng-show='displayedCaches.length == 0 && caches.length != 0')
                     label Wrong caches filter
                 .empty-caches(ng-show='caches.length == 0')


[13/15] ignite git commit: ignite-5937

Posted by sb...@apache.org.
ignite-5937


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

Branch: refs/heads/ignite-5937
Commit: 21bc6338da4e9d794e624b0c84ae5a5615f86d53
Parents: c1b2c03
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 10 13:31:40 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 10 14:41:34 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheOffheapManagerImpl.java    | 141 ++++++-----
 .../dht/preloader/GridDhtPartitionSupplier.java |  24 +-
 .../GridDhtPartitionSupplyMessage.java          |   4 +-
 .../cache/mvcc/CacheCoordinatorsProcessor.java  |  27 +-
 .../cache/mvcc/MvccCoordinatorVersion.java      |   2 +-
 .../cache/persistence/CacheDataRow.java         |   5 +
 .../cache/persistence/CacheDataRowAdapter.java  |   5 +
 .../cache/persistence/CacheSearchRow.java       |   6 +
 .../persistence/GridCacheOffheapManager.java    |   5 +
 .../processors/cache/persistence/RowStore.java  |   2 +
 .../persistence/freelist/FreeListImpl.java      |  11 +-
 .../cache/persistence/tree/io/DataPageIO.java   |  22 +-
 .../cache/tree/AbstractDataInnerIO.java         |  10 +-
 .../cache/tree/AbstractDataLeafIO.java          |  10 +-
 .../cache/tree/CacheDataRowStore.java           |  18 +-
 .../processors/cache/tree/CacheDataTree.java    |   8 +-
 .../internal/processors/cache/tree/DataRow.java |   7 +
 .../processors/cache/tree/MvccDataRow.java      |  32 ++-
 .../cache/tree/MvccKeyMaxVersionBound.java      |   9 +-
 .../processors/cache/tree/MvccRemoveRow.java    |  57 +++++
 .../processors/cache/tree/MvccUpdateRow.java    |  67 +++--
 .../cache/tree/MvccVersionBasedSearchRow.java   |  16 +-
 .../cache/mvcc/CacheMvccTransactionsTest.java   | 245 ++++++++++++++++++-
 .../database/FreeListImplSelfTest.java          |   5 +
 .../processors/query/h2/opt/GridH2Row.java      |   5 +
 25 files changed, 604 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 80d36c1..380ec94 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
 import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorVersion;
 import org.apache.ignite.internal.processors.cache.mvcc.MvccCounter;
 import org.apache.ignite.internal.processors.cache.mvcc.MvccLongList;
@@ -54,9 +55,9 @@ import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
 import org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore;
 import org.apache.ignite.internal.processors.cache.tree.CacheDataTree;
 import org.apache.ignite.internal.processors.cache.tree.DataRow;
-import org.apache.ignite.internal.processors.cache.tree.MvccDataRow;
 import org.apache.ignite.internal.processors.cache.tree.MvccKeyMaxVersionBound;
 import org.apache.ignite.internal.processors.cache.tree.MvccKeyMinVersionBound;
+import org.apache.ignite.internal.processors.cache.tree.MvccRemoveRow;
 import org.apache.ignite.internal.processors.cache.tree.MvccSearchRow;
 import org.apache.ignite.internal.processors.cache.tree.MvccUpdateRow;
 import org.apache.ignite.internal.processors.cache.tree.MvccVersionBasedSearchRow;
@@ -85,6 +86,8 @@ import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_IDX;
 import static org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
 
 /**
  *
@@ -1374,60 +1377,43 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
                 // Make sure value bytes initialized.
                 key.valueBytes(coCtx);
 
-                MvccUpdateRow updateRow = new MvccUpdateRow(
+                MvccRemoveRow updateRow = new MvccRemoveRow(
                     key,
-                    null,
-                    null,
                     mvccVer,
                     partId,
                     cacheId);
 
-                rowStore.addRow(updateRow);
-
-                assert updateRow.link() != 0 : updateRow;
-
                 if (grp.sharedGroup() && updateRow.cacheId() == CU.UNDEFINED_CACHE_ID)
                     updateRow.cacheId(cctx.cacheId());
 
-                GridLongList waitTxs = null;
+                dataTree.iterate(updateRow, new MvccKeyMinVersionBound(cacheId, key), updateRow);
 
-                if (mvccVer.initialLoad()) {
-                    boolean old = dataTree.putx(updateRow);
+                MvccUpdateRow.UpdateResult res = updateRow.updateResult();
 
-                    assert !old;
+                if (res == MvccUpdateRow.UpdateResult.VERSION_FOUND) {
+                    assert !primary : updateRow;
 
-                    incrementSize(cctx.cacheId());
+                    cleanup(updateRow.cleanupRows(), false);
                 }
                 else {
-                    dataTree.iterate(updateRow, new MvccKeyMinVersionBound(cacheId, key), updateRow);
-
-                    boolean old = dataTree.putx(updateRow);
-
-                    assert !old;
+                    if (res == MvccUpdateRow.UpdateResult.PREV_NOT_NULL)
+                        decrementSize(cacheId);
 
-                    if (!updateRow.previousNotNull())
-                        incrementSize(cctx.cacheId());
+                    CacheSearchRow rmvRow = cleanup(updateRow.cleanupRows(), true);
 
-                    waitTxs = updateRow.activeTransactions();
-
-                    List<CacheSearchRow> cleanupRows = updateRow.cleanupRows();
-
-                    if (cleanupRows != null) {
-                        for (int i = 0; i < cleanupRows.size(); i++) {
-                            CacheSearchRow oldRow = cleanupRows.get(i);
-
-                            assert oldRow.link() != 0L : oldRow;
+                    if (rmvRow == null)
+                        rowStore.addRow(updateRow);
+                    else
+                        updateRow.link(rmvRow.link());
 
-                            boolean rmvd = dataTree.removex(oldRow);
+                    assert updateRow.link() != 0L;
 
-                            assert rmvd;
+                    boolean old = dataTree.putx(updateRow);
 
-                            rowStore.removeRow(oldRow.link());
-                        }
-                    }
+                    assert !old;
                 }
 
-                return waitTxs;
+                return updateRow.activeTransactions();
             }
             finally {
                 busyLock.leaveBusy();
@@ -1464,16 +1450,14 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
                     partId,
                     cacheId);
 
-                rowStore.addRow(updateRow);
-
-                assert updateRow.link() != 0 : updateRow;
-
                 if (grp.sharedGroup() && updateRow.cacheId() == CU.UNDEFINED_CACHE_ID)
                     updateRow.cacheId(cctx.cacheId());
 
                 GridLongList waitTxs = null;
 
                 if (mvccVer.initialLoad()) {
+                    rowStore.addRow(updateRow);
+
                     boolean old = dataTree.putx(updateRow);
 
                     assert !old;
@@ -1483,30 +1467,25 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
                 else {
                     dataTree.iterate(updateRow, new MvccKeyMinVersionBound(cacheId, key), updateRow);
 
-                    boolean old = dataTree.putx(updateRow);
-
-                    assert !old;
-
-                    if (!updateRow.previousNotNull())
-                        incrementSize(cctx.cacheId());
-
-                    waitTxs = updateRow.activeTransactions();
+                    MvccUpdateRow.UpdateResult res = updateRow.updateResult();
 
-                    List<CacheSearchRow> cleanupRows = updateRow.cleanupRows();
+                    if (res == MvccUpdateRow.UpdateResult.VERSION_FOUND) {
+                        assert !primary : updateRow;
+                    }
+                    else {
+                        rowStore.addRow(updateRow);
 
-                    if (cleanupRows != null) {
-                        for (int i = 0; i < cleanupRows.size(); i++) {
-                            CacheSearchRow oldRow = cleanupRows.get(i);
+                        boolean old = dataTree.putx(updateRow);
 
-                            assert oldRow.link() != 0L : oldRow;
+                        assert !old;
 
-                            boolean rmvd = dataTree.removex(oldRow);
+                        if (res == MvccUpdateRow.UpdateResult.PREV_NULL)
+                            incrementSize(cctx.cacheId());
+                    }
 
-                            assert rmvd;
+                    cleanup(updateRow.cleanupRows(), false);
 
-                            rowStore.removeRow(oldRow.link());
-                        }
-                    }
+                    waitTxs = updateRow.activeTransactions();
                 }
 
                 return waitTxs;
@@ -1516,6 +1495,39 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
             }
         }
 
+        /**
+         * @param cleanupRows Rows to cleanup.
+         * @param findRmv {@code True} if need keep removed row entry.
+         * @return Removed row entry if found.
+         * @throws IgniteCheckedException If failed.
+         */
+        @Nullable private CacheSearchRow cleanup(@Nullable List<CacheSearchRow> cleanupRows, boolean findRmv)
+            throws IgniteCheckedException {
+            CacheSearchRow rmvRow = null;
+
+            if (cleanupRows != null) {
+                for (int i = 0; i < cleanupRows.size(); i++) {
+                    CacheSearchRow oldRow = cleanupRows.get(i);
+
+                    assert oldRow.link() != 0L : oldRow;
+
+                    boolean rmvd = dataTree.removex(oldRow);
+
+                    assert rmvd;
+
+                    if (findRmv &&
+                        rmvRow == null &&
+                        versionForRemovedValue(oldRow.mvccCoordinatorVersion())) {
+                        rmvRow = oldRow;
+                    }
+                    else
+                        rowStore.removeRow(oldRow.link());
+                }
+            }
+
+            return rmvRow;
+        }
+
         /** {@inheritDoc} */
         @Override public void update(GridCacheContext cctx,
             KeyCacheObject key,
@@ -1832,18 +1844,27 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
                     while (cur.next()) {
                         CacheDataRow row = cur.get();
 
-                        if (row.mvccCoordinatorVersion() > ver.coordinatorVersion()
-                            || row.mvccCounter() > ver.counter())
+                        long rowCrdVerMasked = row.mvccCoordinatorVersion();
+
+                        long rowCrdVer = unmaskCoordinatorVersion(rowCrdVerMasked);
+
+                        if (rowCrdVer > ver.coordinatorVersion() || row.mvccCounter() > ver.counter())
                             continue;
 
                         MvccLongList txs = ver.activeTransactions();
 
-                        if (txs != null && row.mvccCoordinatorVersion() == ver.coordinatorVersion() && txs.contains(row.mvccCounter()))
+                        if (txs != null && rowCrdVer == ver.coordinatorVersion() && txs.contains(row.mvccCounter()))
                             continue;
 
                         if (curKey != null && row.key().equals(curKey))
                             continue;
 
+                        if (CacheCoordinatorsProcessor.versionForRemovedValue(rowCrdVerMasked)) {
+                            curKey = row.key();
+
+                            continue;
+                        }
+
                         curRow = row;
 
                         break;

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index 0905917..357fef8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -31,9 +31,9 @@ import org.apache.ignite.internal.processors.cache.CacheGroupContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
 import org.apache.ignite.internal.processors.cache.GridCacheMvccEntryInfo;
 import org.apache.ignite.internal.processors.cache.IgniteRebalanceIterator;
-import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
+import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.util.lang.GridCloseableIterator;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.T3;
@@ -43,6 +43,7 @@ import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.spi.IgniteSpiException;
 
 import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
 
 /**
  * Thread pool for supplying partitions to demanding nodes.
@@ -375,13 +376,24 @@ class GridDhtPartitionSupplier {
                             GridCacheEntryInfo info = grp.mvccEnabled() ?
                                 new GridCacheMvccEntryInfo() : new GridCacheEntryInfo();
 
+
                             info.key(row.key());
-                            info.expireTime(row.expireTime());
-                            info.version(row.version());
-                            info.value(row.value());
                             info.cacheId(row.cacheId());
-                            info.mvccCoordinatorVersion(row.mvccCoordinatorVersion());
-                            info.mvccCounter(row.mvccCounter());
+
+                            boolean rmvd = false;
+
+                            if (grp.mvccEnabled()) {
+                                info.mvccCoordinatorVersion(row.mvccCoordinatorVersion());
+                                info.mvccCounter(row.mvccCounter());
+
+                                rmvd = versionForRemovedValue(row.mvccCoordinatorVersion());
+                            }
+
+                            if (!rmvd) {
+                                info.value(row.value());
+                                info.version(row.version());
+                                info.expireTime(row.expireTime());
+                            }
 
                             if (preloadPred == null || preloadPred.apply(info))
                                 s.addEntry0(part, info, grp.shared(), grp.cacheObjectContext());

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
index 90d11f5..6675f8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
@@ -42,6 +42,8 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemTy
 import org.apache.ignite.plugin.extensions.communication.MessageReader;
 import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
+
 /**
  * Partition supply message.
  */
@@ -217,7 +219,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheGroupIdMessage imple
     void addEntry0(int p, GridCacheEntryInfo info, GridCacheSharedContext ctx, CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
         assert info != null;
         assert info.key() != null : info;
-        assert info.value() != null : info;
+        assert info.value() != null || versionForRemovedValue(info.coordinatorVersion()): info;
 
         // Need to call this method to initialize info properly.
         marshalInfo(info, ctx, cacheObjCtx);

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsProcessor.java
index 54fb3c8..9f9a7a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/CacheCoordinatorsProcessor.java
@@ -146,21 +146,30 @@ public class CacheCoordinatorsProcessor extends GridProcessorAdapter {
         super(ctx);
     }
 
-    public static int compareCoordinatorVersions(long crdVer1, long crdVer2) {
-        crdVer1 = CRD_VER_MASK & crdVer1;
-        crdVer2 = CRD_VER_MASK & crdVer2;
-
-        return Long.compare(crdVer1, crdVer2);
-    }
-
-    public long createVersionForRemovedValue(long crdVer) {
+    /**
+     * @param crdVer Coordinator version.
+     * @return Coordinator version with removed value flag.
+     */
+    public static long createVersionForRemovedValue(long crdVer) {
         return crdVer | RMVD_VAL_VER_MASK;
     }
 
-    public boolean versionForRemovedValue(long crdVer) {
+    /**
+     * @param crdVer Coordinator version with flags.
+     * @return {@code True} if removed value flag is set.
+     */
+    public static boolean versionForRemovedValue(long crdVer) {
         return (crdVer & RMVD_VAL_VER_MASK) != 0;
     }
 
+    /**
+     * @param crdVer Coordinator version with flags.
+     * @return Coordinator version.
+     */
+    public static long unmaskCoordinatorVersion(long crdVer) {
+        return crdVer & CRD_VER_MASK;
+    }
+
     /** {@inheritDoc} */
     @Override public void start() throws IgniteCheckedException {
         statCntrs = new StatCounter[7];

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
index a0fd5ee..4003b73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
@@ -44,7 +44,7 @@ public interface MvccCoordinatorVersion extends Message {
     public long counter();
 
     /**
-     *
+     * @return {@code True} if version for initial load update.
      */
     public boolean initialLoad();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
index 57aeaef..b76826f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRow.java
@@ -54,4 +54,9 @@ public interface CacheDataRow extends CacheSearchRow {
      * @param key Key.
      */
     public void key(KeyCacheObject key);
+
+    /**
+     * @return {@code True} if this is row for cache remove operation (used only with mvcc).
+     */
+    public boolean removed();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
index 925431f..d0f2dab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheDataRowAdapter.java
@@ -582,6 +582,11 @@ public class CacheDataRowAdapter implements CacheDataRow {
         return 0;
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean removed() {
+        return false;
+    }
+
     /**
      *
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
index 5bf53d8..efdc08f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/CacheSearchRow.java
@@ -43,7 +43,13 @@ public interface CacheSearchRow {
      */
     public int cacheId();
 
+    /**
+     * @return Mvcc coordinator version.
+     */
     public long mvccCoordinatorVersion();
 
+    /**
+     * @return Mvcc counter.
+     */
     public long mvccCounter();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index 1f52309..ee651c2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -837,6 +837,11 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple
         @Override public long mvccCoordinatorVersion() {
             return 0; // TODO IGNITE-3478.
         }
+
+        /** {@inheritDoc} */
+        @Override public boolean removed() {
+            return false;  // TODO IGNITE-3478.
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java
index 9cc5c62..41d2c4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/RowStore.java
@@ -82,6 +82,8 @@ public class RowStore {
 
         try {
             freeList.insertDataRow(row);
+
+            assert row.link() != 0L;
         }
         finally {
             ctx.database().checkpointReadUnlock();

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
index 3eb62ae..9bd27b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/FreeListImpl.java
@@ -590,12 +590,19 @@ public class FreeListImpl extends PagesList implements FreeList, ReuseList {
      */
     public static int getRowSize(CacheDataRow row, boolean withCacheId) throws IgniteCheckedException {
         KeyCacheObject key = row.key();
-        CacheObject val = row.value();
 
         int keyLen = key.valueBytesLength(null);
+
+        int len = keyLen + (withCacheId ? 4 : 0);
+
+        if (row.removed())
+            return len;
+
+        CacheObject val = row.value();
+
         int valLen = val.valueBytesLength(null);
 
-        return keyLen + valLen + CacheVersionIO.size(row.version(), false) + 8 + (withCacheId ? 4 : 0);
+        return len + valLen + CacheVersionIO.size(row.version(), false) + 8;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
index 628ff38..da012e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/tree/io/DataPageIO.java
@@ -1040,13 +1040,19 @@ public class DataPageIO extends PageIO {
         final int payloadSize
     ) throws IgniteCheckedException {
         final int keySize = row.key().valueBytesLength(null);
-        final int valSize = row.value().valueBytesLength(null);
+
+        boolean rmvd = row.removed();
+
+        final int valSize = rmvd ? 0 : row.value().valueBytesLength(null);
 
         int written = writeFragment(row, buf, rowOff, payloadSize, EntryPart.CACHE_ID, keySize, valSize);
         written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.KEY, keySize, valSize);
-        written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.EXPIRE_TIME, keySize, valSize);
-        written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.VALUE, keySize, valSize);
-        written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.VERSION, keySize, valSize);
+
+        if (!rmvd) {
+            written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.EXPIRE_TIME, keySize, valSize);
+            written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.VALUE, keySize, valSize);
+            written += writeFragment(row, buf, rowOff + written, payloadSize - written, EntryPart.VERSION, keySize, valSize);
+        }
 
         assert written == payloadSize;
     }
@@ -1414,9 +1420,15 @@ public class DataPageIO extends PageIO {
             }
 
             addr += row.key().putValue(addr);
+
+            if (row.removed())
+                return;
         }
-        else
+        else {
+            assert !row.removed() : row;
+
             addr += (2 + cacheIdSize + row.key().valueBytesLength(null));
+        }
 
         addr += row.value().putValue(addr);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java
index a07d012..fc82cbb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataInnerIO.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.tree;
 
 import org.apache.ignite.internal.pagemem.PageUtils;
-import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
 import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter;
 import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow;
 import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
@@ -27,6 +26,9 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusInne
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.lang.IgniteInClosure;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.COUNTER_NA;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+
 /**
  *
  */
@@ -59,8 +61,8 @@ public abstract class AbstractDataInnerIO extends BPlusInnerIO<CacheSearchRow> i
         }
 
         if (storeMvccVersion()) {
-            assert row.mvccCoordinatorVersion() > 0 : row;
-            assert row.mvccCounter() != CacheCoordinatorsProcessor.COUNTER_NA : row;
+            assert unmaskCoordinatorVersion(row.mvccCoordinatorVersion()) > 0 : row;
+            assert row.mvccCounter() != COUNTER_NA : row;
 
             PageUtils.putLong(pageAddr, off, row.mvccCoordinatorVersion());
             off += 8;
@@ -123,7 +125,7 @@ public abstract class AbstractDataInnerIO extends BPlusInnerIO<CacheSearchRow> i
             long mvcCntr = rowIo.getMvccCounter(srcPageAddr, srcIdx);
 
             assert mvccTopVer > 0 : mvccTopVer;
-            assert mvcCntr != CacheCoordinatorsProcessor.COUNTER_NA;
+            assert mvcCntr != COUNTER_NA;
 
             PageUtils.putLong(dstPageAddr, off, mvccTopVer);
             off += 8;

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java
index ef08bec..c956d22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/AbstractDataLeafIO.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.tree;
 
 import org.apache.ignite.internal.pagemem.PageUtils;
-import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
 import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter;
 import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow;
 import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree;
@@ -27,6 +26,9 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusLeaf
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.lang.IgniteInClosure;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.COUNTER_NA;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+
 /**
  *
  */
@@ -61,8 +63,8 @@ public abstract class AbstractDataLeafIO extends BPlusLeafIO<CacheSearchRow> imp
             long mvccCrdVer = row.mvccCoordinatorVersion();
             long mvccUpdateCntr = row.mvccCounter();
 
-            assert mvccCrdVer > 0 : mvccCrdVer;
-            assert mvccUpdateCntr != CacheCoordinatorsProcessor.COUNTER_NA;
+            assert unmaskCoordinatorVersion(mvccCrdVer) > 0 : mvccCrdVer;
+            assert mvccUpdateCntr != COUNTER_NA;
 
             PageUtils.putLong(pageAddr, off, mvccCrdVer);
             off += 8;
@@ -98,7 +100,7 @@ public abstract class AbstractDataLeafIO extends BPlusLeafIO<CacheSearchRow> imp
             long mvccUpdateCntr = ((RowLinkIO)srcIo).getMvccCounter(srcPageAddr, srcIdx);
 
             assert mvccUpdateTopVer >=0 : mvccUpdateCntr;
-            assert mvccUpdateCntr != CacheCoordinatorsProcessor.COUNTER_NA;
+            assert mvccUpdateCntr != COUNTER_NA;
 
             PageUtils.putLong(dstPageAddr, off, mvccUpdateTopVer);
             off += 8;

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataRowStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataRowStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataRowStore.java
index f9e1eb3..85624d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataRowStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataRowStore.java
@@ -25,6 +25,8 @@ import org.apache.ignite.internal.processors.cache.persistence.RowStore;
 import org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
+
 /**
  *
  */
@@ -65,17 +67,25 @@ public class CacheDataRowStore extends RowStore {
      * @param cacheId Cache ID.
      * @param hash Hash code.
      * @param link Link.
-     * @param mvccTopVer
-     * @param mvccCntr
+     * @param rowData Required row data.
+     * @param crdVer Mvcc coordinator version.
+     * @param mvccCntr Mvcc counter.
      * @return Search row.
      */
-    MvccDataRow mvccRow(int cacheId, int hash, long link, CacheDataRowAdapter.RowData rowData, long mvccTopVer, long mvccCntr) {
+    MvccDataRow mvccRow(int cacheId, int hash, long link, CacheDataRowAdapter.RowData rowData, long crdVer, long mvccCntr) {
+        if (rowData != CacheDataRowAdapter.RowData.KEY_ONLY && versionForRemovedValue(crdVer)) {
+            if (rowData == CacheDataRowAdapter.RowData.NO_KEY)
+                return MvccDataRow.removedRowNoKey(partId, cacheId, crdVer, mvccCntr);
+            else
+                rowData = CacheDataRowAdapter.RowData.KEY_ONLY;
+        }
+
         MvccDataRow dataRow = new MvccDataRow(grp,
             hash,
             link,
             partId,
             rowData,
-            mvccTopVer,
+            crdVer,
             mvccCntr);
 
         initDataRow(dataRow, cacheId);

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
index eaeefee..6309153 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheDataTree.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
 
 import static org.apache.ignite.internal.pagemem.PageIdUtils.itemId;
 import static org.apache.ignite.internal.pagemem.PageIdUtils.pageId;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
 
 /**
  *
@@ -160,7 +161,8 @@ public class CacheDataTree extends BPlusTree<CacheSearchRow, CacheDataRow> {
 
         long mvccCrdVer = io.getMvccCoordinatorVersion(pageAddr, idx);
 
-        cmp = Long.compare(row.mvccCoordinatorVersion(), mvccCrdVer);
+        cmp = Long.compare(unmaskCoordinatorVersion(row.mvccCoordinatorVersion()),
+            unmaskCoordinatorVersion(mvccCrdVer));
 
         if (cmp != 0)
             return cmp;
@@ -188,10 +190,10 @@ public class CacheDataTree extends BPlusTree<CacheSearchRow, CacheDataRow> {
             CacheDataRowAdapter.RowData.FULL;
 
         if (grp.mvccEnabled()) {
-            long mvccTopVer = rowIo.getMvccCoordinatorVersion(pageAddr, idx);
+            long mvccCrdVer = rowIo.getMvccCoordinatorVersion(pageAddr, idx);
             long mvccCntr = rowIo.getMvccCounter(pageAddr, idx);
 
-            return rowStore.mvccRow(cacheId, hash, link, x, mvccTopVer, mvccCntr);
+            return rowStore.mvccRow(cacheId, hash, link, x, mvccCrdVer, mvccCntr);
         }
         else
             return rowStore.dataRow(cacheId, hash, link, x);

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java
index 29bbaaf..d1e90d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java
@@ -81,6 +81,13 @@ public class DataRow extends CacheDataRowAdapter {
         this.cacheId = cacheId;
     }
 
+    /**
+     *
+     */
+    protected DataRow() {
+        super(0);
+    }
+
     /** {@inheritDoc} */
     @Override public int partition() {
         return part;

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
index eb1ee10..916ea93 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccDataRow.java
@@ -18,12 +18,11 @@
 package org.apache.ignite.internal.processors.cache.tree;
 
 import org.apache.ignite.internal.processors.cache.CacheGroupContext;
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+
 /**
  *
  */
@@ -46,7 +45,7 @@ public class MvccDataRow extends DataRow {
     MvccDataRow(CacheGroupContext grp, int hash, long link, int part, RowData rowData, long crdVer, long mvccCntr) {
         super(grp, hash, link, part, rowData);
 
-        assert crdVer > 0 : crdVer;
+        assert unmaskCoordinatorVersion(crdVer) > 0 : crdVer;
         assert mvccCntr != CacheCoordinatorsProcessor.COUNTER_NA;
 
         this.crdVer = crdVer;
@@ -54,25 +53,32 @@ public class MvccDataRow extends DataRow {
     }
 
     /**
-     * @param key Key.
-     * @param val Value.
-     * @param ver Version.
+     *
+     */
+    private MvccDataRow() {
+        // No-op.
+    }
+
+    /**
      * @param part Partition.
      * @param cacheId Cache ID.
      * @param crdVer Mvcc coordinator version.
      * @param mvccCntr Mvcc counter.
+     * @return Row.
      */
-    public MvccDataRow(KeyCacheObject key,
-        CacheObject val,
-        GridCacheVersion ver,
+    static MvccDataRow removedRowNoKey(
         int part,
         int cacheId,
         long crdVer,
         long mvccCntr) {
-        super(key, val, ver, part, 0L, cacheId);
+        MvccDataRow row = new MvccDataRow();
 
-        this.mvccCntr = mvccCntr;
-        this.crdVer = crdVer;
+        row.cacheId = cacheId;
+        row.part = part;
+        row.crdVer = crdVer;
+        row.mvccCntr = mvccCntr;
+
+        return row;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccKeyMaxVersionBound.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccKeyMaxVersionBound.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccKeyMaxVersionBound.java
index aa9422d..007ac09 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccKeyMaxVersionBound.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccKeyMaxVersionBound.java
@@ -27,6 +27,8 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
+
 /**
  *
  */
@@ -55,7 +57,12 @@ public class MvccKeyMaxVersionBound extends SearchRow implements BPlusTree.TreeR
         int idx)
         throws IgniteCheckedException
     {
-        resRow = ((CacheDataTree)tree).getRow(io, pageAddr, idx, CacheDataRowAdapter.RowData.NO_KEY);
+        RowLinkIO rowIo = (RowLinkIO)io;
+
+        if (versionForRemovedValue(rowIo.getMvccCoordinatorVersion(pageAddr, idx)))
+            resRow = null;
+        else
+            resRow = ((CacheDataTree)tree).getRow(io, pageAddr, idx, CacheDataRowAdapter.RowData.NO_KEY);
 
         return false;  // Stop search.
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
new file mode 100644
index 0000000..8fd8a6e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
@@ -0,0 +1,57 @@
+/*
+ * 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.processors.cache.tree;
+
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
+import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorVersion;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ *
+ */
+public class MvccRemoveRow extends MvccUpdateRow {
+    /**
+     * @param key Key.
+     * @param mvccVer Mvcc version.
+     * @param part Partition.
+     * @param cacheId Cache ID.
+     */
+    public MvccRemoveRow(
+        KeyCacheObject key,
+        MvccCoordinatorVersion mvccVer,
+        int part,
+        int cacheId) {
+        super(key, null, null, mvccVer, part, cacheId);
+    }
+
+    /** {@inheritDoc} */
+    @Override public long mvccCoordinatorVersion() {
+        return CacheCoordinatorsProcessor.createVersionForRemovedValue(super.mvccCoordinatorVersion());
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean removed() {
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(MvccRemoveRow.class, this, "super", super.toString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
index d3303e8..794661d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
@@ -22,6 +22,7 @@ import java.util.List;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
 import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorVersion;
 import org.apache.ignite.internal.processors.cache.persistence.CacheDataRow;
 import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow;
@@ -32,12 +33,14 @@ import org.apache.ignite.internal.util.GridLongList;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+
 /**
  *
  */
 public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<CacheSearchRow, CacheDataRow> {
     /** */
-    private Boolean hasPrev;
+    private UpdateResult res;
 
     /** */
     private boolean canCleanup;
@@ -74,8 +77,8 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
     /**
      * @return {@code True} if previous value was non-null.
      */
-    public boolean previousNotNull() {
-        return hasPrev != null && hasPrev;
+    public UpdateResult updateResult() {
+        return res == null ? UpdateResult.PREV_NULL : res;
     }
 
     /**
@@ -98,17 +101,18 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
      * @param idx Item index.
      * @return Always {@code true}.
      */
-    private boolean assertVersionGreater(RowLinkIO io, long pageAddr, int idx) {
-        long rowCrdVer = io.getMvccCoordinatorVersion(pageAddr, idx);
+    private boolean assertVersion(RowLinkIO io, long pageAddr, int idx) {
+        long rowCrdVer = unmaskCoordinatorVersion(io.getMvccCoordinatorVersion(pageAddr, idx));
         long rowCntr = io.getMvccCounter(pageAddr, idx);
 
-        int cmp = Long.compare(mvccCoordinatorVersion(), rowCrdVer);
+        int cmp = Long.compare(mvccVer.coordinatorVersion(), rowCrdVer);
 
         if (cmp == 0)
-            cmp = Long.compare(mvccCounter(), rowCntr);
+            cmp = Long.compare(mvccVer.counter(), rowCntr);
 
-        assert cmp > 0 : "[updCrd=" + mvccCoordinatorVersion() +
-            ", updCntr=" + mvccCounter() +
+        // Can be equals if backup rebalanced value updated on primary.
+        assert cmp >= 0 : "[updCrd=" + mvccVer.coordinatorVersion() +
+            ", updCntr=" + mvccVer.counter() +
             ", rowCrd=" + rowCrdVer +
             ", rowCntr=" + rowCntr + ']';
 
@@ -124,15 +128,31 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
     {
         RowLinkIO rowIo = (RowLinkIO)io;
 
-        // All previous versions should be less then new one.
-        assert assertVersionGreater(rowIo, pageAddr, idx);
+        // Assert version grows.
+        assert assertVersion(rowIo, pageAddr, idx);
 
         boolean checkActive = mvccVer.activeTransactions().size() > 0;
 
         boolean txActive = false;
 
+        long rowCrdVerMasked = rowIo.getMvccCoordinatorVersion(pageAddr, idx);
+        long rowCrdVer = unmaskCoordinatorVersion(rowCrdVerMasked);
+
+        if (res == null) {
+            int cmp = Long.compare(mvccVer.coordinatorVersion(), rowCrdVer);
+
+            if (cmp == 0)
+                cmp = Long.compare(mvccVer.coordinatorVersion(), rowIo.getMvccCounter(pageAddr, idx));
+
+            if (cmp == 0)
+                res = UpdateResult.VERSION_FOUND;
+            else
+                res = CacheCoordinatorsProcessor.versionForRemovedValue(rowCrdVerMasked) ?
+                    UpdateResult.PREV_NULL : UpdateResult.PREV_NOT_NULL;
+        }
+
         // Suppose transactions on previous coordinator versions are done.
-        if (checkActive && mvccVer.coordinatorVersion() == rowIo.getMvccCoordinatorVersion(pageAddr, idx)) {
+        if (checkActive && mvccVer.coordinatorVersion() == rowCrdVer) {
             long rowMvccCntr = rowIo.getMvccCounter(pageAddr, idx);
 
             if (mvccVer.activeTransactions().contains(rowMvccCntr)) {
@@ -145,15 +165,12 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
             }
         }
 
-        if (hasPrev == null)
-            hasPrev = Boolean.TRUE; // TODO IGNITE-3478 support removes.
-
         if (!txActive) {
-            assert Long.compare(mvccVer.coordinatorVersion(), rowIo.getMvccCoordinatorVersion(pageAddr, idx)) >= 0;
+            assert Long.compare(mvccVer.coordinatorVersion(), rowCrdVer) >= 0;
 
             int cmp;
 
-            if (mvccVer.coordinatorVersion() == rowIo.getMvccCoordinatorVersion(pageAddr, idx))
+            if (mvccVer.coordinatorVersion() == rowCrdVer)
                 cmp = Long.compare(mvccVer.cleanupVersion(), rowIo.getMvccCounter(pageAddr, idx));
             else
                 cmp = 1;
@@ -163,10 +180,10 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
                 if (canCleanup) {
                     CacheSearchRow row = io.getLookupRow(tree, pageAddr, idx);
 
-                    assert row.link() != 0 && row.mvccCoordinatorVersion() > 0 : row;
+                    assert row.link() != 0 && row.mvccCounter() != CacheCoordinatorsProcessor.COUNTER_NA : row;
 
                     // Should not be possible to cleanup active tx.
-                    assert row.mvccCoordinatorVersion() != mvccVer.coordinatorVersion()
+                    assert rowCrdVer != mvccVer.coordinatorVersion()
                         || !mvccVer.activeTransactions().contains(row.mvccCounter());
 
                     if (cleanupRows == null)
@@ -196,4 +213,16 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
     @Override public String toString() {
         return S.toString(MvccUpdateRow.class, this, "super", super.toString());
     }
+
+    /**
+     *
+     */
+    public enum UpdateResult {
+        /** */
+        VERSION_FOUND,
+        /** */
+        PREV_NULL,
+        /** */
+        PREV_NOT_NULL
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccVersionBasedSearchRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccVersionBasedSearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccVersionBasedSearchRow.java
index c829afb..a1d0127 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccVersionBasedSearchRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccVersionBasedSearchRow.java
@@ -28,6 +28,9 @@ import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.versionForRemovedValue;
+
 /**
  *
  */
@@ -66,16 +69,23 @@ public class MvccVersionBasedSearchRow extends SearchRow implements BPlusTree.Tr
     {
         boolean visible = true;
 
+        RowLinkIO rowIo = (RowLinkIO)io;
+
+        long crdVerMasked = rowIo.getMvccCoordinatorVersion(pageAddr, idx);
+
         if (ver.activeTransactions().size() > 0) {
-            RowLinkIO rowIo = (RowLinkIO)io;
+            long rowCrdVer = unmaskCoordinatorVersion(crdVerMasked);
 
             // TODO IGNITE-3478 sort active transactions?
-            if (rowIo.getMvccCoordinatorVersion(pageAddr, idx) == ver.coordinatorVersion())
+            if (rowCrdVer == ver.coordinatorVersion())
                 visible = !ver.activeTransactions().contains(rowIo.getMvccCounter(pageAddr, idx));
         }
 
         if (visible) {
-            resRow = ((CacheDataTree) tree).getRow(io, pageAddr, idx, CacheDataRowAdapter.RowData.NO_KEY);
+            if (versionForRemovedValue(crdVerMasked))
+                resRow = null;
+            else
+                resRow = ((CacheDataTree)tree).getRow(io, pageAddr, idx, CacheDataRowAdapter.RowData.NO_KEY);
 
             return false; // Stop search.
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
index 115e8a2..d45afe7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
@@ -17,7 +17,9 @@
 
 package org.apache.ignite.internal.processors.cache.mvcc;
 
+import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -45,6 +47,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.cluster.ClusterTopologyException;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
 import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.TestRecordingCommunicationSpi;
@@ -119,6 +122,9 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
     /** */
     private String nodeAttr;
 
+    /** */
+    private static final int PAGE_SIZE = MemoryConfiguration.DFLT_PAGE_SIZE;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -137,6 +143,12 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
         if (nodeAttr != null)
             cfg.setUserAttributes(F.asMap(nodeAttr, true));
 
+        MemoryConfiguration memCfg = new MemoryConfiguration();
+
+        memCfg.setPageSize(PAGE_SIZE);
+
+        cfg.setMemoryConfiguration(memCfg);
+
         return cfg;
     }
 
@@ -376,6 +388,109 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testSimplePutRemove() throws Exception {
+        simplePutRemove(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSimplePutRemove_LargeKeys() throws Exception {
+        simplePutRemove(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     * @param largeKeys {@code True} to use large keys (not fitting in single page).
+     */
+    private void simplePutRemove(boolean largeKeys) throws Exception {
+        Ignite node = startGrid(0);
+
+        IgniteTransactions txs = node.transactions();
+
+        final IgniteCache<Object, Object> cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, 1));
+
+        final int KEYS = 100;
+
+        checkValues(new HashMap<>(), cache);
+
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 0; k < KEYS; k++)
+                cache.remove(testKey(largeKeys, k));
+
+            tx.commit();
+        }
+
+        checkValues(new HashMap<>(), cache);
+
+        Map<Object, Object> expVals = new HashMap<>();
+
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 0; k < KEYS; k++) {
+                Object key = testKey(largeKeys, k);
+
+                expVals.put(key, k);
+
+                cache.put(key, k);
+            }
+
+            tx.commit();
+        }
+
+        checkValues(expVals, cache);
+
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 0; k < KEYS; k++) {
+                if (k % 2 == 0) {
+                    Object key = testKey(largeKeys, k);
+
+                    cache.remove(key);
+
+                    expVals.remove(key);
+                }
+            }
+
+            tx.commit();
+        }
+
+        checkValues(expVals, cache);
+    }
+
+    /**
+     * @param largeKeys {@code True} to use large keys (not fitting in single page).
+     * @param idx Index.
+     * @return Key instance.
+     */
+    private static Object testKey(boolean largeKeys, int idx) {
+        if (largeKeys) {
+            int payloadSize = PAGE_SIZE + ThreadLocalRandom.current().nextInt(PAGE_SIZE * 10);
+
+            return new TestKey(idx, payloadSize);
+        }
+        else
+            return idx;
+    }
+
+    /**
+     * @param expVals Expected values.
+     * @param cache Cache.
+     */
+    private void checkValues(Map<Object, Object> expVals, IgniteCache<Object, Object> cache) {
+        Map<Object, Object> res = cache.getAll(expVals.keySet());
+
+        assertEquals(expVals, res);
+
+        res = new HashMap<>();
+
+        for (IgniteCache.Entry<Object, Object> e : cache)
+            res.put(e.getKey(), e.getValue());
+
+        assertEquals(expVals, res);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testThreadUpdatesAreVisibleForThisThread() throws Exception {
         final Ignite ignite = startGrid(0);
 
@@ -1601,7 +1716,7 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void testRebalance1() throws Exception {
+    public void testSimpleRebalance() throws Exception {
         Ignite srv0 = startGrid(0);
 
         IgniteCache<Integer, Integer> cache =  (IgniteCache)srv0.createCache(
@@ -1664,6 +1779,32 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testSimpleRebalanceWithRemovedValues() throws Exception {
+        Ignite node = startGrid(0);
+
+        IgniteTransactions txs = node.transactions();
+
+        final IgniteCache<Object, Object> cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, 64));
+
+        final int KEYS = 100;
+
+        checkValues(new HashMap<>(), cache);
+
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 0; k < KEYS; k++)
+                cache.remove(k);
+
+            tx.commit();
+        }
+
+        startGrid(1);
+
+        awaitPartitionMapExchange();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testCoordinatorFailurePessimisticTx() throws Exception {
         testSpi = true;
 
@@ -2722,9 +2863,55 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
             assertEquals(KEYS, cache.size());
         }
 
-        // TODO IGNITE-3478: test removes.
-    }
+        int size = KEYS;
+
+        for (int i = 0; i < KEYS; i++) {
+            if (i % 2 == 0) {
+                final Integer key = i;
+
+                try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                    cache.remove(key);
 
+                    tx.commit();
+                }
+
+                size--;
+
+                assertEquals(size, cache.size());
+            }
+        }
+
+        // Check size does not change if remove already removed keys.
+        for (int i = 0; i < KEYS; i++) {
+            if (i % 2 == 0) {
+                final Integer key = i;
+
+                try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                    cache.remove(key);
+
+                    tx.commit();
+                }
+
+                assertEquals(size, cache.size());
+            }
+        }
+
+        for (int i = 0; i < KEYS; i++) {
+            if (i % 2 == 0) {
+                final Integer key = i;
+
+                try (Transaction tx = node.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+                    cache.put(key, i);
+
+                    tx.commit();
+                }
+
+                size++;
+
+                assertEquals(size, cache.size());
+            }
+        }
+    }
 
     /**
      * @throws IgniteCheckedException If failed.
@@ -2792,7 +2979,7 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
                 key0,
                 vers.get(0).get1());
 
-            MvccCoordinatorVersionResponse ver = version(crd.currentCoordinator().coordinatorVersion(), 100000);
+            MvccCoordinatorVersionResponse ver = version(vers.get(0).get2().coordinatorVersion(), 100000);
 
             for (int v = 0; v < vers.size(); v++) {
                 MvccCounter cntr = vers.get(v).get2();
@@ -3074,4 +3261,54 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
             return null;
         }
     }
+
+    /**
+     *
+     */
+    static class TestKey implements Serializable {
+        /** */
+        private final int key;
+
+        /** */
+        private final byte[] payload;
+
+        /**
+         * @param key Key.
+         * @param payloadSize Payload size.
+         */
+        public TestKey(int key, int payloadSize) {
+            this.key = key;
+            this.payload = new byte[payloadSize];
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean equals(Object o) {
+            if (this == o)
+                return true;
+
+            if (o == null || getClass() != o.getClass())
+                return false;
+
+            TestKey testKey = (TestKey)o;
+
+            if (key != testKey.key)
+                return false;
+
+            return Arrays.equals(payload, testKey.payload);
+        }
+
+        /** {@inheritDoc} */
+        @Override public int hashCode() {
+            int res = key;
+
+            res = 31 * res + Arrays.hashCode(payload);
+
+            return res;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return "TestKey [k=" + key + ", payloadLen=" + payload.length + ']';
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
index d0897e1..600c8df 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/database/FreeListImplSelfTest.java
@@ -435,6 +435,11 @@ public class FreeListImplSelfTest extends GridCommonAbstractTest {
         @Override public long mvccCounter() {
             return 0;
         }
+
+        /** {@inheritDoc} */
+        @Override public boolean removed() {
+            return false;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/21bc6338/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
index 392301c..1819cfe 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Row.java
@@ -174,4 +174,9 @@ public abstract class GridH2Row implements SearchRow, CacheDataRow, Row {
     @Override public long mvccCounter() {
         throw new UnsupportedOperationException();
     }
+
+    /** {@inheritDoc} */
+    @Override public boolean removed() {
+        throw new UnsupportedOperationException();
+    }
 }
\ No newline at end of file


[05/15] ignite git commit: IGNITE-6397 .NET thin client: basic cache operations. This closes #2725.

Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
index c456592..083038a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTest.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
     using System.Linq;
     using System.Threading;
     using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Client;
     using Apache.Ignite.Core.Impl.Client;
     using NUnit.Framework;
@@ -58,6 +59,11 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
 
                 // Null key.
                 Assert.Throws<ArgumentNullException>(() => clientCache.Get(null));
+
+                // Null vs 0.
+                var intCache = client.GetCache<int?, int?>(CacheName);
+                intCache.Put(1, 0);
+                Assert.AreEqual(0, intCache.Get(1));
             }
         }
 
@@ -78,7 +84,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
             {
                 var person = new Person {Id = 100, Name = "foo"};
                 var person2 = new Person2 {Id = 200, Name = "bar"};
-                
+
                 var serverCache = GetCache<Person>();
                 var clientCache = client.GetCache<int?, Person>(CacheName);
 
@@ -110,6 +116,604 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
         }
 
         /// <summary>
+        /// Tests the TryGet method.
+        /// </summary>
+        [Test]
+        public void TestTryGet()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int>(CacheName);
+
+                cache[1] = 0;
+                cache[2] = 2;
+
+                // Non-existent key.
+                int res;
+                var success = cache.TryGet(0, out res);
+
+                Assert.AreEqual(0, res);
+                Assert.IsFalse(success);
+
+                // Key with default value.
+                success = cache.TryGet(1, out res);
+
+                Assert.AreEqual(0, res);
+                Assert.IsTrue(success);
+
+                // Key with custom value.
+                success = cache.TryGet(2, out res);
+
+                Assert.AreEqual(2, res);
+                Assert.IsTrue(success);
+
+                // Null key.
+                Assert.Throws<ArgumentNullException>(() => cache.TryGet(null, out res));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAll method.
+        /// </summary>
+        [Test]
+        public void TestGetAll()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+                cache[3] = 3;
+
+                var res = cache.GetAll(new int?[] {1}).Single();
+                Assert.AreEqual(1, res.Key);
+                Assert.AreEqual(1, res.Value);
+
+                res = cache.GetAll(new int?[] {1, -1}).Single();
+                Assert.AreEqual(1, res.Key);
+                Assert.AreEqual(1, res.Value);
+
+                CollectionAssert.AreEquivalent(new[] {1, 2, 3},
+                    cache.GetAll(new int?[] {1, 2, 3}).Select(x => x.Value));
+
+                Assert.Throws<ArgumentNullException>(() => cache.GetAll(null));
+
+                Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {1, null}));
+                Assert.Throws<IgniteClientException>(() => cache.GetAll(new int?[] {null}));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAndPut method.
+        /// </summary>
+        [Test]
+        public void TestGetAndPut()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.GetAndPut(1, 1);
+                Assert.IsFalse(res.Success);
+                Assert.IsNull(res.Value);
+
+                Assert.IsTrue(cache.ContainsKey(1));
+
+                res = cache.GetAndPut(1, 2);
+                Assert.IsTrue(res.Success);
+                Assert.AreEqual(1, res.Value);
+
+                Assert.AreEqual(2, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(1, null));
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndPut(null, 1));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAndReplace method.
+        /// </summary>
+        [Test]
+        public void TestGetAndReplace()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.GetAndReplace(1, 1);
+                Assert.IsFalse(res.Success);
+                Assert.IsNull(res.Value);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+                cache[1] = 1;
+
+                res = cache.GetAndReplace(1, 2);
+                Assert.IsTrue(res.Success);
+                Assert.AreEqual(1, res.Value);
+
+                Assert.AreEqual(2, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(1, null));
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndReplace(null, 1));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAndRemove method.
+        /// </summary>
+        [Test]
+        public void TestGetAndRemove()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.GetAndRemove(1);
+                Assert.IsFalse(res.Success);
+                Assert.IsNull(res.Value);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+                cache[1] = 1;
+
+                res = cache.GetAndRemove(1);
+                Assert.IsTrue(res.Success);
+                Assert.AreEqual(1, res.Value);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndRemove(null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the ContainsKey method.
+        /// </summary>
+        [Test]
+        public void TestContainsKey()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int>(CacheName);
+
+                cache[1] = 1;
+
+                Assert.IsTrue(cache.ContainsKey(1));
+                Assert.IsFalse(cache.ContainsKey(2));
+
+                Assert.Throws<ArgumentNullException>(() => cache.ContainsKey(null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the ContainsKeys method.
+        /// </summary>
+        [Test]
+        public void TestContainsKeys()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int, int>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+                cache[3] = 3;
+
+                Assert.IsTrue(cache.ContainsKeys(new[] {1}));
+                Assert.IsTrue(cache.ContainsKeys(new[] {1, 2}));
+                Assert.IsTrue(cache.ContainsKeys(new[] {2, 1}));
+                Assert.IsTrue(cache.ContainsKeys(new[] {1, 2, 3}));
+                Assert.IsTrue(cache.ContainsKeys(new[] {1, 3, 2}));
+
+                Assert.IsFalse(cache.ContainsKeys(new[] {0}));
+                Assert.IsFalse(cache.ContainsKeys(new[] {0, 1}));
+                Assert.IsFalse(cache.ContainsKeys(new[] {1, 0}));
+                Assert.IsFalse(cache.ContainsKeys(new[] {1, 2, 3, 0}));
+
+                Assert.Throws<ArgumentNullException>(() => cache.ContainsKeys(null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the PutIfAbsent method.
+        /// </summary>
+        [Test]
+        public void TestPutIfAbsent()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.PutIfAbsent(1, 1);
+                Assert.IsTrue(res);
+                Assert.AreEqual(1, cache[1]);
+
+                res = cache.PutIfAbsent(1, 2);
+                Assert.IsFalse(res);
+                Assert.AreEqual(1, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(null, 1));
+                Assert.Throws<ArgumentNullException>(() => cache.PutIfAbsent(1, null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetAndPutIfAbsent method.
+        /// </summary>
+        [Test]
+        public void TestGetAndPutIfAbsent()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.GetAndPutIfAbsent(1, 1);
+                Assert.IsFalse(res.Success);
+                Assert.IsNull(res.Value);
+                Assert.AreEqual(1, cache[1]);
+
+                res = cache.GetAndPutIfAbsent(1, 2);
+                Assert.IsTrue(res.Success);
+                Assert.AreEqual(1, res.Value);
+                Assert.AreEqual(1, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(null, 1));
+                Assert.Throws<ArgumentNullException>(() => cache.GetAndPutIfAbsent(1, null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Replace method.
+        /// </summary>
+        [Test]
+        public void TestReplace()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.Replace(1, 1);
+                Assert.IsFalse(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                cache[1] = 1;
+
+                res = cache.Replace(1, 2);
+                Assert.IsTrue(res);
+                Assert.AreEqual(2, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1));
+                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Replace overload with additional argument.
+        /// </summary>
+        [Test]
+        public void TestReplace2()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                var res = cache.Replace(1, 1, 2);
+                Assert.IsFalse(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+
+                cache[1] = 1;
+
+                res = cache.Replace(1, -1, 2);
+                Assert.IsFalse(res);
+                Assert.AreEqual(1, cache[1]);
+
+                res = cache.Replace(1, 1, 2);
+                Assert.IsTrue(res);
+                Assert.AreEqual(2, cache[1]);
+
+                Assert.Throws<ArgumentNullException>(() => cache.Replace(null, 1, 1));
+                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, null, 1));
+                Assert.Throws<ArgumentNullException>(() => cache.Replace(1, 1, null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the PutAll method.
+        /// </summary>
+        [Test]
+        public void TestPutAll()
+        {
+            using (var client = GetClient())
+            {
+                // Primitives.
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache.PutAll(Enumerable.Range(1, 3).ToDictionary(x => (int?) x, x => (int?) x + 1));
+
+                Assert.AreEqual(2, cache[1]);
+                Assert.AreEqual(3, cache[2]);
+                Assert.AreEqual(4, cache[3]);
+
+                // Objects.
+                var cache2 = client.GetCache<int, Container>(CacheName);
+
+                var obj1 = new Container();
+                var obj2 = new Container();
+                var obj3 = new Container();
+
+                obj1.Inner = obj2;
+                obj2.Inner = obj1;
+                obj3.Inner = obj2;
+
+                cache2.PutAll(new Dictionary<int, Container>
+                {
+                    {1, obj1},
+                    {2, obj2},
+                    {3, obj3}
+                });
+
+                var res1 = cache2[1];
+                var res2 = cache2[2];
+                var res3 = cache2[3];
+
+                Assert.AreEqual(res1, res1.Inner.Inner);
+                Assert.AreEqual(res2, res2.Inner.Inner);
+                Assert.IsNotNull(res3.Inner.Inner.Inner);
+
+                // Nulls.
+                Assert.Throws<ArgumentNullException>(() => cache.PutAll(null));
+
+                Assert.Throws<IgniteClientException>(() => cache.PutAll(new[]
+                {
+                    new KeyValuePair<int?, int?>(null, 1)
+                }));
+
+                Assert.Throws<IgniteClientException>(() => cache.PutAll(new[]
+                {
+                    new KeyValuePair<int?, int?>(1, null)
+                }));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Clear method.
+        /// </summary>
+        [Test]
+        public void TestClear()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+
+                cache.Clear();
+
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsFalse(cache.ContainsKey(2));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Clear method with a key argument.
+        /// </summary>
+        [Test]
+        public void TestClearKey()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+
+                cache.Clear(1);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsTrue(cache.ContainsKey(2));
+
+                cache.Clear(2);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsFalse(cache.ContainsKey(2));
+
+                Assert.Throws<ArgumentNullException>(() => cache.Clear(null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the ClearAll method.
+        /// </summary>
+        [Test]
+        public void TestClearAll()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+                cache[3] = 3;
+
+                cache.ClearAll(new int?[] {1, 3});
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsTrue(cache.ContainsKey(2));
+                Assert.IsFalse(cache.ContainsKey(3));
+
+                Assert.Throws<ArgumentNullException>(() => cache.ClearAll(null));
+                Assert.Throws<IgniteClientException>(() => cache.ClearAll(new int?[] {null, 1}));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Remove method.
+        /// </summary>
+        [Test]
+        public void TestRemove()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+
+                var res = cache.Remove(1);
+                Assert.IsTrue(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsTrue(cache.ContainsKey(2));
+
+                res = cache.Remove(2);
+                Assert.IsTrue(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsFalse(cache.ContainsKey(2));
+
+                res = cache.Remove(-1);
+                Assert.IsFalse(res);
+
+                Assert.Throws<ArgumentNullException>(() => cache.Remove(null));
+            }
+        }
+
+        /// <summary>
+        /// Tests the Remove method with value argument.
+        /// </summary>
+        [Test]
+        public void TestRemoveKeyVal()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+
+                var res = cache.Remove(1, 0);
+                Assert.IsFalse(res);
+
+                res = cache.Remove(0, 0);
+                Assert.IsFalse(res);
+
+                res = cache.Remove(1, 1);
+                Assert.IsTrue(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsTrue(cache.ContainsKey(2));
+
+                res = cache.Remove(2, 2);
+                Assert.IsTrue(res);
+                Assert.IsFalse(cache.ContainsKey(1));
+                Assert.IsFalse(cache.ContainsKey(2));
+
+                res = cache.Remove(2, 2);
+                Assert.IsFalse(res);
+
+                Assert.Throws<ArgumentNullException>(() => cache.Remove(1, null));
+                Assert.Throws<ArgumentNullException>(() => cache.Remove(null, 1));
+            }
+        }
+
+        /// <summary>
+        /// Tests the RemoveAll with a set of keys.
+        /// </summary>
+        [Test]
+        public void TestRemoveReys()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int?, int?>(CacheName);
+                var keys = Enumerable.Range(1, 10).Cast<int?>().ToArray();
+
+                cache.PutAll(keys.ToDictionary(x => x, x => x));
+
+                cache.RemoveAll(keys.Skip(2));
+                CollectionAssert.AreEquivalent(keys.Take(2), cache.GetAll(keys).Select(x => x.Key));
+
+                cache.RemoveAll(new int?[] {1});
+                Assert.AreEqual(2, cache.GetAll(keys).Single().Value);
+
+                cache.RemoveAll(keys);
+                cache.RemoveAll(keys);
+
+                Assert.AreEqual(0, cache.GetSize());
+
+                Assert.Throws<ArgumentNullException>(() => cache.RemoveAll(null));
+                Assert.Throws<IgniteClientException>(() => cache.RemoveAll(new int?[] {1, null}));
+            }
+        }
+
+        /// <summary>
+        /// Tests the RemoveAll method without argument.
+        /// </summary>
+        [Test]
+        public void TestRemoveAll()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int, int>(CacheName);
+
+                cache[1] = 1;
+                cache[2] = 2;
+
+                cache.RemoveAll();
+
+                Assert.AreEqual(0, cache.GetSize());
+            }
+        }
+
+        /// <summary>
+        /// Tests the GetSize method.
+        /// </summary>
+        [Test]
+        public void TestGetSize()
+        {
+            using (var client = GetClient())
+            {
+                var cache = client.GetCache<int, int>(CacheName);
+
+                Assert.AreEqual(0, cache.GetSize());
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.All));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Offheap));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Primary));
+
+                cache[1] = 1;
+                
+                Assert.AreEqual(1, cache.GetSize());
+                Assert.AreEqual(1, cache.GetSize(CachePeekMode.All));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+                Assert.AreEqual(1, cache.GetSize(CachePeekMode.Offheap));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+                Assert.AreEqual(1, cache.GetSize(CachePeekMode.Primary));
+
+                cache.PutAll(Enumerable.Range(1, 100).ToDictionary(x => x, x => x));
+                
+                Assert.AreEqual(100, cache.GetSize());
+                Assert.AreEqual(100, cache.GetSize(CachePeekMode.All));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Backup));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Near));
+                Assert.AreEqual(100, cache.GetSize(CachePeekMode.Offheap));
+                Assert.AreEqual(0, cache.GetSize(CachePeekMode.Onheap));
+                Assert.AreEqual(100, cache.GetSize(CachePeekMode.Primary));
+            }
+        }
+
+        /// <summary>
         /// Tests client get in multiple threads with a single client.
         /// </summary>
         [Test]
@@ -170,5 +774,10 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
                 Assert.AreEqual((int) ClientStatus.CacheDoesNotExist, ex.ErrorCode);
             }
         }
+
+        private class Container
+        {
+            public Container Inner;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
index 6695835..782e3cc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Cache/CacheTestNoMeta.cs
@@ -52,7 +52,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
             using (var client = Ignition.StartClient(cfg))
             {
                 var serverCache = Ignition.GetIgnite().GetOrCreateCache<int?, Person>(
-                    new CacheConfiguration(CacheName, new QueryEntity
+                    new CacheConfiguration("person", new QueryEntity
                     {
                         KeyType = typeof(int),
                         ValueType = typeof(Person),
@@ -63,7 +63,7 @@ namespace Apache.Ignite.Core.Tests.Client.Cache
                         }
                     }));
 
-                var clientCache = client.GetCache<int?, Person>(CacheName);
+                var clientCache = client.GetCache<int?, Person>(serverCache.Name);
 
                 // Put through client cache.
                 clientCache.Put(1, new Person { Id = 100, Name = "foo" });

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
index 81e1418..408eb73 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientTestBase.cs
@@ -76,6 +76,15 @@ namespace Apache.Ignite.Core.Tests.Client
         }
 
         /// <summary>
+        /// Sets up the test.
+        /// </summary>
+        [SetUp]
+        public void TestSetUp()
+        {
+            GetCache<int>().RemoveAll();
+        }
+
+        /// <summary>
         /// Gets the cache.
         /// </summary>
         protected static ICache<int, T> GetCache<T>()

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
index edd411c..d772ba6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Cache/ICacheClient.cs
@@ -51,6 +51,25 @@ namespace Apache.Ignite.Core.Client.Cache
         TV Get(TK key);
 
         /// <summary>
+        /// Retrieves value mapped to the specified key from cache.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <param name="value">When this method returns, the value associated with the specified key,
+        /// if the key is found; otherwise, the default value for the type of the value parameter.
+        /// This parameter is passed uninitialized.</param>
+        /// <returns>
+        /// true if the cache contains an element with the specified key; otherwise, false.
+        /// </returns>
+        bool TryGet(TK key, out TV value);
+
+        /// <summary>
+        /// Retrieves values mapped to the specified keys from cache.
+        /// </summary>
+        /// <param name="keys">Keys.</param>
+        /// <returns>Map of key-value pairs.</returns>
+        ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys);
+
+        /// <summary>
         /// Gets or sets a cache value with the specified key.
         /// Shortcut to <see cref="Get"/> and <see cref="Put"/>
         /// </summary>
@@ -60,10 +79,146 @@ namespace Apache.Ignite.Core.Client.Cache
         TV this[TK key] { get; set; }
 
         /// <summary>
+        /// Check if cache contains mapping for this key.
+        /// </summary>
+        /// <param name="key">Key.</param>
+        /// <returns>True if cache contains mapping for this key.</returns>
+        bool ContainsKey(TK key);
+
+        /// <summary>
+        /// Check if cache contains mapping for these keys.
+        /// </summary>
+        /// <param name="keys">Keys.</param>
+        /// <returns>True if cache contains mapping for all these keys.</returns>
+        bool ContainsKeys(IEnumerable<TK> keys);
+
+        /// <summary>
         /// Executes a Scan query.
         /// </summary>
         /// <param name="scanQuery">Scan query.</param>
         /// <returns>Query cursor.</returns>
         IQueryCursor<ICacheEntry<TK, TV>> Query(ScanQuery<TK, TV> scanQuery);
+
+        /// <summary>
+        /// Associates the specified value with the specified key in this cache,
+        /// returning an existing value if one existed.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>
+        /// The value associated with the key at the start of the operation.
+        /// </returns>
+        CacheResult<TV> GetAndPut(TK key, TV val);
+
+        /// <summary>
+        /// Atomically replaces the value for a given key if and only if there is a value currently mapped by the key.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>
+        /// The previous value associated with the specified key.
+        /// </returns>
+        CacheResult<TV> GetAndReplace(TK key, TV val);
+
+        /// <summary>
+        /// Atomically removes the entry for a key only if currently mapped to some value.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is associated.</param>
+        /// <returns>The value if one existed.</returns>
+        CacheResult<TV> GetAndRemove(TK key);
+
+        /// <summary>
+        /// Atomically associates the specified key with the given value if it is not already associated with a value.
+        /// </summary>
+        /// <param name="key">Key with which the specified value is to be associated.</param>
+        /// <param name="val">Value to be associated with the specified key.</param>
+        /// <returns>True if a value was set.</returns>
+        bool PutIfAbsent(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if cache had no previous mapping for it.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="val">Value to be associated with the given key.</param>
+        /// <returns>
+        /// Previously contained value regardless of whether put happened or not.
+        /// </returns>
+        CacheResult<TV> GetAndPutIfAbsent(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if there is a previous mapping for it.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="val">Value to be associated with the given key.</param>
+        /// <returns>True if the value was replaced.</returns>
+        bool Replace(TK key, TV val);
+
+        /// <summary>
+        /// Stores given key-value pair in cache only if only if the previous value is equal to the
+        /// old value passed as argument.
+        /// </summary>
+        /// <param name="key">Key to store in cache.</param>
+        /// <param name="oldVal">Old value to match.</param>
+        /// <param name="newVal">Value to be associated with the given key.</param>
+        /// <returns>True if replace happened, false otherwise.</returns>
+        bool Replace(TK key, TV oldVal, TV newVal);
+
+        /// <summary>
+        /// Stores given key-value pairs in cache.
+        /// </summary>
+        /// <param name="vals">Key-value pairs to store in cache.</param>
+        void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals);
+
+        /// <summary>
+        /// Clears the contents of the cache, without notifying listeners or CacheWriters.
+        /// </summary>
+        void Clear();
+
+        /// <summary>
+        /// Clear entry from the cache, without notifying listeners or CacheWriters.
+        /// </summary>
+        /// <param name="key">Key to clear.</param>
+        void Clear(TK key);
+
+        /// <summary>
+        /// Clear entries from the cache, without notifying listeners or CacheWriters.
+        /// </summary>
+        /// <param name="keys">Keys to clear.</param>
+        void ClearAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Removes given key mapping from cache, notifying listeners and cache writers.
+        /// </summary>
+        /// <param name="key">Key to remove.</param>
+        /// <returns>True if entry was removed, false otherwise.</returns>
+        bool Remove(TK key);
+
+        /// <summary>
+        /// Removes given key mapping from cache if one exists and value is equal to the passed in value.
+        /// </summary>
+        /// <param name="key">Key whose mapping is to be removed from cache.</param>
+        /// <param name="val">Value to match against currently cached value.</param>
+        /// <returns>True if entry was removed, false otherwise.</returns>
+        bool Remove(TK key, TV val);
+
+        /// <summary>
+        /// Removes given key mappings from cache, notifying listeners and cache writers.
+        /// </summary>
+        /// <param name="keys">Keys to be removed from cache.</param>
+        void RemoveAll(IEnumerable<TK> keys);
+
+        /// <summary>
+        /// Removes all mappings from cache, notifying listeners and cache writers.
+        /// </summary>
+        void RemoveAll();
+
+        /// <summary>
+        /// Gets the number of all entries cached across all nodes.
+        /// <para />
+        /// NOTE: this operation is distributed and will query all participating nodes for their cache sizes.
+        /// </summary>
+        /// <param name="modes">Optional peek modes. If not provided, then total cache size is returned.</param>
+        /// <returns>Cache size across all nodes.</returns>
+        long GetSize(params CachePeekMode[] modes);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientException.cs
index a20bec3..2df3d1b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientException.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/IgniteClientException.cs
@@ -104,5 +104,13 @@ namespace Apache.Ignite.Core.Client
 
             info.AddValue(ErrorCodeField, _errorCode);
         }
+
+        /// <summary>
+        /// Returns a <see cref="string" /> that represents this instance.
+        /// </summary>
+        public override string ToString()
+        {
+            return string.Format("{0} [ErrorCode={1}]", base.ToString(), ErrorCode);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index 9d45f50..ca9fb63 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -342,7 +342,7 @@ namespace Apache.Ignite.Core.Impl.Cache
                 w =>
                 {
                     w.WriteObjectDetached(key);
-                    w.WriteInt(EncodePeekModes(modes));
+                    w.WriteInt(IgniteUtils.EncodePeekModes(modes));
                 },
                 (s, r) => r == True ? new CacheResult<TV>(Unmarshal<TV>(s)) : new CacheResult<TV>(),
                 _readException);
@@ -808,7 +808,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritDoc /> */
         public Task<int> GetSizeAsync(params CachePeekMode[] modes)
         {
-            var modes0 = EncodePeekModes(modes);
+            var modes0 = IgniteUtils.EncodePeekModes(modes);
 
             return DoOutOpAsync<int>(CacheOp.SizeAsync, w => w.WriteInt(modes0));
         }
@@ -821,7 +821,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /// <returns>Size.</returns>
         private int Size0(bool loc, params CachePeekMode[] modes)
         {
-            var modes0 = EncodePeekModes(modes);
+            var modes0 = IgniteUtils.EncodePeekModes(modes);
 
             var op = loc ? CacheOp.SizeLoc : CacheOp.Size;
 
@@ -1147,7 +1147,7 @@ namespace Apache.Ignite.Core.Impl.Cache
         /** <inheritdoc /> */
         public IEnumerable<ICacheEntry<TK, TV>> GetLocalEntries(CachePeekMode[] peekModes)
         {
-            return new CacheEnumerable<TK, TV>(this, EncodePeekModes(peekModes));
+            return new CacheEnumerable<TK, TV>(this, IgniteUtils.EncodePeekModes(peekModes));
         }
 
         /** <inheritdoc /> */
@@ -1189,22 +1189,6 @@ namespace Apache.Ignite.Core.Impl.Cache
         }
 
         /// <summary>
-        /// Encodes the peek modes into a single int value.
-        /// </summary>
-        private static int EncodePeekModes(CachePeekMode[] modes)
-        {
-            int modesEncoded = 0;
-
-            if (modes != null)
-            {
-                foreach (var mode in modes)
-                    modesEncoded |= (int) mode;
-            }
-
-            return modesEncoded;
-        }
-
-        /// <summary>
         /// Reads results of InvokeAll operation.
         /// </summary>
         /// <typeparam name="T">The type of the result.</typeparam>

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
index 5492ef8..be6e7da 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Cache/CacheClient.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
     using System.Collections.Generic;
     using System.Diagnostics;
     using System.IO;
+    using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cache.Query;
     using Apache.Ignite.Core.Client;
@@ -54,7 +55,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         private readonly Marshaller _marsh;
 
         /** Keep binary flag. */
-        private bool _keepBinary = false;
+        private readonly bool _keepBinary = false;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="CacheClient{TK, TV}" /> class.
@@ -94,6 +95,39 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         }
 
         /** <inheritDoc /> */
+        public bool TryGet(TK key, out TV value)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            var res = DoOutInOp(ClientOp.CacheGet, w => w.WriteObject(key), UnmarshalCacheResult<TV>);
+
+            value = res.Value;
+
+            return res.Success;
+        }
+
+        /** <inheritDoc /> */
+        public ICollection<ICacheEntry<TK, TV>> GetAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutInOp(ClientOp.CacheGetAll, w => w.WriteEnumerable(keys), stream =>
+            {
+                var reader = _marsh.StartUnmarshal(stream, _keepBinary);
+
+                var cnt = reader.ReadInt();
+                var res = new List<ICacheEntry<TK, TV>>(cnt);
+
+                for (var i = 0; i < cnt; i++)
+                {
+                    res.Add(new CacheEntry<TK, TV>(reader.ReadObject<TK>(), reader.ReadObject<TV>()));
+                }
+
+                return res;
+            });
+        }
+
+        /** <inheritDoc /> */
         public void Put(TK key, TV val)
         {
             IgniteArgumentCheck.NotNull(key, "key");
@@ -107,6 +141,22 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         }
 
         /** <inheritDoc /> */
+        public bool ContainsKey(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp(ClientOp.CacheContainsKey, w => w.WriteObjectDetached(key), r => r.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public bool ContainsKeys(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            return DoOutInOp(ClientOp.CacheContainsKeys, w => w.WriteEnumerable(keys), r => r.ReadBool());
+        }
+
+        /** <inheritDoc /> */
         public IQueryCursor<ICacheEntry<TK, TV>> Query(ScanQuery<TK, TV> scanQuery)
         {
             IgniteArgumentCheck.NotNull(scanQuery, "query");
@@ -116,6 +166,166 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
             return DoOutInOp(ClientOp.QueryScan, w => WriteScanQuery(w, scanQuery),
                 s => new ClientQueryCursor<TK, TV>(_ignite, s.ReadLong(), _keepBinary, s));
         }
+        
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndPut(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CacheGetAndPut, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, UnmarshalCacheResult<TV>);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndReplace(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CacheGetAndReplace, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, UnmarshalCacheResult<TV>);
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndRemove(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp(ClientOp.CacheGetAndRemove, w => w.WriteObjectDetached(key), 
+                UnmarshalCacheResult<TV>);
+        }
+
+        /** <inheritDoc /> */
+        public bool PutIfAbsent(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CachePutIfAbsent, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, s => s.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public CacheResult<TV> GetAndPutIfAbsent(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CacheGetAndPutIfAbsent, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, UnmarshalCacheResult<TV>);
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CacheReplace, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, s => s.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public bool Replace(TK key, TV oldVal, TV newVal)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(oldVal, "oldVal");
+            IgniteArgumentCheck.NotNull(newVal, "newVal");
+
+            return DoOutInOp(ClientOp.CacheReplaceIfEquals, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(oldVal);
+                w.WriteObjectDetached(newVal);
+            }, s => s.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public void PutAll(IEnumerable<KeyValuePair<TK, TV>> vals)
+        {
+            IgniteArgumentCheck.NotNull(vals, "vals");
+
+            DoOutOp(ClientOp.CachePutAll, w => w.WriteDictionary(vals));
+        }
+
+        /** <inheritDoc /> */
+        public void Clear()
+        {
+            DoOutOp(ClientOp.CacheClear);
+        }
+
+        /** <inheritDoc /> */
+        public void Clear(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            DoOutOp(ClientOp.CacheClearKey, w => w.WriteObjectDetached(key));
+        }
+
+        /** <inheritDoc /> */
+        public void ClearAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp(ClientOp.CacheClearKeys, w => w.WriteEnumerable(keys));
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+
+            return DoOutInOp(ClientOp.CacheRemoveKey, w => w.WriteObjectDetached(key), r => r.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public bool Remove(TK key, TV val)
+        {
+            IgniteArgumentCheck.NotNull(key, "key");
+            IgniteArgumentCheck.NotNull(val, "val");
+
+            return DoOutInOp(ClientOp.CacheRemoveIfEquals, w =>
+            {
+                w.WriteObjectDetached(key);
+                w.WriteObjectDetached(val);
+            }, r => r.ReadBool());
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll(IEnumerable<TK> keys)
+        {
+            IgniteArgumentCheck.NotNull(keys, "keys");
+
+            DoOutOp(ClientOp.CacheRemoveKeys, w => w.WriteEnumerable(keys));
+        }
+
+        /** <inheritDoc /> */
+        public void RemoveAll()
+        {
+            DoOutOp(ClientOp.CacheRemoveAll);
+        }
+
+        /** <inheritDoc /> */
+        public long GetSize(params CachePeekMode[] modes)
+        {
+            return DoOutInOp(ClientOp.CacheGetSize, w => WritePeekModes(modes, w), s => s.ReadLong());
+        }
 
         /// <summary>
         /// Does the out in op.
@@ -142,7 +352,7 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         /// <summary>
         /// Does the out op.
         /// </summary>
-        private void DoOutOp(ClientOp opId, Action<BinaryWriter> writeAction)
+        private void DoOutOp(ClientOp opId, Action<BinaryWriter> writeAction = null)
         {
             DoOutInOp<object>(opId, writeAction, null);
         }
@@ -165,6 +375,23 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         }
 
         /// <summary>
+        /// Unmarshals the value, wrapping in a cache result.
+        /// </summary>
+        private CacheResult<T> UnmarshalCacheResult<T>(IBinaryStream stream)
+        {
+            var hdr = stream.ReadByte();
+
+            if (hdr == BinaryUtils.HdrNull)
+            {
+                return new CacheResult<T>();
+            }
+
+            stream.Seek(-1, SeekOrigin.Current);
+
+            return new CacheResult<T>(_marsh.Unmarshal<T>(stream));
+        }
+
+        /// <summary>
         /// Writes the scan query.
         /// </summary>
         private void WriteScanQuery(BinaryWriter writer, ScanQuery<TK, TV> qry)
@@ -214,5 +441,34 @@ namespace Apache.Ignite.Core.Impl.Client.Cache
         {
             return new KeyNotFoundException("The given key was not present in the cache.");
         }
+
+        /// <summary>
+        /// Writes the peek modes.
+        /// </summary>
+        private static void WritePeekModes(ICollection<CachePeekMode> modes, IBinaryRawWriter w)
+        {
+            if (modes == null)
+            {
+                w.WriteInt(0);
+            }
+            else
+            {
+                w.WriteInt(modes.Count);
+
+                foreach (var m in modes)
+                {
+                    // Convert bit flag to ordinal.
+                    byte val = 0;
+                    var flagVal = (int)m;
+
+                    while ((flagVal = flagVal >> 1) > 0)
+                    {
+                        val++;
+                    }
+
+                    w.WriteByte(val);
+                }
+            }
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
index c39b68f..3511a79 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientOp.cs
@@ -30,6 +30,25 @@ namespace Apache.Ignite.Core.Impl.Client
         BinaryTypePut = 6,
         QueryScan = 7,
         QueryScanCursorGetPage = 8,
-        ResourceClose = 9
+        ResourceClose = 9,
+        CacheContainsKey = 10,
+        CacheContainsKeys = 11,
+        CacheGetAll = 12,
+        CacheGetAndPut = 13,
+        CacheGetAndReplace = 14,
+        CacheGetAndRemove = 15,
+        CachePutIfAbsent = 16,
+        CacheGetAndPutIfAbsent = 17,
+        CacheReplace = 18,
+        CacheReplaceIfEquals = 19,
+        CachePutAll = 20,
+        CacheClear = 21,
+        CacheClearKey = 22,
+        CacheClearKeys = 23,
+        CacheRemoveKey = 24,
+        CacheRemoveIfEquals = 25,
+        CacheGetSize = 26,
+        CacheRemoveKeys = 27,
+        CacheRemoveAll = 28
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/97b91e9c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index d55960a..e439208 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -27,6 +27,7 @@ namespace Apache.Ignite.Core.Impl
     using System.Reflection;
     using System.Runtime.InteropServices;
     using System.Text;
+    using Apache.Ignite.Core.Cache;
     using Apache.Ignite.Core.Cluster;
     using Apache.Ignite.Core.Common;
     using Apache.Ignite.Core.Impl.Binary;
@@ -510,5 +511,25 @@ namespace Apache.Ignite.Core.Impl
 
             return res;
         }
+
+        /// <summary>
+        /// Encodes the peek modes into a single int value.
+        /// </summary>
+        public static int EncodePeekModes(CachePeekMode[] modes)
+        {
+            var res = 0;
+
+            if (modes == null)
+            {
+                return res;
+            }
+
+            foreach (var mode in modes)
+            {
+                res |= (int)mode;
+            }
+
+            return res;
+        }
     }
 }


[04/15] ignite git commit: Fixed "IGNITE-6483 Tests for availability of metrics in MX beans". This closes #2806.

Posted by sb...@apache.org.
Fixed "IGNITE-6483 Tests for availability of metrics in MX beans". This closes #2806.

Signed-off-by: nikolay_tikhonov <nt...@gridgain.com>


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

Branch: refs/heads/ignite-5937
Commit: 218416c3a432040253cf0bfcb193fc33f02b804b
Parents: a45677c
Author: Ilya Kasnacheev <il...@gmail.com>
Authored: Mon Oct 9 16:36:07 2017 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Mon Oct 9 16:36:07 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheMetricsImpl.java      |   2 +-
 .../CacheMetricsForClusterGroupSelfTest.java    | 119 ++++++++++++-------
 ...heapCacheMetricsForClusterGroupSelfTest.java |  19 ++-
 3 files changed, 96 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/218416c3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index 413b60d..7d9cda8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -227,7 +227,7 @@ public class CacheMetricsImpl implements CacheMetrics {
     /** {@inheritDoc} */
     @Override public long getHeapEntriesCount() {
         try {
-            return cctx.cache().localSize(ONHEAP_PEEK_MODES);
+            return cctx.cache().localSizeLong(ONHEAP_PEEK_MODES);
         }
         catch (IgniteCheckedException ignored) {
             return 0;

http://git-wip-us.apache.org/repos/asf/ignite/blob/218416c3/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 ee8aa8a..aefbc23 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
@@ -91,26 +91,29 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest
     public void testMetricsStatisticsEnabled() throws Exception {
         createCaches(true);
 
-        populateCacheData(cache1, ENTRY_CNT_CACHE1);
-        populateCacheData(cache2, ENTRY_CNT_CACHE2);
+        try {
+            populateCacheData(cache1, ENTRY_CNT_CACHE1);
+            populateCacheData(cache2, ENTRY_CNT_CACHE2);
 
-        readCacheData(cache1, ENTRY_CNT_CACHE1);
-        readCacheData(cache2, ENTRY_CNT_CACHE2);
+            readCacheData(cache1, ENTRY_CNT_CACHE1);
+            readCacheData(cache2, ENTRY_CNT_CACHE2);
 
-        awaitMetricsUpdate();
+            awaitMetricsUpdate();
 
-        Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
+            Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
 
-        for (ClusterNode node : nodes) {
-            Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
-            assertNotNull(metrics);
-            assertFalse(metrics.isEmpty());
-        }
-
-        assertMetrics(cache1);
-        assertMetrics(cache2);
+            for (ClusterNode node : nodes) {
+                Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode)node).cacheMetrics();
+                assertNotNull(metrics);
+                assertFalse(metrics.isEmpty());
+            }
 
-        destroyCaches();
+            assertMetrics(cache1, true);
+            assertMetrics(cache2, true);
+        }
+        finally {
+            destroyCaches();
+        }
     }
 
     /**
@@ -119,26 +122,29 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest
     public void testMetricsStatisticsDisabled() throws Exception {
         createCaches(false);
 
-        populateCacheData(cache1, ENTRY_CNT_CACHE1);
-        populateCacheData(cache2, ENTRY_CNT_CACHE2);
+        try {
+            populateCacheData(cache1, ENTRY_CNT_CACHE1);
+            populateCacheData(cache2, ENTRY_CNT_CACHE2);
 
-        readCacheData(cache1, ENTRY_CNT_CACHE1);
-        readCacheData(cache2, ENTRY_CNT_CACHE2);
+            readCacheData(cache1, ENTRY_CNT_CACHE1);
+            readCacheData(cache2, ENTRY_CNT_CACHE2);
 
-        awaitMetricsUpdate();
+            awaitMetricsUpdate();
 
-        Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
+            Collection<ClusterNode> nodes = grid(0).cluster().forRemotes().nodes();
 
-        for (ClusterNode node : nodes) {
-            Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
-            assertNotNull(metrics);
-            assertTrue(metrics.isEmpty());
-        }
-
-        assertMetrics(cache1);
-        assertMetrics(cache2);
+            for (ClusterNode node : nodes) {
+                Map<Integer, CacheMetrics> metrics = ((TcpDiscoveryNode) node).cacheMetrics();
+                assertNotNull(metrics);
+                assertTrue(metrics.isEmpty());
+            }
 
-        destroyCaches();
+            assertMetrics(cache1, false);
+            assertMetrics(cache2, false);
+        }
+        finally {
+            destroyCaches();
+        }
     }
 
     /**
@@ -200,13 +206,13 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest
      */
     private void readCacheData(IgniteCache<Integer, Integer> cache, int cnt) {
         for (int i = 0; i < cnt; i++)
-            cache.get(i);
+            grid(i % GRID_CNT).cache(cache.getName()).get(i);
     }
 
     /**
      * @param cache Cache.
      */
-    private void assertMetrics(IgniteCache<Integer, Integer> cache) {
+    private void assertMetrics(IgniteCache<Integer, Integer> cache, boolean expectNonZero) {
         CacheMetrics[] ms = new CacheMetrics[GRID_CNT];
 
         for (int i = 0; i < GRID_CNT; i++) {
@@ -220,36 +226,65 @@ public class CacheMetricsForClusterGroupSelfTest extends GridCommonAbstractTest
                 assertEquals(metrics.name(), ms[j].name());
 
             // Dynamic metrics
-            assertEquals(metrics.getCacheGets(), sum(ms, new IgniteClosure<CacheMetrics, Long>() {
+            long sumGets = sum(ms, new IgniteClosure<CacheMetrics, Long>() {
                 @Override public Long apply(CacheMetrics input) {
                     return input.getCacheGets();
                 }
-            }));
+            }, expectNonZero);
+
+            assertEquals(metrics.getCacheGets(), sumGets);
+            assertEquals(cache.mxBean().getCacheGets(), sumGets);
 
-            assertEquals(metrics.getCachePuts(), sum(ms, new IgniteClosure<CacheMetrics, Long>() {
+            long sumPuts = sum(ms, new IgniteClosure<CacheMetrics, Long>() {
                 @Override public Long apply(CacheMetrics input) {
                     return input.getCachePuts();
                 }
-            }));
+            }, expectNonZero);
 
-            assertEquals(metrics.getCacheHits(), sum(ms, new IgniteClosure<CacheMetrics, Long>() {
+            assertEquals(metrics.getCachePuts(), sumPuts);
+            assertEquals(cache.mxBean().getCachePuts(), sumPuts);
+
+            long sumHits = sum(ms, new IgniteClosure<CacheMetrics, Long>() {
                 @Override public Long apply(CacheMetrics input) {
                     return input.getCacheHits();
                 }
-            }));
+            }, expectNonZero);
+
+            assertEquals(metrics.getCacheHits(), sumHits);
+            assertEquals(cache.mxBean().getCacheHits(), sumHits);
+
+            if (expectNonZero) {
+                long sumHeapEntries = sum(ms, new IgniteClosure<CacheMetrics, Long>() {
+                    @Override public Long apply(CacheMetrics input) {
+                        return input.getHeapEntriesCount();
+                    }
+                    // Currently non-zero even when statistics is off
+                }, true);
+
+                assertEquals(metrics.getHeapEntriesCount(), sumHeapEntries);
+                assertEquals(cache.mxBean().getHeapEntriesCount(), sumHeapEntries);
+            }
+
         }
     }
 
     /**
      * @param ms Milliseconds.
      * @param f Function.
+     * @param expectNonZero Check if each value is non-zero.
      */
-    private long sum(CacheMetrics[] ms, IgniteClosure<CacheMetrics, Long> f) {
+    private long sum(CacheMetrics[] ms, IgniteClosure<CacheMetrics, Long> f, boolean expectNonZero) {
         long res = 0;
 
-        for (int i = 0; i < GRID_CNT; i++)
-            res += f.apply(ms[i]);
+        for (int i = 0; i < GRID_CNT; i++) {
+            long val = f.apply(ms[i]);
+
+            if (expectNonZero)
+                assertTrue(val > 0);
+
+            res += val;
+        }
 
         return res;
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/218416c3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java
index a3d3130..e13f99b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/OffheapCacheMetricsForClusterGroupSelfTest.java
@@ -117,14 +117,31 @@ public class OffheapCacheMetricsForClusterGroupSelfTest extends GridCommonAbstra
     }
 
     private void assertGetOffHeapPrimaryEntriesCount(String cacheName, int count) throws Exception {
+        long localPrimary = 0L;
+        long localBackups = 0L;
+
         for (int i = 0; i < GRID_CNT; i++) {
             IgniteCache<Integer, Integer> cache = grid("server-" + i).cache(cacheName);
             assertEquals(count, cache.metrics().getOffHeapPrimaryEntriesCount());
+            assertEquals(count, cache.mxBean().getOffHeapPrimaryEntriesCount());
+            assertEquals(count, cache.metrics().getOffHeapBackupEntriesCount());
+            assertEquals(count, cache.mxBean().getOffHeapBackupEntriesCount());
+
+            localPrimary += cache.localMxBean().getOffHeapPrimaryEntriesCount();
+            localBackups += cache.localMxBean().getOffHeapPrimaryEntriesCount();
         }
 
+        assertEquals(count, localPrimary);
+        assertEquals(count, localBackups);
+
         for (int i = 0; i < CLIENT_CNT; i++) {
             IgniteCache<Integer, Integer> cache = grid("client-" + i).cache(cacheName);
             assertEquals(count, cache.metrics().getOffHeapPrimaryEntriesCount());
+            assertEquals(count, cache.mxBean().getOffHeapPrimaryEntriesCount());
+            assertEquals(count, cache.metrics().getOffHeapBackupEntriesCount());
+            assertEquals(count, cache.mxBean().getOffHeapBackupEntriesCount());
+            assertEquals(0L, cache.localMxBean().getOffHeapPrimaryEntriesCount());
+            assertEquals(0L, cache.localMxBean().getOffHeapBackupEntriesCount());
         }
     }
 
@@ -135,4 +152,4 @@ public class OffheapCacheMetricsForClusterGroupSelfTest extends GridCommonAbstra
         cfg.setStatisticsEnabled(true);
         return cfg;
     }
-}
\ No newline at end of file
+}


[11/15] ignite git commit: Removed unused GridDhtLocalPartition.evictHist.

Posted by sb...@apache.org.
Removed unused GridDhtLocalPartition.evictHist.


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

Branch: refs/heads/ignite-5937
Commit: 74c48496d432367856da380f17ffb788810782c4
Parents: bf99fd3
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 10 14:35:00 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 10 14:35:00 2017 +0300

----------------------------------------------------------------------
 .../distributed/dht/GridDhtLocalPartition.java  | 59 --------------------
 .../dht/preloader/GridDhtPartitionDemander.java |  9 ---
 2 files changed, 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/74c48496/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index f0e0d47..c363729 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -17,10 +17,8 @@
 
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -127,10 +125,6 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
     @GridToStringExclude
     private final long createTime = U.currentTimeMillis();
 
-    /** Eviction history. */
-    @GridToStringExclude
-    private final Map<KeyCacheObject, GridCacheVersion> evictHist = new HashMap<>();
-
     /** Lock. */
     @GridToStringExclude
     private final ReentrantLock lock = new ReentrantLock();
@@ -429,53 +423,6 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
     }
 
     /**
-     * @param key Key.
-     * @param ver Version.
-     */
-    public void onEntryEvicted(KeyCacheObject key, GridCacheVersion ver) {
-        assert key != null;
-        assert ver != null;
-        assert lock.isHeldByCurrentThread(); // Only one thread can enter this method at a time.
-
-        if (state() != MOVING)
-            return;
-
-        Map<KeyCacheObject, GridCacheVersion> evictHist0 = evictHist;
-
-        if (evictHist0 != null) {
-            GridCacheVersion ver0 = evictHist0.get(key);
-
-            if (ver0 == null || ver0.isLess(ver)) {
-                GridCacheVersion ver1 = evictHist0.put(key, ver);
-
-                assert ver1 == ver0;
-            }
-        }
-    }
-
-    /**
-     * Cache preloader should call this method within partition lock.
-     *
-     * @param key Key.
-     * @param ver Version.
-     * @return {@code True} if preloading is permitted.
-     */
-    public boolean preloadingPermitted(KeyCacheObject key, GridCacheVersion ver) {
-        assert key != null;
-        assert ver != null;
-        assert lock.isHeldByCurrentThread(); // Only one thread can enter this method at a time.
-
-        if (state() != MOVING)
-            return false;
-
-        GridCacheVersion ver0 = evictHist.get(key);
-
-        // Permit preloading if version in history
-        // is missing or less than passed in.
-        return ver0 == null || ver0.isLess(ver);
-    }
-
-    /**
      * Reserves a partition so it won't be cleared.
      *
      * @return {@code True} if reserved.
@@ -593,9 +540,6 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
                 if (log.isDebugEnabled())
                     log.debug("Owned partition: " + this);
 
-                // No need to keep history any more.
-                evictHist.clear();
-
                 return true;
             }
         }
@@ -637,9 +581,6 @@ public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements
                 if (log.isDebugEnabled())
                     log.debug("Marked partition as LOST: " + this);
 
-                // No need to keep history any more.
-                evictHist.clear();
-
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/74c48496/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 54661ec..b0ac657 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -674,15 +674,6 @@ public class GridDhtPartitionDemander {
                         try {
                             // Loop through all received entries and try to preload them.
                             for (GridCacheEntryInfo entry : e.getValue().infos()) {
-                                if (!part.preloadingPermitted(entry.key(), entry.version())) {
-                                    if (log.isDebugEnabled())
-                                        log.debug("Preloading is not permitted for entry due to " +
-                                            "evictions [key=" + entry.key() +
-                                            ", ver=" + entry.version() + ']');
-
-                                    continue;
-                                }
-
                                 if (!preloadEntry(node, p, entry, topVer)) {
                                     if (log.isDebugEnabled())
                                         log.debug("Got entries for invalid partition during " +


[09/15] ignite git commit: IGNITE-6569: Fixed hang when trying to execute "DROP TABLE" on the cache this table belongs to. This closes #2823.

Posted by sb...@apache.org.
IGNITE-6569: Fixed hang when trying to execute "DROP TABLE" on the cache this table belongs to. This closes #2823.


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

Branch: refs/heads/ignite-5937
Commit: 5f67cf25d6ead0e62ba973be7a6f3cd8cab49678
Parents: 2e55682
Author: Alexander Paschenko <al...@gmail.com>
Authored: Mon Oct 9 22:17:28 2017 +0300
Committer: devozerov <pp...@gmail.com>
Committed: Mon Oct 9 22:17:28 2017 +0300

----------------------------------------------------------------------
 .../processors/query/GridQueryProcessor.java    | 17 +++++++++++++++
 .../cache/index/H2DynamicTableSelfTest.java     | 23 ++++++++++++++++++++
 2 files changed, 40 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5f67cf25/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 f044c1d..0d8ee47 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
@@ -70,6 +70,7 @@ import org.apache.ignite.internal.processors.cache.StoredCacheData;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryFuture;
 import org.apache.ignite.internal.processors.cache.query.CacheQueryType;
 import org.apache.ignite.internal.processors.cache.query.GridCacheQueryType;
+import org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.query.property.QueryBinaryProperty;
 import org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor;
@@ -186,6 +187,9 @@ public class GridQueryProcessor extends GridProcessorAdapter {
     /** Pending status messages. */
     private final LinkedList<SchemaOperationStatusMessage> pendingMsgs = new LinkedList<>();
 
+    /** Current cache that has a query running on it. */
+    private final ThreadLocal<GridCacheContext> curCache = new ThreadLocal<>();
+
     /** Disconnected flag. */
     private boolean disconnected;
 
@@ -1440,6 +1444,13 @@ public class GridQueryProcessor extends GridProcessorAdapter {
      */
     @SuppressWarnings("unchecked")
     public void dynamicTableDrop(String cacheName, String tblName, boolean ifExists) throws SchemaOperationException {
+        GridCacheContext currCache = this.curCache.get();
+
+        if (currCache != null && F.eq(currCache.name(), cacheName))
+            throw new IgniteSQLException("DROP TABLE cannot be called from the same cache that holds " +
+                "the table being dropped [cacheName-" + cacheName + ", tblName=" + tblName + ']',
+                IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
+
         boolean res = ctx.grid().destroyCache0(cacheName, true);
 
         if (!res && !ifExists)
@@ -1853,6 +1864,10 @@ public class GridQueryProcessor extends GridProcessorAdapter {
         if (!busyLock.enterBusy())
             throw new IllegalStateException("Failed to execute query (grid is stopping).");
 
+        GridCacheContext oldCctx = curCache.get();
+
+        curCache.set(cctx);
+
         try {
             final String schemaName = qry.getSchema() != null ? qry.getSchema() : idx.schema(cctx.name());
             final int mainCacheId = CU.cacheId(cctx.name());
@@ -1898,6 +1913,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
             throw new CacheException(e);
         }
         finally {
+            curCache.set(oldCctx);
+
             busyLock.leaveBusy();
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5f67cf25/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index e0ab6c5..b108bb3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -652,6 +652,29 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
     }
 
     /**
+     * Test that attempting to execute {@code DROP TABLE} via API of cache being dropped yields an error.
+     * @throws Exception if failed.
+     */
+    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+    public void testCacheSelfDrop() throws Exception {
+        execute("CREATE TABLE IF NOT EXISTS \"Person\" (\"id\" int, \"city\" varchar," +
+            " \"name\" varchar, \"surname\" varchar, \"age\" int, PRIMARY KEY (\"id\", \"city\")) WITH " +
+            "\"template=cache\"");
+
+        GridTestUtils.assertThrows(null, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                client().cache(QueryUtils.createTableCacheName(QueryUtils.DFLT_SCHEMA, "Person"))
+                    .query(new SqlFieldsQuery("DROP TABLE \"Person\"")).getAll();
+
+                return null;
+            }
+        }, IgniteSQLException.class, "DROP TABLE cannot be called from the same cache that holds the table " +
+            "being dropped");
+
+        execute("DROP TABLE \"Person\"");
+    }
+
+    /**
      * Test that attempting to {@code DROP TABLE} that does not exist does not yield an error if the statement contains
      *     {@code IF EXISTS} clause.
      *


[15/15] ignite git commit: ignite-5937

Posted by sb...@apache.org.
ignite-5937


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

Branch: refs/heads/ignite-5937
Commit: bb969db0457e46fc2db4322927bd3536fdd9fb7b
Parents: de3ed0d
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 10 15:36:01 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 10 15:41:21 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheEntryInfo.java    |   5 -
 .../processors/cache/GridCacheMapEntry.java     |  18 ++-
 .../cache/IgniteCacheOffheapManager.java        |  39 +++++
 .../cache/IgniteCacheOffheapManagerImpl.java    | 160 +++++++++++++------
 .../cache/mvcc/MvccCoordinatorVersion.java      |   5 -
 .../mvcc/MvccCoordinatorVersionResponse.java    |   5 -
 .../persistence/GridCacheOffheapManager.java    |  14 ++
 .../processors/cache/tree/MvccRemoveRow.java    |  11 +-
 .../processors/cache/tree/MvccUpdateRow.java    |  25 ++-
 .../datastreamer/DataStreamerImpl.java          |   6 +-
 .../cache/mvcc/CacheMvccTransactionsTest.java   |  34 +++-
 11 files changed, 235 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
index 8a5f0df..e09d33c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
@@ -101,11 +101,6 @@ public class GridCacheEntryInfo implements Message, MvccCoordinatorVersion {
         return 0;
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean initialLoad() {
-        return true;
-    }
-
     /**
      * @return Cache ID.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index ded9513..a1535e9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -2581,6 +2581,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
             boolean walEnabled = !cctx.isNear() && cctx.shared().wal() != null;
 
+            // TODO IGNITE-3478: move checks in special initialValue method.
             if (cctx.shared().database().persistenceEnabled()) {
                 unswap(false);
 
@@ -2603,14 +2604,19 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                 val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
 
-                if (val != null) {
-                    if (cctx.mvccEnabled())
-                        cctx.offheap().mvccUpdate(false, this, val, ver, mvccVer);
-                    else
-                        storeValue(val, expTime, ver, null);
+                if (cctx.mvccEnabled()) {
+                    cctx.offheap().mvccInitialValue(this, val, ver, mvccVer);
+
+                    if (val != null)
+                        update(val, expTime, ttl, ver, true);
                 }
+                else {
+                    if (val != null) {
+                        storeValue(val, expTime, ver, null);
 
-                update(val, expTime, ttl, ver, true);
+                        update(val, expTime, ttl, ver, true);
+                    }
+                }
 
                 boolean skipQryNtf = false;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index bee2108..9e3d0fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -189,6 +189,7 @@ public interface IgniteCacheOffheapManager {
         throws IgniteCheckedException;
 
     /**
+     * @param primary {@code True} if on primary node.
      * @param entry Entry.
      * @param val Value.
      * @param ver Cache version.
@@ -204,6 +205,13 @@ public interface IgniteCacheOffheapManager {
         MvccCoordinatorVersion mvccVer
     ) throws IgniteCheckedException;
 
+    /**
+     * @param primary {@code True} if on primary node.
+     * @param entry Entry.
+     * @param mvccVer Mvcc update version.
+     * @return Transactions to wait for before finishing current transaction.
+     * @throws IgniteCheckedException If failed.
+     */
     @Nullable public GridLongList mvccRemove(
         boolean primary,
         GridCacheMapEntry entry,
@@ -211,6 +219,21 @@ public interface IgniteCacheOffheapManager {
     ) throws IgniteCheckedException;
 
     /**
+     * @param entry Entry.
+     * @param val Value.
+     * @param ver Version.
+     * @param mvccVer Mvcc update version.
+     * @return {@code True} if value was inserted.
+     * @throws IgniteCheckedException If failed.
+     */
+    public boolean mvccInitialValue(
+        GridCacheMapEntry entry,
+        @Nullable CacheObject val,
+        GridCacheVersion ver,
+        MvccCoordinatorVersion mvccVer
+    ) throws IgniteCheckedException;
+
+    /**
      * @param cctx Cache context.
      * @param key  Key.
      * @param val  Value.
@@ -507,6 +530,22 @@ public interface IgniteCacheOffheapManager {
          * @param val Value.
          * @param ver Version.
          * @param mvccVer Mvcc version.
+         * @return {@code True} if new value was inserted.
+         * @throws IgniteCheckedException If failed.
+         */
+        boolean mvccInitialValue(
+            GridCacheContext cctx,
+            KeyCacheObject key,
+            @Nullable CacheObject val,
+            GridCacheVersion ver,
+            MvccCoordinatorVersion mvccVer) throws IgniteCheckedException;
+
+        /**
+         * @param cctx Cache context.
+         * @param key Key.
+         * @param val Value.
+         * @param ver Version.
+         * @param mvccVer Mvcc version.
          * @return List of transactions to wait for.
          * @throws IgniteCheckedException If failed.
          */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 380ec94..4fb5bfd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -383,6 +383,20 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
     }
 
     /** {@inheritDoc} */
+    @Override public boolean mvccInitialValue(
+        GridCacheMapEntry entry,
+        CacheObject val,
+        GridCacheVersion ver,
+        MvccCoordinatorVersion mvccVer) throws IgniteCheckedException {
+        return dataStore(entry.localPartition()).mvccInitialValue(
+            entry.context(),
+            entry.key(),
+            val,
+            ver,
+            mvccVer);
+    }
+
+    /** {@inheritDoc} */
     @Override public GridLongList mvccUpdate(
         boolean primary,
         GridCacheMapEntry entry,
@@ -1360,9 +1374,76 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
         }
 
         /** {@inheritDoc} */
-        @Override public GridLongList mvccRemove(GridCacheContext cctx,
+        @Override public boolean mvccInitialValue(
+            GridCacheContext cctx,
+            KeyCacheObject key,
+            @Nullable CacheObject val,
+            GridCacheVersion ver,
+            MvccCoordinatorVersion mvccVer)
+            throws IgniteCheckedException
+        {
+            assert mvccVer != null;
+
+            if (!busyLock.enterBusy())
+                throw new NodeStoppingException("Operation has been cancelled (node is stopping).");
+
+            try {
+                assert val != null || CacheCoordinatorsProcessor.versionForRemovedValue(mvccVer.coordinatorVersion());
+
+                int cacheId = grp.storeCacheIdInDataPage() ? cctx.cacheId() : CU.UNDEFINED_CACHE_ID;
+
+                CacheObjectContext coCtx = cctx.cacheObjectContext();
+
+                // Make sure value bytes initialized.
+                key.valueBytes(coCtx);
+
+                MvccUpdateRow updateRow;
+
+                if (val != null) {
+                    val.valueBytes(coCtx);
+
+                    updateRow = new MvccUpdateRow(
+                        key,
+                        val,
+                        ver,
+                        mvccVer,
+                        partId,
+                        cacheId);
+                }
+                else {
+                    updateRow = new MvccRemoveRow(
+                        key,
+                        mvccVer,
+                        partId,
+                        cacheId);
+                }
+
+                if (grp.sharedGroup() && updateRow.cacheId() == CU.UNDEFINED_CACHE_ID)
+                    updateRow.cacheId(cctx.cacheId());
+
+                rowStore.addRow(updateRow);
+
+                boolean old = dataTree.putx(updateRow);
+
+                assert !old;
+
+                if (val != null)
+                    incrementSize(cctx.cacheId());
+            }
+            finally {
+                busyLock.leaveBusy();
+            }
+
+            return true;
+        }
+
+        /** {@inheritDoc} */
+        @Override public GridLongList mvccUpdate(
+            GridCacheContext cctx,
             boolean primary,
             KeyCacheObject key,
+            CacheObject val,
+            GridCacheVersion ver,
             MvccCoordinatorVersion mvccVer) throws IgniteCheckedException {
             assert mvccVer != null;
 
@@ -1376,9 +1457,12 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
                 // Make sure value bytes initialized.
                 key.valueBytes(coCtx);
+                val.valueBytes(coCtx);
 
-                MvccRemoveRow updateRow = new MvccRemoveRow(
+                MvccUpdateRow updateRow = new MvccUpdateRow(
                     key,
+                    val,
+                    ver,
                     mvccVer,
                     partId,
                     cacheId);
@@ -1392,27 +1476,20 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
                 if (res == MvccUpdateRow.UpdateResult.VERSION_FOUND) {
                     assert !primary : updateRow;
-
-                    cleanup(updateRow.cleanupRows(), false);
                 }
                 else {
-                    if (res == MvccUpdateRow.UpdateResult.PREV_NOT_NULL)
-                        decrementSize(cacheId);
-
-                    CacheSearchRow rmvRow = cleanup(updateRow.cleanupRows(), true);
-
-                    if (rmvRow == null)
-                        rowStore.addRow(updateRow);
-                    else
-                        updateRow.link(rmvRow.link());
-
-                    assert updateRow.link() != 0L;
+                    rowStore.addRow(updateRow);
 
                     boolean old = dataTree.putx(updateRow);
 
                     assert !old;
+
+                    if (res == MvccUpdateRow.UpdateResult.PREV_NULL)
+                        incrementSize(cctx.cacheId());
                 }
 
+                cleanup(updateRow.cleanupRows(), false);
+
                 return updateRow.activeTransactions();
             }
             finally {
@@ -1421,12 +1498,9 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
         }
 
         /** {@inheritDoc} */
-        @Override public GridLongList mvccUpdate(
-            GridCacheContext cctx,
+        @Override public GridLongList mvccRemove(GridCacheContext cctx,
             boolean primary,
             KeyCacheObject key,
-            CacheObject val,
-            GridCacheVersion ver,
             MvccCoordinatorVersion mvccVer) throws IgniteCheckedException {
             assert mvccVer != null;
 
@@ -1440,12 +1514,9 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
                 // Make sure value bytes initialized.
                 key.valueBytes(coCtx);
-                val.valueBytes(coCtx);
 
-                MvccUpdateRow updateRow = new MvccUpdateRow(
+                MvccRemoveRow updateRow = new MvccRemoveRow(
                     key,
-                    val,
-                    ver,
                     mvccVer,
                     partId,
                     cacheId);
@@ -1453,42 +1524,34 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
                 if (grp.sharedGroup() && updateRow.cacheId() == CU.UNDEFINED_CACHE_ID)
                     updateRow.cacheId(cctx.cacheId());
 
-                GridLongList waitTxs = null;
-
-                if (mvccVer.initialLoad()) {
-                    rowStore.addRow(updateRow);
+                dataTree.iterate(updateRow, new MvccKeyMinVersionBound(cacheId, key), updateRow);
 
-                    boolean old = dataTree.putx(updateRow);
+                MvccUpdateRow.UpdateResult res = updateRow.updateResult();
 
-                    assert !old;
+                if (res == MvccUpdateRow.UpdateResult.VERSION_FOUND) {
+                    assert !primary : updateRow;
 
-                    incrementSize(cctx.cacheId());
+                    cleanup(updateRow.cleanupRows(), false);
                 }
                 else {
-                    dataTree.iterate(updateRow, new MvccKeyMinVersionBound(cacheId, key), updateRow);
+                    if (res == MvccUpdateRow.UpdateResult.PREV_NOT_NULL)
+                        decrementSize(cacheId);
 
-                    MvccUpdateRow.UpdateResult res = updateRow.updateResult();
+                    CacheSearchRow rmvRow = cleanup(updateRow.cleanupRows(), true);
 
-                    if (res == MvccUpdateRow.UpdateResult.VERSION_FOUND) {
-                        assert !primary : updateRow;
-                    }
-                    else {
+                    if (rmvRow == null)
                         rowStore.addRow(updateRow);
+                    else
+                        updateRow.link(rmvRow.link());
 
-                        boolean old = dataTree.putx(updateRow);
-
-                        assert !old;
-
-                        if (res == MvccUpdateRow.UpdateResult.PREV_NULL)
-                            incrementSize(cctx.cacheId());
-                    }
+                    assert updateRow.link() != 0L;
 
-                    cleanup(updateRow.cleanupRows(), false);
+                    boolean old = dataTree.putx(updateRow);
 
-                    waitTxs = updateRow.activeTransactions();
+                    assert !old;
                 }
 
-                return waitTxs;
+                return updateRow.activeTransactions();
             }
             finally {
                 busyLock.leaveBusy();
@@ -1848,7 +1911,10 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
 
                         long rowCrdVer = unmaskCoordinatorVersion(rowCrdVerMasked);
 
-                        if (rowCrdVer > ver.coordinatorVersion() || row.mvccCounter() > ver.counter())
+                        if (rowCrdVer > ver.coordinatorVersion())
+                            continue;
+
+                        if (rowCrdVer == ver.coordinatorVersion() && row.mvccCounter() > ver.counter())
                             continue;
 
                         MvccLongList txs = ver.activeTransactions();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
index 4003b73..d80e43c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersion.java
@@ -42,9 +42,4 @@ public interface MvccCoordinatorVersion extends Message {
      * @return Counter.
      */
     public long counter();
-
-    /**
-     * @return {@code True} if version for initial load update.
-     */
-    public boolean initialLoad();
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
index 20d23ed..c037226 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/mvcc/MvccCoordinatorVersionResponse.java
@@ -159,11 +159,6 @@ public class MvccCoordinatorVersionResponse implements MvccCoordinatorMessage, M
     }
 
     /** {@inheritDoc} */
-    @Override public boolean initialLoad() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
         writer.setBuffer(buf);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
index ee651c2..45b78d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/GridCacheOffheapManager.java
@@ -1256,6 +1256,20 @@ public class GridCacheOffheapManager extends IgniteCacheOffheapManagerImpl imple
         }
 
         /** {@inheritDoc} */
+        @Override public boolean mvccInitialValue(
+            GridCacheContext cctx,
+            KeyCacheObject key,
+            @Nullable CacheObject val,
+            GridCacheVersion ver,
+            MvccCoordinatorVersion mvccVer)
+            throws IgniteCheckedException
+        {
+            CacheDataStore delegate = init0(false);
+
+            return delegate.mvccInitialValue(cctx, key, val, ver, mvccVer);
+        }
+
+        /** {@inheritDoc} */
         @Override public GridLongList mvccUpdate(
             GridCacheContext cctx,
             boolean primary,

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
index 8fd8a6e..af11a9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccRemoveRow.java
@@ -18,10 +18,12 @@
 package org.apache.ignite.internal.processors.cache.tree;
 
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor;
 import org.apache.ignite.internal.processors.cache.mvcc.MvccCoordinatorVersion;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.createVersionForRemovedValue;
+import static org.apache.ignite.internal.processors.cache.mvcc.CacheCoordinatorsProcessor.unmaskCoordinatorVersion;
+
 /**
  *
  */
@@ -42,7 +44,12 @@ public class MvccRemoveRow extends MvccUpdateRow {
 
     /** {@inheritDoc} */
     @Override public long mvccCoordinatorVersion() {
-        return CacheCoordinatorsProcessor.createVersionForRemovedValue(super.mvccCoordinatorVersion());
+        return createVersionForRemovedValue(super.mvccCoordinatorVersion());
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long unmaskedCoordinatorVersion() {
+        return unmaskCoordinatorVersion(super.mvccCoordinatorVersion());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
index 794661d..137ca28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/MvccUpdateRow.java
@@ -105,13 +105,13 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
         long rowCrdVer = unmaskCoordinatorVersion(io.getMvccCoordinatorVersion(pageAddr, idx));
         long rowCntr = io.getMvccCounter(pageAddr, idx);
 
-        int cmp = Long.compare(mvccVer.coordinatorVersion(), rowCrdVer);
+        int cmp = Long.compare(unmaskedCoordinatorVersion(), rowCrdVer);
 
         if (cmp == 0)
             cmp = Long.compare(mvccVer.counter(), rowCntr);
 
         // Can be equals if backup rebalanced value updated on primary.
-        assert cmp >= 0 : "[updCrd=" + mvccVer.coordinatorVersion() +
+        assert cmp >= 0 : "[updCrd=" + unmaskedCoordinatorVersion() +
             ", updCntr=" + mvccVer.counter() +
             ", rowCrd=" + rowCrdVer +
             ", rowCntr=" + rowCntr + ']';
@@ -138,11 +138,13 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
         long rowCrdVerMasked = rowIo.getMvccCoordinatorVersion(pageAddr, idx);
         long rowCrdVer = unmaskCoordinatorVersion(rowCrdVerMasked);
 
+        long crdVer = unmaskedCoordinatorVersion();
+
         if (res == null) {
-            int cmp = Long.compare(mvccVer.coordinatorVersion(), rowCrdVer);
+            int cmp = Long.compare(crdVer, rowCrdVer);
 
             if (cmp == 0)
-                cmp = Long.compare(mvccVer.coordinatorVersion(), rowIo.getMvccCounter(pageAddr, idx));
+                cmp = Long.compare(mvccVer.counter(), rowIo.getMvccCounter(pageAddr, idx));
 
             if (cmp == 0)
                 res = UpdateResult.VERSION_FOUND;
@@ -152,7 +154,7 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
         }
 
         // Suppose transactions on previous coordinator versions are done.
-        if (checkActive && mvccVer.coordinatorVersion() == rowCrdVer) {
+        if (checkActive && crdVer == rowCrdVer) {
             long rowMvccCntr = rowIo.getMvccCounter(pageAddr, idx);
 
             if (mvccVer.activeTransactions().contains(rowMvccCntr)) {
@@ -166,11 +168,11 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
         }
 
         if (!txActive) {
-            assert Long.compare(mvccVer.coordinatorVersion(), rowCrdVer) >= 0;
+            assert Long.compare(crdVer, rowCrdVer) >= 0;
 
             int cmp;
 
-            if (mvccVer.coordinatorVersion() == rowCrdVer)
+            if (crdVer == rowCrdVer)
                 cmp = Long.compare(mvccVer.cleanupVersion(), rowIo.getMvccCounter(pageAddr, idx));
             else
                 cmp = 1;
@@ -183,7 +185,7 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
                     assert row.link() != 0 && row.mvccCounter() != CacheCoordinatorsProcessor.COUNTER_NA : row;
 
                     // Should not be possible to cleanup active tx.
-                    assert rowCrdVer != mvccVer.coordinatorVersion()
+                    assert rowCrdVer != crdVer
                         || !mvccVer.activeTransactions().contains(row.mvccCounter());
 
                     if (cleanupRows == null)
@@ -199,6 +201,13 @@ public class MvccUpdateRow extends DataRow implements BPlusTree.TreeRowClosure<C
         return true;
     }
 
+    /**
+     * @return Coordinator version without flags.
+     */
+    protected long unmaskedCoordinatorVersion() {
+        return mvccVer.coordinatorVersion();
+    }
+
     /** {@inheritDoc} */
     @Override public long mvccCoordinatorVersion() {
         return mvccVer.coordinatorVersion();

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
index 6ced2f9..30145ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastreamer/DataStreamerImpl.java
@@ -134,11 +134,7 @@ public class DataStreamerImpl<K, V> implements IgniteDataStreamer<K, V>, Delayed
 
     /** Version which is less then any version generated on coordinator. */
     private static final MvccCoordinatorVersion ISOLATED_STREAMER_MVCC_VER =
-        new MvccCoordinatorVersionResponse(1L, CacheCoordinatorsProcessor.START_VER, 0L) {
-            @Override public boolean initialLoad() {
-                return true;
-            }
-        };
+        new MvccCoordinatorVersionResponse(1L, CacheCoordinatorsProcessor.START_VER, 0L);
 
     /** Cache receiver. */
     private StreamReceiver<K, V> rcvr = ISOLATED_UPDATER;

http://git-wip-us.apache.org/repos/asf/ignite/blob/bb969db0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
index d45afe7..1abc116 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/mvcc/CacheMvccTransactionsTest.java
@@ -1786,13 +1786,33 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
 
         final IgniteCache<Object, Object> cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, 64));
 
-        final int KEYS = 100;
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 0; k < 100; k++)
+                cache.remove(k);
 
-        checkValues(new HashMap<>(), cache);
+            tx.commit();
+        }
+
+        Map<Object, Object> expVals = new HashMap<>();
 
         try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
-            for (int k = 0; k < KEYS; k++)
-                cache.remove(k);
+            for (int k = 100; k < 200; k++) {
+                cache.put(k, k);
+
+                expVals.put(k, k);
+            }
+
+            tx.commit();
+        }
+
+        try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+            for (int k = 100; k < 200; k++) {
+                if (k % 2 == 0) {
+                    cache.remove(k);
+
+                    expVals.remove(k);
+                }
+            }
 
             tx.commit();
         }
@@ -1800,6 +1820,12 @@ public class CacheMvccTransactionsTest extends GridCommonAbstractTest {
         startGrid(1);
 
         awaitPartitionMapExchange();
+
+        checkValues(expVals, jcache(1));
+
+        stopGrid(0);
+
+        checkValues(expVals, jcache(1));
     }
 
     /**


[02/15] ignite git commit: IGNITE-6529: JDBC thin: fixed driver protocol compatibility. This closes #2819.

Posted by sb...@apache.org.
IGNITE-6529: JDBC thin: fixed driver protocol compatibility. This closes #2819.


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

Branch: refs/heads/ignite-5937
Commit: dc514c7083bc5529c886f6cce3d600663733e6d7
Parents: 3184437
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Mon Oct 9 15:14:23 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Oct 9 15:14:23 2017 +0300

----------------------------------------------------------------------
 .../internal/jdbc/thin/JdbcThinTcpIo.java       | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/dc514c70/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
index 688f908..9e12fbf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinTcpIo.java
@@ -49,6 +49,9 @@ public class JdbcThinTcpIo {
     /** Version 2.1.0. */
     private static final ClientListenerProtocolVersion VER_2_1_0 = ClientListenerProtocolVersion.create(2, 1, 0);
 
+    /** Version 2.1.5: added "lazy" flag. */
+    private static final ClientListenerProtocolVersion VER_2_1_5 = ClientListenerProtocolVersion.create(2, 1, 5);
+
     /** Version 2.3.1. */
     private static final ClientListenerProtocolVersion VER_2_3_0 = ClientListenerProtocolVersion.create(2, 3, 0);
 
@@ -180,22 +183,25 @@ public class JdbcThinTcpIo {
                 SqlStateCode.CLIENT_CONNECTION_FAILED, e);
         }
 
-        handshake();
+        handshake(CURRENT_VER);
     }
 
     /**
+     * Used for versions: 2.1.5 and 2.3.0. The protocol version is changed but handshake format isn't changed.
+     *
+     * @param ver JDBC client version.
      * @throws IOException On IO error.
      * @throws SQLException On connection reject.
      */
-    public void handshake() throws IOException, SQLException {
+    public void handshake(ClientListenerProtocolVersion ver) throws IOException, SQLException {
         BinaryWriterExImpl writer = new BinaryWriterExImpl(null, new BinaryHeapOutputStream(HANDSHAKE_MSG_SIZE),
             null, null);
 
         writer.writeByte((byte) ClientListenerRequest.HANDSHAKE);
 
-        writer.writeShort(CURRENT_VER.major());
-        writer.writeShort(CURRENT_VER.minor());
-        writer.writeShort(CURRENT_VER.maintenance());
+        writer.writeShort(ver.major());
+        writer.writeShort(ver.minor());
+        writer.writeShort(ver.maintenance());
 
         writer.writeByte(ClientListenerNioListener.JDBC_CLIENT);
 
@@ -238,7 +244,9 @@ public class JdbcThinTcpIo {
 
             ClientListenerProtocolVersion srvProtocolVer = ClientListenerProtocolVersion.create(maj, min, maintenance);
 
-            if (VER_2_1_0.equals(srvProtocolVer))
+            if (VER_2_1_5.equals(srvProtocolVer))
+                handshake(VER_2_1_5);
+            else if (VER_2_1_0.equals(srvProtocolVer))
                 handshake_2_1_0();
             else {
                 throw new SQLException("Handshake failed [driverProtocolVer=" + CURRENT_VER +


[14/15] ignite git commit: Merge remote-tracking branch 'remotes/origin/ignite-3478' into ignite-5937

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-3478' into ignite-5937


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

Branch: refs/heads/ignite-5937
Commit: de3ed0d3cb8b1474cc520f1001f9f378e5070699
Parents: 21bc633 61b46c4
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 10 14:43:11 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 10 14:43:11 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheMetrics.java   |  20 +
 .../internal/jdbc/thin/JdbcThinTcpIo.java       |  20 +-
 .../cache/CacheAffinitySharedManager.java       |  15 +-
 .../cache/CacheClusterMetricsMXBeanImpl.java    |  10 +
 .../cache/CacheLocalMetricsMXBeanImpl.java      |  10 +
 .../processors/cache/CacheMetricsImpl.java      |  14 +-
 .../processors/cache/CacheMetricsSnapshot.java  |  10 +
 .../processors/cache/ClusterCachesInfo.java     |   1 +
 .../distributed/dht/GridDhtLocalPartition.java  |  59 --
 .../dht/preloader/GridDhtPartitionDemander.java |   9 -
 .../processors/cluster/ClusterProcessor.java    |  39 +-
 .../processors/cluster/GridUpdateNotifier.java  | 224 +++----
 .../cluster/HttpIgniteUpdatesChecker.java       |  29 +-
 .../platform/client/ClientIntResponse.java      |  46 ++
 .../platform/client/ClientLongResponse.java     |  46 ++
 .../platform/client/ClientMessageParser.java    | 133 ++++
 .../cache/ClientCacheClearKeyRequest.java       |  44 ++
 .../cache/ClientCacheClearKeysRequest.java      |  44 ++
 .../client/cache/ClientCacheClearRequest.java   |  44 ++
 .../cache/ClientCacheContainsKeyRequest.java    |  45 ++
 .../cache/ClientCacheContainsKeysRequest.java   |  45 ++
 .../client/cache/ClientCacheGetAllRequest.java  |  46 ++
 .../client/cache/ClientCacheGetAllResponse.java |  57 ++
 .../ClientCacheGetAndPutIfAbsentRequest.java    |  45 ++
 .../cache/ClientCacheGetAndPutRequest.java      |  45 ++
 .../cache/ClientCacheGetAndRemoveRequest.java   |  45 ++
 .../cache/ClientCacheGetAndReplaceRequest.java  |  45 ++
 .../client/cache/ClientCacheGetRequest.java     |   9 +-
 .../client/cache/ClientCacheGetSizeRequest.java |  57 ++
 .../client/cache/ClientCacheKeyRequest.java     |  48 ++
 .../cache/ClientCacheKeyValueRequest.java       |  48 ++
 .../client/cache/ClientCacheKeysRequest.java    |  68 +++
 .../client/cache/ClientCachePutAllRequest.java  |  57 ++
 .../cache/ClientCachePutIfAbsentRequest.java    |  45 ++
 .../client/cache/ClientCachePutRequest.java     |  13 +-
 .../cache/ClientCacheRemoveAllRequest.java      |  44 ++
 .../cache/ClientCacheRemoveIfEqualsRequest.java |  45 ++
 .../cache/ClientCacheRemoveKeyRequest.java      |  45 ++
 .../cache/ClientCacheRemoveKeysRequest.java     |  44 ++
 .../ClientCacheReplaceIfEqualsRequest.java      |  50 ++
 .../client/cache/ClientCacheReplaceRequest.java |  45 ++
 .../client/cache/ClientCacheRequest.java        |   2 +-
 .../processors/query/GridQueryProcessor.java    |  19 +
 .../internal/visor/query/VisorQueryTask.java    |  15 +-
 .../cache/CacheGroupsMetricsRebalanceTest.java  |   6 +-
 .../CacheMetricsForClusterGroupSelfTest.java    | 119 ++--
 ...heapCacheMetricsForClusterGroupSelfTest.java |  19 +-
 .../cluster/GridUpdateNotifierSelfTest.java     |  50 +-
 .../platform/PlatformCacheWriteMetricsTask.java |  10 +
 .../cache/index/H2DynamicTableSelfTest.java     |  23 +
 .../IgnitePersistentStoreSchemaLoadTest.java    |   2 +
 .../Client/Cache/CacheTest.cs                   | 611 ++++++++++++++++++-
 .../Client/Cache/CacheTestNoMeta.cs             |   4 +-
 .../Client/ClientTestBase.cs                    |   9 +
 .../Client/Cache/ICacheClient.cs                | 155 +++++
 .../Client/IgniteClientException.cs             |   8 +
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  24 +-
 .../Impl/Client/Cache/CacheClient.cs            | 260 +++++++-
 .../Apache.Ignite.Core/Impl/Client/ClientOp.cs  |  21 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  21 +
 modules/web-console/backend/app/mongo.js        |   1 +
 .../frontend/app/helpers/jade/mixins.pug        |   9 +-
 .../generator/ConfigurationGenerator.js         |   6 +-
 .../frontend/app/modules/sql/sql.controller.js  |  14 +-
 .../states/configuration/caches/store.pug       |   4 +-
 .../configuration/clusters/attributes.pug       |   4 +-
 .../clusters/collision/job-stealing.pug         |   4 +-
 .../states/configuration/domains/general.pug    |   2 +-
 .../states/configuration/domains/query.pug      |   8 +-
 .../frontend/app/services/JavaTypes.service.js  |  15 +
 .../app/services/LegacyUtils.service.js         |  16 +-
 .../frontend/controllers/domains-controller.js  |   7 +-
 .../frontend/public/stylesheets/style.scss      |   8 +
 .../web-console/frontend/views/sql/sql.tpl.pug  |  10 +
 74 files changed, 2867 insertions(+), 427 deletions(-)
----------------------------------------------------------------------



[08/15] ignite git commit: IGNITE-6583 Proper getters for rebalance metrics were added; ignite-style getters (without get) were deprecated

Posted by sb...@apache.org.
IGNITE-6583 Proper getters for rebalance metrics were added; ignite-style getters (without get) were deprecated

Signed-off-by: Andrey Gura <ag...@apache.org>


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

Branch: refs/heads/ignite-5937
Commit: 2e556829386eda34fb1ac78a39d1a4b4c4af4ce2
Parents: a8ac443
Author: Sergey Chugunov <se...@gmail.com>
Authored: Mon Oct 9 18:35:11 2017 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Mon Oct 9 18:35:11 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheMetrics.java   | 20 ++++++++++++++++++++
 .../cache/CacheClusterMetricsMXBeanImpl.java    | 10 ++++++++++
 .../cache/CacheLocalMetricsMXBeanImpl.java      | 10 ++++++++++
 .../processors/cache/CacheMetricsImpl.java      | 12 +++++++++++-
 .../processors/cache/CacheMetricsSnapshot.java  | 10 ++++++++++
 .../cache/CacheGroupsMetricsRebalanceTest.java  |  6 +++---
 .../platform/PlatformCacheWriteMetricsTask.java | 10 ++++++++++
 7 files changed, 74 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
index 20ea692..fe789ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheMetrics.java
@@ -506,16 +506,36 @@ public interface CacheMetrics {
     public long getRebalancingBytesRate();
 
     /**
+     * This method is deprecated and will be deleted in future major release.
+     *
+     * Use {@link #getEstimatedRebalancingFinishTime()} instead.
+     *
      * @return Estimated rebalancing finished time.
      */
+    @Deprecated
     public long estimateRebalancingFinishTime();
 
     /**
+     * This method is deprecated and will be deleted in future major release.
+     *
+     * Use {@link #getRebalancingStartTime()} instead.
+     *
      * @return Rebalancing start time.
      */
+    @Deprecated
     public long rebalancingStartTime();
 
     /**
+     * @return Estimated rebalancing finish time.
+     */
+    public long getEstimatedRebalancingFinishTime();
+
+    /**
+     * @return Rebalancing start time.
+     */
+    public long getRebalancingStartTime();
+
+    /**
      * Checks whether statistics collection is enabled in this cache.
      * <p>
      * The default value is {@code false}.

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClusterMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClusterMetricsMXBeanImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClusterMetricsMXBeanImpl.java
index df4a6ab..1611840 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClusterMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheClusterMetricsMXBeanImpl.java
@@ -392,4 +392,14 @@ class CacheClusterMetricsMXBeanImpl implements CacheMetricsMXBean {
     @Override public long rebalancingStartTime() {
         return cache.clusterMetrics().rebalancingStartTime();
     }
+
+    /** {@inheritDoc} */
+    @Override public long getEstimatedRebalancingFinishTime() {
+        return cache.clusterMetrics().getEstimatedRebalancingFinishTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getRebalancingStartTime() {
+        return cache.clusterMetrics().getRebalancingStartTime();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLocalMetricsMXBeanImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLocalMetricsMXBeanImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLocalMetricsMXBeanImpl.java
index a767193..4a8c25c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLocalMetricsMXBeanImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLocalMetricsMXBeanImpl.java
@@ -392,4 +392,14 @@ class CacheLocalMetricsMXBeanImpl implements CacheMetricsMXBean {
     @Override public long rebalancingStartTime() {
         return cache.metrics0().rebalancingStartTime();
     }
+
+    /** {@inheritDoc} */
+    @Override public long getEstimatedRebalancingFinishTime() {
+        return cache.metrics0().getEstimatedRebalancingFinishTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getRebalancingStartTime() {
+        return cache.metrics0().getRebalancingStartTime();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index 7d9cda8..c98d51f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -808,6 +808,16 @@ public class CacheMetricsImpl implements CacheMetrics {
 
     /** {@inheritDoc} */
     @Override public long estimateRebalancingFinishTime() {
+        return getEstimatedRebalancingFinishTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long rebalancingStartTime() {
+        return rebalanceStartTime.get();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getEstimatedRebalancingFinishTime() {
         long rate = rebalancingKeysRate.getRate();
 
         return rate <= 0 ? -1L :
@@ -815,7 +825,7 @@ public class CacheMetricsImpl implements CacheMetrics {
     }
 
     /** {@inheritDoc} */
-    @Override public long rebalancingStartTime() {
+    @Override public long getRebalancingStartTime() {
         return rebalanceStartTime.get();
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
index 2d38db8..9590c88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsSnapshot.java
@@ -734,6 +734,16 @@ public class CacheMetricsSnapshot implements CacheMetrics, Externalizable {
     }
 
     /** {@inheritDoc} */
+    @Override public long getEstimatedRebalancingFinishTime() {
+        return rebalanceFinishTime;
+    }
+
+    /** {@inheritDoc} */
+    @Override public long getRebalancingStartTime() {
+        return rebalanceStartTime;
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean isWriteBehindEnabled() {
         return isWriteBehindEnabled;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
index a49ce61..eb7c3a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGroupsMetricsRebalanceTest.java
@@ -189,13 +189,13 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
 
         waitForCondition(new PA() {
             @Override public boolean apply() {
-                return ig2.cache(CACHE1).localMetrics().rebalancingStartTime() != -1L;
+                return ig2.cache(CACHE1).localMetrics().getRebalancingStartTime() != -1L;
             }
         }, 5_000);
 
         CacheMetrics metrics = ig2.cache(CACHE1).localMetrics();
 
-        long startTime = metrics.rebalancingStartTime();
+        long startTime = metrics.getRebalancingStartTime();
 
         assertTrue(startTime > 0);
         assertTrue((U.currentTimeMillis() - startTime) < 5000);
@@ -235,7 +235,7 @@ public class CacheGroupsMetricsRebalanceTest extends GridCommonAbstractTest {
 
         latch.await();
 
-        long finishTime = ig2.cache(CACHE1).localMetrics().estimateRebalancingFinishTime();
+        long finishTime = ig2.cache(CACHE1).localMetrics().getEstimatedRebalancingFinishTime();
 
         assertTrue(finishTime > 0);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e556829/modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheWriteMetricsTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheWriteMetricsTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheWriteMetricsTask.java
index 64ff0bc..e7404fa 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheWriteMetricsTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformCacheWriteMetricsTask.java
@@ -443,6 +443,16 @@ public class PlatformCacheWriteMetricsTask extends ComputeTaskAdapter<Long, Obje
         @Override public long rebalancingStartTime() {
             return 61;
         }
+
+        /** {@inheritDoc} */
+        @Override public long getEstimatedRebalancingFinishTime() {
+            return 62;
+        }
+
+        /** {@inheritDoc} */
+        @Override public long getRebalancingStartTime() {
+            return 63;
+        }
     }
 }
 


[10/15] ignite git commit: IGNITE-6568: Fixed cache configuration persistence logic. This closes #2815.

Posted by sb...@apache.org.
IGNITE-6568: Fixed cache configuration persistence logic. This closes #2815.


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

Branch: refs/heads/ignite-5937
Commit: bf99fd3ab8a187ba901c75b7647c833758d0e18f
Parents: 5f67cf2
Author: Alexander Paschenko <al...@gmail.com>
Authored: Tue Oct 10 10:05:12 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Oct 10 10:05:12 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheAffinitySharedManager.java | 15 ++++++++-------
 .../internal/processors/cache/ClusterCachesInfo.java |  1 +
 .../processors/query/GridQueryProcessor.java         |  2 ++
 .../IgnitePersistentStoreSchemaLoadTest.java         |  2 ++
 4 files changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bf99fd3a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
index 741e204..a413ade 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
@@ -2500,7 +2500,7 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
          * @param desc Description.
          */
         private DynamicCacheDescriptor registerCache(DynamicCacheDescriptor desc) {
-            saveCacheConfiguration(desc.cacheConfiguration());
+            saveCacheConfiguration(desc.cacheConfiguration(), desc.sql());
 
             return registeredCaches.put(desc.cacheId(), desc);
         }
@@ -2509,8 +2509,6 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
          * @param grpDesc Group description.
          */
         private CacheGroupDescriptor registerGroup(CacheGroupDescriptor grpDesc) {
-            saveCacheConfiguration(grpDesc.config());
-
             return registeredGrps.put(grpDesc.groupId(), grpDesc);
         }
 
@@ -2591,13 +2589,16 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap
 
     /**
      * @param cfg cache configuration
+     * @param sql SQL flag.
      */
-    private void saveCacheConfiguration(CacheConfiguration<?, ?> cfg) {
+    private void saveCacheConfiguration(CacheConfiguration<?, ?> cfg, boolean sql) {
         if (cctx.pageStore() != null && cctx.database().persistenceEnabled() && !cctx.kernalContext().clientNode()) {
             try {
-                cctx.pageStore().storeCacheData(
-                    new StoredCacheData(cfg),
-                    false);
+                StoredCacheData data = new StoredCacheData(cfg);
+
+                data.sql(sql);
+
+                cctx.pageStore().storeCacheData(data, false);
             }
             catch (IgniteCheckedException e) {
                 U.error(log(), "Error while saving cache configuration on disk, cfg = " + cfg, e);

http://git-wip-us.apache.org/repos/asf/ignite/blob/bf99fd3a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 5e2c8db..b4cc9c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -1219,6 +1219,7 @@ class ClusterCachesInfo {
                         req.startCacheConfiguration(ccfg);
                         req.cacheType(ctx.cache().cacheType(ccfg.getName()));
                         req.schema(new QuerySchema(storedCfg.queryEntities()));
+                        req.sql(storedCfg.sql());
 
                         reqs.add(req);
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bf99fd3a/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 0d8ee47..3a1cdb7 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
@@ -2564,6 +2564,8 @@ public class GridQueryProcessor extends GridProcessorAdapter {
                 if (desc.schema() != null)
                     data.queryEntities(desc.schema().entities());
 
+                data.sql(desc.sql());
+
                 cctx.pageStore().storeCacheData(data, true);
             }
             catch (IgniteCheckedException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/bf99fd3a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
index 85ce4d8..a408596 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/database/IgnitePersistentStoreSchemaLoadTest.java
@@ -208,6 +208,8 @@ public class IgnitePersistentStoreSchemaLoadTest extends GridCommonAbstractTest
         node.active(true);
 
         checkDynamicSchemaChanges(node, SQL_CACHE_NAME);
+
+        node.context().query().querySqlFieldsNoCache(new SqlFieldsQuery("drop table \"Person\""), false).getAll();
     }
 
     /** */


[12/15] ignite git commit: Merge remote-tracking branch 'remotes/origin/master' into ignite-3478

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-3478


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

Branch: refs/heads/ignite-5937
Commit: 61b46c47f01c702a17b683c69a80a7c85c389b84
Parents: fd53c1a 74c4849
Author: sboikov <sb...@gridgain.com>
Authored: Tue Oct 10 14:39:21 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Oct 10 14:39:21 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cache/CacheMetrics.java   |  20 +
 .../internal/jdbc/thin/JdbcThinTcpIo.java       |  20 +-
 .../cache/CacheAffinitySharedManager.java       |  15 +-
 .../cache/CacheClusterMetricsMXBeanImpl.java    |  10 +
 .../cache/CacheLocalMetricsMXBeanImpl.java      |  10 +
 .../processors/cache/CacheMetricsImpl.java      |  14 +-
 .../processors/cache/CacheMetricsSnapshot.java  |  10 +
 .../processors/cache/ClusterCachesInfo.java     |   1 +
 .../distributed/dht/GridDhtLocalPartition.java  |  59 --
 .../dht/preloader/GridDhtPartitionDemander.java |   9 -
 .../processors/cluster/ClusterProcessor.java    |  39 +-
 .../processors/cluster/GridUpdateNotifier.java  | 224 +++----
 .../cluster/HttpIgniteUpdatesChecker.java       |  29 +-
 .../platform/client/ClientIntResponse.java      |  46 ++
 .../platform/client/ClientLongResponse.java     |  46 ++
 .../platform/client/ClientMessageParser.java    | 133 ++++
 .../cache/ClientCacheClearKeyRequest.java       |  44 ++
 .../cache/ClientCacheClearKeysRequest.java      |  44 ++
 .../client/cache/ClientCacheClearRequest.java   |  44 ++
 .../cache/ClientCacheContainsKeyRequest.java    |  45 ++
 .../cache/ClientCacheContainsKeysRequest.java   |  45 ++
 .../client/cache/ClientCacheGetAllRequest.java  |  46 ++
 .../client/cache/ClientCacheGetAllResponse.java |  57 ++
 .../ClientCacheGetAndPutIfAbsentRequest.java    |  45 ++
 .../cache/ClientCacheGetAndPutRequest.java      |  45 ++
 .../cache/ClientCacheGetAndRemoveRequest.java   |  45 ++
 .../cache/ClientCacheGetAndReplaceRequest.java  |  45 ++
 .../client/cache/ClientCacheGetRequest.java     |   9 +-
 .../client/cache/ClientCacheGetSizeRequest.java |  57 ++
 .../client/cache/ClientCacheKeyRequest.java     |  48 ++
 .../cache/ClientCacheKeyValueRequest.java       |  48 ++
 .../client/cache/ClientCacheKeysRequest.java    |  68 +++
 .../client/cache/ClientCachePutAllRequest.java  |  57 ++
 .../cache/ClientCachePutIfAbsentRequest.java    |  45 ++
 .../client/cache/ClientCachePutRequest.java     |  13 +-
 .../cache/ClientCacheRemoveAllRequest.java      |  44 ++
 .../cache/ClientCacheRemoveIfEqualsRequest.java |  45 ++
 .../cache/ClientCacheRemoveKeyRequest.java      |  45 ++
 .../cache/ClientCacheRemoveKeysRequest.java     |  44 ++
 .../ClientCacheReplaceIfEqualsRequest.java      |  50 ++
 .../client/cache/ClientCacheReplaceRequest.java |  45 ++
 .../client/cache/ClientCacheRequest.java        |   2 +-
 .../processors/query/GridQueryProcessor.java    |  19 +
 .../internal/visor/query/VisorQueryTask.java    |  15 +-
 .../cache/CacheGroupsMetricsRebalanceTest.java  |   6 +-
 .../CacheMetricsForClusterGroupSelfTest.java    | 119 ++--
 ...heapCacheMetricsForClusterGroupSelfTest.java |  19 +-
 .../cluster/GridUpdateNotifierSelfTest.java     |  50 +-
 .../platform/PlatformCacheWriteMetricsTask.java |  10 +
 .../cache/index/H2DynamicTableSelfTest.java     |  23 +
 .../IgnitePersistentStoreSchemaLoadTest.java    |   2 +
 .../Client/Cache/CacheTest.cs                   | 611 ++++++++++++++++++-
 .../Client/Cache/CacheTestNoMeta.cs             |   4 +-
 .../Client/ClientTestBase.cs                    |   9 +
 .../Client/Cache/ICacheClient.cs                | 155 +++++
 .../Client/IgniteClientException.cs             |   8 +
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |  24 +-
 .../Impl/Client/Cache/CacheClient.cs            | 260 +++++++-
 .../Apache.Ignite.Core/Impl/Client/ClientOp.cs  |  21 +-
 .../Apache.Ignite.Core/Impl/IgniteUtils.cs      |  21 +
 modules/web-console/backend/app/mongo.js        |   1 +
 .../frontend/app/helpers/jade/mixins.pug        |   9 +-
 .../generator/ConfigurationGenerator.js         |   6 +-
 .../frontend/app/modules/sql/sql.controller.js  |  14 +-
 .../states/configuration/caches/store.pug       |   4 +-
 .../configuration/clusters/attributes.pug       |   4 +-
 .../clusters/collision/job-stealing.pug         |   4 +-
 .../states/configuration/domains/general.pug    |   2 +-
 .../states/configuration/domains/query.pug      |   8 +-
 .../frontend/app/services/JavaTypes.service.js  |  15 +
 .../app/services/LegacyUtils.service.js         |  16 +-
 .../frontend/controllers/domains-controller.js  |   7 +-
 .../frontend/public/stylesheets/style.scss      |   8 +
 .../web-console/frontend/views/sql/sql.tpl.pug  |  10 +
 74 files changed, 2867 insertions(+), 427 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/61b46c47/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/61b46c47/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ignite/blob/61b46c47/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------