hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r566467 - in /lucene/hadoop/trunk/src/contrib/hbase: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/shell/ src/java/org/apache/hadoop/hbase/shell/generated/
Date Thu, 16 Aug 2007 01:56:30 GMT
Author: stack
Date: Wed Aug 15 18:56:29 2007
New Revision: 566467

URL: http://svn.apache.org/viewvc?view=rev&rev=566467
Log:
HADOOP-1672 HBase Shell should use new client classes

Use HTable and HTableAdmin to do what HClient used (Removed all
references to HClient).


Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ClearCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/Command.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CommandFactory.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConsoleTable.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CreateCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DeleteCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DropCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ExitCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/InsertCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ReturnMsg.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShowCommand.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Wed Aug 15 18:56:29 2007
@@ -96,3 +96,5 @@
  59. HADOOP-1711 HTable API should use interfaces instead of concrete classes as
      method parameters and return values
  60. HADOOP-1644 Compactions should not block updates
+ 60. HADOOP-1672 HBase Shell should use new client classes
+     (Edward Yoon via Stack).

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/Shell.java Wed
Aug 15 18:56:29 2007
@@ -43,7 +43,6 @@
   /** Main method */
   public static void main(String args[]) throws IOException {
     Configuration conf = new HBaseConfiguration();
-    HClient client = new HClient(conf);
     ConsoleReader reader = new ConsoleReader();
     reader.setBellEnabled(conf.getBoolean("hbaseshell.jline.bell.enabled",
         DEFAULT_BELL_ENABLED));
@@ -60,7 +59,7 @@
         try {
           Command cmd = parser.terminatedCommand();
           if (cmd != null) {
-            rs = cmd.execute(client);
+            rs = cmd.execute(conf);
           }
         } catch (ParseException pe) {
           String[] msg = pe.getMessage().split("[\n]");

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ClearCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ClearCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ClearCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ClearCommand.java
Wed Aug 15 18:56:29 2007
@@ -21,11 +21,11 @@
 
 import java.io.IOException;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
 
 public class ClearCommand extends BasicCommand {
 
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     clear();
     return null;
   }
@@ -34,7 +34,7 @@
     String osName = System.getProperty("os.name");
     if (osName.length() > 7 && osName.subSequence(0, 7).equals("Windows")) {
       try {
-        Runtime.getRuntime().exec("cls");
+        Runtime.getRuntime().exec("cmd /C cls");
       } catch (IOException e) {
         System.out.println("Can't clear." + e.toString());
       }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/Command.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/Command.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/Command.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/Command.java
Wed Aug 15 18:56:29 2007
@@ -19,12 +19,14 @@
  */
 package org.apache.hadoop.hbase.shell;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
 
 public interface Command {
+  
   /** family indicator */
   public static final String FAMILY_INDICATOR = ":";
 
   /** Execute a command */
-  public ReturnMsg execute(HClient client);
+  public ReturnMsg execute(Configuration conf);
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CommandFactory.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CommandFactory.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CommandFactory.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CommandFactory.java
Wed Aug 15 18:56:29 2007
@@ -23,5 +23,7 @@
  * Parser uses command factories to create command.
  */
 public interface CommandFactory {
+  
   Command getCommand();
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConsoleTable.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConsoleTable.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConsoleTable.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ConsoleTable.java
Wed Aug 15 18:56:29 2007
@@ -23,6 +23,7 @@
  * Manufactures console table, but stupid.
  */
 public class ConsoleTable {
+  
   public static void printHead(String name) {
     System.out.println("+------+----------------------+");
     System.out.print("| No.  | ");
@@ -187,4 +188,5 @@
       "----------------------+----------------------+");
     System.out.println();
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CreateCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CreateCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CreateCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/CreateCommand.java
Wed Aug 15 18:56:29 2007
@@ -22,36 +22,41 @@
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.io.Text;
 
 public class CreateCommand extends BasicCommand {
-  String table;
+  
+  private Text table;
+  private List<String> columnfamilies;
+  @SuppressWarnings("unused")
+  private int limit;
 
-  List<String> columnfamilies;
-
-  int limit;
-
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     if (this.table == null || this.columnfamilies == null)
       return new ReturnMsg(0, "Syntax error : Please check 'Create' syntax.");
 
     try {
-      HTableDescriptor desc = new HTableDescriptor(this.table);
-
+      HConnection conn = HConnectionManager.getConnection(conf);
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      
+      if (conn.tableExists(this.table)) {
+        return new ReturnMsg(0, "Table was already exsits.");
+      }
+      HTableDescriptor desc = new HTableDescriptor(this.table.toString());
       for (int i = 0; i < this.columnfamilies.size(); i++) {
-
         String columnFamily = columnfamilies.get(i);
         if (columnFamily.lastIndexOf(':') == (columnFamily.length() - 1)) {
           columnFamily = columnFamily.substring(0, columnFamily.length() - 1);
         }
         desc.addFamily(new HColumnDescriptor(columnFamily + FAMILY_INDICATOR));
-
       }
-
-      client.createTable(desc);
-
+      admin.createTable(desc);
       return new ReturnMsg(1, "Table created successfully.");
     } catch (IOException e) {
       return new ReturnMsg(0, "error msg : " + e.toString());
@@ -59,7 +64,7 @@
   }
 
   public void setTable(String table) {
-    this.table = table;
+    this.table = new Text(table);
   }
 
   public void setColumnfamilies(List<String> columnfamilies) {
@@ -69,4 +74,5 @@
   public void setLimit(int limit) {
     this.limit = limit;
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DeleteCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DeleteCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DeleteCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DeleteCommand.java
Wed Aug 15 18:56:29 2007
@@ -24,36 +24,35 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.io.Text;
 
 public class DeleteCommand extends BasicCommand {
-  String table;
+  
+  private Text table;
+  private Map<String, List<String>> condition;
 
-  Map<String, List<String>> condition;
-
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     if (this.table == null || condition == null)
       return new ReturnMsg(0, "Syntax error : Please check 'Delete' syntax.");
 
     try {
-      client.openTable(new Text(this.table));
-      long lockId = client.startUpdate(getRow());
+      HTable table = new HTable(conf, this.table);
+      long lockId = table.startUpdate(getRow());
 
       if (getColumn() != null) {
-
-        client.delete(lockId, getColumn());
-
+        table.delete(lockId, getColumn());
       } else {
-        Set<Text> keySet = client.getRow(getRow()).keySet();
+        Set<Text> keySet = table.getRow(getRow()).keySet();
         Text[] columnKey = keySet.toArray(new Text[keySet.size()]);
 
         for (int i = 0; i < columnKey.length; i++) {
-          client.delete(lockId, columnKey[i]);
+          table.delete(lockId, columnKey[i]);
         }
       }
 
-      client.commit(lockId);
+      table.commit(lockId);
 
       return new ReturnMsg(1, "1 deleted successfully. ");
     } catch (IOException e) {
@@ -62,7 +61,7 @@
   }
 
   public void setTable(String table) {
-    this.table = table;
+    this.table = new Text(table);
   }
 
   public void setCondition(Map<String, List<String>> cond) {
@@ -80,4 +79,5 @@
       return null;
     }
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DescCommand.java
Wed Aug 15 18:56:29 2007
@@ -21,31 +21,36 @@
 
 import java.io.IOException;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.io.Text;
 
 public class DescCommand extends BasicCommand {
-  String argument;
+  
+  private Text table;
 
-  public ReturnMsg execute(HClient client) {
-    if (this.argument == null) 
+  public ReturnMsg execute(Configuration conf) {
+    if (this.table == null) 
       return new ReturnMsg(0, "Syntax error : Please check 'Describe' syntax.");
 
     try {
-      HTableDescriptor[] tables = client.listTables();
+      HConnection conn = HConnectionManager.getConnection(conf);
+      
+      if (!conn.tableExists(this.table)) {
+        return new ReturnMsg(0, "Table not found.");
+      }
+
+      HTableDescriptor[] tables = conn.listTables();
       Text[] columns = null;
 
       for (int i = 0; i < tables.length; i++) {
-        if (tables[i].getName().toString().equals(this.argument)) {
+        if (tables[i].getName().equals(this.table)) {
           columns = tables[i].families().keySet().toArray(new Text[] {});
         }
       }
 
-      if (columns == null) {
-        return new ReturnMsg(0, "Table not found.");
-      }
-
       ConsoleTable.printHead("ColumnFamily Name");
       for (int ii = 0; ii < columns.length; ii++) {
         String familyName = columns[ii].toString().replace(FAMILY_INDICATOR, "");
@@ -59,7 +64,8 @@
     }
   }
 
-  public void setArgument(String argument) {
-    this.argument = argument;
+  public void setArgument(String table) {
+    this.table = new Text(table);
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DropCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DropCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DropCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/DropCommand.java
Wed Aug 15 18:56:29 2007
@@ -21,18 +21,21 @@
 
 import java.io.IOException;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.io.Text;
 
 public class DropCommand extends BasicCommand {
-  String argument;
+  
+  private Text table;
 
-  public ReturnMsg execute(HClient client) {
-    if (this.argument == null) 
+  public ReturnMsg execute(Configuration conf) {
+    if (this.table == null) 
       return new ReturnMsg(0, "Syntax error : Please check 'Drop' syntax.");
 
     try {
-      client.deleteTable(new Text(this.argument));
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      admin.deleteTable(this.table);
       
       return new ReturnMsg(1, "Table droped successfully.");
     } catch (IOException e) {
@@ -40,7 +43,8 @@
     }
   }
 
-  public void setArgument(String argument) {
-    this.argument = argument;
+  public void setArgument(String table) {
+    this.table = new Text(table);
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ExitCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ExitCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ExitCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ExitCommand.java
Wed Aug 15 18:56:29 2007
@@ -19,11 +19,11 @@
  */
 package org.apache.hadoop.hbase.shell;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
 
 public class ExitCommand extends BasicCommand {
 
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     System.exit(1);
     return null;
   }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HBaseShell.jj
Wed Aug 15 18:56:29 2007
@@ -38,7 +38,7 @@
  * Parsing command line.
  */
 public class Parser {
-  private static String QueryString;
+  private String QueryString;
   
   public Parser(String query) {
     this((Reader)(new StringReader(query)));

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/HelpCommand.java
Wed Aug 15 18:56:29 2007
@@ -19,12 +19,13 @@
  */
 package org.apache.hadoop.hbase.shell;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
 
 public class HelpCommand extends BasicCommand {
-  String argument;
+  
+  private String argument;
 
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     HelpManager.printHelp(this.argument);
     return null;
   }
@@ -32,4 +33,5 @@
   public void setArgument(String argument) {
     this.argument = argument;
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/InsertCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/InsertCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/InsertCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/InsertCommand.java
Wed Aug 15 18:56:29 2007
@@ -23,19 +23,18 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.io.Text;
 
 public class InsertCommand extends BasicCommand {
-  String table;
+  
+  private Text table;
+  private List<String> columnfamilies;
+  private List<String> values;
+  private Map<String, List<String>> condition;
 
-  List<String> columnfamilies;
-
-  List<String> values;
-
-  Map<String, List<String>> condition;
-
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     if (this.table == null || this.values == null || this.condition == null)
       return new ReturnMsg(0, "Syntax error : Please check 'Insert' syntax.");
 
@@ -44,14 +43,14 @@
           "Mismatch between values list and columnfamilies list");
 
     try {
-      client.openTable(new Text(this.table));
-      long lockId = client.startUpdate(new Text(getRow()));
+      HTable table = new HTable(conf, this.table);
+      long lockId = table.startUpdate(getRow());
 
       for (int i = 0; i < this.values.size(); i++) {
-        client.put(lockId, getColumn(i), getValue(i));
+        table.put(lockId, getColumn(i), getValue(i));
+        
       }
-
-      client.commit(lockId);
+      table.commit(lockId);
 
       return new ReturnMsg(1, "1 row inserted successfully.");
     } catch (IOException e) {
@@ -61,7 +60,7 @@
   }
 
   public void setTable(String table) {
-    this.table = table;
+    this.table = new Text(table);
   }
 
   public void setColumnfamilies(List<String> columnfamilies) {

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ReturnMsg.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ReturnMsg.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ReturnMsg.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ReturnMsg.java
Wed Aug 15 18:56:29 2007
@@ -20,8 +20,8 @@
 package org.apache.hadoop.hbase.shell;
 
 public class ReturnMsg {
+  
   private String msg;
-
   private int type;
 
   public ReturnMsg(int i, String string) {
@@ -41,4 +41,5 @@
   public int getType() {
     return this.type;
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/SelectCommand.java
Wed Aug 15 18:56:29 2007
@@ -24,47 +24,49 @@
 import java.util.Map;
 import java.util.TreeMap;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HScannerInterface;
 import org.apache.hadoop.hbase.HStoreKey;
+import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.Text;
 
 public class SelectCommand extends BasicCommand {
-  String table;
+  
+  private Text table;
+  private int limit;
+  private Map<String, List<String>> condition;
 
-  int limit;
-
-  Map<String, List<String>> condition;
-
-  public ReturnMsg execute(HClient client) {
+  public ReturnMsg execute(Configuration conf) {
     if (this.condition != null && this.condition.containsKey("error"))
       return new ReturnMsg(0, "Syntax error : Please check 'Select' syntax.");
 
     try {
-      client.openTable(new Text(this.table));
-
+      HTable table = new HTable(conf, this.table);
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      
       switch (getCondition()) {
       case 0:
 
-        HTableDescriptor[] tables = client.listTables();
+        HTableDescriptor[] tables = admin.listTables();
         Text[] columns = null;
 
-        if (this.table.equals(HConstants.ROOT_TABLE_NAME.toString())
-            || this.table.equals(HConstants.META_TABLE_NAME.toString())) {
+        if (this.table.equals(HConstants.ROOT_TABLE_NAME)
+            || this.table.equals(HConstants.META_TABLE_NAME)) {
           columns = HConstants.COLUMN_FAMILY_ARRAY;
         } else {
           for (int i = 0; i < tables.length; i++) {
-            if (tables[i].getName().toString().equals(this.table)) {
+            if (tables[i].getName().equals(this.table)) {
               columns = tables[i].families().keySet().toArray(new Text[] {});
             }
           }
         }
 
-        HScannerInterface scan = client.obtainScanner(columns, new Text(""));
+        HScannerInterface scan = table.obtainScanner(columns, new Text(""));
         HStoreKey key = new HStoreKey();
         TreeMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
 
@@ -100,7 +102,7 @@
 
         count = 0;
         ConsoleTable.selectHead();
-        for (Map.Entry<Text, byte[]> entry : client.getRow(new Text(getRow())).entrySet())
{
+        for (Map.Entry<Text, byte[]> entry : table.getRow(new Text(getRow())).entrySet())
{
 
           byte[] value = entry.getValue();
           String cellData = new String(value);
@@ -125,7 +127,7 @@
 
         Text[] column = new Text[] { new Text(getColumn()) };
 
-        HScannerInterface scanner = client.obtainScanner(column, new Text(""));
+        HScannerInterface scanner = table.obtainScanner(column, new Text(""));
         HStoreKey k = new HStoreKey();
         TreeMap<Text, byte[]> r = new TreeMap<Text, byte[]>();
 
@@ -150,7 +152,7 @@
 
       case 3:
 
-        byte[] rs1 = client.get(new Text(getRow()), new Text(getColumn()));
+        byte[] rs1 = table.get(new Text(getRow()), new Text(getColumn()));
 
         ConsoleTable.selectHead();
         ConsoleTable.printLine(0, getRow(), getColumn(),
@@ -161,7 +163,7 @@
 
       case 4:
 
-        byte[][] rs2 = client.get(new Text(getRow()), new Text(getColumn()), this.limit);
+        byte[][] rs2 = table.get(new Text(getRow()), new Text(getColumn()), this.limit);
 
         ConsoleTable.selectHead();
         for (int i = 0; i < rs2.length; i++) {
@@ -174,7 +176,7 @@
 
       case 5:
 
-        byte[][] rs3 = client.get(new Text(getRow()), new Text(getColumn()), getTime(), this.limit);
+        byte[][] rs3 = table.get(new Text(getRow()), new Text(getColumn()), getTime(), this.limit);
 
         ConsoleTable.selectHead();
         for (int i = 0; i < rs3.length; i++) {
@@ -194,7 +196,7 @@
   }
 
   public void setTable(String table) {
-    this.table = table;
+    this.table = new Text(table);
   }
 
   public void setLimit(int limit) {

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShowCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShowCommand.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShowCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/ShowCommand.java
Wed Aug 15 18:56:29 2007
@@ -21,21 +21,24 @@
 
 import java.io.IOException;
 
-import org.apache.hadoop.hbase.HClient;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HTableDescriptor;
 
 public class ShowCommand extends BasicCommand {
-  String argument;
+  
+  private String command;
 
-  public ReturnMsg execute(HClient client) {
-    if (this.argument == null)
+  public ReturnMsg execute(Configuration conf) {
+    if (this.command == null)
       return new ReturnMsg(0, "Syntax error : Please check 'Show' syntax.");
 
     try {
+      HBaseAdmin admin = new HBaseAdmin(conf);
+      
       int tableLength = 0;
-
-      if ("tables".equals(this.argument)) {
-        HTableDescriptor[] tables = client.listTables();
+      if ("tables".equals(this.command)) {
+        HTableDescriptor[] tables = admin.listTables();
         tableLength = tables.length;
         if (tableLength == 0) {
           return new ReturnMsg(0, "Table not found.");
@@ -57,6 +60,7 @@
   }
 
   public void setArgument(String argument) {
-    this.argument = argument;
+    this.command = argument;
   }
+  
 }

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java?view=diff&rev=566467&r1=566466&r2=566467
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/generated/Parser.java
Wed Aug 15 18:56:29 2007
@@ -33,7 +33,7 @@
  * Parsing command line.
  */
 public class Parser implements ParserConstants {
-  private static String QueryString;
+  private String QueryString;
 
   public Parser(String query) {
     this((Reader)(new StringReader(query)));



Mime
View raw message