jerryshao commented on code in PR #11266: URL: https://github.com/apache/gravitino/pull/11266#discussion_r3322068994
########## iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/purge/IcebergPurgeJobMapper.java: ########## @@ -0,0 +1,84 @@ +/* + * 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.iceberg.service.purge; + +import java.util.List; +import org.apache.ibatis.annotations.DeleteProvider; +import org.apache.ibatis.annotations.InsertProvider; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; + +/** + * MyBatis mapper for the {@code iceberg_cleanup_job} table. SQL is supplied per backend by {@link + * IcebergPurgeJobSQLProviderFactory} and executed through the Gravitino entity store's shared + * {@code SqlSessionFactory}, so async purge reuses the relational backend's connection pool and + * multi-backend handling instead of opening its own JDBC connections. + */ +public interface IcebergPurgeJobMapper { + + String TABLE_NAME = "iceberg_cleanup_job"; + + @InsertProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "insertPurgeJob") + void insertPurgeJob(@Param("po") IcebergPurgeJobPO po); + + @SelectProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "selectRunnableJobIds") + List<Long> selectRunnableJobIds( + @Param("staleBefore") long staleBefore, @Param("window") int window); + + @UpdateProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "markRunning") + int markRunning( + @Param("id") long id, @Param("now") long now, @Param("staleBefore") long staleBefore); + + @SelectProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "selectById") + IcebergPurgeJobPO selectById(@Param("id") long id); + + @UpdateProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "markFinished") + int markFinished( + @Param("id") long id, + @Param("state") String state, + @Param("reason") String reason, + @Param("now") long now); + + @UpdateProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "recordFailure") + int recordFailure( + @Param("id") long id, + @Param("reason") String reason, + @Param("maxAttempts") int maxAttempts, + @Param("now") long now); + + @UpdateProvider(type = IcebergPurgeJobSQLProviderFactory.class, method = "heartbeat") + int heartbeat( + @Param("id") long id, @Param("lastWritten") long lastWritten, @Param("now") long now); Review Comment: `lastHearbeat`? -- 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]
