singhpk234 commented on code in PR #10484: URL: https://github.com/apache/iceberg/pull/10484#discussion_r1707557043
########## flink/v1.19/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/TriggerLockFactory.java: ########## @@ -0,0 +1,63 @@ +/* + * 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.iceberg.flink.maintenance.operator; + +import java.io.Closeable; +import java.io.Serializable; +import org.apache.flink.annotation.Experimental; + +/** Lock interface for handling locks for the Flink Table Maintenance jobs. */ +@Experimental +public interface TriggerLockFactory extends Serializable, Closeable { + void open(); + + Lock createLock(); + + Lock createRecoveryLock(); + + interface Lock { + /** + * Tries to acquire a lock with a given key. Anyone already holding a lock would prevent + * acquiring this lock. Not reentrant. + * + * <p>Called by {@link TriggerManager}. Implementations could assume that are no concurrent + * calls for this method. + * + * @return <code>true</code> if the lock is acquired by this job, <code>false</code> if the lock + * is already held by someone + */ + boolean tryLock(); + + /** + * Checks if the lock is already taken. + * + * @return <code>true</code> if the lock is held by someone + */ + boolean isHeld(); + + // TODO: Fix the link to the LockRemover when we have a final name and implementation + /** + * Releases the lock. Should not fail if the lock is not held by anyone. + * + * <p>Called by LockRemover. Implementations could assume that are no concurrent calls for this + * method. + */ + void unlock(); + } Review Comment: Why are creating new interfaces rather than enhancing the existing ones ? https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/LockManager.java -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org