This is an automated email from the ASF dual-hosted git repository.
cshannon pushed a commit to branch elasticity
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push:
new c720dd4e6d Replace boolean with enum for table locks in Elasticity
(#4298)
c720dd4e6d is described below
commit c720dd4e6d865ea8b7d5d8624c29a488a3abcfa2
Author: Christopher L. Shannon <[email protected]>
AuthorDate: Mon Feb 26 13:28:19 2024 -0500
Replace boolean with enum for table locks in Elasticity (#4298)
Instead of using a boolean value for obtaining table locks, use an enum
which makes the code more readable and makes it easier to search and
catch errors with the lock type.
This closes #4276
---
.../fate/zookeeper/DistributedReadWriteLock.java | 2 +-
.../manager/tableOps/ChangeTableState.java | 13 +++---
.../apache/accumulo/manager/tableOps/Utils.java | 53 +++++++++++-----------
.../availability/SetTabletAvailability.java | 13 +++---
.../manager/tableOps/clone/CloneTable.java | 11 +++--
.../manager/tableOps/clone/CloneZookeeper.java | 9 ++--
.../manager/tableOps/clone/FinishCloneTable.java | 9 ++--
.../manager/tableOps/compact/CompactRange.java | 10 ++--
.../tableOps/compact/cancel/CancelCompactions.java | 10 ++--
.../compact/cancel/FinishCancelCompaction.java | 5 +-
.../manager/tableOps/create/CreateTable.java | 7 +--
.../manager/tableOps/create/FinishCreateTable.java | 5 +-
.../manager/tableOps/create/PopulateZookeeper.java | 5 +-
.../accumulo/manager/tableOps/delete/CleanUp.java | 5 +-
.../manager/tableOps/delete/DeleteTable.java | 10 ++--
.../manager/tableOps/delete/PreDeleteTable.java | 14 +++---
.../manager/tableOps/merge/FinishTableRangeOp.java | 5 +-
.../manager/tableOps/merge/TableRangeOp.java | 10 ++--
.../namespace/create/FinishCreateNamespace.java | 3 +-
.../create/PopulateZookeeperWithNamespace.java | 7 +--
.../tableOps/namespace/delete/DeleteNamespace.java | 5 +-
.../namespace/delete/NamespaceCleanUp.java | 3 +-
.../tableOps/namespace/rename/RenameNamespace.java | 7 +--
.../manager/tableOps/rename/RenameTable.java | 14 +++---
.../tableOps/tableExport/WriteExportFiles.java | 15 +++---
.../tableOps/tableImport/FinishImportTable.java | 5 +-
.../tableImport/ImportPopulateZookeeper.java | 5 +-
.../manager/tableOps/tableImport/ImportTable.java | 7 +--
28 files changed, 150 insertions(+), 117 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java
index 84b3c1148c..0bf4af19c7 100644
---
a/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java
+++
b/core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java
@@ -40,7 +40,7 @@ import org.slf4j.LoggerFactory;
*/
public class DistributedReadWriteLock implements
java.util.concurrent.locks.ReadWriteLock {
- public static enum LockType {
+ public enum LockType {
READ, WRITE,
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/ChangeTableState.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/ChangeTableState.java
index 17fb9b40c0..378f72460d 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/ChangeTableState.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/ChangeTableState.java
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
import org.slf4j.LoggerFactory;
@@ -53,8 +54,8 @@ public class ChangeTableState extends ManagerRepo {
public long isReady(FateId fateId, Manager env) throws Exception {
// reserve the table so that this op does not run concurrently with
create, clone, or delete
// table
- return Utils.reserveNamespace(env, namespaceId, fateId, false, true, top)
- + Utils.reserveTable(env, tableId, fateId, true, true, top);
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
true, top)
+ + Utils.reserveTable(env, tableId, fateId, LockType.WRITE, true, top);
}
@Override
@@ -65,8 +66,8 @@ public class ChangeTableState extends ManagerRepo {
}
env.getTableManager().transitionTableState(tableId, ts,
expectedCurrStates);
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
- Utils.unreserveTable(env, tableId, fateId, true);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(env, tableId, fateId, LockType.WRITE);
LoggerFactory.getLogger(ChangeTableState.class).debug("Changed table state
{} {}", tableId, ts);
env.getEventCoordinator().event(tableId, "Set table state of %s to %s",
tableId, ts);
return null;
@@ -74,7 +75,7 @@ public class ChangeTableState extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
- Utils.unreserveTable(env, tableId, fateId, true);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(env, tableId, fateId, LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java
index dce71c231d..069939608e 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/Utils.java
@@ -89,9 +89,9 @@ public class Utils {
static final Lock tableNameLock = new ReentrantLock();
static final Lock idLock = new ReentrantLock();
- public static long reserveTable(Manager env, TableId tableId, FateId fateId,
boolean writeLock,
+ public static long reserveTable(Manager env, TableId tableId, FateId fateId,
LockType lockType,
boolean tableMustExist, TableOperation op) throws Exception {
- if (getLock(env.getContext(), tableId, fateId, writeLock).tryLock()) {
+ if (getLock(env.getContext(), tableId, fateId, lockType).tryLock()) {
if (tableMustExist) {
ZooReaderWriter zk = env.getContext().getZooReaderWriter();
if (!zk.exists(env.getContext().getZooKeeperRoot() + Constants.ZTABLES
+ "/" + tableId)) {
@@ -99,8 +99,7 @@ public class Utils {
TableOperationExceptionType.NOTFOUND, "Table does not exist");
}
}
- log.info("table {} {} locked for {} operation: {}", tableId, fateId,
- (writeLock ? "write" : "read"), op);
+ log.info("table {} {} locked for {} operation: {}", tableId, fateId,
lockType, op);
return 0;
} else {
return 100;
@@ -108,21 +107,20 @@ public class Utils {
}
public static void unreserveTable(Manager env, TableId tableId, FateId
fateId,
- boolean writeLock) {
- getLock(env.getContext(), tableId, fateId, writeLock).unlock();
- log.info("table {} {} unlocked for {}", tableId, fateId, (writeLock ?
"write" : "read"));
+ LockType lockType) {
+ getLock(env.getContext(), tableId, fateId, lockType).unlock();
+ log.info("table {} {} unlocked for {}", tableId, fateId, lockType);
}
public static void unreserveNamespace(Manager env, NamespaceId namespaceId,
FateId fateId,
- boolean writeLock) {
- getLock(env.getContext(), namespaceId, fateId, writeLock).unlock();
- log.info("namespace {} {} unlocked for {}", namespaceId, fateId,
- (writeLock ? "write" : "read"));
+ LockType lockType) {
+ getLock(env.getContext(), namespaceId, fateId, lockType).unlock();
+ log.info("namespace {} {} unlocked for {}", namespaceId, fateId, lockType);
}
public static long reserveNamespace(Manager env, NamespaceId namespaceId,
FateId fateId,
- boolean writeLock, boolean mustExist, TableOperation op) throws
Exception {
- if (getLock(env.getContext(), namespaceId, fateId, writeLock).tryLock()) {
+ LockType lockType, boolean mustExist, TableOperation op) throws
Exception {
+ if (getLock(env.getContext(), namespaceId, fateId, lockType).tryLock()) {
if (mustExist) {
ZooReaderWriter zk = env.getContext().getZooReaderWriter();
if (!zk.exists(
@@ -131,8 +129,7 @@ public class Utils {
TableOperationExceptionType.NAMESPACE_NOTFOUND, "Namespace does
not exist");
}
}
- log.info("namespace {} {} locked for {} operation: {}", namespaceId,
fateId,
- (writeLock ? "write" : "read"), op);
+ log.info("namespace {} {} locked for {} operation: {}", namespaceId,
fateId, lockType, op);
return 0;
} else {
return 100;
@@ -161,7 +158,7 @@ public class Utils {
}
private static Lock getLock(ServerContext context, AbstractId<?> id, FateId
fateId,
- boolean writeLock) {
+ LockType lockType) {
byte[] lockData = fateId.canonical().getBytes(UTF_8);
var fLockPath =
FateLock.path(context.getZooKeeperRoot() + Constants.ZTABLE_LOCKS +
"/" + id.canonical());
@@ -170,18 +167,22 @@ public class Utils {
if (lock != null) {
// Validate the recovered lock type
- boolean isWriteLock = lock.getType() == LockType.WRITE;
- if (writeLock != isWriteLock) {
- throw new IllegalStateException("Unexpected lock type " +
lock.getType()
- + " recovered for transaction " + fateId + " on object " + id + ".
Expected "
- + (writeLock ? LockType.WRITE : LockType.READ) + " lock instead.");
+ if (lock.getType() != lockType) {
+ throw new IllegalStateException(
+ "Unexpected lock type " + lock.getType() + " recovered for
transaction " + fateId
+ + " on object " + id + ". Expected " + lockType + " lock
instead.");
}
} else {
DistributedReadWriteLock locker = new DistributedReadWriteLock(qlock,
lockData);
- if (writeLock) {
- lock = locker.writeLock();
- } else {
- lock = locker.readLock();
+ switch (lockType) {
+ case WRITE:
+ lock = locker.writeLock();
+ break;
+ case READ:
+ lock = locker.readLock();
+ break;
+ default:
+ throw new IllegalStateException("Unexpected LockType: " + lockType);
}
}
return lock;
@@ -196,7 +197,7 @@ public class Utils {
}
public static Lock getReadLock(Manager env, AbstractId<?> id, FateId fateId)
{
- return Utils.getLock(env.getContext(), id, fateId, false);
+ return Utils.getLock(env.getContext(), id, fateId, LockType.READ);
}
public static void checkNamespaceDoesNotExist(ServerContext context, String
namespace,
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/availability/SetTabletAvailability.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/availability/SetTabletAvailability.java
index 30cfeb9d8d..6397ccb1e7 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/availability/SetTabletAvailability.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/availability/SetTabletAvailability.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.dataImpl.KeyExtent;
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.LockType;
import org.apache.accumulo.core.metadata.schema.Ample.TabletsMutator;
import org.apache.accumulo.core.metadata.schema.TabletMetadata;
import org.apache.accumulo.core.metadata.schema.TabletsMetadata;
@@ -59,9 +60,9 @@ public class SetTabletAvailability extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager manager) throws Exception {
- return Utils.reserveNamespace(manager, namespaceId, fateId, false, true,
+ return Utils.reserveNamespace(manager, namespaceId, fateId, LockType.READ,
true,
TableOperation.SET_TABLET_AVAILABILITY)
- + Utils.reserveTable(manager, tableId, fateId, true, true,
+ + Utils.reserveTable(manager, tableId, fateId, LockType.WRITE, true,
TableOperation.SET_TABLET_AVAILABILITY);
}
@@ -116,15 +117,15 @@ public class SetTabletAvailability extends ManagerRepo {
mutator.mutateTablet(tabletExtent).putTabletAvailability(tabletAvailability).mutate();
}
}
- Utils.unreserveNamespace(manager, namespaceId, fateId, false);
- Utils.unreserveTable(manager, tableId, fateId, true);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(manager, tableId, fateId, LockType.WRITE);
return null;
}
@Override
public void undo(FateId fateId, Manager manager) throws Exception {
- Utils.unreserveNamespace(manager, namespaceId, fateId, false);
- Utils.unreserveTable(manager, tableId, fateId, true);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(manager, tableId, fateId, LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneTable.java
index d7bad0955c..b0c6bb6262 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneTable.java
@@ -26,6 +26,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -49,9 +50,9 @@ public class CloneTable extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- long val = Utils.reserveNamespace(environment, cloneInfo.srcNamespaceId,
fateId, false, true,
- TableOperation.CLONE);
- val += Utils.reserveTable(environment, cloneInfo.srcTableId, fateId,
false, true,
+ long val = Utils.reserveNamespace(environment, cloneInfo.srcNamespaceId,
fateId, LockType.READ,
+ true, TableOperation.CLONE);
+ val += Utils.reserveTable(environment, cloneInfo.srcTableId, fateId,
LockType.READ, true,
TableOperation.CLONE);
return val;
}
@@ -72,8 +73,8 @@ public class CloneTable extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager environment) {
- Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, fateId,
false);
- Utils.unreserveTable(environment, cloneInfo.srcTableId, fateId, false);
+ Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, fateId,
LockType.READ);
+ Utils.unreserveTable(environment, cloneInfo.srcTableId, fateId,
LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneZookeeper.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneZookeeper.java
index 9ce4e76243..a2682ab67b 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneZookeeper.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/CloneZookeeper.java
@@ -24,6 +24,7 @@ import org.apache.accumulo.core.clientImpl.Namespaces;
import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.util.tables.TableNameUtil;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -46,10 +47,10 @@ class CloneZookeeper extends ManagerRepo {
public long isReady(FateId fateId, Manager environment) throws Exception {
long val = 0;
if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) {
- val += Utils.reserveNamespace(environment, cloneInfo.namespaceId,
fateId, false, true,
+ val += Utils.reserveNamespace(environment, cloneInfo.namespaceId,
fateId, LockType.READ, true,
TableOperation.CLONE);
}
- val += Utils.reserveTable(environment, cloneInfo.tableId, fateId, true,
false,
+ val += Utils.reserveTable(environment, cloneInfo.tableId, fateId,
LockType.WRITE, false,
TableOperation.CLONE);
return val;
}
@@ -78,9 +79,9 @@ class CloneZookeeper extends ManagerRepo {
public void undo(FateId fateId, Manager environment) throws Exception {
environment.getTableManager().removeTable(cloneInfo.tableId);
if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) {
- Utils.unreserveNamespace(environment, cloneInfo.namespaceId, fateId,
false);
+ Utils.unreserveNamespace(environment, cloneInfo.namespaceId, fateId,
LockType.READ);
}
- Utils.unreserveTable(environment, cloneInfo.tableId, fateId, true);
+ Utils.unreserveTable(environment, cloneInfo.tableId, fateId,
LockType.WRITE);
environment.getContext().clearTableListCache();
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/FinishCloneTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/FinishCloneTable.java
index fc3b4706cf..8dff1c78f1 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/FinishCloneTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/clone/FinishCloneTable.java
@@ -22,6 +22,7 @@ import java.util.EnumSet;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -60,12 +61,12 @@ class FinishCloneTable extends ManagerRepo {
environment.getTableManager().transitionTableState(cloneInfo.tableId,
ts, expectedCurrStates);
}
- Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, fateId,
false);
+ Utils.unreserveNamespace(environment, cloneInfo.srcNamespaceId, fateId,
LockType.READ);
if (!cloneInfo.srcNamespaceId.equals(cloneInfo.namespaceId)) {
- Utils.unreserveNamespace(environment, cloneInfo.namespaceId, fateId,
false);
+ Utils.unreserveNamespace(environment, cloneInfo.namespaceId, fateId,
LockType.READ);
}
- Utils.unreserveTable(environment, cloneInfo.srcTableId, fateId, false);
- Utils.unreserveTable(environment, cloneInfo.tableId, fateId, true);
+ Utils.unreserveTable(environment, cloneInfo.srcTableId, fateId,
LockType.READ);
+ Utils.unreserveTable(environment, cloneInfo.tableId, fateId,
LockType.WRITE);
environment.getEventCoordinator().event(cloneInfo.tableId, "Cloned table
%s from %s",
cloneInfo.tableName, cloneInfo.srcTableId);
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactRange.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactRange.java
index 0a813e5014..279010bdcc 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactRange.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/CompactRange.java
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.util.TextUtil;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -74,8 +75,9 @@ public class CompactRange extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, namespaceId, fateId, false, true,
TableOperation.COMPACT)
- + Utils.reserveTable(env, tableId, fateId, false, true,
TableOperation.COMPACT);
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
true,
+ TableOperation.COMPACT)
+ + Utils.reserveTable(env, tableId, fateId, LockType.READ, true,
TableOperation.COMPACT);
}
@Override
@@ -89,8 +91,8 @@ public class CompactRange extends ManagerRepo {
try {
CompactionConfigStorage.deleteConfig(env.getContext(), fateId);
} finally {
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
- Utils.unreserveTable(env, tableId, fateId, false);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(env, tableId, fateId, LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
index 4899fec8a5..9868ce94bc 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/CancelCompactions.java
@@ -23,6 +23,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -45,9 +46,10 @@ public class CancelCompactions extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, namespaceId, fateId, false, true,
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
true,
TableOperation.COMPACT_CANCEL)
- + Utils.reserveTable(env, tableId, fateId, false, true,
TableOperation.COMPACT_CANCEL);
+ + Utils.reserveTable(env, tableId, fateId, LockType.READ, true,
+ TableOperation.COMPACT_CANCEL);
}
@Override
@@ -64,8 +66,8 @@ public class CancelCompactions extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveTable(env, tableId, fateId, false);
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
+ Utils.unreserveTable(env, tableId, fateId, LockType.READ);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/FinishCancelCompaction.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/FinishCancelCompaction.java
index 3b25add6ae..fab9e487fb 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/FinishCancelCompaction.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/compact/cancel/FinishCancelCompaction.java
@@ -22,6 +22,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -38,8 +39,8 @@ class FinishCancelCompaction extends ManagerRepo {
@Override
public Repo<Manager> call(FateId fateId, Manager environment) {
- Utils.unreserveTable(environment, tableId, fateId, false);
- Utils.unreserveNamespace(environment, namespaceId, fateId, false);
+ Utils.unreserveTable(environment, tableId, fateId, LockType.READ);
+ Utils.unreserveNamespace(environment, namespaceId, fateId, LockType.READ);
return null;
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/CreateTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/CreateTable.java
index 6d13d40f68..3f5a379c8a 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/CreateTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/CreateTable.java
@@ -29,6 +29,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.TableInfo;
@@ -63,8 +64,8 @@ public class CreateTable extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
// reserve the table's namespace to make sure it doesn't change while the
table is created
- return Utils.reserveNamespace(environment, tableInfo.getNamespaceId(),
fateId, false, true,
- TableOperation.CREATE);
+ return Utils.reserveNamespace(environment, tableInfo.getNamespaceId(),
fateId, LockType.READ,
+ true, TableOperation.CREATE);
}
@Override
@@ -98,7 +99,7 @@ public class CreateTable extends ManagerRepo {
} catch (IOException e) {
log.error("Table failed to be created and failed to clean up split files
at {}", p, e);
} finally {
- Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), fateId, false);
+ Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), fateId,
LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/FinishCreateTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/FinishCreateTable.java
index f0bff38e5f..2ba7e03a36 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/FinishCreateTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/FinishCreateTable.java
@@ -24,6 +24,7 @@ import java.util.EnumSet;
import org.apache.accumulo.core.client.admin.InitialTableState;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -62,8 +63,8 @@ class FinishCreateTable extends ManagerRepo {
TableState.ONLINE, expectedCurrStates);
}
- Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), fateId, false);
- Utils.unreserveTable(env, tableInfo.getTableId(), fateId, true);
+ Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), fateId,
LockType.READ);
+ Utils.unreserveTable(env, tableInfo.getTableId(), fateId, LockType.WRITE);
env.getEventCoordinator().event(tableInfo.getTableId(), "Created table %s
",
tableInfo.getTableName());
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/PopulateZookeeper.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/PopulateZookeeper.java
index a9a0048817..6e0884f76b 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/PopulateZookeeper.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/create/PopulateZookeeper.java
@@ -23,6 +23,7 @@ import
org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType;
import
org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.TableInfo;
@@ -42,7 +43,7 @@ class PopulateZookeeper extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- return Utils.reserveTable(environment, tableInfo.getTableId(), fateId,
true, false,
+ return Utils.reserveTable(environment, tableInfo.getTableId(), fateId,
LockType.WRITE, false,
TableOperation.CREATE);
}
@@ -80,7 +81,7 @@ class PopulateZookeeper extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager manager) throws Exception {
manager.getTableManager().removeTable(tableInfo.getTableId());
- Utils.unreserveTable(manager, tableInfo.getTableId(), fateId, true);
+ Utils.unreserveTable(manager, tableInfo.getTableId(), fateId,
LockType.WRITE);
manager.getContext().clearTableListCache();
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
index be197d7519..9d8d2b86f6 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/CleanUp.java
@@ -34,6 +34,7 @@ import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.iterators.user.GrepIterator;
import org.apache.accumulo.core.metadata.AccumuloTable;
import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection;
@@ -178,8 +179,8 @@ class CleanUp extends ManagerRepo {
log.error("{}", e.getMessage(), e);
}
- Utils.unreserveTable(manager, tableId, fateId, true);
- Utils.unreserveNamespace(manager, namespaceId, fateId, false);
+ Utils.unreserveTable(manager, tableId, fateId, LockType.WRITE);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.READ);
LoggerFactory.getLogger(CleanUp.class).debug("Deleted table " + tableId);
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
index e7006d56b0..1ad900ca16 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/DeleteTable.java
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -44,8 +45,9 @@ public class DeleteTable extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, namespaceId, fateId, false, false,
TableOperation.DELETE)
- + Utils.reserveTable(env, tableId, fateId, true, true,
TableOperation.DELETE);
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
false,
+ TableOperation.DELETE)
+ + Utils.reserveTable(env, tableId, fateId, LockType.WRITE, true,
TableOperation.DELETE);
}
@Override
@@ -59,7 +61,7 @@ public class DeleteTable extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveTable(env, tableId, fateId, true);
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
+ Utils.unreserveTable(env, tableId, fateId, LockType.WRITE);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
index be7cef2ee6..196e898c09 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/delete/PreDeleteTable.java
@@ -25,6 +25,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.manager.Manager;
@@ -52,8 +53,9 @@ public class PreDeleteTable extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, namespaceId, fateId, false, true,
TableOperation.DELETE)
- + Utils.reserveTable(env, tableId, fateId, false, true,
TableOperation.DELETE);
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
true,
+ TableOperation.DELETE)
+ + Utils.reserveTable(env, tableId, fateId, LockType.READ, true,
TableOperation.DELETE);
}
private void preventFutureCompactions(Manager environment)
@@ -77,15 +79,15 @@ public class PreDeleteTable extends ManagerRepo {
}
return new DeleteTable(namespaceId, tableId);
} finally {
- Utils.unreserveTable(environment, tableId, fateId, false);
- Utils.unreserveNamespace(environment, namespaceId, fateId, false);
+ Utils.unreserveTable(environment, tableId, fateId, LockType.READ);
+ Utils.unreserveNamespace(environment, namespaceId, fateId,
LockType.READ);
}
}
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveTable(env, tableId, fateId, false);
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
+ Utils.unreserveTable(env, tableId, fateId, LockType.READ);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/FinishTableRangeOp.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/FinishTableRangeOp.java
index 65cefef1ab..96cd61e20d 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/FinishTableRangeOp.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/FinishTableRangeOp.java
@@ -28,6 +28,7 @@ import java.util.function.Consumer;
import org.apache.accumulo.core.dataImpl.KeyExtent;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.metadata.schema.Ample;
import org.apache.accumulo.core.metadata.schema.TabletOperationId;
import org.apache.accumulo.core.metadata.schema.TabletOperationType;
@@ -54,8 +55,8 @@ class FinishTableRangeOp extends ManagerRepo {
public Repo<Manager> call(FateId fateId, Manager manager) throws Exception {
removeOperationIds(log, data, fateId, manager);
- Utils.unreserveTable(manager, data.tableId, fateId, true);
- Utils.unreserveNamespace(manager, data.namespaceId, fateId, false);
+ Utils.unreserveTable(manager, data.tableId, fateId, LockType.WRITE);
+ Utils.unreserveNamespace(manager, data.namespaceId, fateId, LockType.READ);
return null;
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/TableRangeOp.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/TableRangeOp.java
index 2165629244..ddbbce5b7e 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/TableRangeOp.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/merge/TableRangeOp.java
@@ -23,6 +23,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.metadata.AccumuloTable;
import org.apache.accumulo.core.util.TextUtil;
import org.apache.accumulo.manager.Manager;
@@ -41,8 +42,9 @@ public class TableRangeOp extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, data.namespaceId, fateId, false, true,
TableOperation.MERGE)
- + Utils.reserveTable(env, data.tableId, fateId, true, true,
TableOperation.MERGE);
+ return Utils.reserveNamespace(env, data.namespaceId, fateId,
LockType.READ, true,
+ TableOperation.MERGE)
+ + Utils.reserveTable(env, data.tableId, fateId, LockType.WRITE, true,
TableOperation.MERGE);
}
public TableRangeOp(MergeInfo.Operation op, NamespaceId namespaceId, TableId
tableId,
@@ -70,7 +72,7 @@ public class TableRangeOp extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) throws Exception {
- Utils.unreserveNamespace(env, data.namespaceId, fateId, false);
- Utils.unreserveTable(env, data.tableId, fateId, true);
+ Utils.unreserveNamespace(env, data.namespaceId, fateId, LockType.READ);
+ Utils.unreserveTable(env, data.tableId, fateId, LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/FinishCreateNamespace.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/FinishCreateNamespace.java
index e22e1f30c3..95d1419706 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/FinishCreateNamespace.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/FinishCreateNamespace.java
@@ -20,6 +20,7 @@ package org.apache.accumulo.manager.tableOps.namespace.create;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -43,7 +44,7 @@ class FinishCreateNamespace extends ManagerRepo {
@Override
public Repo<Manager> call(FateId fateId, Manager env) {
- Utils.unreserveNamespace(env, namespaceInfo.namespaceId, fateId, true);
+ Utils.unreserveNamespace(env, namespaceInfo.namespaceId, fateId,
LockType.WRITE);
env.getEventCoordinator().event("Created namespace %s ",
namespaceInfo.namespaceName);
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/PopulateZookeeperWithNamespace.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/PopulateZookeeperWithNamespace.java
index 58fd48b958..af77b469e5 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/PopulateZookeeperWithNamespace.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/create/PopulateZookeeperWithNamespace.java
@@ -21,6 +21,7 @@ package org.apache.accumulo.manager.tableOps.namespace.create;
import org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -41,8 +42,8 @@ class PopulateZookeeperWithNamespace extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- return Utils.reserveNamespace(environment, namespaceInfo.namespaceId,
fateId, true, false,
- TableOperation.CREATE);
+ return Utils.reserveNamespace(environment, namespaceInfo.namespaceId,
fateId, LockType.WRITE,
+ false, TableOperation.CREATE);
}
@Override
@@ -72,7 +73,7 @@ class PopulateZookeeperWithNamespace extends ManagerRepo {
public void undo(FateId fateId, Manager manager) throws Exception {
manager.getTableManager().removeNamespace(namespaceInfo.namespaceId);
manager.getContext().clearTableListCache();
- Utils.unreserveNamespace(manager, namespaceInfo.namespaceId, fateId, true);
+ Utils.unreserveNamespace(manager, namespaceInfo.namespaceId, fateId,
LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/DeleteNamespace.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/DeleteNamespace.java
index 4f2c5a5119..44dc9a950c 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/DeleteNamespace.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/DeleteNamespace.java
@@ -22,6 +22,7 @@ import
org.apache.accumulo.core.clientImpl.thrift.TableOperation;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -38,7 +39,7 @@ public class DeleteNamespace extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- return Utils.reserveNamespace(environment, namespaceId, fateId, true, true,
+ return Utils.reserveNamespace(environment, namespaceId, fateId,
LockType.WRITE, true,
TableOperation.DELETE);
}
@@ -50,7 +51,7 @@ public class DeleteNamespace extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager environment) {
- Utils.unreserveNamespace(environment, namespaceId, fateId, true);
+ Utils.unreserveNamespace(environment, namespaceId, fateId, LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/NamespaceCleanUp.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/NamespaceCleanUp.java
index 1123753388..e3b9337e0a 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/NamespaceCleanUp.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/delete/NamespaceCleanUp.java
@@ -22,6 +22,7 @@ import
org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -64,7 +65,7 @@ class NamespaceCleanUp extends ManagerRepo {
log.error("{}", e.getMessage(), e);
}
- Utils.unreserveNamespace(manager, namespaceId, fateId, true);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.WRITE);
log.debug("Deleted namespace " + namespaceId);
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/rename/RenameNamespace.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/rename/RenameNamespace.java
index 1a0f290635..40ce34db1b 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/rename/RenameNamespace.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/namespace/rename/RenameNamespace.java
@@ -27,6 +27,7 @@ import
org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -42,7 +43,7 @@ public class RenameNamespace extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- return Utils.reserveNamespace(environment, namespaceId, fateId, true, true,
+ return Utils.reserveNamespace(environment, namespaceId, fateId,
LockType.WRITE, true,
TableOperation.RENAME);
}
@@ -79,7 +80,7 @@ public class RenameNamespace extends ManagerRepo {
manager.getContext().clearTableListCache();
} finally {
Utils.getTableNameLock().unlock();
- Utils.unreserveNamespace(manager, namespaceId, fateId, true);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.WRITE);
}
LoggerFactory.getLogger(RenameNamespace.class).debug("Renamed namespace {}
{} {}", namespaceId,
@@ -90,7 +91,7 @@ public class RenameNamespace extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveNamespace(env, namespaceId, fateId, true);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.WRITE);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/rename/RenameTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/rename/RenameTable.java
index b5f8ae2eaa..c29b959bd4 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/rename/RenameTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/rename/RenameTable.java
@@ -30,6 +30,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
import org.apache.accumulo.core.util.Pair;
import org.apache.accumulo.core.util.tables.TableNameUtil;
@@ -48,8 +49,9 @@ public class RenameTable extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager env) throws Exception {
- return Utils.reserveNamespace(env, namespaceId, fateId, false, true,
TableOperation.RENAME)
- + Utils.reserveTable(env, tableId, fateId, true, true,
TableOperation.RENAME);
+ return Utils.reserveNamespace(env, namespaceId, fateId, LockType.READ,
true,
+ TableOperation.RENAME)
+ + Utils.reserveTable(env, tableId, fateId, LockType.WRITE, true,
TableOperation.RENAME);
}
public RenameTable(NamespaceId namespaceId, TableId tableId, String
oldTableName,
@@ -101,8 +103,8 @@ public class RenameTable extends ManagerRepo {
manager.getContext().clearTableListCache();
} finally {
Utils.getTableNameLock().unlock();
- Utils.unreserveTable(manager, tableId, fateId, true);
- Utils.unreserveNamespace(manager, namespaceId, fateId, false);
+ Utils.unreserveTable(manager, tableId, fateId, LockType.WRITE);
+ Utils.unreserveNamespace(manager, namespaceId, fateId, LockType.READ);
}
LoggerFactory.getLogger(RenameTable.class).debug("Renamed table {} {} {}",
tableId,
@@ -113,8 +115,8 @@ public class RenameTable extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveTable(env, tableId, fateId, true);
- Utils.unreserveNamespace(env, namespaceId, fateId, false);
+ Utils.unreserveTable(env, tableId, fateId, LockType.WRITE);
+ Utils.unreserveNamespace(env, namespaceId, fateId, LockType.READ);
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableExport/WriteExportFiles.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableExport/WriteExportFiles.java
index 85dcd5298f..d40cf09a83 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableExport/WriteExportFiles.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableExport/WriteExportFiles.java
@@ -49,6 +49,7 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.dataImpl.KeyExtent;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.core.metadata.AccumuloTable;
import org.apache.accumulo.core.metadata.StoredTabletFile;
@@ -93,9 +94,9 @@ class WriteExportFiles extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager manager) throws Exception {
- long reserved = Utils.reserveNamespace(manager, tableInfo.namespaceID,
fateId, false, true,
- TableOperation.EXPORT)
- + Utils.reserveTable(manager, tableInfo.tableID, fateId, false, true,
+ long reserved = Utils.reserveNamespace(manager, tableInfo.namespaceID,
fateId, LockType.READ,
+ true, TableOperation.EXPORT)
+ + Utils.reserveTable(manager, tableInfo.tableID, fateId,
LockType.READ, true,
TableOperation.EXPORT);
if (reserved > 0) {
return reserved;
@@ -143,16 +144,16 @@ class WriteExportFiles extends ManagerRepo {
tableInfo.tableName, TableOperation.EXPORT,
TableOperationExceptionType.OTHER,
"Failed to create export files " + ioe.getMessage());
}
- Utils.unreserveNamespace(manager, tableInfo.namespaceID, fateId, false);
- Utils.unreserveTable(manager, tableInfo.tableID, fateId, false);
+ Utils.unreserveNamespace(manager, tableInfo.namespaceID, fateId,
LockType.READ);
+ Utils.unreserveTable(manager, tableInfo.tableID, fateId, LockType.READ);
Utils.unreserveHdfsDirectory(manager, new
Path(tableInfo.exportDir).toString(), fateId);
return null;
}
@Override
public void undo(FateId fateId, Manager env) {
- Utils.unreserveNamespace(env, tableInfo.namespaceID, fateId, false);
- Utils.unreserveTable(env, tableInfo.tableID, fateId, false);
+ Utils.unreserveNamespace(env, tableInfo.namespaceID, fateId,
LockType.READ);
+ Utils.unreserveTable(env, tableInfo.tableID, fateId, LockType.READ);
}
public static void exportTable(VolumeManager fs, ServerContext context,
String tableName,
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
index 245d10676a..a5a55dcd6c 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/FinishImportTable.java
@@ -24,6 +24,7 @@ import java.util.EnumSet;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -59,8 +60,8 @@ class FinishImportTable extends ManagerRepo {
final TableState newState = tableInfo.keepOffline ? TableState.OFFLINE :
TableState.ONLINE;
env.getTableManager().transitionTableState(tableInfo.tableId, newState,
expectedCurrStates);
- Utils.unreserveNamespace(env, tableInfo.namespaceId, fateId, false);
- Utils.unreserveTable(env, tableInfo.tableId, fateId, true);
+ Utils.unreserveNamespace(env, tableInfo.namespaceId, fateId,
LockType.READ);
+ Utils.unreserveTable(env, tableInfo.tableId, fateId, LockType.WRITE);
for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) {
Utils.unreserveHdfsDirectory(env, new Path(dm.exportDir).toString(),
fateId);
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportPopulateZookeeper.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportPopulateZookeeper.java
index 2b3af949db..c2b58b2128 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportPopulateZookeeper.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportPopulateZookeeper.java
@@ -29,6 +29,7 @@ import
org.apache.accumulo.core.clientImpl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.core.util.tables.TableNameUtil;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
@@ -51,7 +52,7 @@ class ImportPopulateZookeeper extends ManagerRepo {
@Override
public long isReady(FateId fateId, Manager environment) throws Exception {
- return Utils.reserveTable(environment, tableInfo.tableId, fateId, true,
false,
+ return Utils.reserveTable(environment, tableInfo.tableId, fateId,
LockType.WRITE, false,
TableOperation.IMPORT);
}
@@ -105,7 +106,7 @@ class ImportPopulateZookeeper extends ManagerRepo {
@Override
public void undo(FateId fateId, Manager env) throws Exception {
env.getTableManager().removeTable(tableInfo.tableId);
- Utils.unreserveTable(env, tableInfo.tableId, fateId, true);
+ Utils.unreserveTable(env, tableInfo.tableId, fateId, LockType.WRITE);
env.getContext().clearTableListCache();
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
index 90eb7f1fbf..3ebf2cf333 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/tableOps/tableImport/ImportTable.java
@@ -41,6 +41,7 @@ import org.apache.accumulo.core.data.NamespaceId;
import org.apache.accumulo.core.data.TableId;
import org.apache.accumulo.core.fate.FateId;
import org.apache.accumulo.core.fate.Repo;
+import
org.apache.accumulo.core.fate.zookeeper.DistributedReadWriteLock.LockType;
import org.apache.accumulo.manager.Manager;
import org.apache.accumulo.manager.tableOps.ManagerRepo;
import org.apache.accumulo.manager.tableOps.Utils;
@@ -79,8 +80,8 @@ public class ImportTable extends ManagerRepo {
for (ImportedTableInfo.DirectoryMapping dm : tableInfo.directories) {
result += Utils.reserveHdfsDirectory(environment, new
Path(dm.exportDir).toString(), fateId);
}
- result += Utils.reserveNamespace(environment, tableInfo.namespaceId,
fateId, false, true,
- TableOperation.IMPORT);
+ result += Utils.reserveNamespace(environment, tableInfo.namespaceId,
fateId, LockType.READ,
+ true, TableOperation.IMPORT);
return result;
}
@@ -162,7 +163,7 @@ public class ImportTable extends ManagerRepo {
Utils.unreserveHdfsDirectory(env, new Path(dm.exportDir).toString(),
fateId);
}
- Utils.unreserveNamespace(env, tableInfo.namespaceId, fateId, false);
+ Utils.unreserveNamespace(env, tableInfo.namespaceId, fateId,
LockType.READ);
}
static List<ImportedTableInfo.DirectoryMapping> parseExportDir(Set<String>
exportDirs) {