gavinchou commented on code in PR #55612:
URL: https://github.com/apache/doris/pull/55612#discussion_r2319467241
##########
cloud/src/meta-service/meta_service_resource.cpp:
##########
@@ -1961,6 +2049,69 @@ void
MetaServiceImpl::alter_instance(google::protobuf::RpcController* controller
return std::make_pair(MetaServiceCode::OK, ret);
});
} break;
+ /**
+ * Handle SET_SNAPSHOT_PROPERTY operation - configures snapshot-related
properties for an instance.
+ *
+ * Supported property keys and their expected values:
+ * - "enabled": "true" | "false"
+ * Controls whether snapshot functionality is enabled for the instance
+ *
+ * - "max_reserved_snapshots": numeric string (0-35)
+ * Sets the maximum number of snapshots to retain for the instance
+ *
+ * - "snapshot_intervals": numeric string (60-max)
+ * Sets the snapshot creation interval in seconds (minimum 60s)
+ *
+ * Each property is validated by its respective handler function which
ensures
+ * the provided values conform to the expected format and constraints.
+ */
+ case AlterInstanceRequest::SET_SNAPSHOT_PROPERTY: {
+ ret = alter_instance(request, [&request](InstanceInfoPB* instance) {
+ std::string msg;
+ auto properties = request->properties();
+ if (properties.empty()) {
+ msg = "propertiy is empty, instance_id = " +
request->instance_id();
+ LOG(WARNING) << msg;
+ return std::make_pair(MetaServiceCode::INVALID_ARGUMENT, msg);
+ }
+ for (const auto& property : properties) {
+ std::string key = property.first;
+ std::string value = property.second;
+
+ std::pair<MetaServiceCode, std::string> result;
+
+ if (key == "enabled") {
+ result = handle_snapshot_switch(request->instance_id(),
key, value, instance);
+ } else if (key == "max_reserved_snapshots") {
+ result =
handle_max_reserved_snapshots(request->instance_id(), key, value,
+ instance);
+ } else if (key == "snapshot_intervals") {
+ result =
+ handle_snapshot_intervals(request->instance_id(),
key, value, instance);
+ } else {
+ msg = "unsupported property: " + key;
+ LOG(WARNING) << msg;
+ return std::make_pair(MetaServiceCode::INVALID_ARGUMENT,
msg);
+ }
+
+ if (result.first != MetaServiceCode::OK) {
Review Comment:
不管 结果如何 都把日志打出来
##########
cloud/src/meta-service/meta_service_resource.cpp:
##########
@@ -1961,6 +2049,69 @@ void
MetaServiceImpl::alter_instance(google::protobuf::RpcController* controller
return std::make_pair(MetaServiceCode::OK, ret);
});
} break;
+ /**
+ * Handle SET_SNAPSHOT_PROPERTY operation - configures snapshot-related
properties for an instance.
+ *
+ * Supported property keys and their expected values:
+ * - "enabled": "true" | "false"
+ * Controls whether snapshot functionality is enabled for the instance
+ *
+ * - "max_reserved_snapshots": numeric string (0-35)
+ * Sets the maximum number of snapshots to retain for the instance
+ *
+ * - "snapshot_intervals": numeric string (60-max)
+ * Sets the snapshot creation interval in seconds (minimum 60s)
+ *
+ * Each property is validated by its respective handler function which
ensures
+ * the provided values conform to the expected format and constraints.
+ */
+ case AlterInstanceRequest::SET_SNAPSHOT_PROPERTY: {
+ ret = alter_instance(request, [&request](InstanceInfoPB* instance) {
+ std::string msg;
+ auto properties = request->properties();
+ if (properties.empty()) {
+ msg = "propertiy is empty, instance_id = " +
request->instance_id();
+ LOG(WARNING) << msg;
+ return std::make_pair(MetaServiceCode::INVALID_ARGUMENT, msg);
+ }
+ for (const auto& property : properties) {
+ std::string key = property.first;
+ std::string value = property.second;
+
+ std::pair<MetaServiceCode, std::string> result;
+
+ if (key == "enabled") {
+ result = handle_snapshot_switch(request->instance_id(),
key, value, instance);
+ } else if (key == "max_reserved_snapshots") {
+ result =
handle_max_reserved_snapshots(request->instance_id(), key, value,
+ instance);
+ } else if (key == "snapshot_intervals") {
+ result =
+ handle_snapshot_intervals(request->instance_id(),
key, value, instance);
+ } else {
+ msg = "unsupported property: " + key;
+ LOG(WARNING) << msg;
+ return std::make_pair(MetaServiceCode::INVALID_ARGUMENT,
msg);
+ }
+
+ if (result.first != MetaServiceCode::OK) {
Review Comment:
不管 结果如何 都把日志 result 的msg 打出来
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]