Repository: ignite Updated Branches: refs/heads/ignite-843-rc2 9e4d7aad1 -> 2a9c5d3f0
IGNITE-2217 WIP Binary configuration. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2a9c5d3f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2a9c5d3f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2a9c5d3f Branch: refs/heads/ignite-843-rc2 Commit: 2a9c5d3f016333af99c21ecb7b92df18a0b93026 Parents: 9e4d7aa Author: Alexey Kuznetsov <[email protected]> Authored: Thu Dec 24 18:55:06 2015 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Thu Dec 24 18:55:06 2015 +0700 ---------------------------------------------------------------------- .../main/js/controllers/clusters-controller.js | 86 +++++++++++++++++++- .../main/js/controllers/models/clusters.json | 48 ++++++++++- .../main/js/helpers/generator/generator-java.js | 58 ++++++++++++- .../main/js/helpers/generator/generator-xml.js | 54 +++++++++++- .../src/main/js/views/includes/controls.jade | 37 +++++++++ 5 files changed, 276 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2a9c5d3f/modules/control-center-web/src/main/js/controllers/clusters-controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/clusters-controller.js b/modules/control-center-web/src/main/js/controllers/clusters-controller.js index dfa8b9d..53a7eb3 100644 --- a/modules/control-center-web/src/main/js/controllers/clusters-controller.js +++ b/modules/control-center-web/src/main/js/controllers/clusters-controller.js @@ -35,12 +35,28 @@ consoleModule.controller('clustersController', [ $scope.tableVisibleRow = $table.tableVisibleRow; $scope.tableReset = $table.tableReset; - $scope.tableNewItem = $table.tableNewItem; + $scope.tableNewItem = function (field) { + if (field.type === 'typeConfigurations') { + var binary = $scope.backupItem.binaryConfiguration; + + if (!binary) + $scope.backupItem.binaryConfiguration = { typeConfigurations: [{}] }; + else if (!$common.isDefined(binary.typeConfigurations)) + binary.typeConfigurations = [{}]; + else + binary.typeConfigurations.push({}); + } + else + $table.tableNewItem(field); + }; $scope.tableNewItemActive = $table.tableNewItemActive; $scope.tableEditing = $table.tableEditing; $scope.tableStartEdit = $table.tableStartEdit; $scope.tableRemove = function (item, field, index) { - $table.tableRemove(item, field, index); + if (field.type === 'typeConfigurations') + $scope.backupItem.binaryConfiguration.typeConfigurations.splice(index, 1); + else + $table.tableRemove(item, field, index); }; $scope.tableSimpleSave = $table.tableSimpleSave; @@ -370,7 +386,11 @@ consoleModule.controller('clustersController', [ function prepareNewItem(id) { var newItem = { discovery: {kind: 'Multicast', Vm: {addresses: ['127.0.0.1:47500..47510']}, Multicast: {}}, - deploymentMode: 'SHARED' + deploymentMode: 'SHARED', + binaryConfiguration: { + typeConfigurations: [], + compactFooter: true + } }; newItem.caches = id && _.find($scope.caches, {value: id}) ? [id] : []; @@ -406,6 +426,66 @@ consoleModule.controller('clustersController', [ if ($common.isEmptyString(item.name)) return showPopoverMessage($scope.panels, 'general', 'clusterName', 'Name should not be empty'); + var b = item.binaryConfiguration; + + if ($common.isDefined(b)) { + if (!$common.isEmptyString(b.idMapper) && !$common.isValidJavaClass('ID mapper', b.idMapper, false, 'idMapper', false, $scope.panels, 'binary')) { + $scope.ui.expanded = true; + + return false; + } + + if (!$common.isEmptyString(b.serializer) && !$common.isValidJavaClass('Serializer', b.serializer, false, 'serializer', false, $scope.panels, 'binary')) { + $scope.ui.expanded = true; + + return false; + } + + if (!$common.isEmptyArray(b.typeConfigurations)) { + var sameName = function (t, ix) { + return ix < typeIx && t.typeName === type.typeName; + }; + + for (var typeIx = 0; typeIx < b.typeConfigurations.length; typeIx++) { + var type = b.typeConfigurations[typeIx]; + + if ($common.isEmptyString(type.typeName)) { + $scope.ui.expanded = true; + + showPopoverMessage($scope.panels, 'binary', 'typeName' + typeIx, 'Type name should be specified'); + + return false; + } + + if (!$common.isEmptyString(type.typeName) && !$common.isValidJavaClass('Type name', type.typeName, false, 'typeName' + typeIx, false, $scope.panels, 'binary')) { + $scope.ui.expanded = true; + + return false; + } + + if (!$common.isEmptyString(type.idMapper) && !$common.isValidJavaClass('ID mapper', type.idMapper, false, 'idMapper' + typeIx, false, $scope.panels, 'binary')) { + $scope.ui.expanded = true; + + return false; + } + + if (!$common.isEmptyString(type.serializer) && !$common.isValidJavaClass('Serializer', type.serializer, false, 'serializer' + typeIx, false, $scope.panels, 'binary')) { + $scope.ui.expanded = true; + + return false; + } + + if (_.find(b.typeConfigurations, sameName)) { + $scope.ui.expanded = true; + + showPopoverMessage($scope.panels, 'binary', 'typeName' + typeIx, 'Type with such name is already specified'); + + return false; + } + } + } + } + var c = item.communication; if ($common.isDefined(c)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/2a9c5d3f/modules/control-center-web/src/main/js/controllers/models/clusters.json ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/models/clusters.json b/modules/control-center-web/src/main/js/controllers/models/clusters.json index 70878e3..dcea6b6 100644 --- a/modules/control-center-web/src/main/js/controllers/models/clusters.json +++ b/modules/control-center-web/src/main/js/controllers/models/clusters.json @@ -429,12 +429,56 @@ { "label": "Type configurations", "id": "typeConfigurations", - "type": "text", + "type": "typeConfigurations", "path": "binaryConfiguration", "model": "typeConfigurations", - "placeholder": "TODO table", + "addTip": "Add new type configuration", + "removeTip": "Remove type configuration", "tip": [ "Configuration properties for binary types" + ], + "fields": [ + { + "label": "Type name", + "id": "typeName", + "type": "text", + "model": "typeName", + "required": true, + "placeholder": "Enter fully qualified class name", + "tip" : [ + "Type name" + ] + }, + { + "label": "ID mapper", + "id": "idMapper", + "type": "text", + "model": "idMapper", + "placeholder": "Enter fully qualified class name", + "tip" : [ + "Type and field ID mapper for binary objects", + "Ignite never writes full strings for field or type names. Instead, for performance reasons, Ignite writes integer hash codes for type and field names. It has been tested that hash code conflicts for the type names or the field names within the same type are virtually non-existent and, to gain performance, it is safe to work with hash codes. For the cases when hash codes for different types or fields actually do collide <b>BinaryIdMapper</b> allows to override the automatically generated hash code IDs for the type and field names" + ] + }, + { + "label": "Serializer", + "id": "serializer", + "type": "text", + "model": "serializer", + "placeholder": "Enter fully qualified class name", + "tip" : [ + "Class with custom serialization logic for binary object" + ] + }, + { + "label": "Enum", + "id": "enum", + "type": "check", + "model": "enum", + "tip" : [ + "Flag indicating that this type is the enum" + ] + } ] }, { http://git-wip-us.apache.org/repos/asf/ignite/blob/2a9c5d3f/modules/control-center-web/src/main/js/helpers/generator/generator-java.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js index 5c93e07..5b9eb56 100644 --- a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js +++ b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js @@ -546,7 +546,61 @@ $generatorJava.clusterBinary = function (cluster, res) { if (!res) res = $generatorCommon.builder(); - res.line('// TODO'); + var binary = cluster.binaryConfiguration; + + if (binary && ($commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer) || + $commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations) || !binary.compactFooter)) { + var varName = 'binary'; + + $generatorJava.declareVariable(res, varName, 'org.apache.ignite.configuration.BinaryConfiguration'); + + if ($commonUtils.isDefinedAndNotEmpty(binary.idMapper)) + res.line(varName + '.setIdMapper(new ' + res.importClass(binary.idMapper) + '());'); + + if ($commonUtils.isDefinedAndNotEmpty(binary.serializer)) + res.line(varName + '.setSerializer(new ' + res.importClass(binary.serializer) + '());'); + + res.needEmptyLine = $commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer); + + if ($commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations)) { + var arrVar = 'types'; + + $generatorJava.declareVariable(res, arrVar, 'java.util.Collection', 'java.util.ArrayList', 'org.apache.ignite.binary.BinaryTypeConfiguration'); + + _.forEach(binary.typeConfigurations, function (type) { + var typeVar = 'typeCfg'; + + $generatorJava.declareVariable(res, typeVar, 'org.apache.ignite.binary.BinaryTypeConfiguration'); + + $generatorJava.property(res, typeVar, type, 'typeName'); + + if ($commonUtils.isDefinedAndNotEmpty(type.idMapper)) + res.line(typeVar + '.setIdMapper(new ' + res.importClass(type.idMapper) + '());'); + + if ($commonUtils.isDefinedAndNotEmpty(type.serializer)) + res.line(typeVar + '.setSerializer(new ' + res.importClass(type.serializer) + '());'); + + + $generatorJava.property(res, typeVar, type, 'enum', undefined, undefined, false); + + res.needEmptyLine = true; + + res.line(arrVar + '.add(' + typeVar + ');'); + + res.needEmptyLine = true; + }); + + res.line(varName + '.setTypeConfigurations(' + arrVar + ');'); + + res.needEmptyLine = true; + } + + $generatorJava.property(res, binary, 'compactFooter', undefined, true); + + res.line('cfg.setBinaryConfiguration(' + varName + ')'); + + res.needEmptyLine = true; + } return res; }; @@ -2050,6 +2104,8 @@ $generatorJava.clusterConfiguration = function (cluster, clientNearCfg, res) { $generatorJava.clusterAtomics(cluster, res); + $generatorJava.clusterBinary(cluster, res); + $generatorJava.clusterCommunication(cluster, res); $generatorJava.clusterConnector(cluster, res); http://git-wip-us.apache.org/repos/asf/ignite/blob/2a9c5d3f/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js index c9fddbd..4305736 100644 --- a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js +++ b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js @@ -62,6 +62,21 @@ $generatorXml.property = function (res, obj, propName, setterName, dflt) { return false; }; +// Add property. +$generatorXml.emptyBeanProperty = function (res, obj, propName) { + if ($commonUtils.isDefined(obj)) { + var val = obj[propName]; + + if ($commonUtils.isDefinedAndNotEmpty(val)) { + res.startBlock('<property name="' + propName + '">'); + res.line('<bean class="' + val + '"/>'); + res.endBlock('</property>'); + } + } + + return false; +}; + // Add property for class name. $generatorXml.classNameProperty = function (res, obj, propName) { var val = obj[propName]; @@ -384,7 +399,42 @@ $generatorXml.clusterBinary = function (cluster, res) { if (!res) res = $generatorCommon.builder(); - res.line('<todo>TODO</todo>'); + var binary = cluster.binaryConfiguration; + + if (binary && ($commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer) || + $commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations) || !binary.compactFooter)) { + res.startBlock('<property name="binaryConfiguration">'); + res.startBlock('<bean class="org.apache.ignite.configuration.BinaryConfiguration">'); + + $generatorXml.emptyBeanProperty(res, binary, 'idMapper'); + $generatorXml.emptyBeanProperty(res, binary, 'serializer'); + + if ($commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations)) { + res.startBlock('<property name="typeConfigurations">'); + res.startBlock('<list>'); + + _.forEach(binary.typeConfigurations, function (type) { + res.startBlock('<bean class="org.apache.ignite.binary.BinaryTypeConfiguration">'); + + $generatorXml.property(res, type, 'typeName'); + $generatorXml.emptyBeanProperty(res, type, 'idMapper'); + $generatorXml.emptyBeanProperty(res, type, 'serializer'); + $generatorXml.property(res, type, 'enum', undefined, false); + + res.endBlock('</bean>'); + }); + + res.endBlock('</list>'); + res.endBlock('</property>'); + } + + $generatorXml.property(res, binary, 'compactFooter', undefined, true); + + res.endBlock('</bean>'); + res.endBlock('</property>'); + + res.needEmptyLine = true; + } return res; }; @@ -1439,6 +1489,8 @@ $generatorXml.clusterConfiguration = function (cluster, clientNearCfg, res) { $generatorXml.clusterAtomics(cluster, res); + $generatorXml.clusterBinary(cluster, res); + $generatorXml.clusterCommunication(cluster, res); $generatorXml.clusterConnector(cluster, res); http://git-wip-us.apache.org/repos/asf/ignite/blob/2a9c5d3f/modules/control-center-web/src/main/js/views/includes/controls.jade ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/views/includes/controls.jade b/modules/control-center-web/src/main/js/views/includes/controls.jade index fd49122..3384257 100644 --- a/modules/control-center-web/src/main/js/views/includes/controls.jade +++ b/modules/control-center-web/src/main/js/views/includes/controls.jade @@ -286,6 +286,41 @@ mixin table-index-item-edit(prefix, index, sortAvailable, idAddition) .input-tip input.form-control(id='{{::"#{fieldName}" + #{idAddition}}}' type='text' ng-model=fieldNameModel placeholder='Field name' on-enter=btnVisibleAndSave on-escape='tableReset()') +mixin table-binary-configurations(tblMdl, keyFld, valFld, keyPlaceholder, valPlaceholder) + .col-sm-12.group + .group-legend + label {{field.label}} + +group-tip('field.tip') + +group-btn-add('tableNewItem(field)', 'field.addTip') + .group-content-empty(ng-if='!(#{tblMdl} && #{tblMdl}.length > 0)') Not defined + .group-content(ng-show='#{tblMdl} && #{tblMdl}.length > 0') + table(id='{{field.model}}' st-table=tblMdl) + tbody: tr(ng-repeat='(rowIndex, item) in #{tblMdl}'): td + hr(ng-if='$index !== 0') + .settings-row(ng-repeat='tableField in field.fields') + +table-row(['col-xs-4 col-sm-4 col-md-4'], ['col-xs-8 col-sm-8 col-md-8']) + +mixin table-row(lblClasses, fieldClasses) + - var lblRowClasses = lblClasses + ' details-label' + + - var rowMdl = 'getModel(backupItem, field)[field.model][rowIndex][tableField.model]'; + - var rowCommon = {'ng-model': rowMdl, 'ng-required': '{{tableField.required}}', 'ng-disabled': '{{tableField.disabled}}'}; + + div(ng-switch='tableField.type') + div.checkbox(ng-switch-when='check') + label(id='{{tableField.id + rowIndex}}') + input(type='checkbox')&attributes(rowCommon) + | {{tableField.label}} + +tipLabel('tableField.tip') + div(ng-switch-when='text') + label(class=lblRowClasses ng-class='{required: tableField.required}') {{tableField.label}}: + .div(class=fieldClasses) + +tipField('tableField.tip') + div(ng-if='$index===0') + +btn-remove('tableRemove(backupItem, field, rowIndex)', 'field.removeTip') + .input-tip + input.form-control(id='{{tableField.model + rowIndex}}' type='text' placeholder='{{tableField.placeholder}}')&attributes(rowCommon) + mixin form-row(dataSource) +form-row-custom(['col-xs-4 col-sm-4 col-md-4'], ['col-xs-8 col-sm-8 col-md-8'], dataSource) @@ -404,6 +439,8 @@ mixin form-row-custom(lblClasses, fieldClasses, dataSource) +table-pair('{{::field.label}}', fieldMdl, 'field', 'alias', 'Field name', 'Field Alias', false, false, '->') .group-section(ng-switch-when='pathModes' ng-hide=fieldHide) +table-igfs-path-mode('{{::field.label}}', fieldMdl, 'path', 'mode', 'Path', 'Mode') + .group-section(ng-switch-when='typeConfigurations' ng-hide=fieldHide) + +table-binary-configurations(fieldMdl, 'path', 'mode', 'Path', 'Mode') .group-section(ng-switch-when='table-db-fields' ng-hide=fieldHide) .col-sm-12.group .group-legend
