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.
}
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;
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 {
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();
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);
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;
}
*/
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,