Remove unused master_get_round_robin_candidate_nodes

pull/1255/head
Brian Cloutier 2017-03-07 11:47:34 +03:00
parent 807beb7bc0
commit 95936ff481
6 changed files with 1 additions and 113 deletions

View File

@ -3,5 +3,6 @@
SET search_path = 'pg_catalog';
DROP FUNCTION IF EXISTS master_get_local_first_candidate_nodes();
DROP FUNCTION IF EXISTS master_get_round_robin_candidate_nodes();
RESET search_path;

View File

@ -166,15 +166,6 @@ CREATE FUNCTION master_get_active_worker_nodes(OUT node_name text, OUT node_port
COMMENT ON FUNCTION master_get_active_worker_nodes()
IS 'fetch set of active worker nodes';
CREATE FUNCTION master_get_round_robin_candidate_nodes(shard_id bigint,
OUT node_name text,
OUT node_port bigint)
RETURNS SETOF record
LANGUAGE C STRICT ROWS 100
AS 'MODULE_PATHNAME', $$master_get_round_robin_candidate_nodes$$;
COMMENT ON FUNCTION master_get_round_robin_candidate_nodes(shard_id bigint)
IS 'fetch set of candidate nodes for shard uploading in round-robin manner';
CREATE FUNCTION master_create_distributed_table(table_name regclass,
distribution_column text,
distribution_method citus.distribution_type)

View File

@ -77,7 +77,6 @@ PG_FUNCTION_INFO_V1(master_get_table_metadata);
PG_FUNCTION_INFO_V1(master_get_table_ddl_events);
PG_FUNCTION_INFO_V1(master_get_new_shardid);
PG_FUNCTION_INFO_V1(master_get_new_placementid);
PG_FUNCTION_INFO_V1(master_get_round_robin_candidate_nodes);
PG_FUNCTION_INFO_V1(master_get_active_worker_nodes);
@ -365,90 +364,6 @@ GetNextPlacementId(void)
}
/*
* master_get_round_robin_candidate_nodes returns a set of candidate host names
* and port numbers on which to place new shards. The function uses the round
* robin policy to choose the nodes and tries to ensure that there is an even
* distribution of shards across the worker nodes. This function errors out if
* the number of available nodes falls short of the replication factor.
*/
Datum
master_get_round_robin_candidate_nodes(PG_FUNCTION_ARGS)
{
uint64 shardId = PG_GETARG_INT64(0);
FuncCallContext *functionContext = NULL;
uint32 desiredNodeCount = 0;
uint32 currentNodeCount = 0;
if (SRF_IS_FIRSTCALL())
{
MemoryContext oldContext = NULL;
TupleDesc tupleDescriptor = NULL;
List *workerNodeList = NIL;
TypeFuncClass resultTypeClass = 0;
uint32 workerNodeCount = 0;
/* create a function context for cross-call persistence */
functionContext = SRF_FIRSTCALL_INIT();
/* switch to memory context appropriate for multiple function calls */
oldContext = MemoryContextSwitchTo(functionContext->multi_call_memory_ctx);
/* get the worker node list and sort it for determinism */
workerNodeList = WorkerNodeList();
workerNodeList = SortList(workerNodeList, CompareWorkerNodes);
functionContext->user_fctx = workerNodeList;
functionContext->max_calls = ShardReplicationFactor;
/* if we enough live nodes, return an extra candidate node as backup */
workerNodeCount = (uint32) list_length(workerNodeList);
if (workerNodeCount > ShardReplicationFactor)
{
functionContext->max_calls = ShardReplicationFactor + 1;
}
/* create tuple descriptor for return value */
resultTypeClass = get_call_result_type(fcinfo, NULL, &tupleDescriptor);
if (resultTypeClass != TYPEFUNC_COMPOSITE)
{
ereport(ERROR, (errmsg("return type must be a row type")));
}
functionContext->tuple_desc = tupleDescriptor;
MemoryContextSwitchTo(oldContext);
}
functionContext = SRF_PERCALL_SETUP();
desiredNodeCount = functionContext->max_calls;
currentNodeCount = functionContext->call_cntr;
if (currentNodeCount < desiredNodeCount)
{
List *workerNodeList = functionContext->user_fctx;
WorkerNode *candidateNode = NULL;
Datum candidateDatum = 0;
candidateNode = WorkerGetRoundRobinCandidateNode(workerNodeList, shardId,
currentNodeCount);
if (candidateNode == NULL)
{
ereport(ERROR, (errmsg("could only find %u of %u required nodes",
currentNodeCount, desiredNodeCount)));
}
candidateDatum = WorkerNodeGetDatum(candidateNode, functionContext->tuple_desc);
SRF_RETURN_NEXT(functionContext, candidateDatum);
}
else
{
SRF_RETURN_DONE(functionContext);
}
}
/*
* master_get_active_worker_nodes returns a set of active worker host names and
* port numbers in deterministic order. Currently we assume that all worker

View File

@ -126,7 +126,6 @@ extern Datum master_get_table_metadata(PG_FUNCTION_ARGS);
extern Datum master_get_table_ddl_events(PG_FUNCTION_ARGS);
extern Datum master_get_new_shardid(PG_FUNCTION_ARGS);
extern Datum master_get_new_placementid(PG_FUNCTION_ARGS);
extern Datum master_get_round_robin_candidate_nodes(PG_FUNCTION_ARGS);
extern Datum master_get_active_worker_nodes(PG_FUNCTION_ARGS);
/* Function declarations to help with data staging and deletion */

View File

@ -25,20 +25,6 @@ SELECT * FROM master_get_new_shardid();
740000
(1 row)
SELECT * FROM master_get_round_robin_candidate_nodes(1);
node_name | node_port
-----------+-----------
localhost | 57638
localhost | 57637
(2 rows)
SELECT * FROM master_get_round_robin_candidate_nodes(2);
node_name | node_port
-----------+-----------
localhost | 57637
localhost | 57638
(2 rows)
SELECT * FROM master_get_active_worker_nodes();
node_name | node_port
-----------+-----------

View File

@ -15,8 +15,4 @@ SELECT * FROM master_get_table_ddl_events('lineitem');
SELECT * FROM master_get_new_shardid();
SELECT * FROM master_get_round_robin_candidate_nodes(1);
SELECT * FROM master_get_round_robin_candidate_nodes(2);
SELECT * FROM master_get_active_worker_nodes();