Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.accumulo.core.fate.zookeeper;

import org.apache.accumulo.core.data.RowRange;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.dataImpl.KeyExtent;
import org.apache.hadoop.io.Text;
Expand Down Expand Up @@ -73,6 +74,13 @@ public static LockRange of(Text startRow, Text endRow) {
return new LockRange(startRow, endRow);
}

public static LockRange of(RowRange rowRange) {
if (rowRange == null) {
return infinite();
}
return of(rowRange.getLowerBound(), rowRange.getUpperBound());
}

public static LockRange infinite() {
return INF;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
import org.apache.accumulo.core.client.admin.TabletAvailability;
import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.RowRange;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.dataImpl.thrift.TRange;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
import org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock;
import org.apache.accumulo.core.fate.zookeeper.LockRange;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
Expand All @@ -48,10 +51,18 @@ public LockTable(TableId tableId, NamespaceId namespaceId, TRange range,

@Override
public long isReady(FateId fateId, Manager manager) throws Exception {
final Range range = new Range(tRange);
final RowRange rowRange = RowRange.range(
range.isInfiniteStartKey() ? null : range.getStartKey().getRow(),
range.isStartKeyInclusive(), range.isInfiniteStopKey() ? null : range.getEndKey().getRow(),
range.isEndKeyInclusive());
Comment on lines +57 to +58
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not anything for this PR but is a bit confusing that Range uses both "Stop Key" and "End Key" to mean the same thing

final LockRange lockRange = LockRange.of(rowRange);
Copy link
Member

@kevinrr888 kevinrr888 Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a RowRange object needed in this method? Seems like more info is computed than needed (inclusive start/end). Can just have
final LockRange lockRange = LockRange.of(range.isInfiniteStartKey() ? null : range.getStartKey().getRow(), range.isInfiniteStopKey() ? null : range.getEndKey().getRow())


return Utils.reserveNamespace(manager.getContext(), namespaceId, fateId,
DistributedReadWriteLock.LockType.READ, true, TableOperation.SET_TABLET_AVAILABILITY)
+ Utils.reserveTable(manager.getContext(), tableId, fateId,
DistributedReadWriteLock.LockType.WRITE, true, TableOperation.SET_TABLET_AVAILABILITY);
DistributedReadWriteLock.LockType.WRITE, true, TableOperation.SET_TABLET_AVAILABILITY,
lockRange);
}

@Override
Expand Down