Skip to content

Commit

Permalink
[2.0] Deprecate the "Master" nomenclature in nodejs client (#222)
Browse files Browse the repository at this point in the history
* [2.0] Deprecate the "Master" nomenclature in nodejs client

1.Deprecate setting cluster.initial_master_nodes and introduce
the alternative setting cluster.initial_cluster_manager_nodes.
2.Use a new node role cluster_manager that has the same functionality
with master in the node setting node.roles: [ master ]
3.Cat API _cat/master is deprecated with _cat/cluster_manager
4.Deprecate master_timeout parameter to cluster_manager_timeout
5.Deprecate several interfaces, for example CatMasterMasterRecord
6.Replaces tests and comments

Issue Resolved:
#221

Signed-off-by: Anan Zhuang <[email protected]>

add some comments and toDos for master deprecation

Signed-off-by: Anan Zhuang <[email protected]>

update TODO and use JSDoc

Signed-off-by: Anan Zhuang <[email protected]>

* add more unit test to test cluster_manager role

Signed-off-by: Anan Zhuang <[email protected]>
  • Loading branch information
ananzh authored May 25, 2022
1 parent 9f137e9 commit e008fe8
Show file tree
Hide file tree
Showing 31 changed files with 2,114 additions and 2,238 deletions.
27 changes: 27 additions & 0 deletions api/api/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const acceptedQuerystring = [
'source',
'filter_path',
'bytes',
'cluster_manager_timeout',
'master_timeout',
'fields',
'time',
Expand All @@ -74,6 +75,7 @@ const snakeCase = {
expandWildcards: 'expand_wildcards',
errorTrace: 'error_trace',
filterPath: 'filter_path',
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
includeUnloadedSegments: 'include_unloaded_segments',
allowNoMatch: 'allow_no_match',
Expand Down Expand Up @@ -263,6 +265,31 @@ CatApi.prototype.indices = function catIndicesApi(params, options, callback) {
return this.transport.request(request, options, callback);
};

CatApi.prototype.cluster_manager = function catClusterManagerApi(params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

let { method, body, ...querystring } = params;
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);

let path = '';
if (method == null) method = 'GET';
path = '/' + '_cat' + '/' + 'cluster_manager';

// build request object
const request = {
method,
path,
body: null,
querystring,
};

return this.transport.request(request, options, callback);
};

/**
* // TODO: delete CatApi.prototype.master when it is removed from OpenSearch
* @deprecated use CatApi.prototype.cluster_manager instead
*/
CatApi.prototype.master = function catMasterApi(params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);

Expand Down
2 changes: 2 additions & 0 deletions api/api/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const acceptedQuerystring = [
'source',
'filter_path',
'timeout',
'cluster_manager_timeout',
'master_timeout',
'wait_for_removal',
'local',
Expand Down Expand Up @@ -73,6 +74,7 @@ const snakeCase = {
includeDiskInfo: 'include_disk_info',
errorTrace: 'error_trace',
filterPath: 'filter_path',
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
waitForRemoval: 'wait_for_removal',
flatSettings: 'flat_settings',
Expand Down
2 changes: 2 additions & 0 deletions api/api/dangling_indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } =
const acceptedQuerystring = [
'accept_data_loss',
'timeout',
'cluster_manager_timeout',
'master_timeout',
'pretty',
'human',
Expand All @@ -46,6 +47,7 @@ const acceptedQuerystring = [
];
const snakeCase = {
acceptDataLoss: 'accept_data_loss',
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/delete_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'timeout',
'cluster_manager_timeout',
'master_timeout',
'pretty',
'human',
Expand All @@ -44,6 +45,7 @@ const acceptedQuerystring = [
'filter_path',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'master_timeout',
'pretty',
'human',
Expand All @@ -43,6 +44,7 @@ const acceptedQuerystring = [
'filter_path',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/get_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'master_timeout',
'pretty',
'human',
Expand All @@ -43,6 +44,7 @@ const acceptedQuerystring = [
'filter_path',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'timeout',
'master_timeout',
'ignore_unavailable',
Expand Down Expand Up @@ -92,6 +93,7 @@ const acceptedQuerystring = [
'all_shards',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
Expand Down
2 changes: 2 additions & 0 deletions api/api/ingest.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'master_timeout',
'timeout',
'pretty',
Expand All @@ -46,6 +47,7 @@ const acceptedQuerystring = [
'verbose',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/put_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'timeout',
'master_timeout',
'context',
Expand All @@ -45,6 +46,7 @@ const acceptedQuerystring = [
'filter_path',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
2 changes: 2 additions & 0 deletions api/api/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
const acceptedQuerystring = [
'cluster_manager_timeout',
'master_timeout',
'timeout',
'pretty',
Expand All @@ -61,6 +62,7 @@ const acceptedQuerystring = [
'rarely_abort_writes',
];
const snakeCase = {
clusterManagerTimeout: 'cluster_manager_timeout',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path',
Expand Down
Loading

0 comments on commit e008fe8

Please sign in to comment.