You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by vi...@apache.org on 2012/01/12 19:14:48 UTC

svn commit: r1230680 - /incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java

Author: vines
Date: Thu Jan 12 18:14:48 2012
New Revision: 1230680

URL: http://svn.apache.org/viewvc?rev=1230680&view=rev
Log:
Fixes ACCUMULO-310 - refactored static methids to Configurations

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java?rev=1230680&r1=1230679&r2=1230680&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java (original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java Thu Jan 12 18:14:48 2012
@@ -101,9 +101,27 @@ public class AccumuloOutputFormat extend
    *          the output format will create new tables as necessary. Table names can only be alpha-numeric and underscores.
    * @param defaultTable
    *          the table to use when the tablename is null in the write call
+   * @deprecated Use {@link #setOutputInfo(Configuration,String,byte[],boolean,String)} instead
    */
   public static void setOutputInfo(JobContext job, String user, byte[] passwd, boolean createTables, String defaultTable) {
-    Configuration conf = job.getConfiguration();
+    setOutputInfo(job.getConfiguration(), user, passwd, createTables, defaultTable);
+  }
+
+  /**
+   * Configure the output format.
+   * 
+   * @param conf
+   *          the Map/Reduce job object
+   * @param user
+   *          the username, which must have the Table.CREATE permission to create tables
+   * @param passwd
+   *          the passwd for the username
+   * @param createTables
+   *          the output format will create new tables as necessary. Table names can only be alpha-numeric and underscores.
+   * @param defaultTable
+   *          the table to use when the tablename is null in the write call
+   */
+  public static void setOutputInfo(Configuration conf, String user, byte[] passwd, boolean createTables, String defaultTable) {
     if (conf.getBoolean(OUTPUT_INFO_HAS_BEEN_SET, false))
       throw new IllegalStateException("Output info can only be set once per job");
     conf.setBoolean(OUTPUT_INFO_HAS_BEEN_SET, true);
@@ -116,8 +134,14 @@ public class AccumuloOutputFormat extend
       conf.set(DEFAULT_TABLE_NAME, defaultTable);
   }
   
+  /**
+   * @deprecated Use {@link #setZooKeeperInstance(Configuration,String,String)} instead
+   */
   public static void setZooKeeperInstance(JobContext job, String instanceName, String zooKeepers) {
-    Configuration conf = job.getConfiguration();
+    setZooKeeperInstance(job.getConfiguration(), instanceName, zooKeepers);
+  }
+
+  public static void setZooKeeperInstance(Configuration conf, String instanceName, String zooKeepers) {
     if (conf.getBoolean(INSTANCE_HAS_BEEN_SET, false))
       throw new IllegalStateException("Instance info can only be set once per job");
     conf.setBoolean(INSTANCE_HAS_BEEN_SET, true);
@@ -127,81 +151,194 @@ public class AccumuloOutputFormat extend
     conf.set(ZOOKEEPERS, zooKeepers);
   }
   
+  /**
+   * @deprecated Use {@link #setMockInstance(Configuration,String)} instead
+   */
   public static void setMockInstance(JobContext job, String instanceName) {
-    Configuration conf = job.getConfiguration();
+    setMockInstance(job.getConfiguration(), instanceName);
+  }
+
+  public static void setMockInstance(Configuration conf, String instanceName) {
     conf.setBoolean(INSTANCE_HAS_BEEN_SET, true);
     conf.setBoolean(MOCK, true);
     conf.set(INSTANCE_NAME, instanceName);
   }
   
+  /**
+   * @deprecated Use {@link #setMaxMutationBufferSize(Configuration,long)} instead
+   */
   public static void setMaxMutationBufferSize(JobContext job, long numberOfBytes) {
-    job.getConfiguration().setLong(MAX_MUTATION_BUFFER_SIZE, numberOfBytes);
+    setMaxMutationBufferSize(job.getConfiguration(), numberOfBytes);
+  }
+
+  public static void setMaxMutationBufferSize(Configuration conf, long numberOfBytes) {
+    conf.setLong(MAX_MUTATION_BUFFER_SIZE, numberOfBytes);
   }
   
+  /**
+   * @deprecated Use {@link #setMaxLatency(Configuration,int)} instead
+   */
   public static void setMaxLatency(JobContext job, int numberOfMilliseconds) {
-    job.getConfiguration().setInt(MAX_LATENCY, numberOfMilliseconds);
+    setMaxLatency(job.getConfiguration(), numberOfMilliseconds);
   }
   
+  public static void setMaxLatency(Configuration conf, int numberOfMilliseconds) {
+    conf.setInt(MAX_LATENCY, numberOfMilliseconds);
+  }
+  
+  /**
+   * @deprecated Use {@link #setMaxWriteThreads(Configuration,int)} instead
+   */
   public static void setMaxWriteThreads(JobContext job, int numberOfThreads) {
-    job.getConfiguration().setInt(NUM_WRITE_THREADS, numberOfThreads);
+    setMaxWriteThreads(job.getConfiguration(), numberOfThreads);
+  }
+  
+  public static void setMaxWriteThreads(Configuration conf, int numberOfThreads) {
+    conf.setInt(NUM_WRITE_THREADS, numberOfThreads);
   }
   
+  /**
+   * @deprecated Use {@link #setLogLevel(Configuration,Level)} instead
+   */
   public static void setLogLevel(JobContext job, Level level) {
+    setLogLevel(job.getConfiguration(), level);
+  }
+  
+  public static void setLogLevel(Configuration conf, Level level) {
     ArgumentChecker.notNull(level);
-    job.getConfiguration().setInt(LOGLEVEL, level.toInt());
+    conf.setInt(LOGLEVEL, level.toInt());
   }
   
+  /**
+   * @deprecated Use {@link #setSimulationMode(Configurtion)} instead
+   */
   public static void setSimulationMode(JobContext job) {
-    job.getConfiguration().setBoolean(SIMULATE, true);
+    setSimulationMode(job.getConfiguration());
   }
   
+  public static void setSimulationMode(Configuration conf) {
+    conf.setBoolean(SIMULATE, true);
+  }
+  
+  /**
+   * @deprecated Use {@link #getUsername(Configuration)} instead
+   */
   protected static String getUsername(JobContext job) {
-    return job.getConfiguration().get(USERNAME);
+    return getUsername(job.getConfiguration());
+  }
+  
+  protected static String getUsername(Configuration conf) {
+    return conf.get(USERNAME);
   }
   
   /**
    * WARNING: The password is stored in the Configuration and shared with all MapReduce tasks; It is BASE64 encoded to provide a charset safe conversion to a
    * string, and is not intended to be secure.
+   * 
+   * @deprecated Use {@link #getPassword(Configuration)} instead
    */
   protected static byte[] getPassword(JobContext job) {
-    return Base64.decodeBase64(job.getConfiguration().get(PASSWORD, "").getBytes());
+    return getPassword(job.getConfiguration());
   }
   
+  /**
+   * WARNING: The password is stored in the Configuration and shared with all MapReduce tasks; It is BASE64 encoded to provide a charset safe conversion to a
+   * string, and is not intended to be secure.
+   */
+  protected static byte[] getPassword(Configuration conf) {
+    return Base64.decodeBase64(conf.get(PASSWORD, "").getBytes());
+  }
+  
+  /**
+   * @deprecated Use {@link #canCreateTables(Configuration)} instead
+   */
   protected static boolean canCreateTables(JobContext job) {
-    return job.getConfiguration().getBoolean(CREATETABLES, false);
+    return canCreateTables(job.getConfiguration());
   }
   
+  protected static boolean canCreateTables(Configuration conf) {
+    return conf.getBoolean(CREATETABLES, false);
+  }
+  
+  /**
+   * @deprecated Use {@link #getDefaultTableName(Configuration)} instead
+   */
   protected static String getDefaultTableName(JobContext job) {
-    return job.getConfiguration().get(DEFAULT_TABLE_NAME);
+    return getDefaultTableName(job.getConfiguration());
+  }
+  
+  protected static String getDefaultTableName(Configuration conf) {
+    return conf.get(DEFAULT_TABLE_NAME);
   }
   
+  /**
+   * @deprecated Use {@link #getInstance(Configuration)} instead
+   */
   protected static Instance getInstance(JobContext job) {
-    Configuration conf = job.getConfiguration();
+    return getInstance(job.getConfiguration());
+  }
+  
+  protected static Instance getInstance(Configuration conf) {
     if (conf.getBoolean(MOCK, false))
       return new MockInstance(conf.get(INSTANCE_NAME));
     return new ZooKeeperInstance(conf.get(INSTANCE_NAME), conf.get(ZOOKEEPERS));
   }
   
+  /**
+   * @deprecated Use {@link #getMaxMutationBufferSize(Configuration)} instead
+   */
   protected static long getMaxMutationBufferSize(JobContext job) {
-    return job.getConfiguration().getLong(MAX_MUTATION_BUFFER_SIZE, DEFAULT_MAX_MUTATION_BUFFER_SIZE);
+    return getMaxMutationBufferSize(job.getConfiguration());
+  }
+  
+  protected static long getMaxMutationBufferSize(Configuration conf) {
+    return conf.getLong(MAX_MUTATION_BUFFER_SIZE, DEFAULT_MAX_MUTATION_BUFFER_SIZE);
   }
   
+  /**
+   * @deprecated Use {@link #getMaxLatency(Configuration)} instead
+   */
   protected static int getMaxLatency(JobContext job) {
-    return job.getConfiguration().getInt(MAX_LATENCY, DEFAULT_MAX_LATENCY);
+    return getMaxLatency(job.getConfiguration());
   }
   
+  protected static int getMaxLatency(Configuration conf) {
+    return conf.getInt(MAX_LATENCY, DEFAULT_MAX_LATENCY);
+  }
+  
+  /**
+   * @deprecated Use {@link #getMaxWriteThreads(Configuration)} instead
+   */
   protected static int getMaxWriteThreads(JobContext job) {
-    return job.getConfiguration().getInt(NUM_WRITE_THREADS, DEFAULT_NUM_WRITE_THREADS);
+    return getMaxWriteThreads(job.getConfiguration());
   }
   
+  protected static int getMaxWriteThreads(Configuration conf) {
+    return conf.getInt(NUM_WRITE_THREADS, DEFAULT_NUM_WRITE_THREADS);
+  }
+  
+  /**
+   * @deprecated Use {@link #getLogLevel(Configuration)} instead
+   */
   protected static Level getLogLevel(JobContext job) {
-    if (job.getConfiguration().get(LOGLEVEL) != null)
-      return Level.toLevel(job.getConfiguration().getInt(LOGLEVEL, Level.INFO.toInt()));
+    return getLogLevel(job.getConfiguration());
+  }
+  
+  protected static Level getLogLevel(Configuration conf) {
+    if (conf.get(LOGLEVEL) != null)
+      return Level.toLevel(conf.getInt(LOGLEVEL, Level.INFO.toInt()));
     return null;
   }
   
+  /**
+   * @deprecated Use {@link #getSimulationMode(Configuration)} instead
+   */
   protected static boolean getSimulationMode(JobContext job) {
-    return job.getConfiguration().getBoolean(SIMULATE, false);
+    return getSimulationMode(job.getConfiguration());
+  }
+  
+  protected static boolean getSimulationMode(Configuration conf) {
+    return conf.getBoolean(SIMULATE, false);
   }
   
   private static class AccumuloRecordWriter extends RecordWriter<Text,Mutation> {