This is an automated email from the ASF dual-hosted git repository. mmiller pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push: new caf75c1 Fixes #421 Organize Fate Operations (#663) caf75c1 is described below commit caf75c15deffe1e0041d2242a350988a17641e58 Author: Christopher McTague <cjmcta...@apache.org> AuthorDate: Wed Oct 3 10:58:20 2018 -0400 Fixes #421 Organize Fate Operations (#663) * Clean up tableOps directory to be organized by Fate operation. --- .../apache/accumulo/master/FateServiceHandler.java | 24 +++--- .../apache/accumulo/master/tableOps/TableInfo.java | 96 +++++++++++++++++++--- .../org/apache/accumulo/master/tableOps/Utils.java | 18 ++-- .../master/tableOps/{ => clone}/CloneInfo.java | 2 +- .../master/tableOps/{ => clone}/CloneMetadata.java | 3 +- .../tableOps/{ => clone}/ClonePermissions.java | 3 +- .../master/tableOps/{ => clone}/CloneTable.java | 9 +- .../tableOps/{ => clone}/CloneZookeeper.java | 8 +- .../tableOps/{ => clone}/FinishCloneTable.java | 4 +- .../tableOps/{ => compact}/CompactRange.java | 4 +- .../tableOps/{ => compact}/CompactionDriver.java | 4 +- .../{ => compact/cancel}/CancelCompactions.java | 4 +- .../cancel}/FinishCancelCompaction.java | 4 +- .../master/tableOps/{ => create}/ChooseDir.java | 23 +++--- .../master/tableOps/{ => create}/CreateDir.java | 13 +-- .../master/tableOps/{ => create}/CreateTable.java | 32 ++++---- .../tableOps/{ => create}/FinishCreateTable.java | 26 +++--- .../tableOps/{ => create}/PopulateMetadata.java | 21 +++-- .../tableOps/{ => create}/PopulateZookeeper.java | 25 +++--- .../tableOps/{ => create}/SetupPermissions.java | 14 ++-- .../master/tableOps/{ => delete}/CleanUp.java | 4 +- .../master/tableOps/{ => delete}/DeleteTable.java | 4 +- .../master/tableOps/{ => merge}/TableRangeOp.java | 4 +- .../tableOps/{ => merge}/TableRangeOpWait.java | 4 +- .../{ => namespace/create}/CreateNamespace.java | 8 +- .../create}/FinishCreateNamespace.java | 4 +- .../{ => namespace/create}/NamespaceInfo.java | 2 +- .../create}/PopulateZookeeperWithNamespace.java | 8 +- .../create}/SetupNamespacePermissions.java | 3 +- .../{ => namespace/delete}/DeleteNamespace.java | 4 +- .../{ => namespace/delete}/NamespaceCleanUp.java | 4 +- .../{ => namespace/rename}/RenameNamespace.java | 8 +- .../master/tableOps/{ => rename}/RenameTable.java | 30 ++++--- .../tableOps/{ => tableExport}/ExportInfo.java | 2 +- .../tableOps/{ => tableExport}/ExportTable.java | 4 +- .../{ => tableExport}/WriteExportFiles.java | 4 +- .../{ => tableImport}/CreateImportDir.java | 3 +- .../{ => tableImport}/FinishImportTable.java | 4 +- .../{ => tableImport}/ImportPopulateZookeeper.java | 8 +- .../{ => tableImport}/ImportSetupPermissions.java | 3 +- .../tableOps/{ => tableImport}/ImportTable.java | 9 +- .../{ => tableImport}/ImportedTableInfo.java | 2 +- .../{ => tableImport}/MapImportFileNames.java | 3 +- .../{ => tableImport}/MoveExportedFiles.java | 3 +- .../{ => tableImport}/PopulateMetadataTable.java | 3 +- server/master/src/main/spotbugs/exclude-filter.xml | 4 +- .../{ => tableImport}/ImportTableTest.java | 2 +- 47 files changed, 317 insertions(+), 161 deletions(-) diff --git a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java index 47dcd0b..c148e2a 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java +++ b/server/master/src/main/java/org/apache/accumulo/master/FateServiceHandler.java @@ -60,21 +60,21 @@ import org.apache.accumulo.core.util.ByteBufferUtil; import org.apache.accumulo.core.util.Validator; import org.apache.accumulo.core.volume.Volume; import org.apache.accumulo.fate.ReadOnlyTStore.TStatus; -import org.apache.accumulo.master.tableOps.CancelCompactions; import org.apache.accumulo.master.tableOps.ChangeTableState; -import org.apache.accumulo.master.tableOps.CloneTable; -import org.apache.accumulo.master.tableOps.CompactRange; -import org.apache.accumulo.master.tableOps.CreateNamespace; -import org.apache.accumulo.master.tableOps.CreateTable; -import org.apache.accumulo.master.tableOps.DeleteNamespace; -import org.apache.accumulo.master.tableOps.DeleteTable; -import org.apache.accumulo.master.tableOps.ExportTable; -import org.apache.accumulo.master.tableOps.ImportTable; -import org.apache.accumulo.master.tableOps.RenameNamespace; -import org.apache.accumulo.master.tableOps.RenameTable; -import org.apache.accumulo.master.tableOps.TableRangeOp; import org.apache.accumulo.master.tableOps.TraceRepo; import org.apache.accumulo.master.tableOps.bulkVer2.PrepBulkImport; +import org.apache.accumulo.master.tableOps.clone.CloneTable; +import org.apache.accumulo.master.tableOps.compact.CompactRange; +import org.apache.accumulo.master.tableOps.compact.cancel.CancelCompactions; +import org.apache.accumulo.master.tableOps.create.CreateTable; +import org.apache.accumulo.master.tableOps.delete.DeleteTable; +import org.apache.accumulo.master.tableOps.merge.TableRangeOp; +import org.apache.accumulo.master.tableOps.namespace.create.CreateNamespace; +import org.apache.accumulo.master.tableOps.namespace.delete.DeleteNamespace; +import org.apache.accumulo.master.tableOps.namespace.rename.RenameNamespace; +import org.apache.accumulo.master.tableOps.rename.RenameTable; +import org.apache.accumulo.master.tableOps.tableExport.ExportTable; +import org.apache.accumulo.master.tableOps.tableImport.ImportTable; import org.apache.accumulo.server.client.ClientServiceHandler; import org.apache.accumulo.server.master.state.MergeInfo; import org.apache.accumulo.server.util.TablePropUtil; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableInfo.java index 6a92820..d77f1f2 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableInfo.java @@ -22,26 +22,100 @@ import java.util.Map; import org.apache.accumulo.core.client.admin.InitialTableState; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Table; +import org.apache.accumulo.core.client.impl.Table.ID; -class TableInfo implements Serializable { +public class TableInfo implements Serializable { private static final long serialVersionUID = 1L; - String tableName; - Table.ID tableId; - Namespace.ID namespaceId; - char timeType; - String user; + private String tableName; + private Table.ID tableId; + private Namespace.ID namespaceId; + + private char timeType; + private String user; // Record requested initial state at creation - InitialTableState initialTableState; + private InitialTableState initialTableState; // Track information related to initial split creation - int initialSplitSize; - String splitFile; - String splitDirsFile; + private int initialSplitSize; + private String splitFile; + private String splitDirsFile; public Map<String,String> props; - public String defaultTabletDir = null; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } + + public ID getTableId() { + return tableId; + } + + public void setTableId(ID tableId) { + this.tableId = tableId; + } + + public Namespace.ID getNamespaceId() { + return namespaceId; + } + + public void setNamespaceId(Namespace.ID namespaceId) { + this.namespaceId = namespaceId; + } + + public char getTimeType() { + return timeType; + } + + public void setTimeType(char timeType) { + this.timeType = timeType; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public String getSplitFile() { + return splitFile; + } + + public void setSplitFile(String splitFile) { + this.splitFile = splitFile; + } + + public String getSplitDirsFile() { + return splitDirsFile; + } + + public void setSplitDirsFile(String splitDirsFile) { + this.splitDirsFile = splitDirsFile; + } + + public InitialTableState getInitialTableState() { + return initialTableState; + } + + public void setInitialTableState(InitialTableState initialTableState) { + this.initialTableState = initialTableState; + } + + public int getInitialSplitSize() { + return initialSplitSize; + } + + public void setInitialSplitSize(int initialSplitSize) { + this.initialSplitSize = initialSplitSize; + } + } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java index 0f656ee..7a3acc8 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java @@ -55,8 +55,8 @@ public class Utils { private static final byte[] ZERO_BYTE = {'0'}; private static final Logger log = LoggerFactory.getLogger(Utils.class); - static void checkTableDoesNotExist(ServerContext context, String tableName, Table.ID tableId, - TableOperation operation) throws AcceptableThriftTableOperationException { + public static void checkTableDoesNotExist(ServerContext context, String tableName, + Table.ID tableId, TableOperation operation) throws AcceptableThriftTableOperationException { Table.ID id = Tables.getNameToIdMap(context).get(tableName); @@ -65,7 +65,7 @@ public class Utils { TableOperationExceptionType.EXISTS, null); } - static <T extends AbstractId> T getNextId(String name, ServerContext context, + public static <T extends AbstractId> T getNextId(String name, ServerContext context, Function<String,T> newIdFunction) throws AcceptableThriftTableOperationException { try { IZooReaderWriter zoo = context.getZooReaderWriter(); @@ -170,11 +170,19 @@ public class Utils { return lock; } + public static Lock getIdLock() { + return idLock; + } + + public static Lock getTableNameLock() { + return tableNameLock; + } + public static Lock getReadLock(Master env, AbstractId tableId, long tid) throws Exception { return Utils.getLock(env.getContext(), tableId, tid, false); } - static void checkNamespaceDoesNotExist(ServerContext context, String namespace, + public static void checkNamespaceDoesNotExist(ServerContext context, String namespace, Namespace.ID namespaceId, TableOperation operation) throws AcceptableThriftTableOperationException { @@ -190,7 +198,7 @@ public class Utils { * the data from a file on the file system. It is assumed that the file is textual and not binary * data. */ - static SortedSet<Text> getSortedSetFromFile(FSDataInputStream inputStream, boolean encoded) + public static SortedSet<Text> getSortedSetFromFile(FSDataInputStream inputStream, boolean encoded) throws IOException { SortedSet<Text> data = new TreeSet<>(); try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneInfo.java similarity index 96% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneInfo.java index f4b983f..6536c54 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneInfo.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import java.io.Serializable; import java.util.Map; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneMetadata.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneMetadata.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneMetadata.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneMetadata.java index 1254477..2549f67 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneMetadata.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneMetadata.java @@ -14,10 +14,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.util.MetadataTableUtil; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ClonePermissions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/ClonePermissions.java similarity index 96% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ClonePermissions.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/ClonePermissions.java index eb7de8d..ce94b1d 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ClonePermissions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/ClonePermissions.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import org.apache.accumulo.core.client.NamespaceNotFoundException; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; @@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.security.AuditedSecurityOperation; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneTable.java similarity index 92% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneTable.java index 406b8a2..b1004b3 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import java.util.Map; import java.util.Set; @@ -24,6 +24,8 @@ import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; public class CloneTable extends MasterRepo { @@ -53,13 +55,14 @@ public class CloneTable extends MasterRepo { @Override public Repo<Master> call(long tid, Master environment) throws Exception { - Utils.idLock.lock(); + Utils.getIdLock().lock(); try { cloneInfo.tableId = Utils.getNextId(cloneInfo.tableName, environment.getContext(), Table.ID::of); + return new ClonePermissions(cloneInfo); } finally { - Utils.idLock.unlock(); + Utils.getIdLock().unlock(); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneZookeeper.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneZookeeper.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneZookeeper.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneZookeeper.java index dac2e93..9054c2d 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CloneZookeeper.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/CloneZookeeper.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import org.apache.accumulo.core.client.NamespaceNotFoundException; import org.apache.accumulo.core.client.impl.ClientContext; @@ -24,6 +24,8 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; class CloneZookeeper extends MasterRepo { @@ -51,7 +53,7 @@ class CloneZookeeper extends MasterRepo { @Override public Repo<Master> call(long tid, Master environment) throws Exception { - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper @@ -65,7 +67,7 @@ class CloneZookeeper extends MasterRepo { return new CloneMetadata(cloneInfo); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCloneTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/FinishCloneTable.java similarity index 94% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCloneTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/FinishCloneTable.java index fa29182..346bcae 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCloneTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/clone/FinishCloneTable.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.clone; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.slf4j.LoggerFactory; class FinishCloneTable extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactRange.java similarity index 97% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactRange.java index 1ee224c..aee6e74 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactRange.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactRange.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.compact; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; @@ -34,6 +34,8 @@ import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.master.tableOps.UserCompactionConfig; import org.apache.commons.codec.binary.Hex; import org.apache.hadoop.io.Text; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactionDriver.java similarity index 97% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactionDriver.java index 81a91c8..af4141f 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CompactionDriver.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/CompactionDriver.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.compact; import java.util.Collections; import java.util.Iterator; @@ -45,6 +45,8 @@ import org.apache.accumulo.core.util.MapCounter; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.master.LiveTServerSet.TServerConnection; import org.apache.accumulo.server.master.state.TServerInstance; import org.apache.hadoop.io.Text; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/CancelCompactions.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/CancelCompactions.java index 2f245d8..bd47a9b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CancelCompactions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/CancelCompactions.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.compact.cancel; import static java.nio.charset.StandardCharsets.UTF_8; @@ -26,6 +26,8 @@ import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; public class CancelCompactions extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCancelCompaction.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/FinishCancelCompaction.java similarity index 90% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCancelCompaction.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/FinishCancelCompaction.java index b89771a..2768cbc 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCancelCompaction.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/compact/cancel/FinishCancelCompaction.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.compact.cancel; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; class FinishCancelCompaction extends MasterRepo { private static final long serialVersionUID = 1L; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/ChooseDir.java similarity index 85% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/ChooseDir.java index dae0bc3..7d58930 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ChooseDir.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/ChooseDir.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.io.IOException; import java.util.SortedSet; @@ -23,6 +23,9 @@ import java.util.TreeSet; import org.apache.accumulo.core.Constants; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.fs.VolumeChooserEnvironment; import org.apache.accumulo.server.fs.VolumeManager; @@ -51,15 +54,15 @@ class ChooseDir extends MasterRepo { // Constants.DEFAULT_TABLET_LOCATION has a leading slash prepended to it so we don't need to add // one here - VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.tableId, + VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.getTableId(), master.getContext()); String baseDir = master.getFileSystem().choose(chooserEnv, ServerConstants.getBaseUris(master.getConfiguration())) + Constants.HDFS_TABLES_DIR - + Path.SEPARATOR + tableInfo.tableId; + + Path.SEPARATOR + tableInfo.getTableId(); tableInfo.defaultTabletDir = baseDir + Constants.DEFAULT_TABLET_LOCATION; - if (tableInfo.initialSplitSize > 0) { + if (tableInfo.getInitialSplitSize() > 0) { createTableDirectoriesInfo(master, baseDir); } return new CreateDir(tableInfo); @@ -68,7 +71,7 @@ class ChooseDir extends MasterRepo { @Override public void undo(long tid, Master master) throws Exception { VolumeManager fs = master.getFileSystem(); - fs.deleteRecursively(new Path(tableInfo.splitDirsFile)); + fs.deleteRecursively(new Path(tableInfo.getSplitDirsFile())); } /** @@ -76,8 +79,8 @@ class ChooseDir extends MasterRepo { * to the file system for later use during this FATE operation. */ private void createTableDirectoriesInfo(Master master, String baseDir) throws IOException { - SortedSet<Text> splits = Utils.getSortedSetFromFile(master.getInputStream(tableInfo.splitFile), - true); + SortedSet<Text> splits = Utils + .getSortedSetFromFile(master.getInputStream(tableInfo.getSplitFile()), true); SortedSet<Text> tabletDirectoryInfo = createTabletDirectoriesSet(master, splits.size(), baseDir); writeTabletDirectoriesToFileSystem(master, tabletDirectoryInfo); @@ -105,9 +108,9 @@ class ChooseDir extends MasterRepo { private void writeTabletDirectoriesToFileSystem(Master master, SortedSet<Text> dirs) throws IOException { FileSystem fs = master.getFileSystem().getDefaultVolume().getFileSystem(); - if (fs.exists(new Path(tableInfo.splitDirsFile))) - fs.delete(new Path(tableInfo.splitDirsFile), true); - try (FSDataOutputStream stream = master.getOutputStream(tableInfo.splitDirsFile)) { + if (fs.exists(new Path(tableInfo.getSplitDirsFile()))) + fs.delete(new Path(tableInfo.getSplitDirsFile()), true); + try (FSDataOutputStream stream = master.getOutputStream(tableInfo.getSplitDirsFile())) { for (Text dir : dirs) stream.writeBytes(dir + "\n"); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateDir.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateDir.java similarity index 87% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateDir.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateDir.java index f3d1a41..742af08 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateDir.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateDir.java @@ -14,13 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.io.IOException; import java.util.SortedSet; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.Text; @@ -45,9 +48,9 @@ class CreateDir extends MasterRepo { fs.mkdirs(new Path(tableInfo.defaultTabletDir)); // read in the splitDir info file and create a directory for each item - if (tableInfo.initialSplitSize > 0) { + if (tableInfo.getInitialSplitSize() > 0) { SortedSet<Text> dirInfo = Utils - .getSortedSetFromFile(master.getInputStream(tableInfo.splitDirsFile), false); + .getSortedSetFromFile(master.getInputStream(tableInfo.getSplitDirsFile()), false); createTabletDirectories(master.getFileSystem(), dirInfo); } return new PopulateMetadata(tableInfo); @@ -58,9 +61,9 @@ class CreateDir extends MasterRepo { VolumeManager fs = master.getFileSystem(); fs.deleteRecursively(new Path(tableInfo.defaultTabletDir)); - if (tableInfo.initialSplitSize > 0) { + if (tableInfo.getInitialSplitSize() > 0) { SortedSet<Text> dirInfo = Utils - .getSortedSetFromFile(master.getInputStream(tableInfo.splitDirsFile), false); + .getSortedSetFromFile(master.getInputStream(tableInfo.getSplitDirsFile()), false); for (Text dirname : dirInfo) { fs.deleteRecursively(new Path(dirname.toString())); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateTable.java similarity index 71% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateTable.java index baea523..24d8188 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/CreateTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.util.Map; @@ -25,6 +25,9 @@ import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.tablets.TabletTime; public class CreateTable extends MasterRepo { @@ -36,21 +39,21 @@ public class CreateTable extends MasterRepo { String splitFile, int splitCount, String splitDirsFile, InitialTableState initialTableState, Namespace.ID namespaceId) { tableInfo = new TableInfo(); - tableInfo.tableName = tableName; - tableInfo.timeType = TabletTime.getTimeID(timeType); - tableInfo.user = user; + tableInfo.setTableName(tableName); + tableInfo.setTimeType(TabletTime.getTimeID(timeType)); + tableInfo.setUser(user); tableInfo.props = props; - tableInfo.namespaceId = namespaceId; - tableInfo.splitFile = splitFile; - tableInfo.initialSplitSize = splitCount; - tableInfo.initialTableState = initialTableState; - tableInfo.splitDirsFile = splitDirsFile; + tableInfo.setNamespaceId(namespaceId); + tableInfo.setSplitFile(splitFile); + tableInfo.setInitialSplitSize(splitCount); + tableInfo.setInitialTableState(initialTableState); + tableInfo.setSplitDirsFile(splitDirsFile); } @Override public long isReady(long tid, Master 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.namespaceId, tid, false, true, + return Utils.reserveNamespace(environment, tableInfo.getNamespaceId(), tid, false, true, TableOperation.CREATE); } @@ -62,18 +65,19 @@ public class CreateTable extends MasterRepo { // assuming only the master process is creating tables - Utils.idLock.lock(); + Utils.getIdLock().lock(); try { - tableInfo.tableId = Utils.getNextId(tableInfo.tableName, master.getContext(), Table.ID::of); + String tName = tableInfo.getTableName(); + tableInfo.setTableId(Utils.getNextId(tName, master.getContext(), Table.ID::of)); return new SetupPermissions(tableInfo); } finally { - Utils.idLock.unlock(); + Utils.getIdLock().unlock(); } } @Override public void undo(long tid, Master env) throws Exception { - Utils.unreserveNamespace(env, tableInfo.namespaceId, tid, false); + Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), tid, false); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/FinishCreateTable.java similarity index 74% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/FinishCreateTable.java index 616001e..b588e0d 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/FinishCreateTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.io.IOException; @@ -23,6 +23,9 @@ import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.core.volume.Volume; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; @@ -44,19 +47,20 @@ class FinishCreateTable extends MasterRepo { @Override public Repo<Master> call(long tid, Master env) throws Exception { - if (tableInfo.initialTableState == InitialTableState.OFFLINE) { - env.getContext().getTableManager().transitionTableState(tableInfo.tableId, + if (tableInfo.getInitialTableState() == InitialTableState.OFFLINE) { + env.getContext().getTableManager().transitionTableState(tableInfo.getTableId(), TableState.OFFLINE); } else { - env.getContext().getTableManager().transitionTableState(tableInfo.tableId, TableState.ONLINE); + env.getContext().getTableManager().transitionTableState(tableInfo.getTableId(), + TableState.ONLINE); } - Utils.unreserveNamespace(env, tableInfo.namespaceId, tid, false); - Utils.unreserveTable(env, tableInfo.tableId, tid, true); + Utils.unreserveNamespace(env, tableInfo.getNamespaceId(), tid, false); + Utils.unreserveTable(env, tableInfo.getTableId(), tid, true); - env.getEventCoordinator().event("Created table %s ", tableInfo.tableName); + env.getEventCoordinator().event("Created table %s ", tableInfo.getTableName()); - if (tableInfo.initialSplitSize > 0) { + if (tableInfo.getInitialSplitSize() > 0) { cleanupSplitFiles(env); } return null; @@ -65,13 +69,13 @@ class FinishCreateTable extends MasterRepo { private void cleanupSplitFiles(Master env) throws IOException { Volume defaultVolume = env.getFileSystem().getDefaultVolume(); FileSystem fs = defaultVolume.getFileSystem(); - fs.delete(new Path(tableInfo.splitFile), true); - fs.delete(new Path(tableInfo.splitDirsFile), true); + fs.delete(new Path(tableInfo.getSplitFile()), true); + fs.delete(new Path(tableInfo.getSplitDirsFile()), true); } @Override public String getReturn() { - return tableInfo.tableId.canonicalID(); + return tableInfo.getTableId().canonicalID(); } @Override diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadata.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateMetadata.java similarity index 86% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadata.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateMetadata.java index db07dd0..63c3b24 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadata.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateMetadata.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.util.Collections; import java.util.HashMap; @@ -31,6 +31,9 @@ import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.metadata.schema.MetadataSchema; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.ServerContext; import org.apache.accumulo.server.util.MetadataTableUtil; import org.apache.accumulo.server.zookeeper.ZooLock; @@ -56,19 +59,19 @@ class PopulateMetadata extends MasterRepo { @Override public Repo<Master> call(long tid, Master environment) throws Exception { - KeyExtent extent = new KeyExtent(tableInfo.tableId, null, null); + KeyExtent extent = new KeyExtent(tableInfo.getTableId(), null, null); MetadataTableUtil.addTablet(extent, tableInfo.defaultTabletDir, environment.getContext(), - tableInfo.timeType, environment.getMasterLock()); + tableInfo.getTimeType(), environment.getMasterLock()); - if (tableInfo.initialSplitSize > 0) { + if (tableInfo.getInitialSplitSize() > 0) { SortedSet<Text> splits = Utils - .getSortedSetFromFile(environment.getInputStream(tableInfo.splitFile), true); + .getSortedSetFromFile(environment.getInputStream(tableInfo.getSplitFile()), true); SortedSet<Text> dirs = Utils - .getSortedSetFromFile(environment.getInputStream(tableInfo.splitDirsFile), false); + .getSortedSetFromFile(environment.getInputStream(tableInfo.getSplitDirsFile()), false); Map<Text,Text> splitDirMap = createSplitDirectoryMap(splits, dirs); try (BatchWriter bw = environment.getClient().createBatchWriter("accumulo.metadata")) { - writeSplitsToMetadataTable(environment.getContext(), tableInfo.tableId, splits, splitDirMap, - tableInfo.timeType, environment.getMasterLock(), bw); + writeSplitsToMetadataTable(environment.getContext(), tableInfo.getTableId(), splits, + splitDirMap, tableInfo.getTimeType(), environment.getMasterLock(), bw); } } return new FinishCreateTable(tableInfo); @@ -94,7 +97,7 @@ class PopulateMetadata extends MasterRepo { @Override public void undo(long tid, Master environment) throws Exception { - MetadataTableUtil.deleteTable(tableInfo.tableId, false, environment.getContext(), + MetadataTableUtil.deleteTable(tableInfo.getTableId(), false, environment.getContext(), environment.getMasterLock()); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeper.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateZookeeper.java similarity index 73% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeper.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateZookeeper.java index 68e783d..b5e2699 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeper.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/PopulateZookeeper.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import java.util.Map.Entry; @@ -23,6 +23,9 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.util.TablePropUtil; class PopulateZookeeper extends MasterRepo { @@ -37,7 +40,7 @@ class PopulateZookeeper extends MasterRepo { @Override public long isReady(long tid, Master environment) throws Exception { - return Utils.reserveTable(environment, tableInfo.tableId, tid, true, false, + return Utils.reserveTable(environment, tableInfo.getTableId(), tid, true, false, TableOperation.CREATE); } @@ -45,31 +48,31 @@ class PopulateZookeeper extends MasterRepo { public Repo<Master> call(long tid, Master master) throws Exception { // reserve the table name in zookeeper or fail - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper - Utils.checkTableDoesNotExist(master.getContext(), tableInfo.tableName, tableInfo.tableId, - TableOperation.CREATE); + Utils.checkTableDoesNotExist(master.getContext(), tableInfo.getTableName(), + tableInfo.getTableId(), TableOperation.CREATE); - master.getTableManager().addTable(tableInfo.tableId, tableInfo.namespaceId, - tableInfo.tableName, NodeExistsPolicy.OVERWRITE); + master.getTableManager().addTable(tableInfo.getTableId(), tableInfo.getNamespaceId(), + tableInfo.getTableName(), NodeExistsPolicy.OVERWRITE); for (Entry<String,String> entry : tableInfo.props.entrySet()) - TablePropUtil.setTableProperty(master.getContext(), tableInfo.tableId, entry.getKey(), + TablePropUtil.setTableProperty(master.getContext(), tableInfo.getTableId(), entry.getKey(), entry.getValue()); Tables.clearCache(master.getContext()); return new ChooseDir(tableInfo); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); } } @Override public void undo(long tid, Master master) throws Exception { - master.getTableManager().removeTable(tableInfo.tableId); - Utils.unreserveTable(master, tableInfo.tableId, tid, true); + master.getTableManager().removeTable(tableInfo.getTableId()); + Utils.unreserveTable(master, tableInfo.getTableId(), tid, true); Tables.clearCache(master.getContext()); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupPermissions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/SetupPermissions.java similarity index 83% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupPermissions.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/create/SetupPermissions.java index c7c71fe..446c198 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupPermissions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/create/SetupPermissions.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.create; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.TableInfo; import org.apache.accumulo.server.security.AuditedSecurityOperation; import org.apache.accumulo.server.security.SecurityOperation; import org.slf4j.LoggerFactory; @@ -30,7 +32,7 @@ class SetupPermissions extends MasterRepo { private TableInfo tableInfo; - public SetupPermissions(TableInfo ti) { + SetupPermissions(TableInfo ti) { this.tableInfo = ti; } @@ -38,11 +40,11 @@ class SetupPermissions extends MasterRepo { public Repo<Master> call(long tid, Master env) throws Exception { // give all table permissions to the creator SecurityOperation security = AuditedSecurityOperation.getInstance(env.getContext()); - if (!tableInfo.user.equals(env.getContext().getCredentials().getPrincipal())) { + if (!tableInfo.getUser().equals(env.getContext().getCredentials().getPrincipal())) { for (TablePermission permission : TablePermission.values()) { try { - security.grantTablePermission(env.getContext().rpcCreds(), tableInfo.user, - tableInfo.tableId, permission, tableInfo.namespaceId); + security.grantTablePermission(env.getContext().rpcCreds(), tableInfo.getUser(), + tableInfo.getTableId(), permission, tableInfo.getNamespaceId()); } catch (ThriftSecurityException e) { LoggerFactory.getLogger(SetupPermissions.class).error("{}", e.getMessage(), e); throw e; @@ -59,7 +61,7 @@ class SetupPermissions extends MasterRepo { @Override public void undo(long tid, Master env) throws Exception { AuditedSecurityOperation.getInstance(env.getContext()).deleteTable(env.getContext().rpcCreds(), - tableInfo.tableId, tableInfo.namespaceId); + tableInfo.getTableId(), tableInfo.getNamespaceId()); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/CleanUp.java similarity index 98% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/CleanUp.java index 83f90eb..0cc23d3 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CleanUp.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/CleanUp.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.delete; import java.io.IOException; import java.net.UnknownHostException; @@ -40,6 +40,8 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Da import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.master.state.MetaDataTableScanner; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/DeleteTable.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/DeleteTable.java index 0922afe..eb63e6e 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/delete/DeleteTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.delete; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Table; @@ -22,6 +22,8 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; public class DeleteTable extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOp.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOp.java similarity index 96% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOp.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOp.java index 0c61fb8..bdd5977 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOp.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOp.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.merge; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; import org.apache.accumulo.core.client.impl.Namespace; @@ -26,6 +26,8 @@ import org.apache.accumulo.core.metadata.RootTable; import org.apache.accumulo.core.util.TextUtil; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.master.state.MergeInfo; import org.apache.accumulo.server.master.state.MergeInfo.Operation; import org.apache.accumulo.server.master.state.MergeState; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOpWait.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOpWait.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOpWait.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOpWait.java index d24b27b..564a11f 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOpWait.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/merge/TableRangeOpWait.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.merge; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.master.state.MergeInfo; import org.apache.accumulo.server.master.state.MergeState; import org.slf4j.Logger; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/CreateNamespace.java similarity index 89% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/CreateNamespace.java index b324176..a99006a 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/CreateNamespace.java @@ -14,13 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.create; import java.util.Map; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; public class CreateNamespace extends MasterRepo { private static final long serialVersionUID = 1L; @@ -41,13 +43,13 @@ public class CreateNamespace extends MasterRepo { @Override public Repo<Master> call(long tid, Master master) throws Exception { - Utils.idLock.lock(); + Utils.getIdLock().lock(); try { namespaceInfo.namespaceId = Utils.getNextId(namespaceInfo.namespaceName, master.getContext(), Namespace.ID::of); return new SetupNamespacePermissions(namespaceInfo); } finally { - Utils.idLock.unlock(); + Utils.getIdLock().unlock(); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/FinishCreateNamespace.java similarity index 91% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateNamespace.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/FinishCreateNamespace.java index 05c9169..c4a21c2 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/FinishCreateNamespace.java @@ -14,10 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.create; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.slf4j.LoggerFactory; class FinishCreateNamespace extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/NamespaceInfo.java similarity index 94% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceInfo.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/NamespaceInfo.java index 0ed01e0..2f05e28 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/NamespaceInfo.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.create; import java.io.Serializable; import java.util.Map; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeperWithNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/PopulateZookeeperWithNamespace.java similarity index 91% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeperWithNamespace.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/PopulateZookeeperWithNamespace.java index 5029349..402a2ec 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateZookeeperWithNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/PopulateZookeeperWithNamespace.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.create; import java.util.Map.Entry; @@ -23,6 +23,8 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.tables.TableManager; import org.apache.accumulo.server.util.NamespacePropUtil; @@ -45,7 +47,7 @@ class PopulateZookeeperWithNamespace extends MasterRepo { @Override public Repo<Master> call(long tid, Master master) throws Exception { - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { Utils.checkNamespaceDoesNotExist(master.getContext(), namespaceInfo.namespaceName, namespaceInfo.namespaceId, TableOperation.CREATE); @@ -62,7 +64,7 @@ class PopulateZookeeperWithNamespace extends MasterRepo { return new FinishCreateNamespace(namespaceInfo); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupNamespacePermissions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/SetupNamespacePermissions.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupNamespacePermissions.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/SetupNamespacePermissions.java index 78639d2..17ffccd 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/SetupNamespacePermissions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/create/SetupNamespacePermissions.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.create; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.NamespacePermission; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.security.AuditedSecurityOperation; import org.apache.accumulo.server.security.SecurityOperation; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/DeleteNamespace.java similarity index 91% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/DeleteNamespace.java index 5d66a3a..c1420c5 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/DeleteNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/DeleteNamespace.java @@ -14,12 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.delete; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; public class DeleteNamespace extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceCleanUp.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/NamespaceCleanUp.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceCleanUp.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/NamespaceCleanUp.java index 3138dbf..54b3aa5 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceCleanUp.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/delete/NamespaceCleanUp.java @@ -14,13 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.delete; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.security.AuditedSecurityOperation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/rename/RenameNamespace.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/rename/RenameNamespace.java index e50d7e3..c31bccf 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/namespace/rename/RenameNamespace.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.namespace.rename; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException; @@ -26,6 +26,8 @@ import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.slf4j.LoggerFactory; public class RenameNamespace extends MasterRepo { @@ -51,7 +53,7 @@ public class RenameNamespace extends MasterRepo { IZooReaderWriter zoo = master.getContext().getZooReaderWriter(); - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { Utils.checkNamespaceDoesNotExist(master.getContext(), newName, namespaceId, TableOperation.RENAME); @@ -74,7 +76,7 @@ public class RenameNamespace extends MasterRepo { }); Tables.clearCache(master.getContext()); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); Utils.unreserveNamespace(master, namespaceId, id, true); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/rename/RenameTable.java similarity index 83% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/rename/RenameTable.java index 60c3619..7069fc8 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/rename/RenameTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.rename; import static java.nio.charset.StandardCharsets.UTF_8; @@ -30,8 +30,9 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.core.util.Pair; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.IZooReaderWriter; -import org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.slf4j.LoggerFactory; public class RenameTable extends MasterRepo { @@ -70,7 +71,7 @@ public class RenameTable extends MasterRepo { IZooReaderWriter zoo = master.getContext().getZooReaderWriter(); - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { Utils.checkTableDoesNotExist(master.getContext(), newTableName, tableId, TableOperation.RENAME); @@ -81,23 +82,20 @@ public class RenameTable extends MasterRepo { final String tap = master.getZooKeeperRoot() + Constants.ZTABLES + "/" + tableId + Constants.ZTABLE_NAME; - zoo.mutate(tap, null, null, new Mutator() { - @Override - public byte[] mutate(byte[] current) throws Exception { - final String currentName = new String(current, UTF_8); - if (currentName.equals(newName)) - return null; // assume in this case the operation is running again, so we are done - if (!currentName.equals(oldName)) { - throw new AcceptableThriftTableOperationException(null, oldTableName, - TableOperation.RENAME, TableOperationExceptionType.NOTFOUND, - "Name changed while processing"); - } - return newName.getBytes(UTF_8); + zoo.mutate(tap, null, null, current -> { + final String currentName = new String(current, UTF_8); + if (currentName.equals(newName)) + return null; // assume in this case the operation is running again, so we are done + if (!currentName.equals(oldName)) { + throw new AcceptableThriftTableOperationException(null, oldTableName, + TableOperation.RENAME, TableOperationExceptionType.NOTFOUND, + "Name changed while processing"); } + return newName.getBytes(UTF_8); }); Tables.clearCache(master.getContext()); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); Utils.unreserveTable(master, tableId, tid, true); Utils.unreserveNamespace(master, namespaceId, tid, false); } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportInfo.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportInfo.java index 6884a44..35567bc 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportInfo.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableExport; import java.io.Serializable; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportTable.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportTable.java index 96ae5ca..bf5065f 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ExportTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/ExportTable.java @@ -14,13 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableExport; import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.hadoop.fs.Path; public class ExportTable extends MasterRepo { diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/WriteExportFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/WriteExportFiles.java similarity index 98% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/WriteExportFiles.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/WriteExportFiles.java index c618fca..aa9ee9b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/WriteExportFiles.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableExport/WriteExportFiles.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableExport; import static java.nio.charset.StandardCharsets.UTF_8; @@ -54,6 +54,8 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Lo import org.apache.accumulo.core.security.Authorizations; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.ServerContext; import org.apache.accumulo.server.conf.TableConfiguration; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/CreateImportDir.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/CreateImportDir.java index 106afb5..2aac167 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/CreateImportDir.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/CreateImportDir.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import java.io.IOException; import java.util.Arrays; @@ -22,6 +22,7 @@ import java.util.Arrays; import org.apache.accumulo.core.Constants; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.tablets.UniqueNameAllocator; import org.apache.hadoop.fs.Path; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishImportTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/FinishImportTable.java similarity index 93% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishImportTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/FinishImportTable.java index 9932afa..1c0a48b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishImportTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/FinishImportTable.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.hadoop.fs.Path; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportPopulateZookeeper.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java similarity index 94% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportPopulateZookeeper.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java index 7aff786..ee87e09 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportPopulateZookeeper.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportPopulateZookeeper.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import java.io.IOException; import java.util.Map; @@ -31,6 +31,8 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.util.TablePropUtil; import org.apache.hadoop.fs.FileSystem; @@ -70,7 +72,7 @@ class ImportPopulateZookeeper extends MasterRepo { public Repo<Master> call(long tid, Master env) throws Exception { // reserve the table name in zookeeper or fail - Utils.tableNameLock.lock(); + Utils.getTableNameLock().lock(); try { // write tableName & tableId to zookeeper Utils.checkTableDoesNotExist(env.getContext(), tableInfo.tableName, tableInfo.tableId, @@ -83,7 +85,7 @@ class ImportPopulateZookeeper extends MasterRepo { Tables.clearCache(env.getContext()); } finally { - Utils.tableNameLock.unlock(); + Utils.getTableNameLock().unlock(); } for (Entry<String,String> entry : getExportedProps(env.getFileSystem()).entrySet()) diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportSetupPermissions.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportSetupPermissions.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportSetupPermissions.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportSetupPermissions.java index 7dc6529..d1626ea 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportSetupPermissions.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportSetupPermissions.java @@ -14,12 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.security.AuditedSecurityOperation; import org.apache.accumulo.server.security.SecurityOperation; import org.slf4j.LoggerFactory; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportTable.java similarity index 94% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportTable.java index 8e41037..98d3c88 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import static java.nio.charset.StandardCharsets.UTF_8; @@ -32,6 +32,9 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; +import org.apache.accumulo.master.tableOps.Utils; +import org.apache.accumulo.master.tableOps.tableExport.ExportTable; import org.apache.accumulo.server.ServerConstants; import org.apache.hadoop.fs.Path; import org.slf4j.Logger; @@ -69,12 +72,12 @@ public class ImportTable extends MasterRepo { // assuming only the master process is creating tables - Utils.idLock.lock(); + Utils.getIdLock().lock(); try { tableInfo.tableId = Utils.getNextId(tableInfo.tableName, env.getContext(), Table.ID::of); return new ImportSetupPermissions(tableInfo); } finally { - Utils.idLock.unlock(); + Utils.getIdLock().unlock(); } } diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportedTableInfo.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportedTableInfo.java similarity index 95% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportedTableInfo.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportedTableInfo.java index 365f693..0f3488b 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportedTableInfo.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/ImportedTableInfo.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import java.io.Serializable; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/MapImportFileNames.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MapImportFileNames.java similarity index 97% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/MapImportFileNames.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MapImportFileNames.java index 8d86261..93986c4 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/MapImportFileNames.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MapImportFileNames.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import static java.nio.charset.StandardCharsets.UTF_8; @@ -29,6 +29,7 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.core.file.FileOperations; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.accumulo.server.tablets.UniqueNameAllocator; import org.apache.hadoop.fs.FileStatus; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MoveExportedFiles.java similarity index 96% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MoveExportedFiles.java index 61ccf09..30596fb 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/MoveExportedFiles.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import java.io.IOException; import java.util.Map; @@ -24,6 +24,7 @@ import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.fs.VolumeManager; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadataTable.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/PopulateMetadataTable.java similarity index 98% rename from server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadataTable.java rename to server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/PopulateMetadataTable.java index 13de036..4413094 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadataTable.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/tableImport/PopulateMetadataTable.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import static java.nio.charset.StandardCharsets.UTF_8; @@ -44,6 +44,7 @@ import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.Da import org.apache.accumulo.core.util.FastFormat; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; +import org.apache.accumulo.master.tableOps.MasterRepo; import org.apache.accumulo.server.ServerConstants; import org.apache.accumulo.server.fs.VolumeChooserEnvironment; import org.apache.accumulo.server.fs.VolumeManager; diff --git a/server/master/src/main/spotbugs/exclude-filter.xml b/server/master/src/main/spotbugs/exclude-filter.xml index 1bce781..b7d3fae 100644 --- a/server/master/src/main/spotbugs/exclude-filter.xml +++ b/server/master/src/main/spotbugs/exclude-filter.xml @@ -22,13 +22,13 @@ </Match> <Match> <!-- shouldn't close the given I/O streams, because they are just wrapped --> - <Class name="org.apache.accumulo.master.tableOps.ImportTable" /> + <Class name="org.apache.accumulo.master.tableOps.tableImport.ImportTable" /> <Method name="checkVersions" params="org.apache.accumulo.master.Master" returns="void" /> <Bug code="OS" pattern="OS_OPEN_STREAM" /> </Match> <Match> <!-- shouldn't close the given I/O streams, because they are just wrapped --> - <Class name="org.apache.accumulo.master.tableOps.WriteExportFiles" /> + <Class name="org.apache.accumulo.master.tableOps.tableExport.WriteExportFiles" /> <Method name="exportTable" params="org.apache.accumulo.server.fs.VolumeManager,org.apache.accumulo.server.ServerContext,java.lang.String,java.lang.String,java.lang.String" returns="void" /> <Bug code="OS" pattern="OS_OPEN_STREAM" /> </Match> diff --git a/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java b/server/master/src/test/java/org/apache/accumulo/master/tableOps/tableImport/ImportTableTest.java similarity index 97% rename from server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java rename to server/master/src/test/java/org/apache/accumulo/master/tableOps/tableImport/ImportTableTest.java index 52568b2..7984206 100644 --- a/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java +++ b/server/master/src/test/java/org/apache/accumulo/master/tableOps/tableImport/ImportTableTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.accumulo.master.tableOps; +package org.apache.accumulo.master.tableOps.tableImport; import static org.junit.Assert.assertEquals;