accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cjno...@apache.org
Subject [4/5] git commit: 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.
Date Sun, 29 Sep 2013 03:29:00 GMT
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/d340d82c
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/d340d82c
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/d340d82c

Branch: refs/heads/ACCUMULO-391
Commit: d340d82c08d4b2181d6900cea1455913f268ba6e
Parents: 01b8f2a
Author: Corey J. Nolet <cjnolet@gmail.com>
Authored: Sat Sep 28 23:01:04 2013 -0400
Committer: Corey J. Nolet <cjnolet@gmail.com>
Committed: Sat Sep 28 23:01:04 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/d340d82c/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/d340d82c/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));
   }
-
 }


Mime
View raw message