http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java index 5932fda..1c4895f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java @@ -88,7 +88,7 @@ public class TabletLocatorImpl extends TabletLocator { static final EndRowComparator endRowComparator = new EndRowComparator(); - protected String tableId; + protected Table.ID tableId; protected TabletLocator parent; protected TreeMap<Text,TabletLocation> metaCache = new TreeMap<>(endRowComparator); protected TabletLocationObtainer locationObtainer; @@ -152,13 +152,13 @@ public class TabletLocatorImpl extends TabletLocator { } } - public TabletLocatorImpl(String tableId, TabletLocator parent, TabletLocationObtainer tlo, TabletServerLockChecker tslc) { + public TabletLocatorImpl(Table.ID tableId, TabletLocator parent, TabletLocationObtainer tlo, TabletServerLockChecker tslc) { this.tableId = tableId; this.parent = parent; this.locationObtainer = tlo; this.lockChecker = tslc; - this.lastTabletRow = new Text(tableId); + this.lastTabletRow = new Text(tableId.getUtf8()); lastTabletRow.append(new byte[] {'<'}, 0, 1); } @@ -474,7 +474,7 @@ public class TabletLocatorImpl extends TabletLocator { private void lookupTabletLocation(ClientContext context, Text row, boolean retry, LockCheckerSession lcSession) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - Text metadataRow = new Text(tableId); + Text metadataRow = new Text(tableId.getUtf8()); metadataRow.append(new byte[] {';'}, 0, 1); metadataRow.append(row.getBytes(), 0, row.getLength()); TabletLocation ptl = parent.locateTablet(context, metadataRow, false, retry);
http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java index d3b26dc..09ac5ea 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchDeleter.java @@ -35,10 +35,10 @@ import org.apache.accumulo.core.security.ColumnVisibility; public class TabletServerBatchDeleter extends TabletServerBatchReader implements BatchDeleter { private final ClientContext context; - private String tableId; + private Table.ID tableId; private BatchWriterConfig bwConfig; - public TabletServerBatchDeleter(ClientContext context, String tableId, Authorizations authorizations, int numQueryThreads, BatchWriterConfig bwConfig) + public TabletServerBatchDeleter(ClientContext context, Table.ID tableId, Authorizations authorizations, int numQueryThreads, BatchWriterConfig bwConfig) throws TableNotFoundException { super(context, tableId, authorizations, numQueryThreads); this.context = context; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java index 0d4909b..0999090 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReader.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; public class TabletServerBatchReader extends ScannerOptions implements BatchScanner { private static final Logger log = LoggerFactory.getLogger(TabletServerBatchReader.class); - private String tableId; + private Table.ID tableId; private int numThreads; private ExecutorService queryThreadPool; @@ -54,7 +54,7 @@ public class TabletServerBatchReader extends ScannerOptions implements BatchScan private final int batchReaderInstance = getNextBatchReaderInstance(); - public TabletServerBatchReader(ClientContext context, String tableId, Authorizations authorizations, int numQueryThreads) { + public TabletServerBatchReader(ClientContext context, Table.ID tableId, Authorizations authorizations, int numQueryThreads) { checkArgument(context != null, "context is null"); checkArgument(tableId != null, "tableId is null"); checkArgument(authorizations != null, "authorizations is null"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java index 8796d3c..62b7eb3 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java @@ -81,7 +81,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value private final ClientContext context; private final Instance instance; - private final String tableId; + private final Table.ID tableId; private Authorizations authorizations = Authorizations.EMPTY; private final int numThreads; private final ExecutorService queryThreadPool; @@ -107,7 +107,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value void receive(List<Entry<Key,Value>> entries); } - public TabletServerBatchReaderIterator(ClientContext context, String tableId, Authorizations authorizations, ArrayList<Range> ranges, int numThreads, + public TabletServerBatchReaderIterator(ClientContext context, Table.ID tableId, Authorizations authorizations, ArrayList<Range> ranges, int numThreads, ExecutorService queryThreadPool, ScannerOptions scannerOptions, long timeout) { this.context = context; @@ -242,9 +242,9 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value // need to always do the check when failures occur if (failures.size() >= lastFailureSize) if (!Tables.exists(instance, tableId)) - throw new TableDeletedException(tableId); + throw new TableDeletedException(tableId.canonicalID()); else if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) - throw new TableOfflineException(instance, tableId); + throw new TableOfflineException(instance, tableId.canonicalID()); lastFailureSize = failures.size(); @@ -374,7 +374,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value Tables.clearCache(instance); if (!Tables.exists(instance, tableId)) - fatalException = new TableDeletedException(tableId); + fatalException = new TableDeletedException(tableId.canonicalID()); else fatalException = e; } catch (SampleNotPresentException e) { @@ -726,7 +726,7 @@ public class TabletServerBatchReaderIterator implements Iterator<Entry<Key,Value log.debug("Server : " + server + " msg : " + e.getMessage(), e); String tableInfo = "?"; if (e.getExtent() != null) { - String tableId = new KeyExtent(e.getExtent()).getTableId(); + Table.ID tableId = new KeyExtent(e.getExtent()).getTableId(); tableInfo = Tables.getPrintableTableInfoFromId(context.getInstance(), tableId); } String message = "Table " + tableInfo + " does not have sampling configured or built"; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java index f74b2d1..6577a71 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java @@ -241,7 +241,7 @@ public class TabletServerBatchWriter { this.notifyAll(); } - public synchronized void addMutation(String table, Mutation m) throws MutationsRejectedException { + public synchronized void addMutation(Table.ID table, Mutation m) throws MutationsRejectedException { if (closed) throw new IllegalStateException("Closed"); @@ -295,7 +295,7 @@ public class TabletServerBatchWriter { } } - public void addMutation(String table, Iterator<Mutation> iterator) throws MutationsRejectedException { + public void addMutation(Table.ID table, Iterator<Mutation> iterator) throws MutationsRejectedException { while (iterator.hasNext()) { addMutation(table, iterator.next()); } @@ -514,14 +514,14 @@ public class TabletServerBatchWriter { if (authorizationFailures.size() > 0) { // was a table deleted? - HashSet<String> tableIds = new HashSet<>(); + HashSet<Table.ID> tableIds = new HashSet<>(); for (KeyExtent ke : authorizationFailures.keySet()) tableIds.add(ke.getTableId()); Tables.clearCache(context.getInstance()); - for (String tableId : tableIds) + for (Table.ID tableId : tableIds) if (!Tables.exists(context.getInstance(), tableId)) - throw new TableDeletedException(tableId); + throw new TableDeletedException(tableId.canonicalID()); synchronized (this) { somethingFailed = true; @@ -609,7 +609,7 @@ public class TabletServerBatchWriter { return recentFailures; } - synchronized void add(String table, ArrayList<Mutation> tableFailures) { + synchronized void add(Table.ID table, ArrayList<Mutation> tableFailures) { init().addAll(table, tableFailures); } @@ -660,7 +660,7 @@ public class TabletServerBatchWriter { private final SimpleThreadPool binningThreadPool; private final Map<String,TabletServerMutations<Mutation>> serversMutations; private final Set<String> queued; - private final Map<String,TabletLocator> locators; + private final Map<Table.ID,TabletLocator> locators; public MutationWriter(int numSendThreads) { serversMutations = new HashMap<>(); @@ -671,7 +671,7 @@ public class TabletServerBatchWriter { binningThreadPool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); } - private synchronized TabletLocator getLocator(String tableId) { + private synchronized TabletLocator getLocator(Table.ID tableId) { TabletLocator ret = locators.get(tableId); if (ret == null) { ret = new TimeoutTabletLocator(timeout, context, tableId); @@ -682,14 +682,12 @@ public class TabletServerBatchWriter { } private void binMutations(MutationSet mutationsToProcess, Map<String,TabletServerMutations<Mutation>> binnedMutations) { - String tableId = null; + Table.ID tableId = null; try { - Set<Entry<String,List<Mutation>>> es = mutationsToProcess.getMutations().entrySet(); - for (Entry<String,List<Mutation>> entry : es) { + Set<Entry<Table.ID,List<Mutation>>> es = mutationsToProcess.getMutations().entrySet(); + for (Entry<Table.ID,List<Mutation>> entry : es) { tableId = entry.getKey(); TabletLocator locator = getLocator(tableId); - - String table = entry.getKey(); List<Mutation> tableMutations = entry.getValue(); if (tableMutations != null) { @@ -697,13 +695,13 @@ public class TabletServerBatchWriter { locator.binMutations(context, tableMutations, binnedMutations, tableFailures); if (tableFailures.size() > 0) { - failedMutations.add(table, tableFailures); + failedMutations.add(tableId, tableFailures); if (tableFailures.size() == tableMutations.size()) if (!Tables.exists(context.getInstance(), entry.getKey())) - throw new TableDeletedException(entry.getKey()); - else if (Tables.getTableState(context.getInstance(), table) == TableState.OFFLINE) - throw new TableOfflineException(context.getInstance(), entry.getKey()); + throw new TableDeletedException(entry.getKey().canonicalID()); + else if (Tables.getTableState(context.getInstance(), tableId) == TableState.OFFLINE) + throw new TableOfflineException(context.getInstance(), entry.getKey().canonicalID()); } } @@ -845,7 +843,7 @@ public class TabletServerBatchWriter { long count = 0; - Set<String> tableIds = new TreeSet<>(); + Set<Table.ID> tableIds = new TreeSet<>(); for (Map.Entry<KeyExtent,List<Mutation>> entry : mutationBatch.entrySet()) { count += entry.getValue().size(); tableIds.add(entry.getKey().getTableId()); @@ -893,11 +891,11 @@ public class TabletServerBatchWriter { if (log.isTraceEnabled()) log.trace("failed to send mutations to {} : {}", location, e.getMessage()); - HashSet<String> tables = new HashSet<>(); + HashSet<Table.ID> tables = new HashSet<>(); for (KeyExtent ke : mutationBatch.keySet()) tables.add(ke.getTableId()); - for (String table : tables) + for (Table.ID table : tables) getLocator(table).invalidateCache(context.getInstance(), location); failedMutations.add(location, tsm); @@ -974,7 +972,7 @@ public class TabletServerBatchWriter { int numCommitted = (int) (long) entry.getValue(); totalCommitted += numCommitted; - String tableId = failedExtent.getTableId(); + Table.ID tableId = failedExtent.getTableId(); getLocator(tableId).invalidateCache(failedExtent); @@ -1015,14 +1013,14 @@ public class TabletServerBatchWriter { private static class MutationSet { - private final HashMap<String,List<Mutation>> mutations; + private final HashMap<Table.ID,List<Mutation>> mutations; private int memoryUsed = 0; MutationSet() { mutations = new HashMap<>(); } - void addMutation(String table, Mutation mutation) { + void addMutation(Table.ID table, Mutation mutation) { List<Mutation> tabMutList = mutations.get(table); if (tabMutList == null) { tabMutList = new ArrayList<>(); @@ -1034,7 +1032,7 @@ public class TabletServerBatchWriter { memoryUsed += mutation.estimatedMemoryUsed(); } - Map<String,List<Mutation>> getMutations() { + Map<Table.ID,List<Mutation>> getMutations() { return mutations; } @@ -1047,10 +1045,10 @@ public class TabletServerBatchWriter { } public void addAll(MutationSet failures) { - Set<Entry<String,List<Mutation>>> es = failures.getMutations().entrySet(); + Set<Entry<Table.ID,List<Mutation>>> es = failures.getMutations().entrySet(); - for (Entry<String,List<Mutation>> entry : es) { - String table = entry.getKey(); + for (Entry<Table.ID,List<Mutation>> entry : es) { + Table.ID table = entry.getKey(); for (Mutation mutation : entry.getValue()) { addMutation(table, mutation); @@ -1058,7 +1056,7 @@ public class TabletServerBatchWriter { } } - public void addAll(String table, List<Mutation> mutations) { + public void addAll(Table.ID table, List<Mutation> mutations) { for (Mutation mutation : mutations) { addMutation(table, mutation); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java index e69143c..b7780ba 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ThriftScanner.java @@ -137,7 +137,7 @@ public class ThriftScanner { public static class ScanState { boolean isolated; - String tableId; + Table.ID tableId; Text startRow; boolean skipStartRow; long readaheadThreshold; @@ -164,7 +164,7 @@ public class ThriftScanner { SamplerConfiguration samplerConfig; - public ScanState(ClientContext context, String tableId, Authorizations authorizations, Range range, SortedSet<Column> fetchedColumns, int size, + public ScanState(ClientContext context, Table.ID tableId, Authorizations authorizations, Range range, SortedSet<Column> fetchedColumns, int size, List<IterInfo> serverSideIteratorList, Map<String,Map<String,String>> serverSideIteratorOptions, boolean isolated, long readaheadThreshold, SamplerConfiguration samplerConfig, long batchTimeOut, String classLoaderContext) { this.context = context; @@ -248,9 +248,9 @@ public class ThriftScanner { if (loc == null) { if (!Tables.exists(instance, scanState.tableId)) - throw new TableDeletedException(scanState.tableId); + throw new TableDeletedException(scanState.tableId.canonicalID()); else if (Tables.getTableState(instance, scanState.tableId) == TableState.OFFLINE) - throw new TableOfflineException(instance, scanState.tableId); + throw new TableOfflineException(instance, scanState.tableId.canonicalID()); error = "Failed to locate tablet for table : " + scanState.tableId + " row : " + scanState.startRow; if (!error.equals(lastError)) @@ -299,7 +299,7 @@ public class ThriftScanner { } catch (AccumuloSecurityException e) { Tables.clearCache(instance); if (!Tables.exists(instance, scanState.tableId)) - throw new TableDeletedException(scanState.tableId); + throw new TableDeletedException(scanState.tableId.canonicalID()); e.setTableInfo(Tables.getPrintableTableInfoFromId(instance, scanState.tableId)); throw e; } catch (TApplicationException tae) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/TimeoutTabletLocator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TimeoutTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TimeoutTabletLocator.java index 6e92b68..dc2af67 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/TimeoutTabletLocator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TimeoutTabletLocator.java @@ -50,7 +50,7 @@ public class TimeoutTabletLocator extends SyncingTabletLocator { firstFailTime = null; } - public TimeoutTabletLocator(long timeout, final ClientContext context, final String table) { + public TimeoutTabletLocator(long timeout, final ClientContext context, final Table.ID table) { super(context, table); this.timeout = timeout; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java index 90691ef..206b113 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java +++ b/core/src/main/java/org/apache/accumulo/core/client/impl/Writer.java @@ -48,9 +48,9 @@ public class Writer { private static final Logger log = LoggerFactory.getLogger(Writer.class); private ClientContext context; - private String tableId; + private Table.ID tableId; - public Writer(ClientContext context, String tableId) { + public Writer(ClientContext context, Table.ID tableId) { checkArgument(context != null, "context is null"); checkArgument(tableId != null, "tableId is null"); this.context = context; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java index 311d271..20c0c44 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/AbstractInputFormat.java @@ -50,6 +50,7 @@ import org.apache.accumulo.core.client.impl.Credentials; import org.apache.accumulo.core.client.impl.DelegationTokenImpl; import org.apache.accumulo.core.client.impl.OfflineScanner; import org.apache.accumulo.core.client.impl.ScannerImpl; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.mapred.impl.BatchInputSplit; @@ -543,13 +544,13 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { try { if (isOffline) { - scanner = new OfflineScanner(instance, new Credentials(principal, token), baseSplit.getTableId(), authorizations); + scanner = new OfflineScanner(instance, new Credentials(principal, token), new Table.ID(baseSplit.getTableId()), authorizations); } else if (DeprecationUtil.isMockInstance(instance)) { scanner = instance.getConnector(principal, token).createScanner(baseSplit.getTableName(), authorizations); } else { ClientConfiguration clientConf = getClientConfiguration(job); ClientContext context = new ClientContext(instance, new Credentials(principal, token), clientConf); - scanner = new ScannerImpl(context, baseSplit.getTableId(), authorizations); + scanner = new ScannerImpl(context, new Table.ID(baseSplit.getTableId()), authorizations); } if (isIsolated) { log.info("Creating isolated scanner"); @@ -622,7 +623,7 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { } - Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobConf job, String tableId, List<Range> ranges) throws TableNotFoundException, AccumuloException, + Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobConf job, Table.ID tableId, List<Range> ranges) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { Instance instance = getInstance(job); @@ -652,10 +653,10 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { InputTableConfig tableConfig = tableConfigEntry.getValue(); Instance instance = getInstance(job); - String tableId; + Table.ID tableId; // resolve table name to id once, and use id from this point forward if (DeprecationUtil.isMockInstance(instance)) { - tableId = ""; + tableId = null; } else { try { tableId = Tables.getTableId(instance, tableName); @@ -704,10 +705,11 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { getClientConfiguration(job)); while (!tl.binRanges(context, ranges, binnedRanges).isEmpty()) { if (!DeprecationUtil.isMockInstance(instance)) { + String tableIdStr = tableId != null ? tableId.canonicalID() : null; if (!Tables.exists(instance, tableId)) - throw new TableDeletedException(tableId); + throw new TableDeletedException(tableIdStr); if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) - throw new TableOfflineException(instance, tableId); + throw new TableOfflineException(instance, tableIdStr); } binnedRanges.clear(); log.warn("Unable to locate bins for specified ranges. Retrying."); @@ -751,7 +753,7 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { for (Range r : extentRanges.getValue()) { if (autoAdjust) { // divide ranges into smaller ranges, based on the tablets - RangeInputSplit split = new RangeInputSplit(tableName, tableId, ke.clip(r), new String[] {location}); + RangeInputSplit split = new RangeInputSplit(tableName, tableId.canonicalID(), ke.clip(r), new String[] {location}); SplitUtils.updateSplit(split, instance, tableConfig, principal, token, auths, logLevel); split.setOffline(tableConfig.isOfflineScan()); split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners()); @@ -773,7 +775,7 @@ public abstract class AbstractInputFormat<K,V> implements InputFormat<K,V> { if (!autoAdjust) for (Map.Entry<Range,ArrayList<String>> entry : splitsToAdd.entrySet()) { - RangeInputSplit split = new RangeInputSplit(tableName, tableId, entry.getKey(), entry.getValue().toArray(new String[0])); + RangeInputSplit split = new RangeInputSplit(tableName, tableId.canonicalID(), entry.getKey(), entry.getValue().toArray(new String[0])); SplitUtils.updateSplit(split, instance, tableConfig, principal, token, auths, logLevel); split.setOffline(tableConfig.isOfflineScan()); split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mapred/impl/BatchInputSplit.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/impl/BatchInputSplit.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/impl/BatchInputSplit.java index a046ee3..d0a4d1f 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/impl/BatchInputSplit.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/impl/BatchInputSplit.java @@ -19,6 +19,7 @@ package org.apache.accumulo.core.client.mapred.impl; import java.io.IOException; import java.util.Collection; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.Range; import org.apache.hadoop.mapred.InputSplit; @@ -35,7 +36,7 @@ public class BatchInputSplit extends org.apache.accumulo.core.client.mapreduce.i super(split); } - public BatchInputSplit(String table, String tableId, Collection<Range> ranges, String[] location) { + public BatchInputSplit(String table, Table.ID tableId, Collection<Range> ranges, String[] location) { super(table, tableId, ranges, location); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java index 254d538..ca8c603 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AbstractInputFormat.java @@ -50,6 +50,7 @@ import org.apache.accumulo.core.client.impl.Credentials; import org.apache.accumulo.core.client.impl.DelegationTokenImpl; import org.apache.accumulo.core.client.impl.OfflineScanner; import org.apache.accumulo.core.client.impl.ScannerImpl; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.mapreduce.impl.BatchInputSplit; @@ -571,13 +572,13 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { try { if (isOffline) { - scanner = new OfflineScanner(instance, new Credentials(principal, token), split.getTableId(), authorizations); + scanner = new OfflineScanner(instance, new Credentials(principal, token), new Table.ID(split.getTableId()), authorizations); } else if (DeprecationUtil.isMockInstance(instance)) { scanner = instance.getConnector(principal, token).createScanner(split.getTableName(), authorizations); } else { ClientConfiguration clientConf = getClientConfiguration(attempt); ClientContext context = new ClientContext(instance, new Credentials(principal, token), clientConf); - scanner = new ScannerImpl(context, split.getTableId(), authorizations); + scanner = new ScannerImpl(context, new Table.ID(split.getTableId()), authorizations); } if (isIsolated) { log.info("Creating isolated scanner"); @@ -667,7 +668,7 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { } } - Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobContext context, String tableId, List<Range> ranges) throws TableNotFoundException, + Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobContext context, Table.ID tableId, List<Range> ranges) throws TableNotFoundException, AccumuloException, AccumuloSecurityException { Instance instance = getInstance(context); @@ -697,10 +698,10 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { InputTableConfig tableConfig = tableConfigEntry.getValue(); Instance instance = getInstance(context); - String tableId; + Table.ID tableId; // resolve table name to id once, and use id from this point forward if (DeprecationUtil.isMockInstance(instance)) { - tableId = ""; + tableId = null; } else { try { tableId = Tables.getTableId(instance, tableName); @@ -750,10 +751,11 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { getClientConfiguration(context)); while (!tl.binRanges(clientContext, ranges, binnedRanges).isEmpty()) { if (!DeprecationUtil.isMockInstance(instance)) { + String tableIdStr = tableId != null ? tableId.canonicalID() : null; if (!Tables.exists(instance, tableId)) - throw new TableDeletedException(tableId); + throw new TableDeletedException(tableIdStr); if (Tables.getTableState(instance, tableId) == TableState.OFFLINE) - throw new TableOfflineException(instance, tableId); + throw new TableOfflineException(instance, tableIdStr); } binnedRanges.clear(); log.warn("Unable to locate bins for specified ranges. Retrying."); @@ -798,7 +800,7 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { for (Range r : extentRanges.getValue()) { if (autoAdjust) { // divide ranges into smaller ranges, based on the tablets - RangeInputSplit split = new RangeInputSplit(tableName, tableId, ke.clip(r), new String[] {location}); + RangeInputSplit split = new RangeInputSplit(tableName, tableId.canonicalID(), ke.clip(r), new String[] {location}); SplitUtils.updateSplit(split, instance, tableConfig, principal, token, auths, logLevel); split.setOffline(tableConfig.isOfflineScan()); split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners()); @@ -820,7 +822,7 @@ public abstract class AbstractInputFormat<K,V> extends InputFormat<K,V> { if (!autoAdjust) for (Map.Entry<Range,ArrayList<String>> entry : splitsToAdd.entrySet()) { - RangeInputSplit split = new RangeInputSplit(tableName, tableId, entry.getKey(), entry.getValue().toArray(new String[0])); + RangeInputSplit split = new RangeInputSplit(tableName, tableId.canonicalID(), entry.getKey(), entry.getValue().toArray(new String[0])); SplitUtils.updateSplit(split, instance, tableConfig, principal, token, auths, logLevel); split.setOffline(tableConfig.isOfflineScan()); split.setIsolatedScan(tableConfig.shouldUseIsolatedScanners()); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplit.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplit.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplit.java index 2965788..f1c612a 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplit.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplit.java @@ -24,6 +24,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.mapreduce.RangeInputSplit; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.PartialKey; @@ -45,8 +46,8 @@ public class BatchInputSplit extends RangeInputSplit { this.setRanges(split.getRanges()); } - public BatchInputSplit(String table, String tableId, Collection<Range> ranges, String[] locations) { - super(table, tableId, new Range(), locations); + public BatchInputSplit(String table, Table.ID tableId, Collection<Range> ranges, String[] locations) { + super(table, tableId.canonicalID(), new Range(), locations); this.ranges = ranges; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/InputConfigurator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/InputConfigurator.java b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/InputConfigurator.java index c8f20e1..a8227fe 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/InputConfigurator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapreduce/lib/impl/InputConfigurator.java @@ -51,6 +51,7 @@ 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.DelegationTokenImpl; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.client.impl.TabletLocator; import org.apache.accumulo.core.client.mapreduce.InputTableConfig; @@ -674,7 +675,7 @@ public class InputConfigurator extends ConfiguratorBase { * if the table name set on the configuration doesn't exist * @since 1.6.0 */ - public static TabletLocator getTabletLocator(Class<?> implementingClass, Configuration conf, String tableId) throws TableNotFoundException { + public static TabletLocator getTabletLocator(Class<?> implementingClass, Configuration conf, Table.ID tableId) throws TableNotFoundException { String instanceType = conf.get(enumToConfKey(implementingClass, InstanceOpts.TYPE)); if ("MockInstance".equals(instanceType)) return DeprecationUtil.makeMockLocator(); @@ -849,7 +850,7 @@ public class InputConfigurator extends ConfiguratorBase { return null; } - public static Map<String,Map<KeyExtent,List<Range>>> binOffline(String tableId, List<Range> ranges, Instance instance, Connector conn) + public static Map<String,Map<KeyExtent,List<Range>>> binOffline(Table.ID tableId, List<Range> ranges, Instance instance, Connector conn) throws AccumuloException, TableNotFoundException { Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<>(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java index 72cb939..4143c28 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockTableOperations.java @@ -366,9 +366,9 @@ class MockTableOperations extends TableOperationsHelper { for (Entry<String,MockTable> entry : acu.tables.entrySet()) { String table = entry.getKey(); if (RootTable.NAME.equals(table)) - result.put(table, RootTable.ID); + result.put(table, RootTable.ID.canonicalID()); else if (MetadataTable.NAME.equals(table)) - result.put(table, MetadataTable.ID); + result.put(table, MetadataTable.ID.canonicalID()); else result.put(table, entry.getValue().getTableId()); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java index a52af79..78f604d 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mock/impl/MockTabletLocator.java @@ -57,7 +57,7 @@ public class MockTabletLocator extends TabletLocator { @Override public List<Range> binRanges(ClientContext context, List<Range> ranges, Map<String,Map<KeyExtent,List<Range>>> binnedRanges) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { - binnedRanges.put("", Collections.singletonMap(new KeyExtent("", null, null), ranges)); + binnedRanges.put("", Collections.singletonMap(new KeyExtent(null, null, null), ranges)); return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/data/impl/KeyExtent.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/data/impl/KeyExtent.java b/core/src/main/java/org/apache/accumulo/core/data/impl/KeyExtent.java index dcb8eb7..e6bc9fd 100644 --- a/core/src/main/java/org/apache/accumulo/core/data/impl/KeyExtent.java +++ b/core/src/main/java/org/apache/accumulo/core/data/impl/KeyExtent.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Map.Entry; @@ -36,6 +37,7 @@ import java.util.TreeSet; import java.util.UUID; import java.util.WeakHashMap; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.ByteSequence; import org.apache.accumulo.core.data.Mutation; import org.apache.accumulo.core.data.Range; @@ -58,13 +60,13 @@ import org.apache.hadoop.io.WritableComparable; public class KeyExtent implements WritableComparable<KeyExtent> { - private static final WeakHashMap<String,WeakReference<String>> tableIds = new WeakHashMap<>(); + private static final WeakHashMap<Table.ID,WeakReference<Table.ID>> tableIds = new WeakHashMap<>(); - private static String dedupeTableId(String tableId) { + private static Table.ID dedupeTableId(Table.ID tableId) { synchronized (tableIds) { - WeakReference<String> etir = tableIds.get(tableId); + WeakReference<Table.ID> etir = tableIds.get(tableId); if (etir != null) { - String eti = etir.get(); + Table.ID eti = etir.get(); if (eti != null) { return eti; } @@ -75,10 +77,12 @@ public class KeyExtent implements WritableComparable<KeyExtent> { } } - private String tableId; + private Table.ID tableId; private Text textEndRow; private Text textPrevEndRow; + private final Table.ID EMPTY_ID = new Table.ID(""); + private void check() { if (getTableId() == null) @@ -97,12 +101,12 @@ public class KeyExtent implements WritableComparable<KeyExtent> { * */ public KeyExtent() { - this.setTableId(""); + this.setTableId(EMPTY_ID); this.setEndRow(new Text(), false, false); this.setPrevEndRow(new Text(), false, false); } - public KeyExtent(String table, Text endRow, Text prevEndRow) { + public KeyExtent(Table.ID table, Text endRow, Text prevEndRow) { this.setTableId(table); this.setEndRow(endRow, false, true); this.setPrevEndRow(prevEndRow, false, true); @@ -120,7 +124,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { } public KeyExtent(TKeyExtent tke) { - this.setTableId(dedupeTableId(new String(ByteBufferUtil.toBytes(tke.table), UTF_8))); + this.setTableId(dedupeTableId(new Table.ID(new String(ByteBufferUtil.toBytes(tke.table), UTF_8)))); this.setEndRow(tke.endRow == null ? null : new Text(ByteBufferUtil.toBytes(tke.endRow)), false, false); this.setPrevEndRow(tke.prevEndRow == null ? null : new Text(ByteBufferUtil.toBytes(tke.prevEndRow)), false, false); @@ -135,7 +139,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { return getMetadataEntry(getTableId(), getEndRow()); } - public static Text getMetadataEntry(String tableId, Text endRow) { + public static Text getMetadataEntry(Table.ID tableId, Text endRow) { return MetadataSchema.TabletsSection.getRow(tableId, endRow); } @@ -166,7 +170,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { * Sets the extents table id * */ - public void setTableId(String tId) { + public void setTableId(Table.ID tId) { if (tId == null) throw new IllegalArgumentException("null table name not allowed"); @@ -180,7 +184,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { * Returns the extent's table id * */ - public String getTableId() { + public Table.ID getTableId() { return tableId; } @@ -248,7 +252,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { public void readFields(DataInput in) throws IOException { Text tid = new Text(); tid.readFields(in); - setTableId(tid.toString()); + setTableId(new Table.ID(tid.toString())); boolean hasRow = in.readBoolean(); if (hasRow) { Text er = new Text(); @@ -272,7 +276,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { @Override public void write(DataOutput out) throws IOException { - new Text(getTableId()).write(out); + new Text(getTableId().getUtf8()).write(out); if (getEndRow() != null) { out.writeBoolean(true); getEndRow().write(out); @@ -462,7 +466,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { public String toString() { String endRowString; String prevEndRowString; - String tableIdString = getTableId().replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); + String tableIdString = getTableId().canonicalID().replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); if (getEndRow() == null) endRowString = "<"; @@ -528,12 +532,13 @@ public class KeyExtent implements WritableComparable<KeyExtent> { throw new IllegalArgumentException("< must come at end of Metadata row " + flattenedExtent); } - String tableId = new String(flattenedExtent.getBytes(), 0, flattenedExtent.getLength() - 1, UTF_8); + String decodedString = new String(Arrays.copyOfRange(flattenedExtent.getBytes(), 0, flattenedExtent.getLength() - 1), UTF_8); + Table.ID tableId = new Table.ID(decodedString); this.setTableId(tableId); this.setEndRow(null, false, false); } else { - String tableId = new String(flattenedExtent.getBytes(), 0, semiPos, UTF_8); + Table.ID tableId = new Table.ID(new String(Arrays.copyOfRange(flattenedExtent.getBytes(), 0, semiPos), UTF_8)); Text endRow = new Text(); endRow.set(flattenedExtent.getBytes(), semiPos + 1, flattenedExtent.getLength() - (semiPos + 1)); @@ -547,7 +552,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { public static byte[] tableOfMetadataRow(Text row) { KeyExtent ke = new KeyExtent(); ke.decodeMetadataRow(row); - return ke.getTableId().getBytes(UTF_8); + return ke.getTableId().getUtf8(); } public boolean contains(final ByteSequence bsrow) { @@ -593,7 +598,7 @@ public class KeyExtent implements WritableComparable<KeyExtent> { } public Range toMetadataRange() { - Text metadataPrevRow = new Text(getTableId()); + Text metadataPrevRow = new Text(getTableId().getUtf8()); metadataPrevRow.append(new byte[] {';'}, 0, 1); if (getPrevEndRow() != null) { metadataPrevRow.append(getPrevEndRow().getBytes(), 0, getPrevEndRow().getLength()); @@ -738,8 +743,8 @@ public class KeyExtent implements WritableComparable<KeyExtent> { } public TKeyExtent toThrift() { - return new TKeyExtent(ByteBuffer.wrap(tableId.getBytes(UTF_8)), textEndRow == null ? null : TextUtil.getByteBuffer(textEndRow), - textPrevEndRow == null ? null : TextUtil.getByteBuffer(textPrevEndRow)); + return new TKeyExtent(ByteBuffer.wrap(tableId.getUtf8()), textEndRow == null ? null : TextUtil.getByteBuffer(textEndRow), textPrevEndRow == null ? null + : TextUtil.getByteBuffer(textPrevEndRow)); } public boolean isPreviousExtent(KeyExtent prevExtent) { http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java b/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java index d34e379..b74ed08 100644 --- a/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java +++ b/core/src/main/java/org/apache/accumulo/core/data/impl/TabletIdImpl.java @@ -36,7 +36,7 @@ public class TabletIdImpl implements TabletId { @Override public Text getTableId() { - return new Text(ke.getTableId()); + return new Text(ke.getTableId().getUtf8()); } @Override http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/MetadataServicer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataServicer.java b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataServicer.java index c6cf61e..7eae639 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataServicer.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataServicer.java @@ -24,6 +24,7 @@ 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.ClientContext; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; /** @@ -33,10 +34,10 @@ public abstract class MetadataServicer { public static MetadataServicer forTableName(ClientContext context, String tableName) throws AccumuloException, AccumuloSecurityException { checkArgument(tableName != null, "tableName is null"); - return forTableId(context, context.getConnector().tableOperations().tableIdMap().get(tableName)); + return forTableId(context, new Table.ID(context.getConnector().tableOperations().tableIdMap().get(tableName))); } - public static MetadataServicer forTableId(ClientContext context, String tableId) { + public static MetadataServicer forTableId(ClientContext context, Table.ID tableId) { checkArgument(tableId != null, "tableId is null"); if (RootTable.ID.equals(tableId)) return new ServicerForRootTable(context); @@ -50,7 +51,7 @@ public abstract class MetadataServicer { * * @return the table id of the table currently being serviced */ - public abstract String getServicedTableId(); + public abstract Table.ID getServicedTableId(); /** * Populate the provided data structure with the known tablets for the table being serviced http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/MetadataTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataTable.java b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataTable.java index 56966d3..fefa679 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/MetadataTable.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/MetadataTable.java @@ -17,12 +17,13 @@ package org.apache.accumulo.core.metadata; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; public class MetadataTable { public static final String OLD_NAME = "!METADATA"; - public static final String ID = "!0"; + public static final Table.ID ID = Table.ID.METADATA; public static final String NAME = Namespaces.ACCUMULO_NAMESPACE + ".metadata"; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/RootTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/RootTable.java b/core/src/main/java/org/apache/accumulo/core/metadata/RootTable.java index 2052563..d2f0705 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/RootTable.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/RootTable.java @@ -17,6 +17,7 @@ package org.apache.accumulo.core.metadata; import org.apache.accumulo.core.client.impl.Namespaces; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; /** @@ -24,7 +25,7 @@ import org.apache.accumulo.core.data.impl.KeyExtent; */ public class RootTable { - public static final String ID = "+r"; + public static final Table.ID ID = Table.ID.ROOT; public static final String NAME = Namespaces.ACCUMULO_NAMESPACE + ".root"; /** http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForRootTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForRootTable.java b/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForRootTable.java index 32b5824..c6c0f00 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForRootTable.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForRootTable.java @@ -23,6 +23,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.data.impl.KeyExtent; /** @@ -38,7 +39,7 @@ class ServicerForRootTable extends MetadataServicer { } @Override - public String getServicedTableId() { + public Table.ID getServicedTableId() { return RootTable.ID; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForUserTables.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForUserTables.java b/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForUserTables.java index 73f9188..c8e4699 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForUserTables.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/ServicerForUserTables.java @@ -17,6 +17,7 @@ package org.apache.accumulo.core.metadata; import org.apache.accumulo.core.client.impl.ClientContext; +import org.apache.accumulo.core.client.impl.Table; /** * A metadata servicer for user tables.<br> @@ -24,7 +25,7 @@ import org.apache.accumulo.core.client.impl.ClientContext; */ class ServicerForUserTables extends TableMetadataServicer { - public ServicerForUserTables(ClientContext context, String tableId) { + public ServicerForUserTables(ClientContext context, Table.ID tableId) { super(context, MetadataTable.NAME, tableId); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java b/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java index fcd74a3..90eab4d 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/TableMetadataServicer.java @@ -26,6 +26,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Scanner; 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.data.Key; import org.apache.accumulo.core.data.Value; import org.apache.accumulo.core.data.impl.KeyExtent; @@ -39,17 +40,17 @@ import org.apache.hadoop.io.Text; abstract class TableMetadataServicer extends MetadataServicer { private final ClientContext context; - private String tableIdBeingServiced; + private Table.ID tableIdBeingServiced; private String serviceTableName; - public TableMetadataServicer(ClientContext context, String serviceTableName, String tableIdBeingServiced) { + public TableMetadataServicer(ClientContext context, String serviceTableName, Table.ID tableIdBeingServiced) { this.context = context; this.serviceTableName = serviceTableName; this.tableIdBeingServiced = tableIdBeingServiced; } @Override - public String getServicedTableId() { + public Table.ID getServicedTableId() { return tableIdBeingServiced; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java index 7e92b64..bb64a90 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataScanner.java @@ -31,6 +31,7 @@ import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.Scanner; 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.data.impl.KeyExtent; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.RootTable; @@ -58,9 +59,9 @@ public class MetadataScanner { ColumnOptions overMetadataTable(); - ColumnOptions overUserTableId(String tableId); + ColumnOptions overUserTableId(Table.ID tableId); - ColumnOptions overUserTableId(String tableId, Text startRow, Text endRow); + ColumnOptions overUserTableId(Table.ID tableId, Text startRow, Text endRow); } public static interface ColumnOptions { @@ -111,7 +112,7 @@ public class MetadataScanner { private Scanner scanner; private ClientContext ctx; private String table; - private String userTableId; + private Table.ID userTableId; private EnumSet<FetchedColumns> fetchedCols = EnumSet.noneOf(FetchedColumns.class); private Text startRow; private Text endRow; @@ -198,7 +199,7 @@ public class MetadataScanner { } @Override - public ColumnOptions overUserTableId(String tableId) { + public ColumnOptions overUserTableId(Table.ID tableId) { Preconditions.checkArgument(!tableId.equals(RootTable.ID) && !tableId.equals(MetadataTable.ID)); this.table = MetadataTable.NAME; @@ -219,7 +220,7 @@ public class MetadataScanner { } @Override - public ColumnOptions overUserTableId(String tableId, Text startRow, Text endRow) { + public ColumnOptions overUserTableId(Table.ID tableId, Text startRow, Text endRow) { this.table = MetadataTable.NAME; this.userTableId = tableId; this.startRow = startRow; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java index c93987d..cf00164 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/MetadataSchema.java @@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import org.apache.accumulo.core.client.admin.TimeType; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.ArrayByteSequence; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.PartialKey; @@ -45,12 +46,12 @@ public class MetadataSchema { return section.getRange(); } - public static Range getRange(String tableId) { - return new Range(new Key(tableId + ';'), true, new Key(tableId + '<').followingKey(PartialKey.ROW), false); + public static Range getRange(Table.ID tableId) { + return new Range(new Key(tableId.canonicalID() + ';'), true, new Key(tableId.canonicalID() + '<').followingKey(PartialKey.ROW), false); } - public static Text getRow(String tableId, Text endRow) { - Text entry = new Text(tableId); + public static Text getRow(Table.ID tableId, Text endRow) { + Text entry = new Text(tableId.getUtf8()); if (endRow == null) { // append delimiter for default tablet @@ -259,9 +260,9 @@ public class MetadataSchema { * @param k * Key to extract from */ - public static String getTableId(Key k) { + public static Table.ID getTableId(Key k) { requireNonNull(k); - return k.getColumnQualifier().toString(); + return new Table.ID(k.getColumnQualifier().toString()); } /** http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java index af5f814..f0c758f 100644 --- a/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java +++ b/core/src/main/java/org/apache/accumulo/core/metadata/schema/TabletMetadata.java @@ -27,6 +27,7 @@ import java.util.Objects; import org.apache.accumulo.core.client.RowIterator; import org.apache.accumulo.core.client.Scanner; +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.Value; @@ -45,7 +46,7 @@ import com.google.common.net.HostAndPort; public class TabletMetadata { - private String tableId; + private Table.ID tableId; private Text prevEndRow; private Text endRow; private Location location; @@ -86,7 +87,7 @@ public class TabletMetadata { } } - public String getTableId() { + public Table.ID getTableId() { return tableId; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/replication/ReplicationSchema.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationSchema.java b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationSchema.java index 94d19b5..5c6a83d 100644 --- a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationSchema.java +++ b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationSchema.java @@ -23,6 +23,7 @@ import static java.util.Objects.requireNonNull; import java.nio.charset.CharacterCodingException; import org.apache.accumulo.core.client.ScannerBase; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.lexicoder.ULongLexicoder; import org.apache.accumulo.core.data.ArrayByteSequence; import org.apache.accumulo.core.data.ByteSequence; @@ -96,9 +97,9 @@ public class ReplicationSchema { * Key to extract from * @return The table ID */ - public static String getTableId(Key k) { + public static Table.ID getTableId(Key k) { requireNonNull(k); - return k.getColumnQualifier().toString(); + return new Table.ID(k.getColumnQualifier().toString()); } /** @@ -124,8 +125,8 @@ public class ReplicationSchema { scanner.fetchColumnFamily(NAME); } - public static Mutation add(Mutation m, String tableId, Value v) { - m.put(NAME, new Text(tableId), v); + public static Mutation add(Mutation m, Table.ID tableId, Value v) { + m.put(NAME, new Text(tableId.getUtf8()), v); return m; } } @@ -217,8 +218,8 @@ public class ReplicationSchema { * Serialized Status msg * @return The original Mutation */ - public static Mutation add(Mutation m, String tableId, Value v) { - m.put(NAME, new Text(tableId), v); + public static Mutation add(Mutation m, Table.ID tableId, Value v) { + m.put(NAME, new Text(tableId.getUtf8()), v); return m; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java index 7076757..4eb2e2c 100644 --- a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java +++ b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTable.java @@ -30,6 +30,7 @@ import org.apache.accumulo.core.client.Scanner; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.TableOfflineException; 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.master.state.tables.TableState; import org.apache.accumulo.core.replication.ReplicationSchema.StatusSection; @@ -45,7 +46,7 @@ import com.google.common.collect.ImmutableMap; public class ReplicationTable { private static final Logger log = LoggerFactory.getLogger(ReplicationTable.class); - public static final String ID = "+rep"; + public static final Table.ID ID = new Table.ID("+rep"); public static final String NAME = Namespaces.ACCUMULO_NAMESPACE + ".replication"; public static final String COMBINER_NAME = "statuscombiner"; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTarget.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTarget.java b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTarget.java index eb7833e..95659a2 100644 --- a/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTarget.java +++ b/core/src/main/java/org/apache/accumulo/core/replication/ReplicationTarget.java @@ -22,6 +22,7 @@ import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import org.apache.accumulo.core.client.impl.Table; import org.apache.hadoop.io.DataInputBuffer; import org.apache.hadoop.io.DataOutputBuffer; import org.apache.hadoop.io.Text; @@ -35,11 +36,11 @@ public class ReplicationTarget implements Writable { private String peerName; private String remoteIdentifier; - private String sourceTableId; + private Table.ID sourceTableId; public ReplicationTarget() {} - public ReplicationTarget(String peerName, String remoteIdentifier, String sourceTableId) { + public ReplicationTarget(String peerName, String remoteIdentifier, Table.ID sourceTableId) { this.peerName = peerName; this.remoteIdentifier = remoteIdentifier; this.sourceTableId = sourceTableId; @@ -61,11 +62,11 @@ public class ReplicationTarget implements Writable { this.remoteIdentifier = remoteIdentifier; } - public String getSourceTableId() { + public Table.ID getSourceTableId() { return sourceTableId; } - public void setSourceTableId(String sourceTableId) { + public void setSourceTableId(Table.ID sourceTableId) { this.sourceTableId = sourceTableId; } @@ -89,7 +90,7 @@ public class ReplicationTarget implements Writable { out.writeBoolean(false); } else { out.writeBoolean(true); - WritableUtils.writeString(out, sourceTableId); + WritableUtils.writeString(out, sourceTableId.canonicalID()); } } @@ -102,7 +103,7 @@ public class ReplicationTarget implements Writable { this.remoteIdentifier = WritableUtils.readString(in); } if (in.readBoolean()) { - this.sourceTableId = WritableUtils.readString(in); + this.sourceTableId = new Table.ID(WritableUtils.readString(in)); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java b/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java index 93aeea7..a4cc96d 100644 --- a/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java +++ b/core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java @@ -45,6 +45,7 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.TableNotFoundException; import org.apache.accumulo.core.client.impl.ClientContext; import org.apache.accumulo.core.client.impl.ServerClient; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.summary.SummarizerConfiguration; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.data.ByteSequence; @@ -99,7 +100,7 @@ public class Gatherer { private static final Logger log = LoggerFactory.getLogger(Gatherer.class); private ClientContext ctx; - private String tableId; + private Table.ID tableId; private SummarizerFactory factory; private Text startRow = null; private Text endRow = null; @@ -114,7 +115,7 @@ public class Gatherer { public Gatherer(ClientContext context, TSummaryRequest request, AccumuloConfiguration tableConfig) { this.ctx = context; - this.tableId = request.tableId; + this.tableId = new Table.ID(request.tableId); this.startRow = ByteBufferUtil.toText(request.bounds.startRow); this.endRow = ByteBufferUtil.toText(request.bounds.endRow); this.clipRange = new Range(startRow, false, endRow, true); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java b/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java index 27188fe..c94c853 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/util/ByteBufferUtil.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.ByteSequence; import org.apache.hadoop.io.Text; @@ -86,6 +87,10 @@ public class ByteBufferUtil { } } + public static Table.ID toTableId(ByteBuffer bytes) { + return new Table.ID(toString(bytes)); + } + public static ByteBuffer toByteBuffers(ByteSequence bs) { if (bs == null) return null; http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/main/java/org/apache/accumulo/core/util/Merge.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/util/Merge.java b/core/src/main/java/org/apache/accumulo/core/util/Merge.java index f15da96..33172d4 100644 --- a/core/src/main/java/org/apache/accumulo/core/util/Merge.java +++ b/core/src/main/java/org/apache/accumulo/core/util/Merge.java @@ -24,6 +24,7 @@ import java.util.Map.Entry; import org.apache.accumulo.core.cli.ClientOnRequiredTable; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Scanner; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.impl.Tables; import org.apache.accumulo.core.conf.AccumuloConfiguration; import org.apache.accumulo.core.conf.ConfigurationCopy; @@ -204,7 +205,7 @@ public class Merge { protected Iterator<Size> getSizeIterator(Connector conn, String tablename, Text start, Text end) throws MergeException { // open up metatadata, walk through the tablets. - String tableId; + Table.ID tableId; Scanner scanner; try { tableId = Tables.getTableId(conn.getInstance(), tablename); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerImplTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerImplTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerImplTest.java index 38e3c07..c6b4082 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerImplTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/impl/ScannerImplTest.java @@ -39,7 +39,7 @@ public class ScannerImplTest { @Test public void testValidReadaheadValues() { - Scanner s = new ScannerImpl(context, "foo", Authorizations.EMPTY); + Scanner s = new ScannerImpl(context, new Table.ID("foo"), Authorizations.EMPTY); s.setReadaheadThreshold(0); s.setReadaheadThreshold(10); s.setReadaheadThreshold(Long.MAX_VALUE); @@ -50,7 +50,7 @@ public class ScannerImplTest { @Test(expected = IllegalArgumentException.class) public void testInValidReadaheadValues() { - Scanner s = new ScannerImpl(context, "foo", Authorizations.EMPTY); + Scanner s = new ScannerImpl(context, new Table.ID("foo"), Authorizations.EMPTY); s.setReadaheadThreshold(-1); s.close(); } @@ -58,7 +58,7 @@ public class ScannerImplTest { @Test public void testGetAuthorizations() { Authorizations expected = new Authorizations("a,b"); - Scanner s = new ScannerImpl(context, "foo", expected); + Scanner s = new ScannerImpl(context, new Table.ID("foo"), expected); assertEquals(expected, s.getAuthorizations()); s.close(); } @@ -66,7 +66,7 @@ public class ScannerImplTest { @SuppressWarnings("resource") @Test(expected = IllegalArgumentException.class) public void testNullAuthorizationsFails() { - new ScannerImpl(context, "foo", null); + new ScannerImpl(context, new Table.ID("foo"), null); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/client/impl/TableOperationsImplTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/TableOperationsImplTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/TableOperationsImplTest.java index 825060b..8f59e17 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/impl/TableOperationsImplTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/impl/TableOperationsImplTest.java @@ -44,7 +44,7 @@ public class TableOperationsImplTest { Connector connector = EasyMock.createMock(Connector.class); Scanner scanner = EasyMock.createMock(Scanner.class); - Range range = new KeyExtent("1", null, null).toMetadataRange(); + Range range = new KeyExtent(new Table.ID("1"), null, null).toMetadataRange(); String user = "root"; PasswordToken token = new PasswordToken("password"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java index 39f1621..079becd 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/impl/TabletLocatorImplTest.java @@ -65,7 +65,7 @@ public class TabletLocatorImplTest { private static final KeyExtent MTE = new KeyExtent(MetadataTable.ID, null, RTE.getEndRow()); static KeyExtent nke(String t, String er, String per) { - return new KeyExtent(t, er == null ? null : new Text(er), per == null ? null : new Text(per)); + return new KeyExtent(new Table.ID(t), er == null ? null : new Text(er), per == null ? null : new Text(per)); } static Range nr(String k1, boolean si, String k2, boolean ei) { @@ -143,7 +143,7 @@ public class TabletLocatorImplTest { RootTabletLocator rtl = new TestRootTabletLocator(); TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker()); - TabletLocatorImpl tab1TabletCache = new TabletLocatorImpl(table, rootTabletCache, ttlo, tslc); + TabletLocatorImpl tab1TabletCache = new TabletLocatorImpl(new Table.ID(table), rootTabletCache, ttlo, tslc); setLocation(tservers, rootTabLoc, RTE, MTE, metaTabLoc); @@ -680,7 +680,7 @@ public class TabletLocatorImplTest { RootTabletLocator rtl = new TestRootTabletLocator(); TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker()); - TabletLocatorImpl tab1TabletCache = new TabletLocatorImpl("tab1", rootTabletCache, ttlo, new YesLockChecker()); + TabletLocatorImpl tab1TabletCache = new TabletLocatorImpl(new Table.ID("tab1"), rootTabletCache, ttlo, new YesLockChecker()); locateTabletTest(tab1TabletCache, "r1", null, null); @@ -1223,14 +1223,14 @@ public class TabletLocatorImplTest { RootTabletLocator rtl = new TestRootTabletLocator(); TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker()); - TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl("0", rootTabletCache, ttlo, new YesLockChecker()); + TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl(new Table.ID("0"), rootTabletCache, ttlo, new YesLockChecker()); setLocation(tservers, "tserver1", RTE, mte1, "tserver2"); setLocation(tservers, "tserver1", RTE, mte2, "tserver3"); // create two tablets that straddle a metadata split point - KeyExtent ke1 = new KeyExtent("0", new Text("0bbf20e"), null); - KeyExtent ke2 = new KeyExtent("0", new Text("0bc0756"), new Text("0bbf20e")); + KeyExtent ke1 = new KeyExtent(new Table.ID("0"), new Text("0bbf20e"), null); + KeyExtent ke2 = new KeyExtent(new Table.ID("0"), new Text("0bc0756"), new Text("0bbf20e")); setLocation(tservers, "tserver2", mte1, ke1, "tserver4"); setLocation(tservers, "tserver3", mte2, ke2, "tserver5"); @@ -1250,7 +1250,7 @@ public class TabletLocatorImplTest { RootTabletLocator rtl = new TestRootTabletLocator(); TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker()); - TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl("0", rootTabletCache, ttlo, new YesLockChecker()); + TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl(new Table.ID("0"), rootTabletCache, ttlo, new YesLockChecker()); setLocation(tservers, "tserver1", RTE, mte1, "tserver2"); setLocation(tservers, "tserver1", RTE, mte2, "tserver3"); @@ -1273,7 +1273,7 @@ public class TabletLocatorImplTest { KeyExtent mte4 = new KeyExtent(MetadataTable.ID, new Text("1;r"), new Text("1;j")); KeyExtent mte5 = new KeyExtent(MetadataTable.ID, null, new Text("1;r")); - KeyExtent ke1 = new KeyExtent("1", null, null); + KeyExtent ke1 = new KeyExtent(new Table.ID("1"), null, null); TServers tservers = new TServers(); TestTabletLocationObtainer ttlo = new TestTabletLocationObtainer(tservers); @@ -1281,7 +1281,7 @@ public class TabletLocatorImplTest { RootTabletLocator rtl = new TestRootTabletLocator(); TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker()); - TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl("1", rootTabletCache, ttlo, new YesLockChecker()); + TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl(new Table.ID("1"), rootTabletCache, ttlo, new YesLockChecker()); setLocation(tservers, "tserver1", RTE, mte1, "tserver2"); setLocation(tservers, "tserver1", RTE, mte2, "tserver3"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderTest.java b/core/src/test/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderTest.java index af4a474..7f2780e 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderTest.java @@ -36,7 +36,7 @@ public class TabletServerBatchReaderTest { @Test public void testGetAuthorizations() { Authorizations expected = new Authorizations("a,b"); - try (BatchScanner s = new TabletServerBatchReader(context, "foo", expected, 1)) { + try (BatchScanner s = new TabletServerBatchReader(context, new Table.ID("foo"), expected, 1)) { assertEquals(expected, s.getAuthorizations()); } } @@ -44,6 +44,6 @@ public class TabletServerBatchReaderTest { @SuppressWarnings("resource") @Test(expected = IllegalArgumentException.class) public void testNullAuthorizationsFails() { - new TabletServerBatchReader(context, "foo", null, 1); + new TabletServerBatchReader(context, new Table.ID("foo"), null, 1); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplitTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplitTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplitTest.java index 17c781d..40f92e1 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplitTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/impl/BatchInputSplitTest.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Set; import org.apache.accumulo.core.client.IteratorSetting; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.client.security.tokens.PasswordToken; import org.apache.accumulo.core.data.Key; import org.apache.accumulo.core.data.Range; @@ -45,7 +46,7 @@ public class BatchInputSplitTest { @Test public void testSimpleWritable() throws IOException { Range[] ranges = new Range[] {new Range(new Key("a"), new Key("b"))}; - BatchInputSplit split = new BatchInputSplit("table", "1", Arrays.asList(ranges), new String[] {"localhost"}); + BatchInputSplit split = new BatchInputSplit("table", new Table.ID("1"), Arrays.asList(ranges), new String[] {"localhost"}); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); @@ -66,7 +67,7 @@ public class BatchInputSplitTest { @Test public void testAllFieldsWritable() throws IOException { Range[] ranges = new Range[] {new Range(new Key("a"), new Key("b"))}; - BatchInputSplit split = new BatchInputSplit("table", "1", Arrays.asList(ranges), new String[] {"localhost"}); + BatchInputSplit split = new BatchInputSplit("table", new Table.ID("1"), Arrays.asList(ranges), new String[] {"localhost"}); Set<Pair<Text,Text>> fetchedColumns = new HashSet<>(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java b/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java index 79968be..73035d6 100644 --- a/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java +++ b/core/src/test/java/org/apache/accumulo/core/data/KeyExtentTest.java @@ -37,6 +37,7 @@ import java.util.SortedMap; import java.util.TreeMap; import java.util.TreeSet; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.hadoop.io.Text; import org.junit.Before; @@ -44,7 +45,7 @@ import org.junit.Test; public class KeyExtentTest { KeyExtent nke(String t, String er, String per) { - return new KeyExtent(t, er == null ? null : new Text(er), per == null ? null : new Text(per)); + return new KeyExtent(new Table.ID(t), er == null ? null : new Text(er), per == null ? null : new Text(per)); } KeyExtent ke; @@ -62,7 +63,7 @@ public class KeyExtentTest { ke = new KeyExtent(flattenedExtent, (Text) null); assertEquals(new Text("bar"), ke.getEndRow()); - assertEquals("foo", ke.getTableId()); + assertEquals("foo", ke.getTableId().canonicalID()); assertNull(ke.getPrevEndRow()); flattenedExtent = new Text("foo<"); @@ -70,7 +71,7 @@ public class KeyExtentTest { ke = new KeyExtent(flattenedExtent, (Text) null); assertNull(ke.getEndRow()); - assertEquals("foo", ke.getTableId()); + assertEquals("foo", ke.getTableId().canonicalID()); assertNull(ke.getPrevEndRow()); flattenedExtent = new Text("foo;bar;"); @@ -78,7 +79,7 @@ public class KeyExtentTest { ke = new KeyExtent(flattenedExtent, (Text) null); assertEquals(new Text("bar;"), ke.getEndRow()); - assertEquals("foo", ke.getTableId()); + assertEquals("foo", ke.getTableId().canonicalID()); assertNull(ke.getPrevEndRow()); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/d6ea49e0/core/src/test/java/org/apache/accumulo/core/data/RangeTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/data/RangeTest.java b/core/src/test/java/org/apache/accumulo/core/data/RangeTest.java index fe7f1f8..388c883 100644 --- a/core/src/test/java/org/apache/accumulo/core/data/RangeTest.java +++ b/core/src/test/java/org/apache/accumulo/core/data/RangeTest.java @@ -27,6 +27,7 @@ import java.util.List; import junit.framework.TestCase; +import org.apache.accumulo.core.client.impl.Table; import org.apache.accumulo.core.data.impl.KeyExtent; import org.apache.accumulo.core.data.thrift.TRange; import org.apache.hadoop.io.Text; @@ -191,30 +192,31 @@ public class RangeTest extends TestCase { public void testMergeOverlapping22() { - Range ke1 = new KeyExtent("tab1", new Text("Bank"), null).toMetadataRange(); - Range ke2 = new KeyExtent("tab1", new Text("Fails"), new Text("Bank")).toMetadataRange(); - Range ke3 = new KeyExtent("tab1", new Text("Sam"), new Text("Fails")).toMetadataRange(); - Range ke4 = new KeyExtent("tab1", new Text("bails"), new Text("Sam")).toMetadataRange(); - Range ke5 = new KeyExtent("tab1", null, new Text("bails")).toMetadataRange(); + Range ke1 = new KeyExtent(new Table.ID("tab1"), new Text("Bank"), null).toMetadataRange(); + Range ke2 = new KeyExtent(new Table.ID("tab1"), new Text("Fails"), new Text("Bank")).toMetadataRange(); + Range ke3 = new KeyExtent(new Table.ID("tab1"), new Text("Sam"), new Text("Fails")).toMetadataRange(); + Range ke4 = new KeyExtent(new Table.ID("tab1"), new Text("bails"), new Text("Sam")).toMetadataRange(); + Range ke5 = new KeyExtent(new Table.ID("tab1"), null, new Text("bails")).toMetadataRange(); List<Range> rl = newRangeList(ke1, ke2, ke3, ke4, ke5); - List<Range> expected = newRangeList(new KeyExtent("tab1", null, null).toMetadataRange()); + List<Range> expected = newRangeList(new KeyExtent(new Table.ID("tab1"), null, null).toMetadataRange()); check(Range.mergeOverlapping(rl), expected); rl = newRangeList(ke1, ke2, ke4, ke5); - expected = newRangeList(new KeyExtent("tab1", new Text("Fails"), null).toMetadataRange(), new KeyExtent("tab1", null, new Text("Sam")).toMetadataRange()); + expected = newRangeList(new KeyExtent(new Table.ID("tab1"), new Text("Fails"), null).toMetadataRange(), new KeyExtent(new Table.ID("tab1"), null, new Text( + "Sam")).toMetadataRange()); check(Range.mergeOverlapping(rl), expected); rl = newRangeList(ke2, ke3, ke4, ke5); - expected = newRangeList(new KeyExtent("tab1", null, new Text("Bank")).toMetadataRange()); + expected = newRangeList(new KeyExtent(new Table.ID("tab1"), null, new Text("Bank")).toMetadataRange()); check(Range.mergeOverlapping(rl), expected); rl = newRangeList(ke1, ke2, ke3, ke4); - expected = newRangeList(new KeyExtent("tab1", new Text("bails"), null).toMetadataRange()); + expected = newRangeList(new KeyExtent(new Table.ID("tab1"), new Text("bails"), null).toMetadataRange()); check(Range.mergeOverlapping(rl), expected); rl = newRangeList(ke2, ke3, ke4); - expected = newRangeList(new KeyExtent("tab1", new Text("bails"), new Text("Bank")).toMetadataRange()); + expected = newRangeList(new KeyExtent(new Table.ID("tab1"), new Text("bails"), new Text("Bank")).toMetadataRange()); check(Range.mergeOverlapping(rl), expected); }