MCPcopy Create free account
hub / github.com/apache/cloudberry / parseEtcdHostConfiguration

Function parseEtcdHostConfiguration

src/common/etcdutils.c:48–75  ·  view source on GitHub ↗

* parseEtcdHostConfiguration: function used to parse etcdhost and etcdport inforamtion from a ETCD configure parameter. * parameter gp_etcd_endpoint IN * parameter gp_etcd_host OUT * parameter gp_etcd_port OUT * return ture if configuration parse succeeded, otherwise retrun false. */

Source from the content-addressed store, hash-verified

46 * return ture if configuration parse succeeded, otherwise retrun false.
47 */
48static bool
49parseEtcdHostConfiguration(const char *gp_etcd_endpoint, char *gp_etcd_host, int *gp_etcd_port)
50{
51 char etcd_host[GP_ETCD_HOSTNAME_LEN];
52 char etcd_port[GP_ETCD_PORT_LEN];
53 memset(etcd_host, 0, GP_ETCD_HOSTNAME_LEN);
54 memset(etcd_port, 0, GP_ETCD_PORT_LEN);
55
56 Assert(gp_etcd_endpoint != NULL && (strcmp(gp_etcd_endpoint, "") != 0));
57
58 if (sscanf(gp_etcd_endpoint, "%[^':']:%s", etcd_host, etcd_port) == GPETCDCONFIGNUMATTR)
59 {
60 if (gp_etcd_host != NULL)
61 {
62 if (strlen(etcd_host) >= GP_ETCD_HOSTNAME_LEN-1)
63 return false;
64 strncpy(gp_etcd_host, etcd_host, GP_ETCD_HOSTNAME_LEN);
65 }
66 if (gp_etcd_port != NULL)
67 {
68 *gp_etcd_port = atoi(etcd_port);
69 }
70 }
71 else
72 return false;
73
74 return true;
75}
76
77/*
78 * generateGPSegConfigKey: function used to generate ETCD configuration key and endpoint information.

Callers 1

generateGPSegConfigKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected