summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2015-04-06 12:34:55 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-04-28 21:30:35 -0700
commitb04b957f2f27cf03958b456b3cec097d1e04923c (patch)
tree311b4c8b93cbf212979d2513c7aa70cb1976d2f7 /rpc
parenta7f848245ae5b0e4bbe363de13ec1676753352c5 (diff)
rpc: Introduce attribute throttle for rpcsvc_t
This attribute will be used to set/unset throttling for a rpcsvc_t program subsequently. Following APIs have been added to get/set throttle. int rpcsvc_set_throttle (rpcsvc_t svc, gf_boolean_t value); gf_boolean_t rpcsvc_get_throttle (rpcsvc_t svc); Change-Id: Ica8a9166cef22eb92d81fe68e48d0a5e24a1ef95 BUG: 1212385 Signed-off-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: http://review.gluster.org/10267 Tested-by: NetBSD Build System Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-lib/src/rpcsvc-common.h2
-rw-r--r--rpc/rpc-lib/src/rpcsvc.c46
-rw-r--r--rpc/rpc-lib/src/rpcsvc.h10
3 files changed, 58 insertions, 0 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc-common.h b/rpc/rpc-lib/src/rpcsvc-common.h
index 3c16abeb77a..832645bd12a 100644
--- a/rpc/rpc-lib/src/rpcsvc-common.h
+++ b/rpc/rpc-lib/src/rpcsvc-common.h
@@ -77,6 +77,8 @@ typedef struct rpcsvc_state {
/* per-client limit of outstanding rpc requests */
int outstanding_rpc_limit;
gf_boolean_t addr_namelookup;
+ /* determine whether throttling is needed, by default OFF */
+ gf_boolean_t throttle;
} rpcsvc_t;
/* DRC START */
diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 5717bedcf17..0a4dc04c731 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -2203,6 +2203,52 @@ rpcsvc_set_outstanding_rpc_limit (rpcsvc_t *svc, dict_t *options, int defvalue)
return (0);
}
+/*
+ * Enable throttling for rpcsvc_t svc.
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+rpcsvc_set_throttle_on (rpcsvc_t *svc)
+{
+
+ if (!svc)
+ return -1;
+
+ svc->throttle = _gf_true;
+
+ return 0;
+}
+
+/*
+ * Disable throttling for rpcsvc_t svc.
+ * Returns 0 on success, -1 otherwise.
+ */
+int
+rpcsvc_set_throttle_off (rpcsvc_t *svc)
+{
+
+ if (!svc)
+ return -1;
+
+ svc->throttle = _gf_false;
+
+ return 0;
+}
+
+/*
+ * Get throttle state for rpcsvc_t svc.
+ * Returns value of attribute throttle on success, _gf_false otherwise.
+ */
+gf_boolean_t
+rpcsvc_get_throttle (rpcsvc_t *svc)
+{
+
+ if (!svc)
+ return _gf_false;
+
+ return svc->throttle;
+}
+
/* The global RPC service initializer.
*/
rpcsvc_t *
diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h
index 1bf6b07ee2f..027e2ca1ffb 100644
--- a/rpc/rpc-lib/src/rpcsvc.h
+++ b/rpc/rpc-lib/src/rpcsvc.h
@@ -604,6 +604,16 @@ int
rpcsvc_set_root_squash (rpcsvc_t *svc, dict_t *options);
int
rpcsvc_set_outstanding_rpc_limit (rpcsvc_t *svc, dict_t *options, int defvalue);
+
+int
+rpcsvc_set_throttle_on (rpcsvc_t *svc);
+
+int
+rpcsvc_set_throttle_off (rpcsvc_t *svc);
+
+gf_boolean_t
+rpcsvc_get_throttle (rpcsvc_t *svc);
+
int
rpcsvc_auth_array (rpcsvc_t *svc, char *volname, int *autharr, int arrlen);
rpcsvc_vector_sizer