hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r598524 - in /lucene/hadoop/trunk/src/contrib/hbase: ./ src/java/org/apache/hadoop/hbase/generated/master/ src/java/org/apache/hadoop/hbase/shell/
Date Tue, 27 Nov 2007 06:12:47 GMT
Author: stack
Date: Mon Nov 26 22:12:46 2007
New Revision: 598524

URL: http://svn.apache.org/viewvc?rev=598524&view=rev
Log:
HADOOP-2289 Useless efforts of looking for the non-existant table in select command.

Modified:
    lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
    lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/AlterCommand.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/EnableCommand.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/SelectCommand.java

Modified: lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt (original)
+++ lucene/hadoop/trunk/src/contrib/hbase/CHANGES.txt Mon Nov 26 22:12:46 2007
@@ -46,6 +46,8 @@
     HADOOP-2139 (phase 1) Increase parallelism in region servers.
     HADOOP-2267 [Hbase Shell] Change the prompt's title from 'hbase' to 'hql'.
     HADOOP-2139 (phase 2) Make region server more event driven
+    HADOOP-2289 Useless efforts of looking for the non-existant table in select
+                command.
 
 Release 0.15.1
 Branch 0.15

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/generated/master/master_jsp.java
Mon Nov 26 22:12:46 2007
@@ -103,13 +103,21 @@
       out.print(msg );
       out.write("</p>\n\n<h2>Region Servers</h2>\n");
  if (serverToServerInfos != null && serverToServerInfos.size() > 0) { 
-      out.write("\n<table>\n<tr><th>Address</th><th>Start Code</th><th>Load</th></tr>\n\n");
+      out.write('\n');
+ int totalRegions = 0;
+   int totalRequests = 0; 
+
+      out.write("\n\n<table>\n<tr><th rowspan=");
+      out.print( serverToServerInfos.size() + 1);
+      out.write("></th><th>Address</th><th>Start Code</th><th>Load</th></tr>\n\n");
    for (Map.Entry<String, HServerInfo> e: serverToServerInfos.entrySet()) {
        HServerInfo hsi = e.getValue();
        String url = "http://" +
          hsi.getServerAddress().getBindAddress().toString() + ":" +
          hsi.getInfoPort() + "/";
        String load = hsi.getLoad().toString();
+       totalRegions += hsi.getLoad().getNumberOfRegions();
+       totalRequests += hsi.getLoad().getNumberOfRequests();
        long startCode = hsi.getStartCode();
        String address = hsi.getServerAddress().toString();
 
@@ -122,9 +130,15 @@
       out.print( startCode );
       out.write("</td><td>");
       out.print( load );
-      out.write("</tr>\n");
+      out.write("</td></tr>\n");
    } 
-      out.write("\n</table>\n<p>Load is requests per <em>hbase.regionsserver.msginterval</em>
(");
+      out.write("\n<tr><th>Total: </th><td>servers: ");
+      out.print( serverToServerInfos.size() );
+      out.write("</td><td>&nbsp;</td><td>requests: ");
+      out.print( totalRequests );
+      out.write(" regions: ");
+      out.print( totalRegions );
+      out.write("</td></tr>\n</table>\n\n<p>Load is requests per
<em>hbase.regionsserver.msginterval</em> (");
       out.print(interval);
       out.write(" second(s)) and count of regions loaded</p>\n");
  } 

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/AlterCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/AlterCommand.java?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/AlterCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/AlterCommand.java
Mon Nov 26 22:12:46 2007
@@ -28,6 +28,8 @@
 import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -38,7 +40,7 @@
   private OperationType operationType = OperationType.NOOP;
   private Map<String, Map<String, Object>> columnSpecMap =
     new HashMap<String, Map<String, Object>>();
-  private String table;
+  private String tableName;
   private String column; // column to be dropped
 
   public AlterCommand(Writer o) {
@@ -47,28 +49,33 @@
 
   public ReturnMsg execute(HBaseConfiguration conf) {
     try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(this.tableName))) {
+        return new ReturnMsg(0, "'" + this.tableName + "' Table not found");
+      }
+      
       HBaseAdmin admin = new HBaseAdmin(conf);
       Set<String> columns = null;
       HColumnDescriptor columnDesc = null;
       switch (operationType) {
       case ADD:
-        disableTable(admin, table);
+        disableTable(admin, tableName);
         columns = columnSpecMap.keySet();
         for (String c : columns) {
           columnDesc = getColumnDescriptor(c, columnSpecMap.get(c));
-          println("Adding " + c + " to " + table +
+          println("Adding " + c + " to " + tableName +
             "... Please wait.");
-          admin.addColumn(new Text(table), columnDesc);
+          admin.addColumn(new Text(tableName), columnDesc);
         }
-        enableTable(admin, table);
+        enableTable(admin, tableName);
         break;
       case DROP:
-        disableTable(admin, table);
-        println("Dropping " + column + " from " + table +
+        disableTable(admin, tableName);
+        println("Dropping " + column + " from " + tableName +
           "... Please wait.");
         column = appendDelimiter(column);
-        admin.deleteColumn(new Text(table), new Text(column));
-        enableTable(admin, table);
+        admin.deleteColumn(new Text(tableName), new Text(column));
+        enableTable(admin, tableName);
         break;
       case CHANGE:
         // Not yet supported
@@ -98,7 +105,7 @@
    * @param t Table to be altered.
    */
   public void setTable(String t) {
-    this.table = t;
+    this.tableName = t;
   }
 
   /**

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?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- 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
Mon Nov 26 22:12:46 2007
@@ -27,13 +27,16 @@
 import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 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;
 
 /**
  * Creates tables.
  */
 public class CreateCommand extends SchemaModificationCommand {
-  private String tableName;
+  private Text tableName;
   private Map<String, Map<String, Object>> columnSpecMap =
     new HashMap<String, Map<String, Object>>();
   
@@ -43,8 +46,13 @@
   
   public ReturnMsg execute(HBaseConfiguration conf) {
     try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (conn.tableExists(this.tableName)) {
+        return new ReturnMsg(0, "'" + this.tableName + "' Table already exist");
+      }
+      
       HBaseAdmin admin = new HBaseAdmin(conf);
-      HTableDescriptor tableDesc = new HTableDescriptor(tableName);
+      HTableDescriptor tableDesc = new HTableDescriptor(tableName.toString());
       HColumnDescriptor columnDesc = null;
       Set<String> columns = columnSpecMap.keySet();
       for (String column : columns) {
@@ -66,8 +74,8 @@
    * Sets the table to be created.
    * @param table Table to be created
    */
-  public void setTable(String table) {
-    this.tableName = table;
+  public void setTable(String tableName) {
+    this.tableName = new Text(tableName);
   }
 
   /**

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?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- 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
Mon Nov 26 22:12:46 2007
@@ -26,6 +26,8 @@
 
 import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.io.Text;
 
@@ -46,6 +48,11 @@
       throw new IllegalArgumentException("Column list is null");
     }
     try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(this.tableName))) {
+        return new ReturnMsg(0, "'" + this.tableName + "' Table not found");
+      }
+      
       HBaseAdmin admin = new HBaseAdmin(conf);
       HTable hTable = new HTable(conf, new Text(tableName));
       long lockID = hTable.startUpdate(new Text(rowKey));

Modified: lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/EnableCommand.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/EnableCommand.java?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/EnableCommand.java
(original)
+++ lucene/hadoop/trunk/src/contrib/hbase/src/java/org/apache/hadoop/hbase/shell/EnableCommand.java
Mon Nov 26 22:12:46 2007
@@ -24,6 +24,8 @@
 
 import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.io.Text;
 
 /**
@@ -39,6 +41,11 @@
   public ReturnMsg execute(HBaseConfiguration conf) {
     assert tableName != null;
     try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(new Text(this.tableName))) {
+        return new ReturnMsg(0, "'" + this.tableName + "' Table not found");
+      }
+      
       HBaseAdmin admin = new HBaseAdmin(conf);
       admin.enableTable(new Text(tableName));
       return new ReturnMsg(1, "Table enabled successfully.");

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?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- 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
Mon Nov 26 22:12:46 2007
@@ -24,6 +24,8 @@
 import java.util.List;
 
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.hbase.HTable;
 import org.apache.hadoop.io.Text;
 
@@ -44,6 +46,11 @@
     if (this.tableName == null || this.values == null || this.rowKey == null)
       return new ReturnMsg(0, "Syntax error : Please check 'Insert' syntax.");
 
+    HConnection conn = HConnectionManager.getConnection(conf);
+    if (!conn.tableExists(this.tableName)) {
+      return new ReturnMsg(0, "'" + this.tableName + "' Table not found");
+    }
+    
     if (this.columnfamilies.size() != this.values.size())
       return new ReturnMsg(0,
           "Mismatch between values list and columnfamilies list");

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?rev=598524&r1=598523&r2=598524&view=diff
==============================================================================
--- 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
Mon Nov 26 22:12:46 2007
@@ -30,6 +30,8 @@
 
 import org.apache.hadoop.hbase.HBaseAdmin;
 import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConnection;
+import org.apache.hadoop.hbase.HConnectionManager;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HScannerInterface;
 import org.apache.hadoop.hbase.HStoreKey;
@@ -80,6 +82,11 @@
       return new ReturnMsg(0, "Syntax error : Please check 'Select' syntax.");
     } 
     try {
+      HConnection conn = HConnectionManager.getConnection(conf);
+      if (!conn.tableExists(this.tableName)) {
+        return new ReturnMsg(0, "'" + this.tableName + "' Table not found");
+      }
+      
       HTable table = new HTable(conf, this.tableName);
       HBaseAdmin admin = new HBaseAdmin(conf);
       int count = 0;



Mime
View raw message