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

svn commit: r1230701 - in /incubator/accumulo/trunk: ./ src/core/ src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java src/server/

Author: kturner
Date: Thu Jan 12 18:55:09 2012
New Revision: 1230701

URL: http://svn.apache.org/viewvc?rev=1230701&view=rev
Log:
ACCUMULO-310 - refactored static methids to Configurations (merged from 1.4)

Modified:
    incubator/accumulo/trunk/   (props changed)
    incubator/accumulo/trunk/src/core/   (props changed)
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
    incubator/accumulo/trunk/src/server/   (props changed)

Propchange: incubator/accumulo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 12 18:55:09 2012
@@ -1,3 +1,3 @@
 /incubator/accumulo/branches/1.3:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124,1209526,1209532,1209539,1209541,1209587,1209657,1210518,1210571,1210596,1210598,1213424,1214320,1225006,1227215,1227231,1227611,1228195,1230180
 /incubator/accumulo/branches/1.3.5rc:1209938
-/incubator/accumulo/branches/1.4:1201902-1230674
+/incubator/accumulo/branches/1.4:1201902-1230699

Propchange: incubator/accumulo/trunk/src/core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 12 18:55:09 2012
@@ -1,3 +1,3 @@
 /incubator/accumulo/branches/1.3/src/core:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124,1209526,1209532,1209539,1209541,1209587,1209657,1210518,1210571,1210596,1210598,1213424,1214320,1225006,1227215
 /incubator/accumulo/branches/1.3.5rc/src/core:1209938
-/incubator/accumulo/branches/1.4/src/core:1201902-1230674
+/incubator/accumulo/branches/1.4/src/core:1201902-1230699

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java?rev=1230701&r1=1230700&r2=1230701&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloOutputFormat.java Thu Jan 12 18:55:09 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> {

Propchange: incubator/accumulo/trunk/src/server/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 12 18:55:09 2012
@@ -1,3 +1,3 @@
 /incubator/accumulo/branches/1.3/src/server:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124,1209526,1209532,1209539,1209541,1209587,1209657,1210518,1210571,1210596,1210598,1213424,1214320,1225006,1227215,1227231,1227611
 /incubator/accumulo/branches/1.3.5rc/src/server:1209938
-/incubator/accumulo/branches/1.4/src/server:1201902-1230674
+/incubator/accumulo/branches/1.4/src/server:1201902-1230699