Skip to content

Commit bc1c39b

Browse files
committed
address comments #2
1 parent 4270f5f commit bc1c39b

File tree

9 files changed

+60
-67
lines changed

9 files changed

+60
-67
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.iceberg;
21+
22+
import java.util.Map;
23+
24+
/**
25+
* An interface for locking, used to ensure commit isolation.
26+
*/
27+
public interface LockManager extends AutoCloseable {
28+
29+
/**
30+
* Try to acquire a lock
31+
* @param entityId ID of the entity to lock
32+
* @param ownerId ID of the owner if the lock
33+
* @return if the lock for the entity is acquired by the owner
34+
*/
35+
boolean acquire(String entityId, String ownerId);
36+
37+
/**
38+
* Release a lock
39+
*
40+
* exception must not be thrown for this method.
41+
*
42+
* @param entityId ID of the entity to lock
43+
* @param ownerId ID of the owner if the lock
44+
* @return if the owner held the lock and successfully released it.
45+
*/
46+
boolean release(String entityId, String ownerId);
47+
48+
/**
49+
* Initialize lock manager from catalog properties.
50+
* @param properties catalog properties
51+
*/
52+
void initialize(Map<String, String> properties);
53+
}

aws/src/main/java/org/apache/iceberg/aws/glue/GlueCatalog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
5050
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
5151
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
52-
import org.apache.iceberg.util.LockManager;
52+
import org.apache.iceberg.LockManager;
5353
import org.apache.iceberg.util.LockManagers;
5454
import org.slf4j.Logger;
5555
import org.slf4j.LoggerFactory;

aws/src/main/java/org/apache/iceberg/aws/glue/GlueTableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.apache.iceberg.io.FileIO;
3434
import org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting;
3535
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
36-
import org.apache.iceberg.util.LockManager;
36+
import org.apache.iceberg.LockManager;
3737
import org.slf4j.Logger;
3838
import org.slf4j.LoggerFactory;
3939
import software.amazon.awssdk.services.glue.GlueClient;

core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.apache.iceberg.BaseMetastoreCatalog;
4040
import org.apache.iceberg.CatalogProperties;
4141
import org.apache.iceberg.CatalogUtil;
42+
import org.apache.iceberg.LockManager;
4243
import org.apache.iceberg.Schema;
4344
import org.apache.iceberg.TableMetadata;
4445
import org.apache.iceberg.TableOperations;
@@ -57,7 +58,6 @@
5758
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
5859
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
5960
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
60-
import org.apache.iceberg.util.LockManager;
6161
import org.apache.iceberg.util.LockManagers;
6262
import org.slf4j.Logger;
6363
import org.slf4j.LoggerFactory;

core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.hadoop.fs.FileSystem;
3434
import org.apache.hadoop.fs.Path;
3535
import org.apache.iceberg.LocationProviders;
36+
import org.apache.iceberg.LockManager;
3637
import org.apache.iceberg.TableMetadata;
3738
import org.apache.iceberg.TableMetadataParser;
3839
import org.apache.iceberg.TableOperations;
@@ -46,7 +47,6 @@
4647
import org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting;
4748
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
4849
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
49-
import org.apache.iceberg.util.LockManager;
5050
import org.apache.iceberg.util.Pair;
5151
import org.apache.iceberg.util.Tasks;
5252
import org.slf4j.Logger;

core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.hadoop.fs.Path;
3030
import org.apache.iceberg.BaseTable;
3131
import org.apache.iceberg.CatalogUtil;
32+
import org.apache.iceberg.LockManager;
3233
import org.apache.iceberg.MetadataTableType;
3334
import org.apache.iceberg.MetadataTableUtils;
3435
import org.apache.iceberg.PartitionSpec;
@@ -48,7 +49,6 @@
4849
import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
4950
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
5051
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
51-
import org.apache.iceberg.util.LockManager;
5252
import org.apache.iceberg.util.LockManagers;
5353
import org.apache.iceberg.util.Pair;
5454
import org.slf4j.Logger;

core/src/main/java/org/apache/iceberg/util/LockManager.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

core/src/main/java/org/apache/iceberg/util/LockManagers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.ScheduledThreadPoolExecutor;
2727
import java.util.concurrent.TimeUnit;
2828
import org.apache.iceberg.CatalogProperties;
29+
import org.apache.iceberg.LockManager;
2930
import org.apache.iceberg.common.DynConstructors;
3031
import org.apache.iceberg.relocated.com.google.common.annotations.VisibleForTesting;
3132
import org.apache.iceberg.relocated.com.google.common.collect.Maps;

core/src/test/java/org/apache/iceberg/util/TestLockManagers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.util.Map;
2323
import org.apache.iceberg.CatalogProperties;
24+
import org.apache.iceberg.LockManager;
2425
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
2526
import org.assertj.core.api.Assertions;
2627
import org.junit.Test;

0 commit comments

Comments
 (0)