]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: push log listing into RGWRados
authorSage Weil <sage.weil@dreamhost.com>
Sat, 8 Oct 2011 21:56:00 +0000 (14:56 -0700)
committerSage Weil <sage@newdream.net>
Mon, 10 Oct 2011 18:51:22 +0000 (11:51 -0700)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/rgw/rgw_access.h
src/rgw/rgw_admin.cc
src/rgw/rgw_fs.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 4f21afd859e11a99aadc29f043454ccd5e9c862b..70ad2ca0d6b24d6435f4444be8dceb9068eabad1 100644 (file)
@@ -37,9 +37,9 @@ public:
   virtual int list_buckets_init(std::string& id, RGWAccessHandle *handle) = 0;
   /** get the next bucket in the provided listing context. */
   virtual int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle) = 0;
-
-  virtual int list_objects_raw_init(rgw_bucket& bucket, RGWAccessHandle *handle) = 0;
-  virtual int list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle) = 0;
+  
+  virtual int log_list_init(const string& prefix, RGWAccessHandle *handle) { return -ENOENT; }
+  virtual int log_list_next(RGWAccessHandle handle, string *name) { return -ENOENT; }
 
   /** 
    * get listing of the objects in a bucket.
index 78f894bf1de89ba7d3ff8038c81a3b7b6a32a615..b990d1649ef544b153fbc532fd76182c2b3d52a7 100644 (file)
@@ -943,8 +943,6 @@ int main(int argc, char **argv)
   }
 
   if (opt_cmd == OPT_LOG_LIST) {
-    rgw_bucket log_bucket(RGW_LOG_POOL_NAME);
-
     // filter by date?
     if (date.size() && date.size() != 10) {
       cerr << "bad date format for '" << date << "', expect YYYY-MM-DD" << std::endl;
@@ -954,7 +952,7 @@ int main(int argc, char **argv)
     formatter->reset();
     formatter->open_array_section("logs");
     RGWAccessHandle h;
-    int r = store->list_objects_raw_init(log_bucket, &h);
+    int r = store->list_logs_init(date, &h);
     if (r == -ENOENT) {
       // no logs.
     } else {
@@ -963,17 +961,15 @@ int main(int argc, char **argv)
        return r;
       }
       while (true) {
-       RGWObjEnt obj;
-       int r = store->list_objects_raw_next(obj, &h);
+       string name;
+       int r = store->list_logs_next(h, &name);
        if (r == -ENOENT)
          break;
        if (r < 0) {
          cerr << "log list: error " << r << std::endl;
          return r;
        }
-       if (date.size() && obj.name.find(date) != 0)
-         continue;
-       formatter->dump_string("object", obj.name);
+       formatter->dump_string("object", name);
       }
     }
     formatter->close_section();
index 0260c720529270ace443f98acb10de5c6c8f8ac9..ce91624afb16e689c389d48f511deac2f335a284 100644 (file)
@@ -14,10 +14,6 @@ public:
   int list_buckets_init(std::string& id, RGWAccessHandle *handle);
   int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle);
 
-  // not implemented here
-  int list_objects_raw_init(rgw_bucket& bucket, RGWAccessHandle *handle) { assert(0); }
-  int list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle) { assert(0); }
-
   int list_objects(std::string& id, rgw_bucket& bucket, int max, std::string& prefix, std::string& delim,
                    std::string& marker, std::vector<RGWObjEnt>& result, map<string, bool>& common_prefixes,
                    bool get_content_type, string& ns, bool *is_truncated, RGWAccessListFilter *filter);
index 4b337ef2afd09abf660ed5092bb539081f545b4f..3fc60a00f8446c1ecdeb8e7acf2000f66aa6c8ee 100644 (file)
@@ -209,31 +209,42 @@ int RGWRados::list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle
   return 0;
 }
 
-struct raw_list_object_state {
+struct log_list_state {
+  string prefix;
   librados::IoCtx io_ctx;
   librados::ObjectIterator obit;
 };
 
-int RGWRados::list_objects_raw_init(rgw_bucket& bucket, RGWAccessHandle *handle)
+int RGWRados::log_list_init(const string& prefix, RGWAccessHandle *handle)
 {
-  raw_list_object_state *state = new raw_list_object_state;
-  int r = open_bucket_ctx(bucket, state->io_ctx);
+  log_list_state *state = new log_list_state;
+  rgw_bucket log_bucket(RGW_LOG_POOL_NAME);
+  int r = open_bucket_ctx(log_bucket, state->io_ctx);
   if (r < 0)
     return r;
+  state->prefix = prefix;
   state->obit = state->io_ctx.objects_begin();
   *handle = (RGWAccessHandle*)state;
   return 0;
 }
 
-int RGWRados::list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle)
+int RGWRados::log_list_next(RGWAccessHandle handle, string *name)
 {
-  raw_list_object_state *state = (raw_list_object_state *)*handle;
-  if (state->obit == state->io_ctx.objects_end()) {
-    delete state;
-    return -ENOENT;
+  log_list_state *state = (log_list_state *)handle;
+  while (true) {
+    if (state->obit == state->io_ctx.objects_end()) {
+      delete state;
+      return -ENOENT;
+    }
+    if (state->prefix.length() &&
+       (*state->obit).find(state->prefix) != 0) {
+      state->obit++;
+      continue;
+    }
+    *name = *state->obit;
+    state->obit++;
+    break;
   }
-  obj.name = *state->obit;
-  state->obit++;
   return 0;
 }
 
index 42baa4ceb7142ff85533de59be40efda326e3777..c9987c3b71e480845c60444b8f7477a2b9946144 100644 (file)
@@ -141,9 +141,9 @@ public:
    */
   virtual int list_buckets_next(std::string& id, RGWObjEnt& obj, RGWAccessHandle *handle);
 
-  /* raw object list interface */
-  virtual int list_objects_raw_init(rgw_bucket& bucket, RGWAccessHandle *handle);
-  virtual int list_objects_raw_next(RGWObjEnt& obj, RGWAccessHandle *handle);
+  /// list logs
+  int log_list_init(const string& prefix, RGWAccessHandle *handle);
+  int log_list_next(RGWAccessHandle handle, string *name);
 
   /** get listing of the objects in a bucket */
   virtual int list_objects(std::string& id, rgw_bucket& bucket, int max, std::string& prefix, std::string& delim,