Skip to contentSkip to conversation

chunkd: write our contact information into CLD

PATCH In review Pete Zaitcev 2 participants 2 messages Aug 11, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 chunkd: write our contact information into CLD

Add our listening information into the parameter file in CLD. For now we only do that, and do not try to reorganize the CLD namespace that Chunk uses, use full path as a parameter, and other planned things. We do switch to asprintf though, it makes the code more robust (no more counting of elements by hand).

doc/api.txt +31 -0
index 1afe3de..002a55f 100644
@@ -36,3 +36,34 @@ username==password, the minimum level of authentication necessary to prove
 that it works.  It does not yet actually authenticate against any password
 database.
 
+
+CLD intergration
+================
+
+This feature may be changing (before version 1.0 especially), so reading
+the file server/cldu.c is probably the best guide.
+
+[root@hitlain zaitcev]# cldcli
+Waiting for thread startup...
+FIXME: timer_ctl
+Type 'help' at the prompt to list commands.
+[cli_user /]$ ls /chunk-default
+9
+[cli_user /]$ cat /chunk-default/9
+<Chunk>
+ <NID>9</NID>
+ <Socket>
+  <Type>chunk</Type>
+  <Host>hitlain.zaitcev.lan</Host>
+  <Port>8082</Port>
+ </Socket>
+ <Geo>
+  <Area>-</Area>
+  <Building>-</Building>
+  <Rack>-</Rack>
+ </Geo>
+</Chunk>
+
+[cli_user /]$ quit
+[root@hitlain zaitcev]#
+
doc/setup.txt +5 -3
index 3e243dc..862237b 100644
@@ -1,7 +1,8 @@
 How to get chunkd running in typical configurations:
 
-*) Make sure a CLD is running somewhere on the network, and has an SRV record,
-   which typically looks like this:
+*) Unless you run Chunk standalone (which is very rare), make sure a CLD is
+   running somewhere on the network, and has an SRV record, which typically
+   looks like this:
 
 [root@table1 ~]# host -t srv _cld._udp
 _cld._udp.phx2.ex.com has SRV record 10 50 8081 pacman.phx2.ex.com.
@@ -64,7 +65,8 @@ _cld._udp.phx2.ex.com has SRV record 10 50 8081 maika.phx2.ex.com.
    It's best to use only ASCII letters, numbers, dash ('-'), underscore ('_'),
    and period ('.') in cell names.
 
-*) configure Node ID (NID), if desired. The NID follows the data, so
+*) For a typical Chunk configuration (not running it standalone),
+   configure Node ID (NID). The NID follows the data, so
    the best practice for NIDs is to have site-wide node bring-up scripts
    create a unique identifier from a per-cell counter, instead of using
    the MAC or IP, or such. One common trick is to use the creation time,
server/chunkd.h +2 -2
index 2d4c811..82b8b97 100644
@@ -141,7 +141,7 @@ struct server_stats {
 
 struct server_socket {
 	int			fd;
-	bool			encrypt;
+	const struct listen_cfg	*cfg;
 	struct event		ev;
 };
 
@@ -153,7 +153,7 @@ struct server {
 	int			pid_fd;
 
 	GList			*listeners;
-	GList			*sockets;
+	GList			*sockets;	/* points into listeners */
 
 	struct list_head	wr_trash;
 	unsigned int		trash_sz;
server/cldu.c +111 -46

221 lines not on this page · raw message

server/server.c +3 -3
index 9ac2b32..2899f6f 100644
@@ -957,7 +957,7 @@ static void tcp_srv_event(int fd, short events, void *userdata)
 	char host[64];
 	int rc, on = 1;
 
-	cli = cli_alloc(sock->encrypt);
+	cli = cli_alloc(sock->cfg->encrypt);
 	if (!cli) {
 		applog(LOG_ERR, "out of memory");
 		return;
@@ -981,7 +981,7 @@ static void tcp_srv_event(int fd, short events, void *userdata)
 		applog(LOG_WARNING, "TCP_NODELAY failed: %s",
 		       strerror(errno));
 
-	if (sock->encrypt) {
+	if (sock->cfg->encrypt) {
 		if (!SSL_set_fd(cli->ssl, cli->fd))
 			goto err_out_fd;
 
@@ -1131,7 +1131,7 @@ static int net_open(const struct listen_cfg *cfg)
 		}
 
 		sock->fd = fd;
-		sock->encrypt = cfg->encrypt;
+		sock->cfg = cfg;
 
 		event_set(&sock->ev, fd, EV_READ | EV_PERSIST,
 			  tcp_srv_event, sock);
#1 lore raw
Quoted 7 lines · Pete Zaitcev

Add our listening information into the parameter file in CLD. For now we only do that, and do not try to reorganize the CLD namespace that Chunk uses, use full path as a parameter, and other planned things. We do switch to asprintf though, it makes the code more robust (no more counting of elements by hand).

applied 3-4