pvary commented on code in PR #6451:
URL: https://github.com/apache/iceberg/pull/6451#discussion_r1062147705
##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:
##########
@@ -606,20 +630,13 @@ private StorageDescriptor storageDescriptor(TableMetadata
metadata, boolean hive
return storageDescriptor;
}
- @SuppressWarnings("ReverseDnsLookup")
@VisibleForTesting
- long acquireLock() throws UnknownHostException, TException,
InterruptedException {
- final LockComponent lockComponent =
- new LockComponent(LockType.EXCLUSIVE, LockLevel.TABLE, database);
- lockComponent.setTablename(tableName);
- final LockRequest lockRequest =
- new LockRequest(
- Lists.newArrayList(lockComponent),
- System.getProperty("user.name"),
- InetAddress.getLocalHost().getHostName());
- LockResponse lockResponse = metaClients.run(client ->
client.lock(lockRequest));
- AtomicReference<LockState> state = new
AtomicReference<>(lockResponse.getState());
- long lockId = lockResponse.getLockid();
+ long acquireLock(String agentInfo) throws UnknownHostException, TException,
InterruptedException {
+ AtomicReference<Long> lockId = new AtomicReference<>();
+ AtomicReference<LockState> state = new AtomicReference<>();
+
+ // This will set the lockId and state if successful
+ tryLock(agentInfo, lockId, state);
Review Comment:
I started with this solution, but changed that later. Let me check again if
I find the reason why I ended up using AtomicReferences again. Maybe this had
to do something with the lambda expressions.
I also prefer returning a LockInfo above using references
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]