提交 f853f3b0 编写于 作者: P Pengzhou Tang

Add GUC gp_resource_manager to switch between resource queue and resource group

gp_resource_manager is reserved for later use to switch resource control stratagy from resource queue to an under-developing resource statagy named resource group. Eg:

gpconfig -c gp_resource_manager -v 'group'
gpconfig -c  gp_resource_manager -v 'queue'

To make it work, a restart of cluster is needed.
上级 e5496129
......@@ -25,6 +25,7 @@
#include "lib/stringinfo.h"
#include "libpq/libpq-be.h"
#include "utils/memutils.h"
#include "utils/resource_manager.h"
#include "storage/bfz.h"
#include "storage/proc.h"
#include "cdb/memquota.h"
......@@ -1191,6 +1192,46 @@ gpvars_assign_gp_fts_probe_pause(bool newval, bool doit, GucSource source)
return true;
}
/*
* gpvars_assign_gp_resource_manager_policy
* gpvars_show_gp_resource_manager_policy
*/
const char *
gpvars_assign_gp_resource_manager_policy(const char *newval, bool doit, GucSource source __attribute__((unused)))
{
ResourceManagerPolicy newtype = RESOURCE_MANAGER_POLICY_QUEUE;
if (newval == NULL || newval[0] == 0 )
newtype = RESOURCE_MANAGER_POLICY_QUEUE;
else if (!pg_strcasecmp("queue", newval))
newtype = RESOURCE_MANAGER_POLICY_QUEUE;
else if (!pg_strcasecmp("group", newval))
newtype = RESOURCE_MANAGER_POLICY_GROUP;
else
elog(ERROR, "unknown resource manager policy: current policy is '%s'", gpvars_show_gp_resource_manager_policy());
if (doit)
{
Gp_resource_manager_policy = newtype;
}
return newval;
}
const char *
gpvars_show_gp_resource_manager_policy(void)
{
switch (Gp_resource_manager_policy)
{
case RESOURCE_MANAGER_POLICY_QUEUE:
return "queue";
case RESOURCE_MANAGER_POLICY_GROUP:
return "group";
default:
Assert(!"unexpected resource manager policy");
return "unknown";
}
}
/*
* gpvars_assign_gp_resqueue_memory_policy
* gpvars_show_gp_resqueue_memory_policy
......
......@@ -10,7 +10,7 @@ include $(top_builddir)/src/Makefile.global
OBJS = fmgrtab.o session_state.o
SUBDIRS = adt cache datumstream error fmgr hash init mb misc mmgr resowner \
resgroup resscheduler sort stat time gpmon gp workfile_manager
resgroup resscheduler sort stat time gpmon gp workfile_manager resource_manager
include $(top_srcdir)/src/backend/common.mk
......
......@@ -334,6 +334,7 @@ static char *gp_log_fts_str;
static char *gp_log_interconnect_str;
static char *gp_interconnect_type_str;
static char *gp_interconnect_fc_method_str;
static char *gp_resource_manager_str;
/*
* These variables are all dummies that don't do anything, except in some
......@@ -5119,6 +5120,14 @@ struct config_string ConfigureNamesString_gp[] =
"MEDIUM", gpvars_assign_gp_resqueue_priority_default_value, NULL
},
{
{"gp_resource_manager", PGC_POSTMASTER, RESOURCES,
gettext_noop("Sets the type of resource manager."),
gettext_noop("Only support \"queue\" and \"group\" for now.")
},
&gp_resource_manager_str,
"queue", gpvars_assign_gp_resource_manager_policy, gpvars_show_gp_resource_manager_policy,
},
{
{"gp_email_smtp_server", PGC_SUSET, LOGGING,
gettext_noop("Sets the SMTP server and port used to send email alerts."),
......
#-------------------------------------------------------------------------
#
# Makefile--
# Makefile for utils/resource_manager
#
# IDENTIFICATION
# src/backend/utils/resource_manager/Makefile
#
#-------------------------------------------------------------------------
subdir = src/backend/utils/resource_manager
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = resource_manager.o
include $(top_srcdir)/src/backend/common.mk
/*-------------------------------------------------------------------------
*
* resource_manager.c
* GPDB resource manager code.
*
*
* Copyright (c) 2006-2017, Greenplum inc.
*
*
-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "utils/guc.h"
#include "utils/resource_manager.h"
/*
* GUC variables.
*/
bool ResourceScheduler; /* Is scheduling enabled? */
ResourceManagerPolicy Gp_resource_manager_policy;
......@@ -42,7 +42,6 @@
/*
* GUC variables.
*/
bool ResourceScheduler; /* Is scheduling enabled? */
int MaxResourceQueues; /* Max # of queues. */
int MaxResourcePortalsPerXact; /* Max # tracked portals -
* per backend . */
......
......@@ -1020,6 +1020,10 @@ extern void write_log(const char *fmt,...) __attribute__((format(printf, 1, 2)))
extern void verifyGpIdentityIsSet(void);
extern const char *gpvars_assign_gp_resource_manager_policy(const char *newval, bool doit, GucSource source __attribute__((unused)) );
extern const char *gpvars_show_gp_resource_manager_policy(void);
extern const char *gpvars_assign_gp_resqueue_memory_policy(const char *newval, bool doit, GucSource source __attribute__((unused)) );
extern const char *gpvars_show_gp_resqueue_memory_policy(void);
......
/*-------------------------------------------------------------------------
*
* resource_manager.h
* GPDB resource manager definitions.
*
*
* Copyright (c) 2006-2017, Greenplum inc.
*
* IDENTIFICATION
* src/include/utils/resource_manager.h
*
*-------------------------------------------------------------------------
*/
#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H
typedef enum
{
RESOURCE_MANAGER_POLICY_QUEUE,
RESOURCE_MANAGER_POLICY_GROUP,
} ResourceManagerPolicy;
/*
* GUC variables.
*/
extern bool ResourceScheduler;
extern ResourceManagerPolicy Gp_resource_manager_policy;
#endif /* RESOURCEMANAGER_H */
......@@ -19,11 +19,11 @@
#include "nodes/plannodes.h"
#include "storage/lock.h"
#include "tcop/dest.h"
#include "utils/resource_manager.h"
/*
* GUC variables.
*/
extern bool ResourceScheduler;
extern int MaxResourceQueues;
extern int MaxResourcePortalsPerXact;
extern bool ResourceSelectOnly;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册