http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java index ecf48f9..fb7bec0 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/MetadataTableUtil.java @@ -52,6 +52,7 @@ import org.apache.accumulo.core.client.impl.BatchWriterImpl; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.Credentials; import org.apache.accumulo.core.client.impl.ScannerImpl; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Writer; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; @@ -346,7 +347,7 @@ public class MetadataTableUtil { public static void addDeleteEntries(KeyExtent extent, Set<FileRef> datafilesToDelete, ClientContext context) throws IOException { - String tableId = extent.getTableId(); + Table.ID tableId = extent.getTableId(); // TODO could use batch writer,would need to handle failure and retry like update does - ACCUMULO-1294 for (FileRef pathToRemove : datafilesToDelete) { @@ -354,11 +355,11 @@ public class MetadataTableUtil { } } - public static void addDeleteEntry(AccumuloServerContext context, String tableId, String path) throws IOException { + public static void addDeleteEntry(AccumuloServerContext context, Table.ID tableId, String path) throws IOException { update(context, createDeleteMutation(tableId, path), new KeyExtent(tableId, null, null)); } - public static Mutation createDeleteMutation(String tableId, String pathToRemove) throws IOException { + public static Mutation createDeleteMutation(Table.ID tableId, String pathToRemove) throws IOException { Path path = VolumeManagerImpl.get().getFullPath(tableId, pathToRemove); Mutation delFlag = new Mutation(new Text(MetadataSchema.DeletesSection.getRowPrefix() + path.toString())); delFlag.put(EMPTY_TEXT, EMPTY_TEXT, new Value(new byte[] {})); @@ -374,7 +375,7 @@ public class MetadataTableUtil { update(context, zooLock, m, extent); } - public static void splitDatafiles(String tableId, Text midRow, double splitRatio, Map<FileRef,FileUtil.FileInfo> firstAndLastRows, + public static void splitDatafiles(Text midRow, double splitRatio, Map<FileRef,FileUtil.FileInfo> firstAndLastRows, SortedMap<FileRef,DataFileValue> datafiles, SortedMap<FileRef,DataFileValue> lowDatafileSizes, SortedMap<FileRef,DataFileValue> highDatafileSizes, List<FileRef> highDatafilesToRemove) { @@ -417,7 +418,7 @@ public class MetadataTableUtil { } } - public static void deleteTable(String tableId, boolean insertDeletes, ClientContext context, ZooLock lock) throws AccumuloException, IOException { + public static void deleteTable(Table.ID tableId, boolean insertDeletes, ClientContext context, ZooLock lock) throws AccumuloException, IOException { try (Scanner ms = new ScannerImpl(context, MetadataTable.ID, Authorizations.EMPTY); BatchWriter bw = new BatchWriterImpl(context, MetadataTable.ID, new BatchWriterConfig().setMaxMemory(1000000) .setMaxLatency(120000l, TimeUnit.MILLISECONDS).setMaxWriteThreads(2))) { @@ -522,7 +523,7 @@ public class MetadataTableUtil { } } else { - String systemTableToCheck = extent.isMeta() ? RootTable.ID : MetadataTable.ID; + Table.ID systemTableToCheck = extent.isMeta() ? RootTable.ID : MetadataTable.ID; try (Scanner scanner = new ScannerImpl(context, systemTableToCheck, Authorizations.EMPTY)) { scanner.fetchColumnFamily(LogColumnFamily.NAME); scanner.fetchColumnFamily(DataFileColumnFamily.NAME); @@ -594,7 +595,7 @@ public class MetadataTableUtil { } private static Scanner getTabletLogScanner(ClientContext context, KeyExtent extent) { - String tableId = MetadataTable.ID; + Table.ID tableId = MetadataTable.ID; if (extent.isMeta()) tableId = RootTable.ID; Scanner scanner = new ScannerImpl(context, tableId, Authorizations.EMPTY); @@ -675,7 +676,7 @@ public class MetadataTableUtil { } } - private static void getFiles(Set<String> files, Map<Key,Value> tablet, String srcTableId) { + private static void getFiles(Set<String> files, Map<Key,Value> tablet, Table.ID srcTableId) { for (Entry<Key,Value> entry : tablet.entrySet()) { if (entry.getKey().getColumnFamily().equals(DataFileColumnFamily.NAME)) { String cf = entry.getKey().getColumnQualifier().toString(); @@ -687,7 +688,7 @@ public class MetadataTableUtil { } } - private static Mutation createCloneMutation(String srcTableId, String tableId, Map<Key,Value> tablet) { + private static Mutation createCloneMutation(Table.ID srcTableId, Table.ID tableId, Map<Key,Value> tablet) { KeyExtent ke = new KeyExtent(tablet.keySet().iterator().next().getRow(), (Text) null); Mutation m = new Mutation(KeyExtent.getMetadataEntry(tableId, ke.getEndRow())); @@ -709,7 +710,7 @@ public class MetadataTableUtil { return m; } - private static Scanner createCloneScanner(String tableName, String tableId, Connector conn) throws TableNotFoundException { + private static Scanner createCloneScanner(String tableName, Table.ID tableId, Connector conn) throws TableNotFoundException { if (tableId.equals(MetadataTable.ID)) tableName = RootTable.NAME; Scanner mscanner = new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY)); @@ -724,7 +725,7 @@ public class MetadataTableUtil { } @VisibleForTesting - public static void initializeClone(String tableName, String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, + public static void initializeClone(String tableName, Table.ID srcTableId, Table.ID tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, MutationsRejectedException { TabletIterator ti; if (srcTableId.equals(MetadataTable.ID)) @@ -742,11 +743,11 @@ public class MetadataTableUtil { } private static int compareEndRows(Text endRow1, Text endRow2) { - return new KeyExtent("0", endRow1, null).compareTo(new KeyExtent("0", endRow2, null)); + return new KeyExtent(new Table.ID("0"), endRow1, null).compareTo(new KeyExtent(new Table.ID("0"), endRow2, null)); } @VisibleForTesting - public static int checkClone(String tableName, String srcTableId, String tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, + public static int checkClone(String tableName, Table.ID srcTableId, Table.ID tableId, Connector conn, BatchWriter bw) throws TableNotFoundException, MutationsRejectedException { TabletIterator srcIter = new TabletIterator(createCloneScanner(tableName, srcTableId, conn), new KeyExtent(srcTableId, null, null).toMetadataRange(), true, true); @@ -830,7 +831,7 @@ public class MetadataTableUtil { return rewrites; } - public static void cloneTable(ClientContext context, String srcTableId, String tableId, VolumeManager volumeManager) throws Exception { + public static void cloneTable(ClientContext context, Table.ID srcTableId, Table.ID tableId, VolumeManager volumeManager) throws Exception { Connector conn = context.getConnector(); try (BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig())) { @@ -892,7 +893,7 @@ public class MetadataTableUtil { update(context, zooLock, m, extent); } - public static void removeBulkLoadEntries(Connector conn, String tableId, long tid) throws Exception { + public static void removeBulkLoadEntries(Connector conn, Table.ID tableId, long tid) throws Exception { try (Scanner mscanner = new IsolatedScanner(conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)); BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig())) { mscanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange()); @@ -957,7 +958,7 @@ public class MetadataTableUtil { // new KeyExtent is only added to force update to write to the metadata table, not the root table // because bulk loads aren't supported to the metadata table - update(context, m, new KeyExtent("anythingNotMetadata", null, null)); + update(context, m, new KeyExtent(new Table.ID("anythingNotMetadata"), null, null)); } public static void removeBulkLoadInProgressFlag(AccumuloServerContext context, String path) { @@ -967,7 +968,7 @@ public class MetadataTableUtil { // new KeyExtent is only added to force update to write to the metadata table, not the root table // because bulk loads aren't supported to the metadata table - update(context, m, new KeyExtent("anythingNotMetadata", null, null)); + update(context, m, new KeyExtent(new Table.ID("anythingNotMetadata"), null, null)); } /** @@ -1009,7 +1010,7 @@ public class MetadataTableUtil { public static void moveMetaDeleteMarkersFrom14(ClientContext context) { // new KeyExtent is only added to force update to write to the metadata table, not the root table - KeyExtent notMetadata = new KeyExtent("anythingNotMetadata", null, null); + KeyExtent notMetadata = new KeyExtent(new Table.ID("anythingNotMetadata"), null, null); // move delete markers from the normal delete keyspace to the root tablet delete keyspace if the files are for the !METADATA table try (Scanner scanner = new ScannerImpl(context, MetadataTable.ID, Authorizations.EMPTY)) {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java index 85cc484..df72d79 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/NamespacePropUtil.java @@ -19,6 +19,7 @@ package org.apache.accumulo.server.util; import static java.nio.charset.StandardCharsets.UTF_8; import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; @@ -28,7 +29,7 @@ import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.zookeeper.KeeperException; public class NamespacePropUtil { - public static boolean setNamespaceProperty(String namespaceId, String property, String value) throws KeeperException, InterruptedException { + public static boolean setNamespaceProperty(Namespace.ID namespaceId, String property, String value) throws KeeperException, InterruptedException { if (!isPropertyValid(property, value)) return false; @@ -51,12 +52,12 @@ public class NamespacePropUtil { return true; } - public static void removeNamespaceProperty(String namespaceId, String property) throws InterruptedException, KeeperException { + public static void removeNamespaceProperty(Namespace.ID namespaceId, String property) throws InterruptedException, KeeperException { String zPath = getPath(namespaceId) + "/" + property; ZooReaderWriter.getInstance().recursiveDelete(zPath, NodeMissingPolicy.SKIP); } - private static String getPath(String namespaceId) { + private static String getPath(Namespace.ID namespaceId) { return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZNAMESPACES + "/" + namespaceId + Constants.ZNAMESPACE_CONF; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java b/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java index fd3077b..bd08b05 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/RandomizeVolumes.java @@ -32,6 +32,7 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Value; @@ -80,11 +81,12 @@ public class RandomizeVolumes { log.error("There are not enough volumes configured"); return 1; } - String tableId = c.tableOperations().tableIdMap().get(tableName); - if (null == tableId) { + String tblStr = c.tableOperations().tableIdMap().get(tableName); + if (null == tblStr) { log.error("Could not determine the table ID for table " + tableName); return 2; } + Table.ID tableId = new Table.ID(tblStr); TableState tableState = TableManager.getInstance().getTableState(tableId); if (TableState.OFFLINE != tableState) { log.info("Taking " + tableName + " offline"); @@ -103,7 +105,7 @@ public class RandomizeVolumes { String directory; if (oldLocation.contains(":")) { String[] parts = oldLocation.split(Path.SEPARATOR); - String tableIdEntry = parts[parts.length - 2]; + Table.ID tableIdEntry = new Table.ID(parts[parts.length - 2]); if (!tableIdEntry.equals(tableId)) { log.error("Unexpected table id found: " + tableIdEntry + ", expected " + tableId + "; skipping"); continue; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java b/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java index e3f531d..e1a1b29 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/RemoveEntriesForMissingFiles.java @@ -35,6 +35,7 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.Credentials; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Mutation; @@ -120,18 +121,18 @@ public class RemoveEntriesForMissingFiles { } } - private static int checkTable(ClientContext context, String table, Range range, boolean fix) throws Exception { + private static int checkTable(ClientContext context, String tableName, Range range, boolean fix) throws Exception { @SuppressWarnings({"rawtypes"}) Map cache = new LRUMap(100000); Set<Path> processing = new HashSet<>(); ExecutorService threadPool = Executors.newFixedThreadPool(16); - System.out.printf("Scanning : %s %s\n", table, range); + System.out.printf("Scanning : %s %s\n", tableName, range); VolumeManager fs = VolumeManagerImpl.get(); Connector connector = context.getConnector(); - Scanner metadata = connector.createScanner(table, Authorizations.EMPTY); + Scanner metadata = connector.createScanner(tableName, Authorizations.EMPTY); metadata.setRange(range); metadata.fetchColumnFamily(DataFileColumnFamily.NAME); int count = 0; @@ -197,7 +198,7 @@ public class RemoveEntriesForMissingFiles { } else if (tableName.equals(MetadataTable.NAME)) { return checkTable(context, RootTable.NAME, MetadataSchema.TabletsSection.getRange(), fix); } else { - String tableId = Tables.getTableId(context.getInstance(), tableName); + Table.ID tableId = Tables.getTableId(context.getInstance(), tableName); Range range = new KeyExtent(tableId, null, null).toMetadataRange(); return checkTable(context, MetadataTable.NAME, range, fix); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java index f234593..9f5abe6 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/ReplicationTableUtil.java @@ -194,7 +194,7 @@ public class ReplicationTableUtil { private static Mutation createUpdateMutation(Text row, Value v, KeyExtent extent) { Mutation m = new Mutation(row); - m.put(MetadataSchema.ReplicationSection.COLF, new Text(extent.getTableId()), v); + m.put(MetadataSchema.ReplicationSection.COLF, new Text(extent.getTableId().getUtf8()), v); return m; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java index 84d76cb..774acf7 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java @@ -34,6 +34,7 @@ import java.util.TreeSet; 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.Table; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.data.Key; @@ -177,7 +178,7 @@ public class TableDiskUsage { throw new RuntimeException(e); } mdScanner.fetchColumnFamily(DataFileColumnFamily.NAME); - mdScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange()); + mdScanner.setRange(new KeyExtent(new Table.ID(tableId), null, null).toMetadataRange()); if (!mdScanner.iterator().hasNext()) { emptyTableIds.add(tableId); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/TablePropUtil.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TablePropUtil.java b/server/base/src/main/java/org/apache/accumulo/server/util/TablePropUtil.java index ab14311..35e42d9 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/TablePropUtil.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/TablePropUtil.java @@ -19,6 +19,7 @@ package org.apache.accumulo.server.util; import static java.nio.charset.StandardCharsets.UTF_8; import org.apache.accumulo.core.Constants; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; @@ -28,7 +29,7 @@ import org.apache.accumulo.server.zookeeper.ZooReaderWriter; import org.apache.zookeeper.KeeperException; public class TablePropUtil { - public static boolean setTableProperty(String tableId, String property, String value) throws KeeperException, InterruptedException { + public static boolean setTableProperty(Table.ID tableId, String property, String value) throws KeeperException, InterruptedException { if (!isPropertyValid(property, value)) return false; @@ -51,12 +52,12 @@ public class TablePropUtil { return true; } - public static void removeTableProperty(String tableId, String property) throws InterruptedException, KeeperException { + public static void removeTableProperty(Table.ID tableId, String property) throws InterruptedException, KeeperException { String zPath = getTablePath(tableId) + "/" + property; ZooReaderWriter.getInstance().recursiveDelete(zPath, NodeMissingPolicy.SKIP); } - private static String getTablePath(String tablename) { - return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLES + "/" + tablename + Constants.ZTABLE_CONF; + private static String getTablePath(Table.ID tableId) { + return ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZTABLES + "/" + tableId.canonicalID() + Constants.ZTABLE_CONF; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/TabletIterator.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TabletIterator.java b/server/base/src/main/java/org/apache/accumulo/server/util/TabletIterator.java index 9569f49..50e9e58 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/TabletIterator.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/TabletIterator.java @@ -28,6 +28,7 @@ import java.util.TreeMap; import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.PartialKey; import org.apache.accumulo.core.data.Range; @@ -119,8 +120,8 @@ public class TabletIterator implements Iterator<Map<Key,Value>> { lastEndRow = new KeyExtent(lastTablet, (Text) null).getEndRow(); // do table transition sanity check - String lastTable = new KeyExtent(lastTablet, (Text) null).getTableId(); - String currentTable = new KeyExtent(prevEndRowKey.getRow(), (Text) null).getTableId(); + Table.ID lastTable = new KeyExtent(lastTablet, (Text) null).getTableId(); + Table.ID currentTable = new KeyExtent(prevEndRowKey.getRow(), (Text) null).getTableId(); if (!lastTable.equals(currentTable) && (per != null || lastEndRow != null)) { log.info("Metadata inconsistency on table transition : " + lastTable + " " + currentTable + " " + per + " " + lastEndRow); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java ---------------------------------------------------------------------- diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java b/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java index bf072f3..da33888 100644 --- a/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java +++ b/server/base/src/main/java/org/apache/accumulo/server/util/VerifyTabletAssignments.java @@ -33,6 +33,7 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.Credentials; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.Range; @@ -89,7 +90,7 @@ public class VerifyTabletAssignments { TreeMap<KeyExtent,String> tabletLocations = new TreeMap<>(); - String tableId = Tables.getNameToIdMap(context.getInstance()).get(tableName); + Table.ID tableId = Tables.lookupTableId(context.getInstance(), tableName); MetadataServicer.forTableId(context, tableId).getTabletLocations(tabletLocations); final HashSet<KeyExtent> failures = new HashSet<>(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java index cb2bd75..5c69521 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/client/BulkImporterTest.java @@ -28,6 +28,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.impl.ClientContext; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.impl.TabletLocator.TabletLocation; import org.apache.accumulo.core.conf.DefaultConfiguration; @@ -52,7 +53,7 @@ import org.junit.Test; public class BulkImporterTest { static final SortedSet<KeyExtent> fakeMetaData = new TreeSet<>(); - static final String tableId = "1"; + static final Table.ID tableId = new Table.ID("1"); static { fakeMetaData.add(new KeyExtent(tableId, new Text("a"), null)); @@ -163,19 +164,19 @@ public class BulkImporterTest { // a correct startRow so that findOverlappingTablets works as intended. // 1;2;1 - KeyExtent extent = new KeyExtent("1", new Text("2"), new Text("1")); + KeyExtent extent = new KeyExtent(new Table.ID("1"), new Text("2"), new Text("1")); Assert.assertEquals(new Text("1\0"), BulkImporter.getStartRowForExtent(extent)); // 1;2< - extent = new KeyExtent("1", new Text("2"), null); + extent = new KeyExtent(new Table.ID("1"), new Text("2"), null); Assert.assertEquals(null, BulkImporter.getStartRowForExtent(extent)); // 1<< - extent = new KeyExtent("1", null, null); + extent = new KeyExtent(new Table.ID("1"), null, null); Assert.assertEquals(null, BulkImporter.getStartRowForExtent(extent)); // 1;8;7777777 - extent = new KeyExtent("1", new Text("8"), new Text("7777777")); + extent = new KeyExtent(new Table.ID("1"), new Text("8"), new Text("7777777")); Assert.assertEquals(new Text("7777777\0"), BulkImporter.getStartRowForExtent(extent)); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java index c0e4bc6..6a24333 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java @@ -36,6 +36,7 @@ import java.util.function.Predicate; import org.apache.accumulo.core.Constants; 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.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationObserver; @@ -47,7 +48,7 @@ import org.junit.Before; import org.junit.Test; public class NamespaceConfigurationTest { - private static final String NSID = "namespace"; + private static final Namespace.ID NSID = new Namespace.ID("namespace"); private static final String ZOOKEEPERS = "localhost"; private static final int ZK_SESSION_TIMEOUT = 120000; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java index 57953c2..602f908 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/conf/ServerConfigurationFactoryTest.java @@ -29,6 +29,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Namespace; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.conf.SiteConfiguration; @@ -113,7 +114,7 @@ public class ServerConfigurationFactoryTest { assertNotNull(c); } - private static final String NSID = "NAMESPACE"; + private static final Namespace.ID NSID = new Namespace.ID("NAMESPACE"); @Test public void testGetNamespaceConfiguration() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java b/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java index 53a56c6..54f72ab 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java @@ -34,6 +34,7 @@ import java.util.function.Predicate; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.ConfigurationObserver; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.core.zookeeper.ZooUtil; @@ -43,7 +44,7 @@ import org.junit.Before; import org.junit.Test; public class TableConfigurationTest { - private static final String TID = "table"; + private static final Table.ID TID = new Table.ID("table"); private static final String ZOOKEEPERS = "localhost"; private static final int ZK_SESSION_TIMEOUT = 120000; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java index ffac2c0..832134f 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/fs/VolumeManagerImplTest.java @@ -20,6 +20,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.conf.ConfigurationCopy; import org.apache.accumulo.core.conf.Property; import org.apache.accumulo.server.fs.VolumeManager.FileType; @@ -112,7 +113,7 @@ public class VolumeManagerImplTest { conf.set(Property.INSTANCE_VOLUMES, StringUtils.join(volumes, ",")); conf.set(Property.GENERAL_VOLUME_CHOOSER, WrongVolumeChooser.class.getName()); VolumeManager vm = VolumeManagerImpl.get(conf); - VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(Optional.of("sometable")); + VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(Optional.of(new Table.ID("sometable"))); String choice = vm.choose(chooserEnv, volumes.toArray(new String[0])); Assert.assertTrue("shouldn't see invalid options from misbehaving chooser.", volumes.contains(choice)); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java index 614fd4b..b44385b 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/BaseHostRegexTableLoadBalancerTest.java @@ -34,7 +34,8 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.client.impl.ClientContext; -import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Namespace; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.TableOperationsImpl; import org.apache.accumulo.core.client.security.tokens.AuthenticationToken; import org.apache.accumulo.core.conf.AccumuloConfiguration; @@ -109,11 +110,11 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL } - protected static class Table { + protected static class TestTable { private String tableName; - private String id; + private Table.ID id; - Table(String tableName, String id) { + TestTable(String tableName, Table.ID id) { this.tableName = tableName; this.id = id; } @@ -122,7 +123,7 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL return tableName; } - public String getId() { + public Table.ID getId() { return id; } } @@ -149,9 +150,9 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL } @Override - public TableConfiguration getTableConfiguration(String tableId) { + public TableConfiguration getTableConfiguration(Table.ID tableId) { // create a dummy namespaceConfiguration to satisfy requireNonNull in TableConfiguration constructor - NamespaceConfiguration dummyConf = new NamespaceConfiguration(Namespaces.DEFAULT_NAMESPACE_ID, this.instance, DefaultConfiguration.getInstance()); + NamespaceConfiguration dummyConf = new NamespaceConfiguration(Namespace.ID.DEFAULT, this.instance, DefaultConfiguration.getInstance()); return new TableConfiguration(this.instance, tableId, dummyConf) { @Override public String get(Property property) { @@ -170,9 +171,9 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL } } - protected static final Table FOO = new Table("foo", "1"); - protected static final Table BAR = new Table("bar", "2"); - protected static final Table BAZ = new Table("baz", "3"); + protected static final TestTable FOO = new TestTable("foo", new Table.ID("1")); + protected static final TestTable BAR = new TestTable("bar", new Table.ID("2")); + protected static final TestTable BAZ = new TestTable("baz", new Table.ID("3")); protected final TestInstance instance = new TestInstance(); protected final TestServerConfigurationFactory factory = new TestServerConfigurationFactory(instance); @@ -234,7 +235,7 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL } protected boolean tabletInBounds(KeyExtent ke, TServerInstance tsi) { - String tid = ke.getTableId().toString(); + String tid = ke.getTableId().canonicalID(); String host = tsi.host(); if (tid.equals("1") && (host.equals("192.168.0.1") || host.equals("192.168.0.2") || host.equals("192.168.0.3") || host.equals("192.168.0.4") || host.equals("192.168.0.5"))) { @@ -257,9 +258,9 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL @Override public Map<String,String> tableIdMap() { HashMap<String,String> tables = new HashMap<>(); - tables.put(FOO.getTableName(), FOO.getId()); - tables.put(BAR.getTableName(), BAR.getId()); - tables.put(BAZ.getTableName(), BAZ.getId()); + tables.put(FOO.getTableName(), FOO.getId().canonicalID()); + tables.put(BAR.getTableName(), BAR.getId().canonicalID()); + tables.put(BAZ.getTableName(), BAZ.getId().canonicalID()); return tables; } @@ -275,7 +276,7 @@ public abstract class BaseHostRegexTableLoadBalancerTest extends HostRegexTableL } @Override - protected TabletBalancer getBalancerForTable(String table) { + protected TabletBalancer getBalancerForTable(Table.ID table) { return new DefaultLoadBalancer(); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java index 2697d75..bd66e80 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/ChaoticLoadBalancerTest.java @@ -28,6 +28,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TableInfo; @@ -50,10 +51,10 @@ public class ChaoticLoadBalancerTest { TabletServerStatus result = new TabletServerStatus(); result.tableMap = new HashMap<>(); for (KeyExtent extent : extents) { - String table = extent.getTableId(); - TableInfo info = result.tableMap.get(table); + Table.ID table = extent.getTableId(); + TableInfo info = result.tableMap.get(table.canonicalID()); if (info == null) - result.tableMap.put(table, info = new TableInfo()); + result.tableMap.put(table.canonicalID(), info = new TableInfo()); info.onlineTablets++; info.recs = info.onlineTablets; info.ingestRate = 123.; @@ -68,7 +69,7 @@ public class ChaoticLoadBalancerTest { class TestChaoticLoadBalancer extends ChaoticLoadBalancer { @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String table) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID table) throws ThriftSecurityException, TException { List<TabletStats> result = new ArrayList<>(); for (KeyExtent extent : servers.get(tserver).extents) { if (extent.getTableId().equals(table)) { @@ -154,7 +155,7 @@ public class ChaoticLoadBalancerTest { } private static KeyExtent makeExtent(String table, String end, String prev) { - return new KeyExtent(table, toText(end), toText(prev)); + return new KeyExtent(new Table.ID(table), toText(end), toText(prev)); } private static Text toText(String value) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java index e0bd2d1..98d7097 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/DefaultLoadBalancerTest.java @@ -31,6 +31,7 @@ import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TableInfo; @@ -54,10 +55,10 @@ public class DefaultLoadBalancerTest { TabletServerStatus result = new TabletServerStatus(); result.tableMap = new HashMap<>(); for (KeyExtent extent : extents) { - String table = extent.getTableId(); - TableInfo info = result.tableMap.get(table); + Table.ID tableId = extent.getTableId(); + TableInfo info = result.tableMap.get(tableId.canonicalID()); if (info == null) - result.tableMap.put(table, info = new TableInfo()); + result.tableMap.put(tableId.canonicalID(), info = new TableInfo()); info.onlineTablets++; info.recs = info.onlineTablets; info.ingestRate = 123.; @@ -73,7 +74,7 @@ public class DefaultLoadBalancerTest { class TestDefaultLoadBalancer extends DefaultLoadBalancer { @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String table) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID table) throws ThriftSecurityException, TException { List<TabletStats> result = new ArrayList<>(); for (KeyExtent extent : servers.get(tserver).extents) { if (extent.getTableId().equals(table)) { @@ -266,7 +267,7 @@ public class DefaultLoadBalancerTest { for (FakeTServer server : servers.values()) { Map<String,Integer> counts = new HashMap<>(); for (KeyExtent extent : server.extents) { - String t = extent.getTableId(); + String t = extent.getTableId().canonicalID(); if (counts.get(t) == null) counts.put(t, 0); counts.put(t, counts.get(t) + 1); @@ -279,7 +280,7 @@ public class DefaultLoadBalancerTest { } private static KeyExtent makeExtent(String table, String end, String prev) { - return new KeyExtent(table, toText(end), toText(prev)); + return new KeyExtent(new Table.ID(table), toText(end), toText(prev)); } private static Text toText(String value) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/GroupBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/GroupBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/GroupBalancerTest.java index 24d8fe2..e7ebe12 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/GroupBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/GroupBalancerTest.java @@ -29,6 +29,7 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.function.Function; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.master.thrift.TabletServerStatus; import org.apache.accumulo.core.util.MapCounter; @@ -67,7 +68,7 @@ public class GroupBalancerTest { public void addTablet(String er, String location) { TServerInstance tsi = new TServerInstance(location, 6); - tabletLocs.put(new KeyExtent("b", er == null ? null : new Text(er), null), new TServerInstance(location, 6)); + tabletLocs.put(new KeyExtent(new Table.ID("b"), er == null ? null : new Text(er), null), new TServerInstance(location, 6)); tservers.add(tsi); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerReconfigurationTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerReconfigurationTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerReconfigurationTest.java index 9c27142..d637dad 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerReconfigurationTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerReconfigurationTest.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.tabletserver.thrift.TabletStats; @@ -90,11 +91,11 @@ public class HostRegexTableLoadBalancerReconfigurationTest extends BaseHostRegex } @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { List<TabletStats> tablets = new ArrayList<>(); // Report assignment information for (Entry<KeyExtent,TServerInstance> e : this.assignments.entrySet()) { - if (e.getValue().equals(tserver) && e.getKey().getTableId().toString().equals(tableId)) { + if (e.getValue().equals(tserver) && e.getKey().getTableId().equals(tableId)) { TabletStats ts = new TabletStats(); ts.setExtent(e.getKey().toThrift()); tablets.add(ts); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerTest.java index 5a8fa0b..ca128e2 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/HostRegexTableLoadBalancerTest.java @@ -29,6 +29,7 @@ import java.util.function.Predicate; import java.util.regex.Pattern; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationCopy; @@ -61,7 +62,7 @@ public class HostRegexTableLoadBalancerTest extends BaseHostRegexTableLoadBalanc Assert.assertEquals(Pattern.compile("r01.*").pattern(), patterns.get(FOO.getTableName()).pattern()); Assert.assertTrue(patterns.containsKey(BAR.getTableName())); Assert.assertEquals(Pattern.compile("r02.*").pattern(), patterns.get(BAR.getTableName()).pattern()); - Map<String,String> tids = this.getTableIdToTableName(); + Map<Table.ID,String> tids = this.getTableIdToTableName(); Assert.assertEquals(3, tids.size()); Assert.assertTrue(tids.containsKey(FOO.getId())); Assert.assertEquals(FOO.getTableName(), tids.get(FOO.getId())); @@ -117,7 +118,7 @@ public class HostRegexTableLoadBalancerTest extends BaseHostRegexTableLoadBalanc init(new AccumuloServerContext(instance, new TestServerConfigurationFactory(instance) { @Override - public TableConfiguration getTableConfiguration(String tableId) { + public TableConfiguration getTableConfiguration(Table.ID tableId) { NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespaces.DEFAULT_NAMESPACE_ID, this.instance, DefaultConfiguration.getInstance()); return new TableConfiguration(instance, tableId, defaultConf) { HashMap<String,String> tableProperties = new HashMap<>(); @@ -189,7 +190,7 @@ public class HostRegexTableLoadBalancerTest extends BaseHostRegexTableLoadBalanc } @Override - public TableConfiguration getTableConfiguration(String tableId) { + public TableConfiguration getTableConfiguration(Table.ID tableId) { NamespaceConfiguration defaultConf = new NamespaceConfiguration(Namespaces.DEFAULT_NAMESPACE_ID, this.instance, DefaultConfiguration.getInstance()); return new TableConfiguration(instance, tableId, defaultConf) { HashMap<String,String> tableProperties = new HashMap<>(); @@ -360,13 +361,13 @@ public class HostRegexTableLoadBalancerTest extends BaseHostRegexTableLoadBalanc } @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { // Report incorrect information so that balance will create an assignment List<TabletStats> tablets = new ArrayList<>(); if (tableId.equals(BAR.getId()) && tserver.host().equals("192.168.0.1")) { // Report that we have a bar tablet on this server TKeyExtent tke = new TKeyExtent(); - tke.setTable(BAR.getId().getBytes()); + tke.setTable(BAR.getId().getUtf8()); tke.setEndRow("11".getBytes()); tke.setPrevEndRow("10".getBytes()); TabletStats ts = new TabletStats(); @@ -375,7 +376,7 @@ public class HostRegexTableLoadBalancerTest extends BaseHostRegexTableLoadBalanc } else if (tableId.equals(FOO.getId()) && tserver.host().equals("192.168.0.6")) { // Report that we have a foo tablet on this server TKeyExtent tke = new TKeyExtent(); - tke.setTable(FOO.getId().getBytes()); + tke.setTable(FOO.getId().getUtf8()); tke.setEndRow("1".getBytes()); tke.setPrevEndRow("0".getBytes()); TabletStats ts = new TabletStats(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java index 8856e08..928f2a2 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/balancer/TableLoadBalancerTest.java @@ -29,6 +29,7 @@ import java.util.TreeMap; import java.util.UUID; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.admin.TableOperations; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException; import org.apache.accumulo.core.conf.DefaultConfiguration; import org.apache.accumulo.core.conf.Property; @@ -76,11 +77,11 @@ public class TableLoadBalancerTest { static SortedMap<TServerInstance,TabletServerStatus> state; - static List<TabletStats> generateFakeTablets(TServerInstance tserver, String tableId) { + static List<TabletStats> generateFakeTablets(TServerInstance tserver, Table.ID tableId) { List<TabletStats> result = new ArrayList<>(); TabletServerStatus tableInfo = state.get(tserver); // generate some fake tablets - for (int i = 0; i < tableInfo.tableMap.get(tableId).onlineTablets; i++) { + for (int i = 0; i < tableInfo.tableMap.get(tableId.canonicalID()).onlineTablets; i++) { TabletStats stats = new TabletStats(); stats.extent = new KeyExtent(tableId, new Text(tserver.host() + String.format("%03d", i + 1)), new Text(tserver.host() + String.format("%03d", i))) .toThrift(); @@ -91,7 +92,7 @@ public class TableLoadBalancerTest { static class DefaultLoadBalancer extends org.apache.accumulo.server.master.balancer.DefaultLoadBalancer { - public DefaultLoadBalancer(String table) { + public DefaultLoadBalancer(Table.ID table) { super(table); } @@ -99,7 +100,7 @@ public class TableLoadBalancerTest { public void init(AccumuloServerContext context) {} @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { return generateFakeTablets(tserver, tableId); } } @@ -113,13 +114,13 @@ public class TableLoadBalancerTest { // use our new classname to test class loading @Override - protected String getLoadBalancerClassNameForTable(String table) { + protected String getLoadBalancerClassNameForTable(Table.ID table) { return DefaultLoadBalancer.class.getName(); } // we don't have real tablet servers to ask: invent some online tablets @Override - public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, String tableId) throws ThriftSecurityException, TException { + public List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, Table.ID tableId) throws ThriftSecurityException, TException { return generateFakeTablets(tserver, tableId); } @@ -142,9 +143,9 @@ public class TableLoadBalancerTest { ServerConfigurationFactory confFactory = new ServerConfigurationFactory(inst) { @Override - public TableConfiguration getTableConfiguration(String tableId) { + public TableConfiguration getTableConfiguration(Table.ID tableId) { // create a dummy namespaceConfiguration to satisfy requireNonNull in TableConfiguration constructor - NamespaceConfiguration dummyConf = new NamespaceConfiguration("", null, null); + NamespaceConfiguration dummyConf = new NamespaceConfiguration(null, null, null); return new TableConfiguration(inst, tableId, dummyConf) { @Override public String get(Property property) { @@ -172,14 +173,14 @@ public class TableLoadBalancerTest { tls.init(new AccumuloServerContext(inst, confFactory)); tls.balance(state, migrations, migrationsOut); int count = 0; - Map<String,Integer> movedByTable = new HashMap<>(); - movedByTable.put(t1Id, Integer.valueOf(0)); - movedByTable.put(t2Id, Integer.valueOf(0)); - movedByTable.put(t3Id, Integer.valueOf(0)); + Map<Table.ID,Integer> movedByTable = new HashMap<>(); + movedByTable.put(new Table.ID(t1Id), Integer.valueOf(0)); + movedByTable.put(new Table.ID(t2Id), Integer.valueOf(0)); + movedByTable.put(new Table.ID(t3Id), Integer.valueOf(0)); for (TabletMigration migration : migrationsOut) { if (migration.oldServer.equals(svr)) count++; - String key = migration.tablet.getTableId(); + Table.ID key = migration.tablet.getTableId(); movedByTable.put(key, movedByTable.get(key) + 1); } Assert.assertEquals(15, count); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/master/state/MergeInfoTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/master/state/MergeInfoTest.java b/server/base/src/test/java/org/apache/accumulo/server/master/state/MergeInfoTest.java index ae06e53..9d8eb69 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/master/state/MergeInfoTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/master/state/MergeInfoTest.java @@ -31,6 +31,7 @@ import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; @@ -71,7 +72,7 @@ public class MergeInfoTest { String table = "table"; Text endRow = new Text("end"); Text prevEndRow = new Text("begin"); - keyExtent = new KeyExtent(table, endRow, prevEndRow); + keyExtent = new KeyExtent(new Table.ID(table), endRow, prevEndRow); mi = new MergeInfo(keyExtent, MergeInfo.Operation.DELETE); mi.setState(MergeState.STARTED); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -88,10 +89,10 @@ public class MergeInfoTest { @Test public void testNeedsToBeChopped_DifferentTables() { - expect(keyExtent.getTableId()).andReturn("table1"); + expect(keyExtent.getTableId()).andReturn(new Table.ID("table1")); replay(keyExtent); KeyExtent keyExtent2 = createMock(KeyExtent.class); - expect(keyExtent2.getTableId()).andReturn("table2"); + expect(keyExtent2.getTableId()).andReturn(new Table.ID("table2")); replay(keyExtent2); mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE); assertFalse(mi.needsToBeChopped(keyExtent2)); @@ -99,9 +100,9 @@ public class MergeInfoTest { @Test public void testNeedsToBeChopped_NotDelete() { - expect(keyExtent.getTableId()).andReturn("table1"); + expect(keyExtent.getTableId()).andReturn(new Table.ID("table1")); KeyExtent keyExtent2 = createMock(KeyExtent.class); - expect(keyExtent2.getTableId()).andReturn("table1"); + expect(keyExtent2.getTableId()).andReturn(new Table.ID("table1")); replay(keyExtent2); expect(keyExtent.overlaps(keyExtent2)).andReturn(true); replay(keyExtent); @@ -125,11 +126,11 @@ public class MergeInfoTest { } private void testNeedsToBeChopped_Delete(String prevEndRow, boolean expected) { - expect(keyExtent.getTableId()).andReturn("table1"); + expect(keyExtent.getTableId()).andReturn(new Table.ID("table1")); expect(keyExtent.getEndRow()).andReturn(new Text("prev")); replay(keyExtent); KeyExtent keyExtent2 = createMock(KeyExtent.class); - expect(keyExtent2.getTableId()).andReturn("table1"); + expect(keyExtent2.getTableId()).andReturn(new Table.ID("table1")); expect(keyExtent2.getPrevEndRow()).andReturn(prevEndRow != null ? new Text(prevEndRow) : null); expectLastCall().anyTimes(); replay(keyExtent2); @@ -150,9 +151,9 @@ public class MergeInfoTest { public void testOverlaps_DoesNotNeedChopping() { KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent.overlaps(keyExtent2)).andReturn(false); - expect(keyExtent.getTableId()).andReturn("table1"); + expect(keyExtent.getTableId()).andReturn(new Table.ID("table1")); replay(keyExtent); - expect(keyExtent2.getTableId()).andReturn("table2"); + expect(keyExtent2.getTableId()).andReturn(new Table.ID("table2")); replay(keyExtent2); mi = new MergeInfo(keyExtent, MergeInfo.Operation.MERGE); assertFalse(mi.overlaps(keyExtent2)); @@ -162,10 +163,10 @@ public class MergeInfoTest { public void testOverlaps_NeedsChopping() { KeyExtent keyExtent2 = createMock(KeyExtent.class); expect(keyExtent.overlaps(keyExtent2)).andReturn(false); - expect(keyExtent.getTableId()).andReturn("table1"); + expect(keyExtent.getTableId()).andReturn(new Table.ID("table1")); expect(keyExtent.getEndRow()).andReturn(new Text("prev")); replay(keyExtent); - expect(keyExtent2.getTableId()).andReturn("table1"); + expect(keyExtent2.getTableId()).andReturn(new Table.ID("table1")); expect(keyExtent2.getPrevEndRow()).andReturn(new Text("prev")); expectLastCall().anyTimes(); replay(keyExtent2); @@ -187,7 +188,7 @@ public class MergeInfoTest { } private static KeyExtent ke(String tableId, String endRow, String prevEndRow) { - return new KeyExtent(tableId, endRow == null ? null : new Text(endRow), prevEndRow == null ? null : new Text(prevEndRow)); + return new KeyExtent(new Table.ID(tableId), endRow == null ? null : new Text(endRow), prevEndRow == null ? null : new Text(prevEndRow)); } @Test http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportTest.java b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportTest.java index 3a9cbc0..ca1ced9 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportTest.java @@ -33,6 +33,7 @@ import java.io.DataOutputStream; import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.Instance; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.util.Encoding; import org.apache.accumulo.core.zookeeper.ZooUtil; import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy; @@ -43,7 +44,7 @@ import org.junit.Before; import org.junit.Test; public class ProblemReportTest { - private static final String TABLE_ID = "table"; + private static final Table.ID TABLE_ID = new Table.ID("table"); private static final String RESOURCE = "resource"; private static final String SERVER = "server"; @@ -64,7 +65,7 @@ public class ProblemReportTest { public void testGetters() { long now = System.currentTimeMillis(); r = new ProblemReport(TABLE_ID, ProblemType.FILE_READ, RESOURCE, SERVER, null, now); - assertEquals(TABLE_ID, r.getTableName()); + assertEquals(TABLE_ID, r.getTableId()); assertSame(ProblemType.FILE_READ, r.getProblemType()); assertEquals(RESOURCE, r.getResource()); assertEquals(SERVER, r.getServer()); @@ -86,7 +87,7 @@ public class ProblemReportTest { ProblemReport r2 = new ProblemReport(TABLE_ID, ProblemType.FILE_READ, RESOURCE, SERVER, null); assertTrue(r.equals(r2)); assertTrue(r2.equals(r)); - ProblemReport rx1 = new ProblemReport(TABLE_ID + "x", ProblemType.FILE_READ, RESOURCE, SERVER, null); + ProblemReport rx1 = new ProblemReport(Table.ID.METADATA, ProblemType.FILE_READ, RESOURCE, SERVER, null); assertFalse(r.equals(rx1)); ProblemReport rx2 = new ProblemReport(TABLE_ID, ProblemType.FILE_WRITE, RESOURCE, SERVER, null); assertFalse(r.equals(rx2)); @@ -115,10 +116,10 @@ public class ProblemReportTest { assertEquals(r.hashCode(), re2.hashCode()); } - private byte[] makeZPathFileName(String table, ProblemType problemType, String resource) throws Exception { + private byte[] makeZPathFileName(Table.ID table, ProblemType problemType, String resource) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); - dos.writeUTF(table); + dos.writeUTF(table.canonicalID()); dos.writeUTF(problemType.name()); dos.writeUTF(resource); dos.close(); @@ -178,7 +179,7 @@ public class ProblemReportTest { replay(zoorw); r = ProblemReport.decodeZooKeeperEntry(node, zoorw, instance); - assertEquals(TABLE_ID, r.getTableName()); + assertEquals(TABLE_ID, r.getTableId()); assertSame(ProblemType.FILE_READ, r.getProblemType()); assertEquals(RESOURCE, r.getResource()); assertEquals(SERVER, r.getServer()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java index ac91bdf..a066780 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/problems/ProblemReportingIteratorTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue; import java.util.Collection; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; @@ -37,7 +38,7 @@ import org.junit.Before; import org.junit.Test; public class ProblemReportingIteratorTest { - private static final String TABLE_ID = "table"; + private static final Table.ID TABLE_ID = new Table.ID("table"); private static final String RESOURCE = "resource"; private InterruptibleIterator ii; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java ---------------------------------------------------------------------- diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java index e135c36..5d3d44e 100644 --- a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java +++ b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java @@ -37,6 +37,7 @@ import org.apache.accumulo.core.client.IteratorSetting.Column; import org.apache.accumulo.core.client.admin.TableOperations; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.Credentials; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Writer; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.conf.Property; @@ -91,7 +92,7 @@ public class ReplicationTableUtilTest { String myFile = "file:////home/user/accumulo/wal/server+port/" + uuid; long createdTime = System.currentTimeMillis(); - ReplicationTableUtil.updateFiles(context, new KeyExtent("1", null, null), myFile, StatusUtil.fileCreated(createdTime)); + ReplicationTableUtil.updateFiles(context, new KeyExtent(new Table.ID("1"), null, null), myFile, StatusUtil.fileCreated(createdTime)); verify(writer); @@ -116,7 +117,7 @@ public class ReplicationTableUtilTest { String file = "file:///accumulo/wal/127.0.0.1+9997" + UUID.randomUUID(); Path filePath = new Path(file); Text row = new Text(filePath.toString()); - KeyExtent extent = new KeyExtent("1", new Text("b"), new Text("a")); + KeyExtent extent = new KeyExtent(new Table.ID("1"), new Text("b"), new Text("a")); Mutation m = ReplicationTableUtil.createUpdateMutation(filePath, ProtobufUtil.toValue(stat), extent); @@ -125,7 +126,7 @@ public class ReplicationTableUtilTest { ColumnUpdate col = m.getUpdates().get(0); Assert.assertEquals(MetadataSchema.ReplicationSection.COLF, new Text(col.getColumnFamily())); - Assert.assertEquals(extent.getTableId(), new Text(col.getColumnQualifier()).toString()); + Assert.assertEquals(extent.getTableId().canonicalID(), new Text(col.getColumnQualifier()).toString()); Assert.assertEquals(0, col.getColumnVisibility().length); Assert.assertArrayEquals(stat.toByteArray(), col.getValue()); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java index 1e15324..7b087aa 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionAlgorithm.java @@ -32,6 +32,7 @@ import org.apache.accumulo.core.Constants; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -243,25 +244,25 @@ public class GarbageCollectionAlgorithm { } private void cleanUpDeletedTableDirs(GarbageCollectionEnvironment gce, SortedMap<String,String> candidateMap) throws IOException { - HashSet<String> tableIdsWithDeletes = new HashSet<>(); + HashSet<Table.ID> tableIdsWithDeletes = new HashSet<>(); // find the table ids that had dirs deleted for (String delete : candidateMap.keySet()) { String[] tokens = delete.split("/"); if (tokens.length == 2) { // its a directory - String tableId = delete.split("/")[0]; + Table.ID tableId = new Table.ID(delete.split("/")[0]); tableIdsWithDeletes.add(tableId); } } - Set<String> tableIdsInZookeeper = gce.getTableIDs(); + Set<Table.ID> tableIdsInZookeeper = gce.getTableIDs(); tableIdsWithDeletes.removeAll(tableIdsInZookeeper); // tableIdsWithDeletes should now contain the set of deleted tables that had dirs deleted - for (String delTableId : tableIdsWithDeletes) { + for (Table.ID delTableId : tableIdsWithDeletes) { gce.deleteTableDirIfEmpty(delTableId); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionEnvironment.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionEnvironment.java b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionEnvironment.java index 1f56fd9..06ba11b 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionEnvironment.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/GarbageCollectionEnvironment.java @@ -27,6 +27,7 @@ import java.util.SortedMap; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableNotFoundException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.metadata.MetadataTable; @@ -71,7 +72,7 @@ public interface GarbageCollectionEnvironment { * * @return The valueSet for the table name to table id map. */ - Set<String> getTableIDs(); + Set<Table.ID> getTableIDs(); /** * Delete the given files from the provided {@link Map} of relative path to absolute path for each file that should be deleted @@ -87,7 +88,7 @@ public interface GarbageCollectionEnvironment { * @param tableID * The id of the table whose directory we are to operate on */ - void deleteTableDirIfEmpty(String tableID) throws IOException; + void deleteTableDirIfEmpty(Table.ID tableID) throws IOException; /** * Increment the number of candidates for deletion for the current garbage collection run http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java ---------------------------------------------------------------------- diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java index 7719766..92a5fa9 100644 --- a/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java +++ b/server/gc/src/main/java/org/apache/accumulo/gc/SimpleGarbageCollector.java @@ -41,6 +41,7 @@ import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.MutationsRejectedException; import org.apache.accumulo.core.client.Scanner; 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.conf.Property; import org.apache.accumulo.core.conf.SiteConfiguration; @@ -291,7 +292,7 @@ public class SimpleGarbageCollector extends AccumuloServerContext implements Ifa } @Override - public Set<String> getTableIDs() { + public Set<Table.ID> getTableIDs() { return Tables.getIdToNameMap(getInstance()).keySet(); } @@ -390,7 +391,7 @@ public class SimpleGarbageCollector extends AccumuloServerContext implements Ifa } String parts[] = fullPath.toString().split(Constants.ZTABLES)[1].split("/"); if (parts.length > 2) { - String tableId = parts[1]; + Table.ID tableId = new Table.ID(parts[1]); String tabletDir = parts[2]; TableManager.getInstance().updateTableStateCache(tableId); TableState tableState = TableManager.getInstance().getTableState(tableId); @@ -438,7 +439,7 @@ public class SimpleGarbageCollector extends AccumuloServerContext implements Ifa } @Override - public void deleteTableDirIfEmpty(String tableID) throws IOException { + public void deleteTableDirIfEmpty(Table.ID tableID) throws IOException { // if dir exist and is empty, then empty list is returned... // hadoop 2.0 will throw an exception if the file does not exist for (String dir : ServerConstants.getTablesDirs()) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java ---------------------------------------------------------------------- diff --git a/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java b/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java index d61fb9e..eea0e76 100644 --- a/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java +++ b/server/gc/src/test/java/org/apache/accumulo/gc/GarbageCollectionTest.java @@ -30,6 +30,7 @@ import java.util.TreeSet; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -49,10 +50,10 @@ public class GarbageCollectionTest { TreeSet<String> candidates = new TreeSet<>(); ArrayList<String> blips = new ArrayList<>(); Map<Key,Value> references = new TreeMap<>(); - HashSet<String> tableIds = new HashSet<>(); + HashSet<Table.ID> tableIds = new HashSet<>(); ArrayList<String> deletes = new ArrayList<>(); - ArrayList<String> tablesDirsToDelete = new ArrayList<>(); + ArrayList<Table.ID> tablesDirsToDelete = new ArrayList<>(); TreeMap<String,Status> filesToReplicate = new TreeMap<>(); @Override @@ -76,7 +77,7 @@ public class GarbageCollectionTest { } @Override - public Set<String> getTableIDs() { + public Set<Table.ID> getTableIDs() { return tableIds; } @@ -87,12 +88,12 @@ public class GarbageCollectionTest { } @Override - public void deleteTableDirIfEmpty(String tableID) { + public void deleteTableDirIfEmpty(Table.ID tableID) { tablesDirsToDelete.add(tableID); } public Key newFileReferenceKey(String tableId, String endRow, String file) { - String row = new KeyExtent(tableId, endRow == null ? null : new Text(endRow), null).getMetadataEntry().toString(); + String row = new KeyExtent(new Table.ID(tableId), endRow == null ? null : new Text(endRow), null).getMetadataEntry().toString(); String cf = MetadataSchema.TabletsSection.DataFileColumnFamily.NAME.toString(); String cq = file; Key key = new Key(row, cf, cq); @@ -110,7 +111,7 @@ public class GarbageCollectionTest { } Key newDirReferenceKey(String tableId, String endRow) { - String row = new KeyExtent(tableId, endRow == null ? null : new Text(endRow), null).getMetadataEntry().toString(); + String row = new KeyExtent(new Table.ID(tableId), endRow == null ? null : new Text(endRow), null).getMetadataEntry().toString(); String cf = MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnFamily().toString(); String cq = MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.getColumnQualifier().toString(); Key key = new Key(row, cf, cq); @@ -533,7 +534,7 @@ public class GarbageCollectionTest { TestGCE gce = new TestGCE(); - gce.tableIds.add("4"); + gce.tableIds.add(new Table.ID("4")); gce.candidates.add("/4/t-0"); gce.candidates.add("/4/t-0/F002.rf"); @@ -545,9 +546,9 @@ public class GarbageCollectionTest { gca.collect(gce); - HashSet<String> tids = new HashSet<>(); - tids.add("5"); - tids.add("6"); + HashSet<Table.ID> tids = new HashSet<>(); + tids.add(new Table.ID("5")); + tids.add(new Table.ID("6")); Assert.assertEquals(tids.size(), gce.tablesDirsToDelete.size()); Assert.assertTrue(tids.containsAll(gce.tablesDirsToDelete));