Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F02A8200CE3 for ; Sun, 30 Jul 2017 01:59:58 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EE8C8164A17; Sat, 29 Jul 2017 23:59:58 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E684E164A15 for ; Sun, 30 Jul 2017 01:59:57 +0200 (CEST) Received: (qmail 971 invoked by uid 500); 29 Jul 2017 23:59:57 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 962 invoked by uid 99); 29 Jul 2017 23:59:57 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jul 2017 23:59:57 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id A68BB811B4; Sat, 29 Jul 2017 23:59:55 +0000 (UTC) Date: Sat, 29 Jul 2017 23:59:55 +0000 To: "commits@couchdb.apache.org" Subject: [couchdb-fauxton] branch master updated: Update for changes to _cluster_setup endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <150137279514.25963.6039210477173653685@gitbox.apache.org> From: wohali@apache.org Reply-To: "commits@couchdb.apache.org" X-Git-Host: gitbox.apache.org X-Git-Repo: couchdb-fauxton X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 5d5126c6c90db3e60322be4db244c6ec80794fb7 X-Git-Newrev: 675a183522c138356127c7f7f4ad3480f22bf17b X-Git-Rev: 675a183522c138356127c7f7f4ad3480f22bf17b X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated archived-at: Sat, 29 Jul 2017 23:59:59 -0000 This is an automated email from the ASF dual-hosted git repository. wohali pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git The following commit(s) were added to refs/heads/master by this push: new 675a183 Update for changes to _cluster_setup endpoint 675a183 is described below commit 675a183522c138356127c7f7f4ad3480f22bf17b Author: Joan Touzet AuthorDate: Mon Jul 17 02:23:47 2017 -0400 Update for changes to _cluster_setup endpoint These changes add support for the new enable_single_node action, which tolerates binding a node to 127.0.0.1. They also add support for the new mandatory node_count parameter when setting up a cluster. This parameter in the API call actually sets [cluster] n value, so it is set to min(3, ) based on recommendations from @rnewson and personal experience. Closes #874 --- app/addons/setup/resources.js | 11 +++++- app/addons/setup/route.js | 1 + app/addons/setup/setup.actions.js | 36 +++++++++++++---- app/addons/setup/setup.actiontypes.js | 1 + app/addons/setup/setup.js | 74 +++++++++++++++++++++++++++++++++-- app/addons/setup/setup.stores.js | 14 ++++++- app/addons/setup/tests/setupSpec.js | 22 +++++++++++ 7 files changed, 146 insertions(+), 13 deletions(-) diff --git a/app/addons/setup/resources.js b/app/addons/setup/resources.js index 1963f04..609ca73 100644 --- a/app/addons/setup/resources.js +++ b/app/addons/setup/resources.js @@ -37,13 +37,22 @@ Setup.Model = Backbone.Model.extend({ return 'Admin password is required'; } - if (attrs.bind_address && attrs.bind_address === '127.0.0.1') { + if (attrs.bind_address && attrs.bind_address === '127.0.0.1' && + !attrs.singlenode) { return 'Bind address can not be 127.0.0.1'; } if (attrs.port && _.isNaN(+attrs.port)) { return 'Bind port must be a number'; } + + if (attrs.nodeCount && _.isNaN(+attrs.nodeCount)) { + return 'Node count must be a number'; + } + + if (attrs.nodeCount && attrs.nodeCount < 1) { + return 'Node count must be >= 1'; + } } }); diff --git a/app/addons/setup/route.js b/app/addons/setup/route.js index e2b487e..b8845bb 100644 --- a/app/addons/setup/route.js +++ b/app/addons/setup/route.js @@ -72,6 +72,7 @@ var RouteObject = FauxtonAPI.RouteObject.extend({ finishView: function () { const setup = new Setup.Model(); + SetupActions.getClusterStateFromCouch(); return } endpoint={setup.url('apiurl')} diff --git a/app/addons/setup/setup.actions.js b/app/addons/setup/setup.actions.js index 79d9ef9..f46e681 100644 --- a/app/addons/setup/setup.actions.js +++ b/app/addons/setup/setup.actions.js @@ -13,6 +13,7 @@ import FauxtonAPI from "../../core/api"; import SetupResources from "./resources"; import ActionTypes from "./setup.actiontypes"; import SetupStores from "./setup.stores"; +import Api from "../auth/api"; var setupStore = SetupStores.setupStore; export default { @@ -66,11 +67,12 @@ export default { var password = setupStore.getPassword(); var setupModel = new SetupResources.Model({ - action: 'enable_cluster', + action: 'enable_single_node', username: username, password: password, bind_address: setupStore.getBindAdressForSetupNode(), - port: setupStore.getPortForSetupNode() + port: setupStore.getPortForSetupNode(), + singlenode: true }); setupModel.on('invalid', function (model, error) { @@ -84,10 +86,16 @@ export default { setupModel.save() .then(function () { - return FauxtonAPI.session.login(username, password); + return Api.login({name: username, password}); }) .then(function () { - return this.finishClusterSetup('CouchDB is set up!'); + FauxtonAPI.addNotification({ + msg: 'Single node setup successful.', + type: 'success', + fade: false, + clear: true + }); + FauxtonAPI.navigate('#setup/finish'); }.bind(this)); }, @@ -96,6 +104,7 @@ export default { var password = setupStore.getPassword(); var portForSetupNode = setupStore.getPortForSetupNode(); var bindAddressForSetupNode = setupStore.getBindAdressForSetupNode(); + var nodeCountForSetupNode = setupStore.getNodeCountForSetupNode(); var bindAddressForAdditionalNode = setupStore.getAdditionalNode().bindAddress; var remoteAddressForAdditionalNode = setupStore.getAdditionalNode().remoteAddress; @@ -107,7 +116,9 @@ export default { username: username, password: password, bind_address: bindAddressForSetupNode, - port: portForSetupNode + port: portForSetupNode, + node_count: nodeCountForSetupNode, + singlenode: false }); setupNode.on('invalid', function (model, error) { @@ -125,6 +136,7 @@ export default { password: password, bind_address: bindAddressForAdditionalNode, port: portForForAdditionalNode, + node_count: nodeCountForSetupNode, remote_node: remoteAddressForAdditionalNode, remote_current_user: username, remote_current_password: password @@ -148,7 +160,7 @@ export default { setupNode .save() .always(function () { - FauxtonAPI.session.login(username, password).then(function () { + Api.login({name: username, password}).then(function() { continueSetup(); }); }); @@ -159,7 +171,8 @@ export default { username: username, password: password, host: remoteAddressForAdditionalNode, - port: portForForAdditionalNode + port: portForForAdditionalNode, + singlenode: false }); additionalNode @@ -263,5 +276,14 @@ export default { value: value } }); + }, + + setNodeCount: function (value) { + FauxtonAPI.dispatch({ + type: ActionTypes.SETUP_NODE_COUNT, + options: { + value: value + } + }); } }; diff --git a/app/addons/setup/setup.actiontypes.js b/app/addons/setup/setup.actiontypes.js index a7ef0eb..0353cc2 100644 --- a/app/addons/setup/setup.actiontypes.js +++ b/app/addons/setup/setup.actiontypes.js @@ -21,4 +21,5 @@ export default { SETUP_REMOTE_ADDRESS_ADDITIONAL_NODE: 'SETUP_REMOTE_ADDRESS_ADDITIONAL_NODE', SETUP_RESET_ADDITIONAL_NODE: 'SETUP_RESET_ADDITIONAL_NODE', SETUP_ADD_NODE_TO_LIST: 'SETUP_ADD_NODE_TO_LIST', + SETUP_NODE_COUNT: 'SETUP_NODE_COUNT', }; diff --git a/app/addons/setup/setup.js b/app/addons/setup/setup.js index 7c4a7b2..4b7bd41 100644 --- a/app/addons/setup/setup.js +++ b/app/addons/setup/setup.js @@ -22,11 +22,44 @@ var ConfirmButton = ReactComponents.ConfirmButton; var ClusterConfiguredScreen = React.createClass({ + getInitialState: function () { + return this.getStoreState(); + }, + + getStoreState: function () { + return { + clusterState: setupStore.getClusterState() + }; + }, + + componentDidMount: function () { + setupStore.on('change', this.onChange, this); + }, + + componentWillUnmount: function () { + setupStore.off('change', this.onChange); + }, + + onChange: function () { + this.setState(this.getStoreState()); + }, + + getNodeType: function() { + if (this.state.clusterState === 'cluster_finished') { + return 'clustered'; + } else if (this.state.clusterState === 'single_node_enabled') { + return 'single'; + } else { + return 'unknown state'; + } + }, render: function () { + var nodetype = this.getNodeType(); + return (
- {app.i18n.en_US['couchdb-productname']} is configured for production usage! + {app.i18n.en_US['couchdb-productname']} is configured for production usage as a {nodetype} node!

Do you want to replicate data? @@ -66,6 +99,32 @@ var SetupCurrentAdminPassword = React.createClass({ }); +var SetupNodeCountSetting = React.createClass({ + getInitialState: function () { + return { + nodeCountValue: this.props.nodeCountValue + }; + }, + + handleNodeCountChange: function (event) { + this.props.onAlterNodeCount(event); + this.setState({nodeCountValue: event.target.value}); + }, + + render: function () { + return ( +
+

Number of nodes to be added to the cluster (including this one)

+ +
+ ); + } +}); var SetupOptionalSettings = React.createClass({ getInitialState: function () { @@ -179,6 +238,10 @@ var SetupMultipleNodesController = React.createClass({ SetupActions.setPortForSetupNode(e.target.value); }, + alterNodeCount: function (e) { + SetupActions.setNodeCount(e.target.value); + }, + finishClusterSetup: function () { SetupActions.finishClusterSetup('CouchDB Cluster set up!'); }, @@ -197,6 +260,8 @@ var SetupMultipleNodesController = React.createClass({ +

@@ -323,7 +388,8 @@ var SetupFirstStepController = React.createClass({ }, render: function () { - if (this.state.clusterState === 'cluster_finished') { + if (this.state.clusterState === 'cluster_finished' || + this.state.clusterState === 'single_node_enabled') { return (); } @@ -340,12 +406,12 @@ var SetupFirstStepController = React.createClass({ + text="Configure a Cluster" /> + text="Configure a Single Node" />
); diff --git a/app/addons/setup/setup.stores.js b/app/addons/setup/setup.stores.js index b033ca8..1ba83f7 100644 --- a/app/addons/setup/setup.stores.js +++ b/app/addons/setup/setup.stores.js @@ -27,7 +27,8 @@ var SetupStore = FauxtonAPI.Store.extend({ this._setupNode = { bindAddress: '0.0.0.0', - port: 5984 + port: 5984, + nodeCount: 3 }; this.resetAddtionalNode(); @@ -91,6 +92,14 @@ var SetupStore = FauxtonAPI.Store.extend({ return this._setupNode.bindAddress; }, + setNodeCountForSetupNode: function (options) { + this._setupNode.nodeCount = Math.min(options.value, 3); + }, + + getNodeCountForSetupNode: function () { + return this._setupNode.nodeCount; + }, + setBindAdressForAdditionalNode: function (options) { this._additionalNode.bindAddress = options.value; }, @@ -159,6 +168,9 @@ var SetupStore = FauxtonAPI.Store.extend({ this.resetAddtionalNode(); break; + case ActionTypes.SETUP_NODE_COUNT: + this.setNodeCountForSetupNode(action.options); + break; default: return; diff --git a/app/addons/setup/tests/setupSpec.js b/app/addons/setup/tests/setupSpec.js index 0e0b2d1..27372bc 100644 --- a/app/addons/setup/tests/setupSpec.js +++ b/app/addons/setup/tests/setupSpec.js @@ -66,4 +66,26 @@ describe('Setup: verify input', function () { assert.ok(error); }); + it('Node count must be a number', function () { + var error = model.validate({ + admin: { + user: 'rocko', + password: 'ente' + }, + nodeCount: 'abc' + }); + assert.ok(error); + }); + + it('Node count must be >= 1', function () { + var error = model.validate({ + admin: { + user: 'rocko', + password: 'ente' + }, + nodeCount: 0 + }); + assert.ok(error); + }); + }); -- To stop receiving notification emails like this one, please contact ['"commits@couchdb.apache.org" '].