The legacy mapred InputFormatBase now verifies (and fixes the scanner for) a possible change in table name that could happen between the configuration of the map/reduce job and the actual processing of the scanner for a specific split. In that case, the most recent table name associated with the id is always used for the scanner (though the table name that was expected during job setup is still used in the RangeInputSplit). ACCUMULO-391
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/c8a85832 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/c8a85832 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/c8a85832 Branch: refs/heads/ACCUMULO-391 Commit: c8a858323b69d5ba73dc684e9b0033772dbf2119 Parents: fca2731 Author: Corey J. Nolet <[email protected]> Authored: Sat Sep 28 23:01:04 2013 -0400 Committer: Corey J. Nolet <[email protected]> Committed: Sat Sep 28 23:29:37 2013 -0400 ---------------------------------------------------------------------- .../accumulo/core/client/mapred/InputFormatBase.java | 15 ++++++++++++++- .../client/mapreduce/AccumuloInputFormatTest.java | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/c8a85832/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java index 2d4eadf..fb1b193 100644 --- a/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java +++ b/core/src/main/java/org/apache/accumulo/core/client/mapred/InputFormatBase.java @@ -594,6 +594,19 @@ public abstract class InputFormatBase<K,V> implements InputFormat<K,V> { AuthenticationToken token = getAuthenticationToken(job); Authorizations authorizations = getScanAuthorizations(job); + // in case the table name changed, we can still use the previous name for terms of configuration, + // but for the scanner, we'll need to reference the new table name. + String actualNameForId = split.getTableName(); + if(!(instance instanceof MockInstance)) { // Really, the Tables helper class should not be tied to Zookeeper + try { + actualNameForId = Tables.getTableName(instance, split.getTableId()); + if (!actualNameForId.equals(split.getTableName())) + log.debug("Table name changed from " + split.getTableName() + " to " + actualNameForId); + } catch (TableNotFoundException e) { + throw new IOException("The specified table was not found for id=" + split.getTableId()); + } + } + try { log.debug("Creating connector with user: " + user); Connector conn = instance.getConnector(user, token); @@ -602,7 +615,7 @@ public abstract class InputFormatBase<K,V> implements InputFormat<K,V> { if (isOfflineScan(job)) { scanner = new OfflineScanner(instance, new Credentials(user, token), Tables.getTableId(instance, getInputTableName(job)), authorizations); } else { - scanner = conn.createScanner(getInputTableName(job), authorizations); + scanner = conn.createScanner(actualNameForId, authorizations); } if (isIsolated(job)) { log.info("Creating isolated scanner"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/c8a85832/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java index 96a67a6..1b4aa26 100644 --- a/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java +++ b/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloInputFormatTest.java @@ -331,5 +331,4 @@ public class AccumuloInputFormatTest { assertEquals(table1, AccumuloInputFormat.getTableQueryConfiguration(job, TEST_TABLE_1)); assertEquals(table2, AccumuloInputFormat.getTableQueryConfiguration(job, TEST_TABLE_2)); } - }
