]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
A properly working testradoscio.c. For the moment it just takes a number of writes...
authorgreg <gregf@skinny.ops.newdream.net>
Mon, 8 Jun 2009 18:35:57 +0000 (11:35 -0700)
committergreg <gregf@skinny.ops.newdream.net>
Tue, 9 Jun 2009 21:56:08 +0000 (14:56 -0700)
src/testradoscio.c

index e68a334a639d458ab65dbcfd99b19bc2b15f554f..8fb338c19569464ff4037b56b1c9b5d6bb837631 100644 (file)
@@ -1,15 +1,15 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
 // vim: ts=8 sw=2 smarttab
 /*
-* Ceph - scalable distributed file system
      *
      *
      * This is free software; you can redistribute it and/or
      * modify it under the terms of the GNU Lesser General Public
      * License version 2.1, as published by the Free Software 
      * Foundation.  See file COPYING.
      
-*/
+ * Ceph - scalable distributed file system
+ *
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software 
+ * Foundation.  See file COPYING.
+ * 
+ */
 
 #include "include/librados.h"
 
 #include <stdlib.h>
 #include <time.h>
 
-       int main(int argc, const char **argv) {
-       if (argc<2) {
-               printf("need to assign # of concurrent ios to perform!\n");
-               exit(1);
-       }
+int main(int argc, const char **argv) {
+  if (argc<2) {
+    printf("need to assign # of concurrent ios to perform!\n");
+    exit(1);
+  }
        
-       int concurrentios = atoi(argv[1]);
-       printf("Performing %d ios\n", concurrentios);
+  int concurrentios = atoi(argv[1]);
+  printf("Performing %d ios\n", concurrentios);
 
-       if (rados_initialize(argc, argv) < 0) {
-               printf("error initializing\n");
-               exit(1);
-       }
+  if (rados_initialize(argc, argv) < 0) {
+    printf("error initializing\n");
+    exit(1);
+  }
        
-       rados_pool_t pool;
-       int r = rados_open_pool("data", &pool);
-       printf("open pool result = %d, pool = %d\n", r, pool);
+  rados_pool_t pool;
+  int r = rados_open_pool("data", &pool);
+  printf("open pool result = %d, pool = %d\n", r, pool);
 
-       rados_completion_t* completions[concurrentios];
-       char* name[concurrentios];
-       char contents[128];
-//     char* buffers[concurrentios];
-       int i;
-       for (i=0; i<concurrentios; i +=1 ) {
-               printf("on loop iteration %d\n", i);
-               completions[i] = (rados_completion_t*) malloc(sizeof(rados_completion_t));
-               name[i] = (char*) malloc(sizeof(char)*128);
-               snprintf(name[i], 127, "%d", i);
-               snprintf(contents, 127, "I'm the %d object!", i);
-               rados_aio_write(pool, name[i], 0, contents, 127, completions[i]);
-               printf("asynchronously writing \"%s\"\n", contents);
-       }
-       printf("Completed asynchronous writes to objects\n");
+  rados_completion_t completions[concurrentios];
+  char* name[concurrentios];
+  char contents[128];
+  //   char* buffers[concurrentios];
+  int i;
+  for (i=0; i<concurrentios; i +=1 ) {
+    printf("on loop iteration %d\n", i);
+    name[i] = (char*) malloc(sizeof(char)*128);
+    snprintf(name[i], 127, "%d", i);
+    snprintf(contents, 127, "I'm the %d object!", i);
+    rados_aio_write(pool, name[i], 0, &contents, 127, &completions[i]);
+    printf("asynchronously writing \"%s\"\n", contents);
+  }
+  printf("Completed asynchronous writes to objects\n");
        
-       rados_completion_t* read_completions[concurrentios];
-       char* readData[concurrentios];
-       for (i=0; i<concurrentios; i+=1 ) {
-               printf("Waiting for %d write to be complete\n", i);
-               rados_aio_wait_for_safe(*completions[i]);
-               printf("Write %d is complete!\n", i);
-               read_completions[i] = (rados_completion_t*) malloc(sizeof(rados_completion_t));
-               readData[i] = (char*) malloc(sizeof(char)*128);
-               rados_aio_read(pool, name[i], 0, readData[i], 127, read_completions[i]);
-               rados_aio_release(*completions[i]);
-       }
-       for (i=0; i<concurrentios; i+=1) {
-               printf("Waiting for %d read\n", i);
-               rados_aio_wait_for_complete(*read_completions[i]);
-               printf("Read %d is complete!\n", i);
-               printf(readData[i]);
-       }
+  rados_completion_t read_completions[concurrentios];
+  char* readData[concurrentios];
+  for (i=0; i<concurrentios; i+=1 ) {
+    printf("Waiting for %d write to be complete\n", i);
+    rados_aio_wait_for_safe(completions[i]);
+    printf("Write %d is complete!\n", i);
+    readData[i] = (char*) malloc(sizeof(char)*128);
+    rados_aio_read(pool, name[i], 0, readData[i], 127, &read_completions[i]);
+    //    rados_aio_release(completions[i]);
+  }
+  for (i=0; i<concurrentios; i+=1) {
+    printf("Waiting for %d read\n", i);
+    rados_aio_wait_for_complete(read_completions[i]);
+    printf("Read %d is complete!\n", i);
+    printf(readData[i]);
+    // rados_aio_release(read_completions[i]);
+  }
        
-       for (i=0; i<concurrentios; i+=1) {
-               free (completions[i]);
-               free (name[i]);
-               free (read_completions[i]);
-               free (readData[i]);
-       }
-       
-       rados_close_pool(pool);
+  for (i=0; i<concurrentios; i+=1) {
+    free (name[i]);
+    free (readData[i]);
+  }
+
+  rados_close_pool(pool);
 
-       rados_deinitialize();
+  rados_deinitialize();
 
-       return 0;
+  return 0;
 }