lasdf1234 commented on code in PR #13766:
URL: https://github.com/apache/gravitino/pull/13766#discussion_r4247456086


##########
api/src/main/java/org/apache/gravitino/maintenance/policy/TableMaintenancePolicyFields.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.maintenance.policy;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * Optional TMS scheduling and Spark / IRC client options shared by the four 
built-in table
+ * maintenance tasks ({@link TableMaintenanceTaskType}).
+ *
+ * <p>This is a value object for shared JSON fields, not a separate policy 
type. Attaching it onto
+ * each built-in {@code PolicyContent} implementation is a separate change.
+ */
+public final class TableMaintenancePolicyFields {

Review Comment:
   Agree. This PR has dropped those unwired public types so they are no longer 
part of the public API here.
   
   Follow-up work renames/clarifies responsibilities along the lines you 
suggested: `MaintenanceTrigger` (onCommit + cron), flat peer fields on 
`TableMaintenanceContent` (no `*Fields` bag), `TableMaintenancePolicies` for 
type mapping + external validation, and `TableMaintenanceTaskType` only as a 
BuiltInType → scheduler mapping with a clear boundary vs `Policy.BuiltInType`.



##########
api/src/main/java/org/apache/gravitino/maintenance/policy/TableMaintenanceSchedule.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.maintenance.policy;
+
+import com.google.common.base.Preconditions;
+import java.util.Map;
+import java.util.Objects;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.StringUtils;
+
+/** Evaluate triggers for TMS ({@code onCommit} and/or {@code crontab}). */
+public final class TableMaintenanceSchedule {
+
+  private final boolean onCommit;
+  @Nullable private final String crontab;

Review Comment:
   Agree. That field is no longer in this PR.
   
   In the follow-up we will rename it to `cronExpression`, document the 
accepted Quartz 6/7-field grammar in Javadoc, and reject invalid expressions in 
external validation.



##########
api/src/main/java/org/apache/gravitino/maintenance/policy/TableMaintenancePolicyContentSupport.java:
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.maintenance.policy;
+
+import javax.annotation.Nullable;
+import org.apache.gravitino.policy.Policy;
+import org.apache.gravitino.policy.PolicyContent;
+
+/**
+ * Maps built-in policy types to TMS task kinds.
+ *
+ * <p>Extracting {@link TableMaintenancePolicyFields} from concrete policy 
content is deferred until
+ * those fields are attached to the four built-in content classes.
+ */
+public final class TableMaintenancePolicyContentSupport {
+
+  private TableMaintenancePolicyContentSupport() {}
+
+  /**
+   * Returns the maintenance task type for a built-in policy, if any.
+   *
+   * @param policyType built-in policy type
+   * @return task type or {@code null}
+   */
+  @Nullable
+  public static TableMaintenanceTaskType taskTypeFor(Policy.BuiltInType 
policyType) {
+    if (policyType == null) {
+      return null;
+    }
+    return 
TableMaintenanceTaskType.fromPolicyTypeString(policyType.policyType());
+  }
+
+  /**
+   * Extracts TMS fields from policy content when present.
+   *
+   * <p>Currently always returns {@code null}; content classes do not carry 
TMS fields yet.
+   *
+   * @param content policy content
+   * @return TMS fields or {@code null}
+   */
+  @Nullable
+  public static TableMaintenancePolicyFields maintenanceFields(PolicyContent 
content) {
+    return null;

Review Comment:
   Agree — that path was a no-op.
   
   We chose to remove the unwired public models from this PR rather than ship 
placeholder validation. End-to-end wiring (attach peers onto the four contents, 
PolicyManager validation, and DTO/REST round-trip) is in the follow-up.



##########
api/src/main/java/org/apache/gravitino/policy/IcebergRewriteManifestsContent.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.policy;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.gravitino.MetadataObject;
+
+/**
+ * Placeholder built-in policy content for Iceberg manifest rewrite.
+ *
+ * <p>Configurable thresholds will be added when the rewrite-manifests policy 
lands; this class
+ * registers the built-in type for TMS task mapping.
+ */
+public class IcebergRewriteManifestsContent implements PolicyContent {

Review Comment:
   Keeping these as REST-creatable BuiltInTypes for now is intentional (Option 
A): TMS needs all four policy types registered for task mapping. The 
placeholder content uses `trigger-expr=false`, so created policies do not 
auto-trigger until real thresholds / consumers land.
   
   If you prefer hiding them from create until semantics are ready, we can 
revisit that in a follow-up.



-- 
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]

Reply via email to