Add Swift back-end
PATCH 8/8 Add Swift back-end
This patch allows to use tabled with OpenStack Swift object store as if it were our chunkserver, with some extra tricks. The configuration has to be entred manually into CLD, just like in case of filesystem back-end.
The code is fairly experimental, so it retains extra messages.
Also, since Swift authorizes by plaintext passwords, support for SSL is essential, but is currently missing.
There is no build-time test for this, because it would require us to depend on OpenStack, which is untenable.
--- doc/etc.tabled.conf | 5 server/Makefile.am | 7 server/object.c | 2 server/replica.c | 4 server/server.c | 8 server/stor_swift.c | 1420 +++++++++++++++++++++++++++++++++++++++++ server/storage.c | 3 server/storparse.c | 7 server/tabled.h | 30 test/swift-test.conf | 8 10 files changed, 1487 insertions(+), 7 deletions(-)
commit f24e2bd00d10f074ca9c6f62794b0838bc2de9b5
Author: Pete Zaitcev <[email protected]> Date: Sun Nov 28 18:07:44 2010 -0700
Add Swift back-end. Sadly, no test.
doc/etc.tabled.conf +3 -2
@@ -43,8 +43,9 @@ </CLD> --> -<ChunkUser>test</ChunkUser> -<ChunkKey>test</ChunkKey> +<!-- swift-auth-add-user -K devauth -a tabled tester1 tester1 --> +<ChunkUser>tester1</ChunkUser> +<ChunkKey>tester1</ChunkKey> <!-- Monitoring interface. Best is not to expose this to Internet. --> <StatusPort>8084</StatusPort>
server/Makefile.am +4 -3
@@ -1,15 +1,16 @@ -INCLUDES = -I$(top_srcdir)/include @GLIB_CFLAGS@ @HAIL_CFLAGS@ +INCLUDES = -I$(top_srcdir)/include \ + @LIBCURL_CPPFLAGS@ @GLIB_CFLAGS@ @HAIL_CFLAGS@ sbin_PROGRAMS = tabled tdbadm tabled_SOURCES = tabled.h \ bucket.c cldu.c config.c metarep.c object.c replica.c \ server.c status.c storage.c storparse.c \ - stor_chunk.c stor_fs.c util.c + stor_chunk.c stor_fs.c stor_swift.c util.c tabled_LDADD = ../lib/libtdb.a \ @HAIL_LIBS@ @PCRE_LIBS@ @GLIB_LIBS@ \ - @CRYPTO_LIBS@ @DB4_LIBS@ @EVENT_LIBS@ @SSL_LIBS@ + @CRYPTO_LIBS@ @DB4_LIBS@ @EVENT_LIBS@ @LIBCURL@ @SSL_LIBS@ tdbadm_SOURCES = tdbadm.c tdbadm_LDADD = ../lib/libtdb.a @GLIB_LIBS@ @DB4_LIBS@
server/object.c +2 -0
@@ -700,6 +700,8 @@ static struct open_chunk *open_chunk1(struct storage_node *stnode,applog (LOG_ERR ,"OOM" ); goto err_alloc; } +INIT_LIST_HEAD (&ochunk->evt_list); +INIT_LIST_HEAD (&ochunk->buf_list); rc =stor_open (ochunk, stnode, tabled_srv.evbase_main);if (rc !=0 ) {
server/replica.c +4 -0
@@ -90,6 +90,10 @@ static struct rep_job *job_alloc(size_t klen, struct db_obj_key *key) job =malloc (len);if (job) {memset (job,0 ,sizeof (struct rep_job )); +INIT_LIST_HEAD (&job->in_ce.evt_list); +INIT_LIST_HEAD (&job->in_ce.buf_list); +INIT_LIST_HEAD (&job->out_ce.evt_list); +INIT_LIST_HEAD (&job->out_ce.buf_list);memcpy (job+1 , key, klen); job->klen = klen; job->key = (struct db_obj_key *)(job+1 );
server/server.c +8 -0
@@ -46,6 +46,7 @@#include <openssl/md5.h> #include <openssl/hmac.h> #include <openssl/ssl.h> +#include <curl/curl.h> #include <elist.h> #include <chunkc.h> #include <cldc.h>
@@ -1245,6 +1246,8 @@ static struct client *cli_alloc(bool is_status)applog (LOG_ERR ,"out of memory" );return NULL ; } +INIT_LIST_HEAD (&cli->in_ce.evt_list); +INIT_LIST_HEAD (&cli->in_ce.buf_list);atcp_wr_init (&cli->wst, &libevent_wr_ops, &cli->write_ev, cli);
@@ -2079,6 +2082,11 @@ int main (int argc, char *argv[])SSL_library_init ();SSL_load_error_strings (); +if (curl_global_init (CURL_GLOBAL_ALL )) { +fprintf (stderr,"curl_global_init failed\n" ); +return 1 ; + } +stc_init ();cld_init ();
server/stor_swift.c new file +1420 -0
1,420 lines not on this page · raw message
server/storage.c +2 -1
@@ -166,7 +166,8 @@ static int stor_add_node_this(struct storage_node *sn, sn->ops = &stor_ops_posix;return stor_add_node_base (sn, base);case STT_SWIFT : -return -1 ; + sn->ops = &stor_ops_swift; +return stor_add_node_addr (sn, hostname, portstr);default : sn->ops = &stor_ops_chunk;return stor_add_node_addr (sn, hostname, portstr);
server/storparse.c +6 -1
@@ -452,7 +452,12 @@ void stor_parse(char *fname, const char *text, size_t len)stor_add_node (ctx.nid,STT_POSIX , ctx.stor_base,NULL ,NULL , &ctx.loc);break ; -case CFG_TYPE_SWIFT : +case CFG_TYPE_SWIFT :/* same as chunk for now */ +if (!stor_verify_chunk (fname, &ctx)) + goto out_free_all; +stor_add_node (ctx.nid,STT_SWIFT ,NULL , + ctx.stor_ok_host, ctx.stor_ok_port, &ctx.loc); +break ;case CFG_TYPE_UNKNOWN :if (debugging)applog (LOG_DEBUG ,"%s: Unknown storage type" , fname);
server/tabled.h +30 -0
@@ -134,6 +134,9 @@ struct storage_node {unsigned alen;struct sockaddr_in6 addr;char *hostname; +/* swift is basically chunk-like, with this temporary addition XXX */ +char *auth_token; +char *auth_url;/* file */ char *basepath;
@@ -142,6 +145,21 @@ struct storage_node {typedef bool (*cli_evt_func )(struct client *,unsigned int ,bool *invalidate_cli); +struct open_event { +struct list_head link; +struct open_chunk *chunk; +int fd; +unsigned int mask; +bool armed; +struct event evt; +}; + +struct open_buf { +struct list_head link; +unsigned char *buf; +size_t length, done; +}; +/* an open chunkd client */ struct open_chunk {struct st_client *stc;
@@ -174,6 +192,15 @@ struct open_chunk {* several fds and then what? It's an implementation detail. */ int pfd; + +/* swift */ +struct list_head evt_list;/* struct open_event */ +struct list_head buf_list;/* struct open_buf */ +long timeout; +struct event timer; +CURLM *cmh; +CURL *c1h; +bool do_multi; };/* internal client socket state */
@@ -529,6 +556,9 @@ extern struct st_node_ops stor_ops_chunk;/* stor_fs.c */ extern struct st_node_ops stor_ops_posix; +/* stor_swift.c */ +extern struct st_node_ops stor_ops_swift; +/* replica.c */ extern void rep_init (struct event_base *ev_base);extern void rep_start (void );
test/swift-test.conf new file +8 -0
@@ -0,0 +1,8 @@ +<Chunk> + <NID>257</NID> + <Type>swift</Type> + <Socket> + <Host>lembas.zaitcev.lan</Host> + <Port>11000</Port> <!-- N.B. this is the auth port --> + </Socket> +</Chunk>
Quoted 6 lines · Pete Zaitcev
This patch allows to use tabled with OpenStack Swift object store as if it were our chunkserver, with some extra tricks. The configuration has to be entred manually into CLD, just like in case of filesystem back-end.
The code is fairly experimental, so it retains extra messages.
Quoted 7 lines
Also, since Swift authorizes by plaintext passwords, support for SSL is essential, but is currently missing.
There is no build-time test for this, because it would require us to depend on OpenStack, which is untenable.
Signed-off-by Pete Zaitcev<[email protected]>
applied patches 6-8. well done, this is a milestone for tabled!