You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2019/04/05 14:15:31 UTC

[ignite] branch master updated: IGNITE-11385 Web console: Actualized cluster configuration.

This is an automated email from the ASF dual-hosted git repository.

akuznetsov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new 5642ce6  IGNITE-11385 Web console: Actualized cluster configuration.
5642ce6 is described below

commit 5642ce6363b18f8468881c52b221d7f3db4a0536
Author: Vasiliy Sisko <vs...@gridgain.com>
AuthorDate: Fri Apr 5 21:15:13 2019 +0700

    IGNITE-11385 Web console: Actualized cluster configuration.
---
 modules/web-console/backend/app/schemas.js         | 12 +++++
 .../components/cluster-edit-form/controller.ts     | 32 ++++++++---
 .../cluster-edit-form/templates/failover.pug       | 62 ++++++++++++++++++++++
 .../app/configuration/generator/generator/Beans.js |  4 ++
 .../generator/generator/ConfigurationGenerator.js  | 59 ++++++++++++++++++++
 .../generator/generator/JavaTransformer.service.js |  7 ++-
 .../generator/defaults/Cluster.service.js          |  3 ++
 7 files changed, 172 insertions(+), 7 deletions(-)

diff --git a/modules/web-console/backend/app/schemas.js b/modules/web-console/backend/app/schemas.js
index dafdc60..65d4b93 100644
--- a/modules/web-console/backend/app/schemas.js
+++ b/modules/web-console/backend/app/schemas.js
@@ -1225,6 +1225,18 @@ module.exports.factory = function(mongoose) {
                 className: String
             }
         },
+        failureHandler: {
+            kind: {type: String, enum: ['RestartProcess', 'StopNodeOnHalt', 'StopNode', 'Noop', 'Custom']},
+            ignoredFailureTypes: [{type: String, enum: ['SEGMENTATION', 'SYSTEM_WORKER_TERMINATION',
+                    'SYSTEM_WORKER_BLOCKED', 'CRITICAL_ERROR', 'SYSTEM_CRITICAL_OPERATION_TIMEOUT']}],
+            StopNodeOnHalt: {
+                tryStop: Boolean,
+                timeout: Number
+            },
+            Custom: {
+                className: String
+            }
+        },
         mvccVacuumThreadCount: Number,
         mvccVacuumFrequency: Number,
         authenticationEnabled: Boolean,
diff --git a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/controller.ts b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/controller.ts
index f1afd3c..3a2c8bf 100644
--- a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/controller.ts
+++ b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/controller.ts
@@ -47,10 +47,6 @@ export default class ClusterEditFormController {
         private IgniteFormUtils: ReturnType<typeof FormUtils>
     ) {}
 
-    $onDestroy() {
-        this.subscription.unsubscribe();
-    }
-
     $onInit() {
         this.available = this.IgniteVersion.available.bind(this.IgniteVersion);
 
@@ -65,6 +61,23 @@ export default class ClusterEditFormController {
                 {value: null, label: 'Default'}
             ];
 
+            this.failureHandlerVariant = [
+                {value: 'RestartProcess', label: 'Restart process'},
+                {value: 'StopNodeOnHalt', label: 'Try stop with timeout'},
+                {value: 'StopNode', label: 'Stop on critical error'},
+                {value: 'Noop', label: 'Disabled'},
+                {value: 'Custom', label: 'Custom'},
+                {value: null, label: 'Default'}
+            ];
+
+            this.ignoredFailureTypes = [
+                {value: 'SEGMENTATION', label: 'SEGMENTATION'},
+                {value: 'SYSTEM_WORKER_TERMINATION', label: 'SYSTEM_WORKER_TERMINATION'},
+                {value: 'SYSTEM_WORKER_BLOCKED', label: 'SYSTEM_WORKER_BLOCKED'},
+                {value: 'CRITICAL_ERROR', label: 'CRITICAL_ERROR'},
+                {value: 'SYSTEM_CRITICAL_OPERATION_TIMEOUT', label: 'SYSTEM_CRITICAL_OPERATION_TIMEOUT'}
+            ];
+
             if (this.available('2.0.0')) {
                 this.eventStorage.push({value: null, label: 'Disabled'});
 
@@ -111,6 +124,10 @@ export default class ClusterEditFormController {
         ];
     }
 
+    $onDestroy() {
+        this.subscription.unsubscribe();
+    }
+
     $onChanges(changes) {
         if ('cluster' in changes && this.shouldOverwriteValue(this.cluster, this.clonedCluster)) {
             this.clonedCluster = cloneDeep(changes.cluster.currentValue);
@@ -146,12 +163,15 @@ export default class ClusterEditFormController {
     save(download) {
         if (this.$scope.ui.inputForm.$invalid)
             return this.IgniteFormUtils.triggerValidation(this.$scope.ui.inputForm, this.$scope);
+
         this.onSave({$event: {cluster: cloneDeep(this.clonedCluster), download}});
     }
 
     reset = () => this.clonedCluster = cloneDeep(this.cluster);
+
     confirmAndReset() {
-        return this.IgniteConfirm.confirm('Are you sure you want to undo all changes for current cluster?')
-        .then(this.reset);
+        return this.IgniteConfirm
+            .confirm('Are you sure you want to undo all changes for current cluster?')
+            .then(this.reset);
     }
 }
diff --git a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug
index 2626778..5320a80 100644
--- a/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug
+++ b/modules/web-console/frontend/app/configuration/components/page-configure-advanced/components/cluster-edit-form/templates/failover.pug
@@ -20,6 +20,7 @@ include /app/configuration/mixins
 -var model = '$ctrl.clonedCluster'
 -var form = 'failoverSpi'
 -var failoverSpi = model + '.failoverSpi'
+-var failureHandler = model + '.failureHandler'
 -var failoverCustom = '$item.kind === "Custom"'
 
 panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`)
@@ -122,6 +123,67 @@ panel-collapsible(ng-form=form on-open=`ui.loadPanel('${form}')`)
                                 )
 
                 +clusters-failover-spi
+            .pc-form-grid-col-60(ng-if='$ctrl.available("2.5.0")')
+                +form-field__dropdown({
+                    label: 'Failure handler:',
+                    model: `${failureHandler}.kind`,
+                    name: '"FailureHandlerKind"',
+                    placeholder: 'Default',
+                    options: '$ctrl.failureHandlerVariant',
+                    tip: 'Handle failures<br/>\
+                        <ul>\
+                            <li>Restart process - Process will be terminated using Ignition.restart call</li>\
+                            <li>Try stop with timeout - Handler will try to stop node if tryStop value is true or terminate forcibly</li>\
+                            <li>Stop on critical error - Handler will stop node in case of critical error</li>\
+                            <li>Disabled - Ignores any failure</li>\n\
+                            <li>Custom - Custom implementation of failure handler</li>\
+                            <li>Default - Default implementation of failure handler</li>\
+                        </ul>'
+                })
+            .pc-form-grid-col-60(ng-if=`$ctrl.available("2.5.0") && ${failureHandler}.kind === "Custom"`)
+                +form-field__java-class({
+                    label: 'Class name:',
+                    model: `${failureHandler}.Custom.className`,
+                    name: '"CustomFailureHandler"',
+                    required: true,
+                    tip: 'Class name of custom failure handler implementation',
+                    validationActive: true
+                })
+            .pc-form-group.pc-form-grid-row(ng-if=`$ctrl.available("2.5.0") && ${failureHandler}.kind === 'StopNodeOnHalt'`)
+                .pc-form-grid-col-60
+                    +form-field__number({
+                        label: 'Stop node timeout:',
+                        model: `${failureHandler}.StopNodeOnHalt.timeout`,
+                        name: '"StopNodeOnHaltTimeout"',
+                        placeholder: '0',
+                        min: '0',
+                        tip: 'Timeout for forcibly terminating by using Runtime.getRuntime().halt()'
+                    })
+                .pc-form-grid-col-60
+                    +form-field__checkbox({
+                        label: 'Try to stop node',
+                        model: `${failureHandler}.StopNodeOnHalt.tryStop`,
+                        name: '"StopNodeOnHaltTryStop"',
+                        tip: 'Try to stop node'
+                    })
+            .pc-form-grid-col-60(ng-if=`$ctrl.available("2.5.0") && ['RestartProcess', 'StopNodeOnHalt', 'StopNode'].indexOf(${failureHandler}.kind) >= 0`)
+                +form-field__dropdown({
+                    label: 'Ignored failure types:',
+                    model: `${failureHandler}.ignoredFailureTypes`,
+                    name: '"FailureHandlerIgnoredFailureTypes"',
+                    multiple: true,
+                    placeholder: 'Choose ignored failure types',
+                    placeholderEmpty: '',
+                    options: '$ctrl.ignoredFailureTypes',
+                    tip: 'Ignored failure types:<br/>\
+                        <ul>\
+                            <li>SEGMENTATION - Node segmentation</li>\
+                            <li>SYSTEM_WORKER_TERMINATION - System worker termination</li>\
+                            <li>SYSTEM_WORKER_BLOCKED - System worker has not updated its heartbeat for a long time</li>\
+                            <li>CRITICAL_ERROR - Critical error - error which leads to the system\'s inoperability</li>\n\
+                            <li>SYSTEM_CRITICAL_OPERATION_TIMEOUT - System-critical operation has been timed out</li>\
+                        </ul>'
+                })
 
         .pca-form-column-6
             +preview-xml-java(model, 'clusterFailover')
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/Beans.js b/modules/web-console/frontend/app/configuration/generator/generator/Beans.js
index 7eae6f9..e4f9001 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/Beans.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/Beans.js
@@ -128,6 +128,10 @@ export class Bean extends EmptyBean {
         return this._property(this.arguments, 'boolean', model, null, nonNil);
     }
 
+    longConstructorArgument(model) {
+        return this._property(this.arguments, 'long', model, null, nonNil);
+    }
+
     classConstructorArgument(model) {
         return this._property(this.arguments, 'java.lang.Class', model, null, nonEmpty);
     }
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
index 0e9e099..bb2d98f 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/ConfigurationGenerator.js
@@ -1298,6 +1298,65 @@ export default class IgniteConfigurationGenerator {
         if (spis.length)
             cfg.arrayProperty('failoverSpi', 'failoverSpi', spis, 'org.apache.ignite.spi.failover.FailoverSpi');
 
+        if (available('2.5.0')) {
+            const handler = cluster.failureHandler;
+            const kind = _.get(handler, 'kind');
+
+            let bean;
+
+            switch (kind) {
+                case 'RestartProcess':
+                    bean = new Bean('org.apache.ignite.failure.RestartProcessFailureHandler', 'failureHandler', handler);
+
+                    break;
+
+                case 'StopNodeOnHalt':
+                    const failover = handler.StopNodeOnHalt;
+
+                    bean = new Bean('org.apache.ignite.failure.StopNodeOrHaltFailureHandler', 'failureHandler', handler.StopNodeOnHalt);
+
+                    if (failover || failover.tryStop || failover.timeout) {
+                        failover.tryStop = failover.tryStop || false;
+                        failover.timeout = failover.timeout || 0;
+
+                        bean.boolConstructorArgument('tryStop')
+                            .longConstructorArgument('timeout');
+                    }
+
+                    break;
+
+                case 'StopNode':
+                    bean = new Bean('org.apache.ignite.failure.StopNodeFailureHandler', 'failureHandler', handler);
+
+                    break;
+
+                case 'Noop':
+                    bean = new Bean('org.apache.ignite.failure.NoOpFailureHandler', 'failureHandler', handler);
+
+                    break;
+
+                case 'Custom':
+                    const clsName = _.get(handler, 'Custom.className');
+
+                    if (clsName)
+                        bean = new Bean(clsName, 'failureHandler', handler);
+
+                    break;
+
+                default:
+                    // No-op.
+            }
+
+            if (bean) {
+                if (['RestartProcess', 'StopNodeOnHalt', 'StopNode'].indexOf(kind) >= 0) {
+                    bean.collectionProperty('ignoredFailureTypes', 'ignoredFailureTypes', handler.ignoredFailureTypes,
+                        'org.apache.ignite.failure.FailureType', 'java.util.HashSet');
+                }
+
+                cfg.beanProperty('failureHandler', bean);
+            }
+        }
+
         return cfg;
     }
 
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/JavaTransformer.service.js b/modules/web-console/frontend/app/configuration/generator/generator/JavaTransformer.service.js
index c1e1cfd..25a9760 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/JavaTransformer.service.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/JavaTransformer.service.js
@@ -318,6 +318,7 @@ export default class IgniteJavaTransformer extends AbstractTransformer {
                     sb.emptyLine();
 
                     break;
+
                 default:
                     if (this._isBean(arg.clsName) && arg.value.isComplex()) {
                         this.constructBean(sb, arg.value, vars, limitLines);
@@ -650,7 +651,10 @@ export default class IgniteJavaTransformer extends AbstractTransformer {
 
                         if (nonBean) {
                             _.forEach(this._toObject(colTypeClsName, prop.items), (item) => {
-                                sb.append(`${prop.id}.add("${item}");`);
+                                if (this.javaTypesNonEnum.nonEnum(prop.typeClsName))
+                                    sb.append(`${prop.id}.add("${item}");`);
+                                else
+                                    sb.append(`${prop.id}.add(${item});`);
 
                                 sb.emptyLine();
                             });
@@ -848,6 +852,7 @@ export default class IgniteJavaTransformer extends AbstractTransformer {
                     });
 
                     break;
+
                 default:
                     // No-op.
             }
diff --git a/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js b/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
index 54e9b3d..af5d111 100644
--- a/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
+++ b/modules/web-console/frontend/app/configuration/generator/generator/defaults/Cluster.service.js
@@ -449,6 +449,9 @@ const DFLT_CLUSTER = {
             masterKeyName: 'ignite.master.key'
         }
     },
+    failureHandler: {
+        ignoredFailureTypes: {clsName: 'org.apache.ignite.failure.FailureType'}
+    },
     authenticationEnabled: false,
     sqlQueryHistorySize: 1000,
     allSegmentationResolversPassRequired: true,