diff options
| author | Koichi Suzuki | 2011-11-29 04:16:16 +0000 |
|---|---|---|
| committer | Koichi Suzuki | 2011-11-29 04:16:16 +0000 |
| commit | a43534d7519176e6dcdaf4517b329c2fed935c8b (patch) | |
| tree | d38427ba59524e1bde9dc997df8d94873d89c1f1 /src/gtm/recovery | |
| parent | 66a9181ee348aa2149b42ef79fa0ef6da95e2390 (diff) | |
This commit includes configuration file support for GTM and GTM-Proxy,
together with a couple of bug fix of GTM Standby and GTM-Proxy reconnect.
Now GTM and GTM-Proxy configuration files are mandatory. They should
be placed at the working directory, as specified by -D command line
option, as "gtm.conf" and "gtm_proxy.conf", respectively.
Their format is the same as Details will be found in the documentation.
Similar to coordinator/datanode, you can override some of the parameters
in configuration file by command line options.
Modified/affected files are as follows:
modified: doc-xc/src/sgml/ref/gtm.sgmlin
modified: doc-xc/src/sgml/ref/gtm_proxy.sgmlin
modified: src/gtm/Makefile
modified: src/gtm/README
modified: src/gtm/common/Makefile
new file: src/gtm/common/gtm_opt_handler.c
new file: src/gtm/common/gtm_opt_scanner.l
modified: src/gtm/gtm_ctl/gtm_ctl.c
modified: src/gtm/main/Makefile
new file: src/gtm/main/gtm.conf.sample
new file: src/gtm/main/gtm_opt.c
modified: src/gtm/main/gtm_standby.c
modified: src/gtm/main/main.c
modified: src/gtm/path/path.c
modified: src/gtm/proxy/Makefile
new file: src/gtm/proxy/gtm_proxy.conf.sample
new file: src/gtm/proxy/gtm_proxy_opt.c
modified: src/gtm/proxy/proxy_main.c
modified: src/gtm/recovery/register.c
modified: src/gtm/recovery/standby_utils.c
modified: src/include/gtm/gtm.h
new file: src/include/gtm/gtm_opt.h
new file: src/include/gtm/gtm_opt_tables.h
modified: src/include/gtm/gtm_proxy.h
modified: src/include/gtm/gtm_standby.h
modified: src/include/gtm/path.h
Diffstat (limited to 'src/gtm/recovery')
| -rw-r--r-- | src/gtm/recovery/register.c | 144 | ||||
| -rw-r--r-- | src/gtm/recovery/standby_utils.c | 6 |
2 files changed, 112 insertions, 38 deletions
diff --git a/src/gtm/recovery/register.c b/src/gtm/recovery/register.c index b081326287..21d416d5e5 100644 --- a/src/gtm/recovery/register.c +++ b/src/gtm/recovery/register.c @@ -381,11 +381,15 @@ Recovery_PGXCNodeRegister(GTM_PGXCNodeType type, /* Fill in structure */ nodeinfo->type = type; - nodeinfo->nodename = pgxcnode_copy_char(nodename); + if (nodename) + nodeinfo->nodename = pgxcnode_copy_char(nodename); nodeinfo->port = port; - nodeinfo->proxyname = pgxcnode_copy_char(proxyname); - nodeinfo->datafolder = pgxcnode_copy_char(datafolder); - nodeinfo->ipaddress = pgxcnode_copy_char(ipaddress); + if (proxyname) + nodeinfo->proxyname = pgxcnode_copy_char(proxyname); + if (datafolder) + nodeinfo->datafolder = pgxcnode_copy_char(datafolder); + if (ipaddress) + nodeinfo->ipaddress = pgxcnode_copy_char(ipaddress); nodeinfo->status = status; nodeinfo->socket = socket; @@ -462,8 +466,6 @@ ProcessPGXCNodeRegister(Port *myport, StringInfo message) memcpy(proxyname, (char *)pq_getmsgbytes(message, len), len); proxyname[len] = '\0'; - elog(LOG, "ProcessPGXCNodeRegister: ipaddress = %s", ipaddress); - /* * Finish by reading Data Folder (length and then string) */ @@ -472,6 +474,11 @@ ProcessPGXCNodeRegister(Port *myport, StringInfo message) memcpy(datafolder, (char *)pq_getmsgbytes(message, len), len); datafolder[len] = '\0'; + elog(LOG, + "ProcessPGXCNodeRegister: ipaddress = \"%s\", node name = \"%s\", proxy name = \"%s\", " + "datafolder \"%s\"", + ipaddress, node_name, proxyname, datafolder); + status = pq_getmsgint(message, sizeof (GTM_PGXCNodeStatus)); if ((type!=PGXC_NODE_GTM_PROXY) && @@ -483,6 +490,7 @@ ProcessPGXCNodeRegister(Port *myport, StringInfo message) ereport(ERROR, (EINVAL, errmsg("Unknown node type."))); + elog(LOG, "Node type = %d", type); /* * We must use the TopMostMemoryContext because the Node ID information is @@ -729,10 +737,10 @@ ProcessPGXCNodeList(Port *myport, StringInfo message) void Recovery_SaveRegisterInfo(void) { -GTM_PGXCNodeInfoHashBucket *bucket; -gtm_ListCell *elem; -GTM_PGXCNodeInfo *nodeinfo = NULL; -int hash, ctlfd; + GTM_PGXCNodeInfoHashBucket *bucket; + gtm_ListCell *elem; + GTM_PGXCNodeInfo *nodeinfo = NULL; + int hash, ctlfd; char filebkp[GTM_NODE_FILE_MAX_PATH]; GTM_RWLockAcquire(&RegisterFileLock, GTM_LOCKMODE_WRITE); @@ -749,7 +757,7 @@ int hash, ctlfd; return; } -for (hash = 0; hash < NODE_HASH_TABLE_SIZE; hash++) + for (hash = 0; hash < NODE_HASH_TABLE_SIZE; hash++) { bucket = >M_PGXCNodes[hash]; @@ -769,24 +777,57 @@ for (hash = 0; hash < NODE_HASH_TABLE_SIZE; hash++) write(ctlfd, &NodeRegisterMagic, sizeof (NodeRegisterMagic)); write(ctlfd, &nodeinfo->type, sizeof (GTM_PGXCNodeType)); - len = strlen(nodeinfo->nodename); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->nodename, len); + if (nodeinfo->nodename) + { + len = strlen(nodeinfo->nodename); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->nodename, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } + write(ctlfd, &nodeinfo->port, sizeof (GTM_PGXCNodePort)); - len = strlen(nodeinfo->proxyname); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->proxyname, len); + if (nodeinfo->proxyname) + { + len = strlen(nodeinfo->proxyname); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->proxyname, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } write(ctlfd, &nodeinfo->status, sizeof (GTM_PGXCNodeStatus)); - len = strlen(nodeinfo->ipaddress); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->ipaddress, len); + if (nodeinfo->ipaddress) + { + len = strlen(nodeinfo->ipaddress); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->ipaddress, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } - len = strlen(nodeinfo->datafolder); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->datafolder, len); + if (nodeinfo->datafolder) + { + len = strlen(nodeinfo->datafolder); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->datafolder, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } write(ctlfd, &NodeEndMagic, sizeof(NodeEndMagic)); @@ -835,9 +876,18 @@ Recovery_RecordRegisterInfo(GTM_PGXCNodeInfo *nodeinfo, bool is_register) write(ctlfd, &NodeUnregisterMagic, sizeof (NodeUnregisterMagic)); write(ctlfd, &nodeinfo->type, sizeof (GTM_PGXCNodeType)); - len = strlen(nodeinfo->nodename); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->nodename, len); + + if (nodeinfo->nodename) + { + len = strlen(nodeinfo->nodename); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->nodename, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } if (is_register) { @@ -845,19 +895,43 @@ Recovery_RecordRegisterInfo(GTM_PGXCNodeInfo *nodeinfo, bool is_register) write(ctlfd, &nodeinfo->port, sizeof (GTM_PGXCNodePort)); - len = strlen(nodeinfo->proxyname); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->proxyname, len); + if (nodeinfo->proxyname) + { + len = strlen(nodeinfo->proxyname); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->proxyname, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } write(ctlfd, &nodeinfo->status, sizeof (GTM_PGXCNodeStatus)); - len = strlen(nodeinfo->ipaddress); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->ipaddress, len); + if (nodeinfo->ipaddress) + { + len = strlen(nodeinfo->ipaddress); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->ipaddress, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } - len = strlen(nodeinfo->datafolder); - write(ctlfd, &len, sizeof(uint32)); - write(ctlfd, nodeinfo->datafolder, len); + if (nodeinfo->datafolder) + { + len = strlen(nodeinfo->datafolder); + write(ctlfd, &len, sizeof(uint32)); + write(ctlfd, nodeinfo->datafolder, len); + } + else + { + len = 0; + write(ctlfd, &len, sizeof(uint32)); + } } write(ctlfd, &NodeEndMagic, sizeof(NodeEndMagic)); diff --git a/src/gtm/recovery/standby_utils.c b/src/gtm/recovery/standby_utils.c index 4acf81c2b3..a28c0f933a 100644 --- a/src/gtm/recovery/standby_utils.c +++ b/src/gtm/recovery/standby_utils.c @@ -21,9 +21,9 @@ /* * Variables to interact with GTM active under GTM standby mode. */ -static bool GTM_StandbyMode = false; -static char *GTM_ActiveAddress; -static int GTM_ActivePort; +bool GTM_StandbyMode = false; +char *GTM_ActiveAddress; +int GTM_ActivePort; /* For thread safety, values above are protected by a lock */ static GTM_RWLock StandbyLock; |
