cerr << " opstate renew renew state on an entry (use client_id, op_id, object)\n";
cerr << " opstate rm remove entry (use client_id, op_id, object)\n";
cerr << " replicalog get get replica metadata log entry\n";
+ cerr << " replicalog update update replica metadata log entry\n";
cerr << " replicalog delete delete replica metadata log entry\n";
cerr << "options:\n";
cerr << " --uid=<id> user id\n";
OPT_OPSTATE_RENEW,
OPT_OPSTATE_RM,
OPT_REPLICALOG_GET,
+ OPT_REPLICALOG_UPDATE,
OPT_REPLICALOG_DELETE,
};
} else if (strcmp(prev_cmd, "replicalog") == 0) {
if (strcmp(cmd, "get") == 0)
return OPT_REPLICALOG_GET;
+ if (strcmp(cmd, "update") == 0)
+ return OPT_REPLICALOG_UPDATE;
if (strcmp(cmd, "delete") == 0)
return OPT_REPLICALOG_DELETE;
}
}
try {
- t.decode_json(&p);
+ decode_json_obj(t, &p);
} catch (JSONDecoder::err& e) {
cout << "failed to decode JSON input: " << e.message << std::endl;
return -EINVAL;
}
}
- if (opt_cmd == OPT_REPLICALOG_GET || opt_cmd == OPT_REPLICALOG_DELETE) {
+ if (opt_cmd == OPT_REPLICALOG_GET || opt_cmd == OPT_REPLICALOG_UPDATE ||
+ opt_cmd == OPT_REPLICALOG_DELETE) {
if (replica_log_type_str.empty()) {
cerr << "ERROR: need to specify --replica-log-type=<metadata | data | bucket>" << std::endl;
return EINVAL;
}
}
+ if (opt_cmd == OPT_REPLICALOG_UPDATE) {
+ if (marker.empty()) {
+ cerr << "ERROR: marker was not specified" <<std::endl;
+ return EINVAL;
+ }
+ utime_t time = ceph_clock_now(NULL);
+ if (!date.empty()) {
+ ret = parse_date_str(date, time);
+ if (ret < 0) {
+ cerr << "ERROR: failed to parse start date" << std::endl;
+ return EINVAL;
+ }
+ }
+ list<RGWReplicaItemMarker> entries;
+ int ret = read_decode_json(infile, entries);
+ if (ret < 0) {
+ cerr << "ERROR: failed to decode entries" << std::endl;
+ return EINVAL;
+ }
+ RGWReplicaBounds bounds;
+ if (replica_log_type == ReplicaLog_Metadata) {
+ if (!specified_shard_id) {
+ cerr << "ERROR: shard-id must be specified for get operation" << std::endl;
+ return EINVAL;
+ }
+
+ RGWReplicaObjectLogger logger(store, pool_name, META_REPLICA_LOG_OBJ_PREFIX);
+ int ret = logger.update_bound(shard_id, daemon_id, marker, time, &entries);
+ if (ret < 0) {
+ cerr << "ERROR: failed to update bounds: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ } else if (replica_log_type == ReplicaLog_Data) {
+ if (!specified_shard_id) {
+ cerr << "ERROR: shard-id must be specified for get operation" << std::endl;
+ return EINVAL;
+ }
+ RGWReplicaObjectLogger logger(store, pool_name, DATA_REPLICA_LOG_OBJ_PREFIX);
+ int ret = logger.update_bound(shard_id, daemon_id, marker, time, &entries);
+ if (ret < 0) {
+ cerr << "ERROR: failed to update bounds: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ } else if (replica_log_type == ReplicaLog_Bucket) {
+ if (bucket_name.empty()) {
+ cerr << "ERROR: bucket not specified" << std::endl;
+ return -EINVAL;
+ }
+ RGWBucketInfo bucket_info;
+ int ret = init_bucket(bucket_name, bucket_id, bucket_info, bucket);
+ if (ret < 0) {
+ cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+
+ RGWReplicaBucketLogger logger(store);
+ ret = logger.update_bound(bucket, shard_id, daemon_id, marker, time, &entries, replicalog_index_by_instance);
+ if (ret < 0) {
+ cerr << "ERROR: failed to update bounds: " << cpp_strerror(-ret) << std::endl;
+ return -ret;
+ }
+ }
+ }
+
bool quota_op = (opt_cmd == OPT_QUOTA_SET || opt_cmd == OPT_QUOTA_ENABLE || opt_cmd == OPT_QUOTA_DISABLE);
if (quota_op) {