You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2017/07/18 20:48:08 UTC
[04/10] accumulo git commit: ACCUMULO-3238 Table.ID Namespace.ID
Refactor
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCancelCompaction.java
----------------------------------------------------------------------
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/FinishCancelCompaction.java
index 6ac60b7..adb8039 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/FinishCancelCompaction.java
@@ -16,15 +16,17 @@
*/
package org.apache.accumulo.master.tableOps;
+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;
class FinishCancelCompaction extends MasterRepo {
private static final long serialVersionUID = 1L;
- private String tableId;
- private String namespaceId;
+ private Table.ID tableId;
+ private Namespace.ID namespaceId;
- public FinishCancelCompaction(String namespaceId, String tableId) {
+ public FinishCancelCompaction(Namespace.ID namespaceId, Table.ID tableId) {
this.tableId = tableId;
this.namespaceId = namespaceId;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateNamespace.java
----------------------------------------------------------------------
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/FinishCreateNamespace.java
index fc47c1e..6663892 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/FinishCreateNamespace.java
@@ -49,7 +49,7 @@ class FinishCreateNamespace extends MasterRepo {
@Override
public String getReturn() {
- return namespaceInfo.namespaceId;
+ return namespaceInfo.namespaceId.canonicalID();
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishCreateTable.java
----------------------------------------------------------------------
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/FinishCreateTable.java
index fd7389a..6fd1305 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/FinishCreateTable.java
@@ -53,7 +53,7 @@ class FinishCreateTable extends MasterRepo {
@Override
public String getReturn() {
- return tableInfo.tableId;
+ return tableInfo.tableId.canonicalID();
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/FinishImportTable.java
----------------------------------------------------------------------
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/FinishImportTable.java
index e27b768..4768757 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/FinishImportTable.java
@@ -59,7 +59,7 @@ class FinishImportTable extends MasterRepo {
@Override
public String getReturn() {
- return tableInfo.tableId;
+ return tableInfo.tableId.canonicalID();
}
@Override
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportPopulateZookeeper.java
----------------------------------------------------------------------
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/ImportPopulateZookeeper.java
index e76dd09..329d495 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/ImportPopulateZookeeper.java
@@ -23,6 +23,7 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Namespaces;
import org.apache.accumulo.core.client.impl.TableOperationsImpl;
import org.apache.accumulo.core.client.impl.Tables;
@@ -60,8 +61,8 @@ class ImportPopulateZookeeper extends MasterRepo {
FileSystem ns = fs.getVolumeByPath(path).getFileSystem();
return TableOperationsImpl.getExportedProps(ns, path);
} catch (IOException ioe) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "Error reading table props from " + path + " " + ioe.getMessage());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "Error reading table props from " + path + " " + ioe.getMessage());
}
}
@@ -77,7 +78,7 @@ class ImportPopulateZookeeper extends MasterRepo {
Utils.checkTableDoesNotExist(instance, tableInfo.tableName, tableInfo.tableId, TableOperation.CREATE);
String namespace = Tables.qualify(tableInfo.tableName).getFirst();
- String namespaceId = Namespaces.getNamespaceId(instance, namespace);
+ Namespace.ID namespaceId = Namespaces.getNamespaceId(instance, namespace);
TableManager.getInstance().addTable(tableInfo.tableId, namespaceId, tableInfo.tableName, NodeExistsPolicy.OVERWRITE);
Tables.clearCache(instance);
@@ -87,8 +88,8 @@ class ImportPopulateZookeeper extends MasterRepo {
for (Entry<String,String> entry : getExportedProps(env.getFileSystem()).entrySet())
if (!TablePropUtil.setTableProperty(tableInfo.tableId, entry.getKey(), entry.getValue())) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "Invalid table property " + entry.getKey());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "Invalid table property " + entry.getKey());
}
return new CreateImportDir(tableInfo);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportTable.java
----------------------------------------------------------------------
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/ImportTable.java
index b9b5327..4c64f08 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/ImportTable.java
@@ -27,6 +27,8 @@ import java.util.zip.ZipInputStream;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
import org.apache.accumulo.fate.Repo;
@@ -43,7 +45,7 @@ public class ImportTable extends MasterRepo {
private ImportedTableInfo tableInfo;
- public ImportTable(String user, String tableName, String exportDir, String namespaceId) {
+ public ImportTable(String user, String tableName, String exportDir, Namespace.ID namespaceId) {
tableInfo = new ImportedTableInfo();
tableInfo.tableName = tableName;
tableInfo.user = user;
@@ -70,7 +72,7 @@ public class ImportTable extends MasterRepo {
Utils.idLock.lock();
try {
Instance instance = env.getInstance();
- tableInfo.tableId = Utils.getNextTableId(tableInfo.tableName, instance);
+ tableInfo.tableId = Utils.getNextTableId(tableInfo.tableName, instance, Table.ID.class);
return new ImportSetupPermissions(tableInfo);
} finally {
Utils.idLock.unlock();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/ImportedTableInfo.java
----------------------------------------------------------------------
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/ImportedTableInfo.java
index 7c09eb1..5378cc4 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/ImportedTableInfo.java
@@ -16,6 +16,9 @@
*/
package org.apache.accumulo.master.tableOps;
+import org.apache.accumulo.core.client.impl.Namespace;
+import org.apache.accumulo.core.client.impl.Table;
+
import java.io.Serializable;
class ImportedTableInfo implements Serializable {
@@ -25,7 +28,7 @@ class ImportedTableInfo implements Serializable {
public String exportDir;
public String user;
public String tableName;
- public String tableId;
+ public Table.ID tableId;
public String importDir;
- public String namespaceId;
+ public Namespace.ID namespaceId;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
index 8ed7451..f84ca96 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.thrift.ClientService;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
@@ -65,13 +66,13 @@ class LoadFiles extends MasterRepo {
private static ExecutorService threadPool = null;
private static final Logger log = LoggerFactory.getLogger(LoadFiles.class);
- private String tableId;
+ private Table.ID tableId;
private String source;
private String bulk;
private String errorDir;
private boolean setTime;
- public LoadFiles(String tableId, String source, String bulk, String errorDir, boolean setTime) {
+ public LoadFiles(Table.ID tableId, String source, String bulk, String errorDir, boolean setTime) {
this.tableId = tableId;
this.source = source;
this.bulk = bulk;
@@ -113,8 +114,8 @@ class LoadFiles extends MasterRepo {
// Maybe this is a re-try... clear the flag and try again
fs.delete(writable);
if (!fs.createNewFile(writable))
- throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.BULK_IMPORT, TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY,
- "Unable to write to " + this.errorDir);
+ throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.BULK_IMPORT,
+ TableOperationExceptionType.BULK_BAD_ERROR_DIRECTORY, "Unable to write to " + this.errorDir);
}
fs.delete(writable);
@@ -171,7 +172,7 @@ class LoadFiles extends MasterRepo {
client = ThriftUtil.getTServerClient(server, master, timeInMillis);
List<String> attempt = Collections.singletonList(file);
log.debug("Asking " + server + " to bulk import " + file);
- List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), master.rpcCreds(), tid, tableId, attempt, errorDir, setTime);
+ List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), master.rpcCreds(), tid, tableId.canonicalID(), attempt, errorDir, setTime);
if (fail.isEmpty()) {
loaded.add(file);
} else {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/MapImportFileNames.java
----------------------------------------------------------------------
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/MapImportFileNames.java
index 06bd86a..eec411d 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/MapImportFileNames.java
@@ -95,8 +95,8 @@ class MapImportFileNames extends MasterRepo {
return new PopulateMetadataTable(tableInfo);
} catch (IOException ioe) {
log.warn("{}", ioe.getMessage(), ioe);
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "Error writing mapping file " + path + " " + ioe.getMessage());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "Error writing mapping file " + path + " " + ioe.getMessage());
} finally {
if (mappingsWriter != null)
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/MoveExportedFiles.java
----------------------------------------------------------------------
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/MoveExportedFiles.java
index d6eb7be..a802dcf 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/MoveExportedFiles.java
@@ -50,8 +50,8 @@ class MoveExportedFiles extends MasterRepo {
for (String oldFileName : fileNameMappings.keySet()) {
if (!fs.exists(new Path(tableInfo.exportDir, oldFileName))) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "File referenced by exported table does not exists " + oldFileName);
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "File referenced by exported table does not exists " + oldFileName);
}
}
@@ -67,8 +67,8 @@ class MoveExportedFiles extends MasterRepo {
return new FinishImportTable(tableInfo);
} catch (IOException ioe) {
log.warn("{}", ioe.getMessage(), ioe);
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "Error renaming files " + ioe.getMessage());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "Error renaming files " + ioe.getMessage());
}
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceCleanUp.java
----------------------------------------------------------------------
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/NamespaceCleanUp.java
index 2444374..eebaeaf 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/NamespaceCleanUp.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.master.tableOps;
+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;
@@ -31,9 +32,9 @@ class NamespaceCleanUp extends MasterRepo {
private static final long serialVersionUID = 1L;
- private String namespaceId;
+ private Namespace.ID namespaceId;
- public NamespaceCleanUp(String namespaceId) {
+ public NamespaceCleanUp(Namespace.ID namespaceId) {
this.namespaceId = namespaceId;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/NamespaceInfo.java
----------------------------------------------------------------------
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/NamespaceInfo.java
index aadb24f..c277233 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/NamespaceInfo.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.master.tableOps;
+import org.apache.accumulo.core.client.impl.Namespace;
+
import java.io.Serializable;
import java.util.Map;
@@ -24,7 +26,7 @@ class NamespaceInfo implements Serializable {
private static final long serialVersionUID = 1L;
String namespaceName;
- String namespaceId;
+ Namespace.ID namespaceId;
String user;
public Map<String,String> props;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/PopulateMetadataTable.java
----------------------------------------------------------------------
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/PopulateMetadataTable.java
index ff3ee18..cfd61fe 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/PopulateMetadataTable.java
@@ -134,7 +134,7 @@ class PopulateMetadataTable extends MasterRepo {
String newName = fileNameMappings.get(oldName);
if (newName == null) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT,
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
TableOperationExceptionType.OTHER, "File " + oldName + " does not exist in import dir");
}
@@ -183,8 +183,8 @@ class PopulateMetadataTable extends MasterRepo {
return new MoveExportedFiles(tableInfo);
} catch (IOException ioe) {
log.warn("{}", ioe.getMessage(), ioe);
- throw new AcceptableThriftTableOperationException(tableInfo.tableId, tableInfo.tableName, TableOperation.IMPORT, TableOperationExceptionType.OTHER,
- "Error reading " + path + " " + ioe.getMessage());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableId.canonicalID(), tableInfo.tableName, TableOperation.IMPORT,
+ TableOperationExceptionType.OTHER, "Error reading " + path + " " + ioe.getMessage());
} finally {
if (zis != null) {
try {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameNamespace.java
----------------------------------------------------------------------
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/RenameNamespace.java
index 5373b94..8637406 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/RenameNamespace.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.master.tableOps;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
@@ -33,7 +34,7 @@ import org.slf4j.LoggerFactory;
public class RenameNamespace extends MasterRepo {
private static final long serialVersionUID = 1L;
- private String namespaceId;
+ private Namespace.ID namespaceId;
private String oldName;
private String newName;
@@ -42,7 +43,7 @@ public class RenameNamespace extends MasterRepo {
return Utils.reserveNamespace(namespaceId, id, true, true, TableOperation.RENAME);
}
- public RenameNamespace(String namespaceId, String oldName, String newName) {
+ public RenameNamespace(Namespace.ID namespaceId, String oldName, String newName) {
this.namespaceId = namespaceId;
this.oldName = oldName;
this.newName = newName;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/RenameTable.java
----------------------------------------------------------------------
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/RenameTable.java
index ebd424f..1a6c696 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/RenameTable.java
@@ -22,7 +22,9 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.NamespaceNotFoundException;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
@@ -38,8 +40,8 @@ import org.slf4j.LoggerFactory;
public class RenameTable extends MasterRepo {
private static final long serialVersionUID = 1L;
- private String tableId;
- private String namespaceId;
+ private Table.ID tableId;
+ private Namespace.ID namespaceId;
private String oldTableName;
private String newTableName;
@@ -48,7 +50,7 @@ public class RenameTable extends MasterRepo {
return Utils.reserveNamespace(namespaceId, tid, false, true, TableOperation.RENAME) + Utils.reserveTable(tableId, tid, true, true, TableOperation.RENAME);
}
- public RenameTable(String namespaceId, String tableId, String oldTableName, String newTableName) throws NamespaceNotFoundException {
+ public RenameTable(Namespace.ID namespaceId, Table.ID tableId, String oldTableName, String newTableName) throws NamespaceNotFoundException {
this.namespaceId = namespaceId;
this.tableId = tableId;
this.oldTableName = oldTableName;
@@ -63,7 +65,7 @@ public class RenameTable extends MasterRepo {
// ensure no attempt is made to rename across namespaces
if (newTableName.contains(".") && !namespaceId.equals(Namespaces.getNamespaceId(instance, qualifiedNewTableName.getFirst())))
- throw new AcceptableThriftTableOperationException(tableId, oldTableName, TableOperation.RENAME, TableOperationExceptionType.INVALID_NAME,
+ throw new AcceptableThriftTableOperationException(tableId.canonicalID(), oldTableName, TableOperation.RENAME, TableOperationExceptionType.INVALID_NAME,
"Namespace in new table name does not match the old table name");
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableInfo.java
----------------------------------------------------------------------
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 ab418ae..5727833 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
@@ -16,6 +16,9 @@
*/
package org.apache.accumulo.master.tableOps;
+import org.apache.accumulo.core.client.impl.Namespace;
+import org.apache.accumulo.core.client.impl.Table;
+
import java.io.Serializable;
import java.util.Map;
@@ -24,8 +27,8 @@ class TableInfo implements Serializable {
private static final long serialVersionUID = 1L;
String tableName;
- String tableId;
- String namespaceId;
+ Table.ID tableId;
+ Namespace.ID namespaceId;
char timeType;
String user;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOp.java
----------------------------------------------------------------------
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/TableRangeOp.java
index 2577a13..3470761 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/TableRangeOp.java
@@ -17,6 +17,8 @@
package org.apache.accumulo.master.tableOps;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
import org.apache.accumulo.core.data.impl.KeyExtent;
@@ -36,8 +38,8 @@ public class TableRangeOp extends MasterRepo {
private static final long serialVersionUID = 1L;
- private final String tableId;
- private final String namespaceId;
+ private final Table.ID tableId;
+ private final Namespace.ID namespaceId;
private byte[] startRow;
private byte[] endRow;
private Operation op;
@@ -47,7 +49,8 @@ public class TableRangeOp extends MasterRepo {
return Utils.reserveNamespace(namespaceId, tid, false, true, TableOperation.MERGE) + Utils.reserveTable(tableId, tid, true, true, TableOperation.MERGE);
}
- public TableRangeOp(MergeInfo.Operation op, String namespaceId, String tableId, Text startRow, Text endRow) throws AcceptableThriftTableOperationException {
+ public TableRangeOp(MergeInfo.Operation op, Namespace.ID namespaceId, Table.ID tableId, Text startRow, Text endRow)
+ throws AcceptableThriftTableOperationException {
this.tableId = tableId;
this.namespaceId = namespaceId;
this.startRow = TextUtil.getBytes(startRow);
@@ -67,7 +70,7 @@ public class TableRangeOp extends MasterRepo {
if (start != null && end != null)
if (start.compareTo(end) >= 0)
- throw new AcceptableThriftTableOperationException(tableId, null, TableOperation.MERGE, TableOperationExceptionType.BAD_RANGE,
+ throw new AcceptableThriftTableOperationException(tableId.canonicalID(), null, TableOperation.MERGE, TableOperationExceptionType.BAD_RANGE,
"start row must be less than end row");
env.mustBeOnline(tableId);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/TableRangeOpWait.java
----------------------------------------------------------------------
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/TableRangeOpWait.java
index 0992b5f..4363909 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/TableRangeOpWait.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.master.tableOps;
+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.server.master.state.MergeInfo;
@@ -40,10 +42,10 @@ class TableRangeOpWait extends MasterRepo {
private static final Logger log = LoggerFactory.getLogger(TableRangeOpWait.class);
private static final long serialVersionUID = 1L;
- private String tableId;
- private String namespaceId;
+ private Table.ID tableId;
+ private Namespace.ID namespaceId;
- public TableRangeOpWait(String namespaceId, String tableId) {
+ public TableRangeOpWait(Namespace.ID namespaceId, Table.ID tableId) {
this.tableId = tableId;
this.namespaceId = namespaceId;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/Utils.java
----------------------------------------------------------------------
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 33dbb18..0719b1b 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
@@ -18,6 +18,7 @@ package org.apache.accumulo.master.tableOps;
import static java.nio.charset.StandardCharsets.UTF_8;
+import java.lang.reflect.Constructor;
import java.math.BigInteger;
import java.util.Base64;
import java.util.concurrent.locks.Lock;
@@ -25,8 +26,11 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.impl.AbstractId;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
@@ -46,18 +50,16 @@ public class Utils {
private static final byte[] ZERO_BYTE = new byte[] {'0'};
private static final Logger log = LoggerFactory.getLogger(Utils.class);
- static void checkTableDoesNotExist(Instance instance, String tableName, String tableId, TableOperation operation)
+ static void checkTableDoesNotExist(Instance instance, String tableName, Table.ID tableId, TableOperation operation)
throws AcceptableThriftTableOperationException {
- String id = Tables.getNameToIdMap(instance).get(tableName);
+ Table.ID id = Tables.lookupTableId(instance, tableName);
if (id != null && !id.equals(tableId))
throw new AcceptableThriftTableOperationException(null, tableName, operation, TableOperationExceptionType.EXISTS, null);
}
- static String getNextTableId(String tableName, Instance instance) throws AcceptableThriftTableOperationException {
-
- String tableId = null;
+ static <T extends AbstractId> T getNextTableId(String tableName, Instance instance, Class<T> idClassType) throws AcceptableThriftTableOperationException {
try {
IZooReaderWriter zoo = ZooReaderWriter.getInstance();
final String ntp = ZooUtil.getRoot(instance) + Constants.ZTABLES;
@@ -69,23 +71,25 @@ public class Utils {
return nextId.toString(Character.MAX_RADIX).getBytes(UTF_8);
}
});
- return new String(nid, UTF_8);
+ Constructor<T> constructor = idClassType.getConstructor(String.class);
+ return constructor.newInstance(new String(nid, UTF_8));
+ // return idClassType.cast(new String(nid, UTF_8));
} catch (Exception e1) {
log.error("Failed to assign tableId to " + tableName, e1);
- throw new AcceptableThriftTableOperationException(tableId, tableName, TableOperation.CREATE, TableOperationExceptionType.OTHER, e1.getMessage());
+ throw new AcceptableThriftTableOperationException(null, tableName, TableOperation.CREATE, TableOperationExceptionType.OTHER, e1.getMessage());
}
}
static final Lock tableNameLock = new ReentrantLock();
static final Lock idLock = new ReentrantLock();
- public static long reserveTable(String tableId, long tid, boolean writeLock, boolean tableMustExist, TableOperation op) throws Exception {
+ public static long reserveTable(Table.ID tableId, long tid, boolean writeLock, boolean tableMustExist, TableOperation op) throws Exception {
if (getLock(tableId, tid, writeLock).tryLock()) {
if (tableMustExist) {
Instance instance = HdfsZooInstance.getInstance();
IZooReaderWriter zk = ZooReaderWriter.getInstance();
if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId))
- throw new AcceptableThriftTableOperationException(tableId, "", op, TableOperationExceptionType.NOTFOUND, "Table does not exist");
+ throw new AcceptableThriftTableOperationException(tableId.canonicalID(), "", op, TableOperationExceptionType.NOTFOUND, "Table does not exist");
}
log.info("table " + tableId + " (" + Long.toHexString(tid) + ") locked for " + (writeLock ? "write" : "read") + " operation: " + op);
return 0;
@@ -93,23 +97,24 @@ public class Utils {
return 100;
}
- public static void unreserveTable(String tableId, long tid, boolean writeLock) throws Exception {
+ public static void unreserveTable(Table.ID tableId, long tid, boolean writeLock) throws Exception {
getLock(tableId, tid, writeLock).unlock();
log.info("table " + tableId + " (" + Long.toHexString(tid) + ") unlocked for " + (writeLock ? "write" : "read"));
}
- public static void unreserveNamespace(String namespaceId, long id, boolean writeLock) throws Exception {
+ public static void unreserveNamespace(Namespace.ID namespaceId, long id, boolean writeLock) throws Exception {
getLock(namespaceId, id, writeLock).unlock();
log.info("namespace " + namespaceId + " (" + Long.toHexString(id) + ") unlocked for " + (writeLock ? "write" : "read"));
}
- public static long reserveNamespace(String namespaceId, long id, boolean writeLock, boolean mustExist, TableOperation op) throws Exception {
+ public static long reserveNamespace(Namespace.ID namespaceId, long id, boolean writeLock, boolean mustExist, TableOperation op) throws Exception {
if (getLock(namespaceId, id, writeLock).tryLock()) {
if (mustExist) {
Instance instance = HdfsZooInstance.getInstance();
IZooReaderWriter zk = ZooReaderWriter.getInstance();
if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZNAMESPACES + "/" + namespaceId))
- throw new AcceptableThriftTableOperationException(namespaceId, "", op, TableOperationExceptionType.NAMESPACE_NOTFOUND, "Namespace does not exist");
+ throw new AcceptableThriftTableOperationException(namespaceId.canonicalID(), "", op, TableOperationExceptionType.NAMESPACE_NOTFOUND,
+ "Namespace does not exist");
}
log.info("namespace " + namespaceId + " (" + Long.toHexString(id) + ") locked for " + (writeLock ? "write" : "read") + " operation: " + op);
return 0;
@@ -136,9 +141,9 @@ public class Utils {
ZooReservation.release(ZooReaderWriter.getInstance(), resvPath, String.format("%016x", tid));
}
- private static Lock getLock(String tableId, long tid, boolean writeLock) throws Exception {
+ private static Lock getLock(AbstractId id, long tid, boolean writeLock) throws Exception {
byte[] lockData = String.format("%016x", tid).getBytes(UTF_8);
- ZooQueueLock qlock = new ZooQueueLock(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLE_LOCKS + "/" + tableId, false);
+ ZooQueueLock qlock = new ZooQueueLock(ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLE_LOCKS + "/" + id, false);
Lock lock = DistributedReadWriteLock.recoverLock(qlock, lockData);
if (lock == null) {
DistributedReadWriteLock locker = new DistributedReadWriteLock(qlock, lockData);
@@ -150,14 +155,14 @@ public class Utils {
return lock;
}
- public static Lock getReadLock(String tableId, long tid) throws Exception {
+ public static Lock getReadLock(AbstractId tableId, long tid) throws Exception {
return Utils.getLock(tableId, tid, false);
}
- static void checkNamespaceDoesNotExist(Instance instance, String namespace, String namespaceId, TableOperation operation)
+ static void checkNamespaceDoesNotExist(Instance instance, String namespace, Namespace.ID namespaceId, TableOperation operation)
throws AcceptableThriftTableOperationException {
- String n = Namespaces.getNameToIdMap(instance).get(namespace);
+ Namespace.ID n = Namespaces.lookupNamespaceId(instance, namespace);
if (n != null && !n.equals(namespaceId))
throw new AcceptableThriftTableOperationException(null, namespace, operation, TableOperationExceptionType.NAMESPACE_EXISTS, null);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/tableOps/WriteExportFiles.java
----------------------------------------------------------------------
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/WriteExportFiles.java
index 12f6ae4..921df85 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/WriteExportFiles.java
@@ -36,6 +36,7 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.client.impl.thrift.TableOperation;
import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType;
@@ -72,8 +73,8 @@ class WriteExportFiles extends MasterRepo {
if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) {
Tables.clearCache(conn.getInstance());
if (Tables.getTableState(conn.getInstance(), tableInfo.tableID) != TableState.OFFLINE) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER,
- "Table is not offline");
+ throw new AcceptableThriftTableOperationException(tableInfo.tableID.canonicalID(), tableInfo.tableName, TableOperation.EXPORT,
+ TableOperationExceptionType.OTHER, "Table is not offline");
}
}
}
@@ -107,8 +108,8 @@ class WriteExportFiles extends MasterRepo {
metaScanner.fetchColumnFamily(LogColumnFamily.NAME);
if (metaScanner.iterator().hasNext()) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER,
- "Write ahead logs found for table");
+ throw new AcceptableThriftTableOperationException(tableInfo.tableID.canonicalID(), tableInfo.tableName, TableOperation.EXPORT,
+ TableOperationExceptionType.OTHER, "Write ahead logs found for table");
}
return 0;
@@ -119,8 +120,8 @@ class WriteExportFiles extends MasterRepo {
try {
exportTable(master.getFileSystem(), master, tableInfo.tableName, tableInfo.tableID, tableInfo.exportDir);
} catch (IOException ioe) {
- throw new AcceptableThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER,
- "Failed to create export files " + ioe.getMessage());
+ throw new AcceptableThriftTableOperationException(tableInfo.tableID.canonicalID(), tableInfo.tableName, TableOperation.EXPORT,
+ TableOperationExceptionType.OTHER, "Failed to create export files " + ioe.getMessage());
}
Utils.unreserveNamespace(tableInfo.namespaceID, tid, false);
Utils.unreserveTable(tableInfo.tableID, tid, false);
@@ -134,7 +135,7 @@ class WriteExportFiles extends MasterRepo {
Utils.unreserveTable(tableInfo.tableID, tid, false);
}
- public static void exportTable(VolumeManager fs, AccumuloServerContext context, String tableName, String tableID, String exportDir) throws Exception {
+ public static void exportTable(VolumeManager fs, AccumuloServerContext context, String tableName, Table.ID tableID, String exportDir) throws Exception {
fs.mkdirs(new Path(exportDir));
Path exportMetaFilePath = fs.getVolumeByPath(new Path(exportDir)).getFileSystem().makeQualified(new Path(exportDir, Constants.EXPORT_FILE));
@@ -144,16 +145,15 @@ class WriteExportFiles extends MasterRepo {
BufferedOutputStream bufOut = new BufferedOutputStream(zipOut);
DataOutputStream dataOut = new DataOutputStream(bufOut);
- try {
+ try (OutputStreamWriter osw = new OutputStreamWriter(dataOut, UTF_8)) {
zipOut.putNextEntry(new ZipEntry(Constants.EXPORT_INFO_FILE));
- OutputStreamWriter osw = new OutputStreamWriter(dataOut, UTF_8);
osw.append(ExportTable.EXPORT_VERSION_PROP + ":" + ExportTable.VERSION + "\n");
osw.append("srcInstanceName:" + context.getInstance().getInstanceName() + "\n");
osw.append("srcInstanceID:" + context.getInstance().getInstanceID() + "\n");
osw.append("srcZookeepers:" + context.getInstance().getZooKeepers() + "\n");
osw.append("srcTableName:" + tableName + "\n");
- osw.append("srcTableID:" + tableID + "\n");
+ osw.append("srcTableID:" + tableID.canonicalID() + "\n");
osw.append(ExportTable.DATA_VERSION_PROP + ":" + ServerConstants.DATA_VERSION + "\n");
osw.append("srcCodeVersion:" + Constants.VERSION + "\n");
@@ -197,7 +197,7 @@ class WriteExportFiles extends MasterRepo {
}
}
- private static Map<String,String> exportMetadata(VolumeManager fs, AccumuloServerContext context, String tableID, ZipOutputStream zipOut,
+ private static Map<String,String> exportMetadata(VolumeManager fs, AccumuloServerContext context, Table.ID tableID, ZipOutputStream zipOut,
DataOutputStream dataOut) throws IOException, TableNotFoundException, AccumuloException, AccumuloSecurityException {
zipOut.putNextEntry(new ZipEntry(Constants.EXPORT_METADATA_FILE));
@@ -235,7 +235,7 @@ class WriteExportFiles extends MasterRepo {
return uniqueFiles;
}
- private static void exportConfig(AccumuloServerContext context, String tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException,
+ private static void exportConfig(AccumuloServerContext context, Table.ID tableID, ZipOutputStream zipOut, DataOutputStream dataOut) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException, IOException {
Connector conn = context.getConnector();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java b/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
index 9a22c31..357ddfe 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/util/TableValidators.java
@@ -23,6 +23,7 @@ import java.util.Arrays;
import java.util.List;
import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable;
import org.apache.accumulo.core.replication.ReplicationTable;
@@ -47,15 +48,16 @@ public class TableValidators {
}
};
- public static final Validator<String> VALID_ID = new Validator<String>() {
+ public static final Validator<Table.ID> VALID_ID = new Validator<Table.ID>() {
@Override
- public boolean test(String tableId) {
+ public boolean test(Table.ID tableId) {
return tableId != null
- && (RootTable.ID.equals(tableId) || MetadataTable.ID.equals(tableId) || ReplicationTable.ID.equals(tableId) || tableId.matches(VALID_ID_REGEX));
+ && (RootTable.ID.equals(tableId) || MetadataTable.ID.equals(tableId) || ReplicationTable.ID.equals(tableId) || tableId.canonicalID().matches(
+ VALID_ID_REGEX));
}
@Override
- public String invalidMessage(String tableId) {
+ public String invalidMessage(Table.ID tableId) {
if (tableId == null)
return "Table id cannot be null";
return "Table IDs are base-36 numbers, represented with lowercase alphanumeric digits: " + tableId;
@@ -103,15 +105,15 @@ public class TableValidators {
}
};
- public static final Validator<String> NOT_ROOT_ID = new Validator<String>() {
+ public static final Validator<Table.ID> NOT_ROOT_ID = new Validator<Table.ID>() {
@Override
- public boolean test(String tableId) {
+ public boolean test(Table.ID tableId) {
return !RootTable.ID.equals(tableId);
}
@Override
- public String invalidMessage(String tableId) {
+ public String invalidMessage(Table.ID tableId) {
return "Table cannot be the " + RootTable.NAME + "(Id: " + RootTable.ID + ") table";
}
};
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/test/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssignerHelperTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssignerHelperTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssignerHelperTest.java
index 789a634..a1c5e69 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssignerHelperTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/DistributedWorkQueueWorkAssignerHelperTest.java
@@ -19,6 +19,7 @@ package org.apache.accumulo.master.replication;
import java.util.Map.Entry;
import java.util.UUID;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.replication.ReplicationTarget;
import org.apache.accumulo.server.replication.DistributedWorkQueueWorkAssignerHelper;
import org.apache.hadoop.fs.Path;
@@ -34,7 +35,7 @@ public class DistributedWorkQueueWorkAssignerHelperTest {
@Test
public void createsValidZKNodeName() {
Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID().toString());
- ReplicationTarget target = new ReplicationTarget("cluster1", "table1", "1");
+ ReplicationTarget target = new ReplicationTarget("cluster1", "table1", new Table.ID("1"));
String key = DistributedWorkQueueWorkAssignerHelper.getQueueKey(p.toString(), target);
@@ -44,7 +45,7 @@ public class DistributedWorkQueueWorkAssignerHelperTest {
@Test
public void queueKeySerialization() {
Path p = new Path("/accumulo/wals/tserver+port/" + UUID.randomUUID().toString());
- ReplicationTarget target = new ReplicationTarget("cluster1", "table1", "1");
+ ReplicationTarget target = new ReplicationTarget("cluster1", "table1", new Table.ID("1"));
String key = DistributedWorkQueueWorkAssignerHelper.getQueueKey(p.toString(), target);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
index 45fe959..83f36f4 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/SequentialWorkAssignerTest.java
@@ -26,6 +26,7 @@ import java.util.TreeMap;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.replication.ReplicationConstants;
import org.apache.accumulo.core.replication.ReplicationTarget;
@@ -59,8 +60,8 @@ public class SequentialWorkAssignerTest {
Map<String,String> cluster1Work = new TreeMap<>();
// Two files for cluster1, one for table '1' and another for table '2' we havce assigned work for
- cluster1Work.put("1", DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", "1")));
- cluster1Work.put("2", DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", "2")));
+ cluster1Work.put("1", DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", new Table.ID("1"))));
+ cluster1Work.put("2", DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", new Table.ID("2"))));
queuedWork.put("cluster1", cluster1Work);
@@ -75,11 +76,11 @@ public class SequentialWorkAssignerTest {
// file1 replicated
expect(
zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/"
- + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", "1")))).andReturn(null);
+ + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file1", new ReplicationTarget("cluster1", "1", new Table.ID("1"))))).andReturn(null);
// file2 still needs to replicate
expect(
zooCache.get(ZooUtil.getRoot("instance") + ReplicationConstants.ZOO_WORK_QUEUE + "/"
- + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", "2")))).andReturn(new byte[0]);
+ + DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", new Table.ID("2"))))).andReturn(new byte[0]);
replay(workQueue, zooCache, conn, inst);
@@ -88,6 +89,7 @@ public class SequentialWorkAssignerTest {
verify(workQueue, zooCache, conn, inst);
Assert.assertEquals(1, cluster1Work.size());
- Assert.assertEquals(DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", "2")), cluster1Work.get("2"));
+ Assert.assertEquals(DistributedWorkQueueWorkAssignerHelper.getQueueKey("file2", new ReplicationTarget("cluster1", "2", new Table.ID("2"))),
+ cluster1Work.get("2"));
}
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
index a9af68b..40e3d9e 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/replication/UnorderedWorkAssignerTest.java
@@ -32,6 +32,7 @@ import java.util.UUID;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.replication.ReplicationConstants;
import org.apache.accumulo.core.replication.ReplicationTarget;
@@ -57,7 +58,7 @@ public class UnorderedWorkAssignerTest {
@Test
public void workQueuedUsingFileName() throws Exception {
- ReplicationTarget target = new ReplicationTarget("cluster1", "table1", "1");
+ ReplicationTarget target = new ReplicationTarget("cluster1", "table1", new Table.ID("1"));
DistributedWorkQueue workQueue = createMock(DistributedWorkQueue.class);
Set<String> queuedWork = new HashSet<>();
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/test/java/org/apache/accumulo/master/state/RootTabletStateStoreTest.java
----------------------------------------------------------------------
diff --git a/server/master/src/test/java/org/apache/accumulo/master/state/RootTabletStateStoreTest.java b/server/master/src/test/java/org/apache/accumulo/master/state/RootTabletStateStoreTest.java
index 6497f96..fe7365d 100644
--- a/server/master/src/test/java/org/apache/accumulo/master/state/RootTabletStateStoreTest.java
+++ b/server/master/src/test/java/org/apache/accumulo/master/state/RootTabletStateStoreTest.java
@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.data.impl.KeyExtent;
import org.apache.accumulo.core.metadata.RootTable;
import org.apache.accumulo.server.master.state.Assignment;
@@ -190,7 +191,7 @@ public class RootTabletStateStoreTest {
}
assertEquals(count, 1);
- KeyExtent notRoot = new KeyExtent("0", null, null);
+ KeyExtent notRoot = new KeyExtent(new Table.ID("0"), null, null);
try {
tstore.setLocations(Collections.singletonList(new Assignment(notRoot, server)));
Assert.fail("should not get here");
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/master/src/test/java/org/apache/accumulo/master/tableOps/ImportTableTest.java
----------------------------------------------------------------------
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/ImportTableTest.java
index 1d9c694..ee54820 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/ImportTableTest.java
@@ -18,6 +18,7 @@ package org.apache.accumulo.master.tableOps;
import java.util.Optional;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.master.Master;
import org.apache.accumulo.server.fs.VolumeChooserEnvironment;
import org.apache.accumulo.server.fs.VolumeManager;
@@ -35,7 +36,7 @@ public class ImportTableTest {
Master master = EasyMock.createMock(Master.class);
VolumeManager volumeManager = EasyMock.createMock(VolumeManager.class);
ImportedTableInfo iti = new ImportedTableInfo();
- iti.tableId = "5";
+ iti.tableId = new Table.ID("5");
// Different volumes with different paths
String[] tableDirs = new String[] {"hdfs://nn1:8020/apps/accumulo1/tables", "hdfs://nn2:8020/applications/accumulo/tables"};
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 67ca0df..5cdc80a 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -42,6 +42,7 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.MasterClient;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.conf.SiteConfiguration;
import org.apache.accumulo.core.gc.thrift.GCMonitorService;
@@ -156,7 +157,7 @@ public class Monitor implements HighlyAvailableService {
private static volatile boolean fetching = false;
private static MasterMonitorInfo mmi;
- private static Map<String,Map<ProblemType,Integer>> problemSummary = Collections.emptyMap();
+ private static Map<Table.ID,Map<ProblemType,Integer>> problemSummary = Collections.emptyMap();
private static Exception problemException;
private static GCStatus gcStatus;
@@ -760,7 +761,7 @@ public class Monitor implements HighlyAvailableService {
return problemException;
}
- public static Map<String,Map<ProblemType,Integer>> getProblemSummary() {
+ public static Map<Table.ID,Map<ProblemType,Integer>> getProblemSummary() {
return problemSummary;
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemDetailInformation.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemDetailInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemDetailInformation.java
index 436e3fd..d32ccf5 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemDetailInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemDetailInformation.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.monitor.rest.problems;
+import org.apache.accumulo.core.client.impl.Table;
+
/**
*
* Generates a problem detail as a JSON object
@@ -27,7 +29,7 @@ public class ProblemDetailInformation {
// Variable names become JSON keys
public String tableName;
- public String tableID;
+ public Table.ID tableID;
public String type;
public String server;
@@ -55,7 +57,7 @@ public class ProblemDetailInformation {
* @param exception
* Exception of the problem
*/
- public ProblemDetailInformation(String tableName, String tableID, String type, String server, Long time, String resource, String exception) {
+ public ProblemDetailInformation(String tableName, Table.ID tableID, String type, String server, Long time, String resource, String exception) {
this.tableName = tableName;
this.tableID = tableID;
this.type = type;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
index 53e032f..78fdbad 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemSummaryInformation.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.monitor.rest.problems;
+import org.apache.accumulo.core.client.impl.Table;
+
/**
*
* Generates a problem summary object
@@ -27,7 +29,7 @@ public class ProblemSummaryInformation {
// Variable names become JSON keys
public String tableName;
- public String tableID;
+ public Table.ID tableID;
public Integer fileRead;
public Integer fileWrite;
@@ -49,7 +51,7 @@ public class ProblemSummaryInformation {
* @param tableLoad
* Number of table loads
*/
- public ProblemSummaryInformation(String tableName, String tableID, Integer fileRead, Integer fileWrite, Integer tableLoad) {
+ public ProblemSummaryInformation(String tableName, Table.ID tableID, Integer fileRead, Integer fileWrite, Integer tableLoad) {
this.tableName = tableName;
this.tableID = tableID;
this.fileRead = fileRead;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemsResource.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemsResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemsResource.java
index baff1de..08549a0 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemsResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/problems/ProblemsResource.java
@@ -29,6 +29,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.monitor.Monitor;
import org.apache.accumulo.server.client.HdfsZooInstance;
@@ -60,10 +61,8 @@ public class ProblemsResource {
ProblemSummary problems = new ProblemSummary();
- Map<String,String> tidToNameMap = Tables.getIdToNameMap(HdfsZooInstance.getInstance());
-
if (Monitor.getProblemException() == null) {
- for (Entry<String,Map<ProblemType,Integer>> entry : Monitor.getProblemSummary().entrySet()) {
+ for (Entry<Table.ID,Map<ProblemType,Integer>> entry : Monitor.getProblemSummary().entrySet()) {
Integer readCount = null, writeCount = null, loadCount = null;
for (ProblemType pt : ProblemType.values()) {
@@ -77,7 +76,7 @@ public class ProblemsResource {
}
}
- String tableName = Tables.getPrintableTableNameFromId(tidToNameMap, entry.getKey());
+ String tableName = Tables.getPrintableTableInfoFromId(HdfsZooInstance.getInstance(), entry.getKey());
problems.addProblemSummary(new ProblemSummaryInformation(tableName, entry.getKey(), readCount, writeCount, loadCount));
}
@@ -97,7 +96,7 @@ public class ProblemsResource {
public void clearTableProblems(@QueryParam("s") String tableID) {
Logger log = LoggerFactory.getLogger(Monitor.class);
try {
- ProblemReports.getInstance(Monitor.getContext()).deleteProblemReports(tableID);
+ ProblemReports.getInstance(Monitor.getContext()).deleteProblemReports(new Table.ID(tableID));
} catch (Exception e) {
log.error("Failed to delete problem reports for table " + tableID, e);
}
@@ -114,17 +113,15 @@ public class ProblemsResource {
ProblemDetail problems = new ProblemDetail();
- Map<String,String> tidToNameMap = Tables.getIdToNameMap(HdfsZooInstance.getInstance());
-
if (Monitor.getProblemException() == null) {
- for (Entry<String,Map<ProblemType,Integer>> entry : Monitor.getProblemSummary().entrySet()) {
+ for (Entry<Table.ID,Map<ProblemType,Integer>> entry : Monitor.getProblemSummary().entrySet()) {
ArrayList<ProblemReport> problemReports = new ArrayList<>();
Iterator<ProblemReport> iter = entry.getKey() == null ? ProblemReports.getInstance(Monitor.getContext()).iterator() : ProblemReports.getInstance(
Monitor.getContext()).iterator(entry.getKey());
while (iter.hasNext())
problemReports.add(iter.next());
for (ProblemReport pr : problemReports) {
- String tableName = Tables.getPrintableTableNameFromId(tidToNameMap, pr.getTableName());
+ String tableName = Tables.getPrintableTableInfoFromId(HdfsZooInstance.getInstance(), pr.getTableId());
problems.addProblemDetail(new ProblemDetailInformation(tableName, entry.getKey(), pr.getProblemType().name(), pr.getServer(), pr.getTime(), pr
.getResource(), pr.getException()));
@@ -150,7 +147,7 @@ public class ProblemsResource {
public void clearDetailsProblems(@QueryParam("table") String tableID, @QueryParam("resource") String resource, @QueryParam("ptype") String ptype) {
Logger log = LoggerFactory.getLogger(Monitor.class);
try {
- ProblemReports.getInstance(Monitor.getContext()).deleteProblemReport(tableID, ProblemType.valueOf(ptype), resource);
+ ProblemReports.getInstance(Monitor.getContext()).deleteProblemReport(new Table.ID(tableID), ProblemType.valueOf(ptype), resource);
} catch (Exception e) {
log.error("Failed to delete problem reports for table " + tableID, e);
}
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/replication/ReplicationResource.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/replication/ReplicationResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/replication/ReplicationResource.java
index 2ca28fe..1c37d0a 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/replication/ReplicationResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/replication/ReplicationResource.java
@@ -37,6 +37,8 @@ import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.TableOfflineException;
import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.core.client.impl.Table;
+import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Range;
@@ -109,14 +111,14 @@ public class ReplicationResource {
// Number of files per target we have to replicate
Map<ReplicationTarget,Long> targetCounts = new HashMap<>();
- Map<String,String> tableNameToId = tops.tableIdMap();
- Map<String,String> tableIdToName = invert(tableNameToId);
+ Map<String,Table.ID> tableNameToId = Tables.getNameToIdMap(null);
+ Map<Table.ID,String> tableIdToName = invert(tableNameToId);
for (String table : tops.list()) {
if (MetadataTable.NAME.equals(table) || RootTable.NAME.equals(table)) {
continue;
}
- String localId = tableNameToId.get(table);
+ Table.ID localId = tableNameToId.get(table);
if (null == localId) {
log.trace("Could not determine ID for {}", table);
continue;
@@ -194,9 +196,9 @@ public class ReplicationResource {
return replicationInformation;
}
- protected Map<String,String> invert(Map<String,String> map) {
- Map<String,String> newMap = new HashMap<>(map.size());
- for (Entry<String,String> entry : map.entrySet()) {
+ protected Map<Table.ID,String> invert(Map<String,Table.ID> map) {
+ Map<Table.ID,String> newMap = new HashMap<>(map.size());
+ for (Entry<String,Table.ID> entry : map.entrySet()) {
newMap.put(entry.getValue(), entry.getKey());
}
return newMap;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
index 51e2390..d151046 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TableInformation.java
@@ -16,6 +16,7 @@
*/
package org.apache.accumulo.monitor.rest.tables;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.master.thrift.TableInfo;
/**
@@ -29,7 +30,7 @@ public class TableInformation {
// Variable names become JSON keys
public String tablename;
- public String tableId;
+ public Table.ID tableId;
public String tableState;
public int tablets;
@@ -72,7 +73,7 @@ public class TableInformation {
* @param tableState
* State of the table
*/
- public TableInformation(String tableName, String tableId, String tableState) {
+ public TableInformation(String tableName, Table.ID tableId, String tableState) {
this.tablename = tableName;
this.tableId = tableId;
this.tableState = tableState;
@@ -92,7 +93,7 @@ public class TableInformation {
* @param tableState
* State of the table
*/
- public TableInformation(String tableName, String tableId, TableInfo info, Double holdTime, String tableState) {
+ public TableInformation(String tableName, Table.ID tableId, TableInfo info, Double holdTime, String tableState) {
this.tablename = tableName;
this.tableId = tableId;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
index 8c4f685..11c8b49 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tables/TablesResource.java
@@ -33,7 +33,9 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.apache.accumulo.core.client.Instance;
+import org.apache.accumulo.core.client.impl.Namespace;
import org.apache.accumulo.core.client.impl.Namespaces;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.impl.KeyExtent;
@@ -72,7 +74,7 @@ public class TablesResource {
* @return Table list
*/
private static TablesList generateTables(String namespace) {
- SortedMap<String,String> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
+ SortedMap<String,Namespace.ID> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
TablesList tableNamespace = new TablesList();
@@ -97,22 +99,22 @@ public class TablesResource {
*/
private static TablesList generateTables(TablesList tableNamespace) {
Instance inst = Monitor.getContext().getInstance();
- Map<String,String> tidToNameMap = Tables.getIdToNameMap(inst);
SortedMap<String,TableInfo> tableStats = new TreeMap<>();
if (Monitor.getMmi() != null && Monitor.getMmi().tableMap != null)
for (Entry<String,TableInfo> te : Monitor.getMmi().tableMap.entrySet())
- tableStats.put(Tables.getPrintableTableNameFromId(tidToNameMap, te.getKey()), te.getValue());
+ tableStats.put(Tables.getPrintableTableInfoFromId(inst, new Table.ID(te.getKey())), te.getValue());
Map<String,Double> compactingByTable = TableInfoUtil.summarizeTableStats(Monitor.getMmi());
TableManager tableManager = TableManager.getInstance();
List<TableInformation> tables = new ArrayList<>();
// Add tables to the list
- for (Entry<String,String> entry : Tables.getNameToIdMap(HdfsZooInstance.getInstance()).entrySet()) {
- String tableName = entry.getKey(), tableId = entry.getValue();
+ for (Entry<String,Table.ID> entry : Tables.getNameToIdMap(HdfsZooInstance.getInstance()).entrySet()) {
+ String tableName = entry.getKey();
+ Table.ID tableId = entry.getValue();
TableInfo tableInfo = tableStats.get(tableName);
if (null != tableInfo) {
- Double holdTime = compactingByTable.get(tableId);
+ Double holdTime = compactingByTable.get(tableId.canonicalID());
if (holdTime == null)
holdTime = Double.valueOf(0.);
@@ -173,7 +175,7 @@ public class TablesResource {
@GET
@Path("namespaces/{namespaces}")
public TablesList getTableWithNamespace(@PathParam("namespaces") String namespaceList) {
- SortedMap<String,String> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
+ SortedMap<String,Namespace.ID> namespaces = Namespaces.getNameToIdMap(Monitor.getContext().getInstance());
TablesList tableNamespace = new TablesList();
/*
@@ -193,14 +195,15 @@ public class TablesResource {
/**
* Generates a list of participating tservers for a table
*
- * @param tableId
+ * @param tableIdStr
* Table ID to find participating tservers
* @return List of participating tservers
*/
@Path("{tableId}")
@GET
- public TabletServers getParticipatingTabletServers(@PathParam("tableId") String tableId) throws Exception {
+ public TabletServers getParticipatingTabletServers(@PathParam("tableId") String tableIdStr) throws Exception {
Instance instance = Monitor.getContext().getInstance();
+ Table.ID tableId = new Table.ID(tableIdStr);
TabletServers tabletServers = new TabletServers(Monitor.getMmi().tServerInfo.size());
@@ -244,7 +247,7 @@ public class TablesResource {
status = NO_STATUS;
TableInfo summary = TableInfoUtil.summarizeTableStats(status);
if (tableId != null)
- summary = status.tableMap.get(tableId);
+ summary = status.tableMap.get(tableId.canonicalID());
if (summary == null)
continue;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
index 4db7587..59908ec 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/CurrentOperations.java
@@ -16,6 +16,8 @@
*/
package org.apache.accumulo.monitor.rest.tservers;
+import org.apache.accumulo.core.client.impl.Table;
+
/**
*
* Generates the current operations for the tablet
@@ -28,7 +30,7 @@ public class CurrentOperations {
// Variable names become JSON keys
public String name;
public String tablet;
- public String tableID;
+ public Table.ID tableID;
public long entries;
public double ingest;
public double query;
@@ -69,7 +71,7 @@ public class CurrentOperations {
* @param majorAvgES
* Major compaction average ES
*/
- public CurrentOperations(String name, String ID, String tablet, long entries, double ingest, double query, Double minorAvg, Double minorStdDev,
+ public CurrentOperations(String name, Table.ID ID, String tablet, long entries, double ingest, double query, Double minorAvg, Double minorStdDev,
Double minorAvgES, Double majorAvg, Double majorStdDev, Double majorAvgES) {
this.name = name;
this.tableID = ID;
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
index a7bafc1..8e5607a 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/rest/tservers/TabletServerResource.java
@@ -21,7 +21,6 @@ import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -36,6 +35,7 @@ import javax.ws.rs.core.Response.Status;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.impl.ClientContext;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.impl.KeyExtent;
@@ -288,8 +288,6 @@ public class TabletServerResource {
private List<CurrentOperations> doCurrentOperations(List<TabletStats> tsStats) throws Exception {
- Map<String,String> tidToNameMap = Tables.getIdToNameMap(HdfsZooInstance.getInstance());
-
List<CurrentOperations> currentOperations = new ArrayList<>();
for (TabletStats info : tsStats) {
@@ -302,7 +300,7 @@ public class TabletServerResource {
ActionStatsUpdator.update(total.majors, info.majors);
KeyExtent extent = new KeyExtent(info.extent);
- String tableId = extent.getTableId();
+ Table.ID tableId = extent.getTableId();
MessageDigest digester = MessageDigest.getInstance("MD5");
if (extent.getEndRow() != null && extent.getEndRow().getLength() > 0) {
digester.update(extent.getEndRow().getBytes(), 0, extent.getEndRow().getLength());
@@ -310,7 +308,7 @@ public class TabletServerResource {
String obscuredExtent = Base64.getEncoder().encodeToString(digester.digest());
String displayExtent = String.format("[%s]", obscuredExtent);
- String tableName = Tables.getPrintableTableNameFromId(tidToNameMap, tableId);
+ String tableName = Tables.getPrintableTableInfoFromId(HdfsZooInstance.getInstance(), tableId);
currentOperations.add(new CurrentOperations(tableName, tableId, displayExtent, info.numEntries, info.ingestRate, info.queryRate,
info.minors.num != 0 ? info.minors.elapsed / info.minors.num : null, stddev(info.minors.elapsed, info.minors.num, info.minors.sumDev),
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
index ea337a3..9bcc177 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/view/WebViews.java
@@ -30,6 +30,7 @@ import javax.ws.rs.core.MediaType;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.client.impl.Table;
import org.apache.accumulo.core.client.impl.Tables;
import org.apache.accumulo.core.util.AddressUtil;
import org.apache.accumulo.monitor.Monitor;
@@ -236,7 +237,7 @@ public class WebViews {
@Template(name = "/default.ftl")
public Map<String,Object> getTables(@PathParam("tableID") String tableID) throws TableNotFoundException {
- String table = Tables.getTableName(Monitor.getContext().getInstance(), tableID);
+ String tableName = Tables.getTableName(Monitor.getContext().getInstance(), new Table.ID(tableID));
Map<String,Object> model = getModel();
model.put("title", "Table Status");
@@ -244,7 +245,7 @@ public class WebViews {
model.put("template", "table.ftl");
model.put("js", "table.js");
model.put("tableID", tableID);
- model.put("table", table);
+ model.put("table", tableName);
return model;
}