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


##########
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:
   The naming of these newly introduced public API types needs more 
consideration. `TableMaintenancePolicyFields` describes the serialized 
structure rather than its domain responsibility; it does not explain why 
`schedule`, `minIntervalMs`, and `jobOptions` form one abstraction. 
`TableMaintenanceSchedule` includes both a time-based cron expression and an 
event-based `onCommit` trigger, so “schedule” does not accurately describe all 
of its behavior. `TableMaintenancePolicyContentSupport` combines type mapping, 
extraction, and validation behind a generic `Support` suffix. 
`TableMaintenanceTaskType` also creates a second type system beside 
`Policy.BuiltInType` while using different vocabulary for the same operations. 
Since these names would become public API, their responsibilities and 
boundaries should be clarified before merging.



##########
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:
   `crontab` is ambiguous here: it can mean a crontab file, an entry, or a cron 
expression. The Javadoc calls it a Quartz-style expression, but the model does 
not define or validate the accepted grammar. Please make this API contract 
explicit before exposing the field.



##########
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:
   This makes the `PolicyManager` validation path a no-op: `maintenanceFields` 
always returns null, so no supported policy content can ever reach 
`fields.validate()`. It also means the `schedule` / `minIntervalMs` / 
`jobOptions` claimed by the PR cannot round-trip through concrete policy 
content. Could we either wire these fields end to end in this PR or remove the 
placeholder validation and public models until that wiring lands?



##########
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:
   Registering a public REST-creatable built-in policy whose content is 
explicitly a placeholder and whose trigger is always false leaves users able to 
create a valid policy that can never take effect. Could we expose this subtype 
only when its content semantics and runtime consumer are implemented?



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