HADOOP-2289 Useless efforts of looking for the non-existant table in select command.
git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk/src/contrib/hbase@598524 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb2c941544
commit
d11960feef
|
@ -46,6 +46,8 @@ Trunk (unreleased changes)
|
||||||
HADOOP-2139 (phase 1) Increase parallelism in region servers.
|
HADOOP-2139 (phase 1) Increase parallelism in region servers.
|
||||||
HADOOP-2267 [Hbase Shell] Change the prompt's title from 'hbase' to 'hql'.
|
HADOOP-2267 [Hbase Shell] Change the prompt's title from 'hbase' to 'hql'.
|
||||||
HADOOP-2139 (phase 2) Make region server more event driven
|
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
|
Release 0.15.1
|
||||||
Branch 0.15
|
Branch 0.15
|
||||||
|
|
|
@ -103,13 +103,21 @@ public final class master_jsp extends org.apache.jasper.runtime.HttpJspBase
|
||||||
out.print(msg );
|
out.print(msg );
|
||||||
out.write("</p>\n\n<h2>Region Servers</h2>\n");
|
out.write("</p>\n\n<h2>Region Servers</h2>\n");
|
||||||
if (serverToServerInfos != null && serverToServerInfos.size() > 0) {
|
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()) {
|
for (Map.Entry<String, HServerInfo> e: serverToServerInfos.entrySet()) {
|
||||||
HServerInfo hsi = e.getValue();
|
HServerInfo hsi = e.getValue();
|
||||||
String url = "http://" +
|
String url = "http://" +
|
||||||
hsi.getServerAddress().getBindAddress().toString() + ":" +
|
hsi.getServerAddress().getBindAddress().toString() + ":" +
|
||||||
hsi.getInfoPort() + "/";
|
hsi.getInfoPort() + "/";
|
||||||
String load = hsi.getLoad().toString();
|
String load = hsi.getLoad().toString();
|
||||||
|
totalRegions += hsi.getLoad().getNumberOfRegions();
|
||||||
|
totalRequests += hsi.getLoad().getNumberOfRequests();
|
||||||
long startCode = hsi.getStartCode();
|
long startCode = hsi.getStartCode();
|
||||||
String address = hsi.getServerAddress().toString();
|
String address = hsi.getServerAddress().toString();
|
||||||
|
|
||||||
|
@ -122,9 +130,15 @@ public final class master_jsp extends org.apache.jasper.runtime.HttpJspBase
|
||||||
out.print( startCode );
|
out.print( startCode );
|
||||||
out.write("</td><td>");
|
out.write("</td><td>");
|
||||||
out.print( load );
|
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> </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.print(interval);
|
||||||
out.write(" second(s)) and count of regions loaded</p>\n");
|
out.write(" second(s)) and count of regions loaded</p>\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import java.util.Set;
|
||||||
import org.apache.hadoop.hbase.HBaseAdmin;
|
import org.apache.hadoop.hbase.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.HConnection;
|
||||||
|
import org.apache.hadoop.hbase.HConnectionManager;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,7 +40,7 @@ public class AlterCommand extends SchemaModificationCommand {
|
||||||
private OperationType operationType = OperationType.NOOP;
|
private OperationType operationType = OperationType.NOOP;
|
||||||
private Map<String, Map<String, Object>> columnSpecMap =
|
private Map<String, Map<String, Object>> columnSpecMap =
|
||||||
new HashMap<String, Map<String, Object>>();
|
new HashMap<String, Map<String, Object>>();
|
||||||
private String table;
|
private String tableName;
|
||||||
private String column; // column to be dropped
|
private String column; // column to be dropped
|
||||||
|
|
||||||
public AlterCommand(Writer o) {
|
public AlterCommand(Writer o) {
|
||||||
|
@ -47,28 +49,33 @@ public class AlterCommand extends SchemaModificationCommand {
|
||||||
|
|
||||||
public ReturnMsg execute(HBaseConfiguration conf) {
|
public ReturnMsg execute(HBaseConfiguration conf) {
|
||||||
try {
|
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);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
Set<String> columns = null;
|
Set<String> columns = null;
|
||||||
HColumnDescriptor columnDesc = null;
|
HColumnDescriptor columnDesc = null;
|
||||||
switch (operationType) {
|
switch (operationType) {
|
||||||
case ADD:
|
case ADD:
|
||||||
disableTable(admin, table);
|
disableTable(admin, tableName);
|
||||||
columns = columnSpecMap.keySet();
|
columns = columnSpecMap.keySet();
|
||||||
for (String c : columns) {
|
for (String c : columns) {
|
||||||
columnDesc = getColumnDescriptor(c, columnSpecMap.get(c));
|
columnDesc = getColumnDescriptor(c, columnSpecMap.get(c));
|
||||||
println("Adding " + c + " to " + table +
|
println("Adding " + c + " to " + tableName +
|
||||||
"... Please wait.");
|
"... Please wait.");
|
||||||
admin.addColumn(new Text(table), columnDesc);
|
admin.addColumn(new Text(tableName), columnDesc);
|
||||||
}
|
}
|
||||||
enableTable(admin, table);
|
enableTable(admin, tableName);
|
||||||
break;
|
break;
|
||||||
case DROP:
|
case DROP:
|
||||||
disableTable(admin, table);
|
disableTable(admin, tableName);
|
||||||
println("Dropping " + column + " from " + table +
|
println("Dropping " + column + " from " + tableName +
|
||||||
"... Please wait.");
|
"... Please wait.");
|
||||||
column = appendDelimiter(column);
|
column = appendDelimiter(column);
|
||||||
admin.deleteColumn(new Text(table), new Text(column));
|
admin.deleteColumn(new Text(tableName), new Text(column));
|
||||||
enableTable(admin, table);
|
enableTable(admin, tableName);
|
||||||
break;
|
break;
|
||||||
case CHANGE:
|
case CHANGE:
|
||||||
// Not yet supported
|
// Not yet supported
|
||||||
|
@ -98,7 +105,7 @@ public class AlterCommand extends SchemaModificationCommand {
|
||||||
* @param t Table to be altered.
|
* @param t Table to be altered.
|
||||||
*/
|
*/
|
||||||
public void setTable(String t) {
|
public void setTable(String t) {
|
||||||
this.table = t;
|
this.tableName = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,13 +27,16 @@ import java.util.Set;
|
||||||
import org.apache.hadoop.hbase.HBaseAdmin;
|
import org.apache.hadoop.hbase.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
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.hbase.HTableDescriptor;
|
||||||
|
import org.apache.hadoop.io.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates tables.
|
* Creates tables.
|
||||||
*/
|
*/
|
||||||
public class CreateCommand extends SchemaModificationCommand {
|
public class CreateCommand extends SchemaModificationCommand {
|
||||||
private String tableName;
|
private Text tableName;
|
||||||
private Map<String, Map<String, Object>> columnSpecMap =
|
private Map<String, Map<String, Object>> columnSpecMap =
|
||||||
new HashMap<String, Map<String, Object>>();
|
new HashMap<String, Map<String, Object>>();
|
||||||
|
|
||||||
|
@ -43,8 +46,13 @@ public class CreateCommand extends SchemaModificationCommand {
|
||||||
|
|
||||||
public ReturnMsg execute(HBaseConfiguration conf) {
|
public ReturnMsg execute(HBaseConfiguration conf) {
|
||||||
try {
|
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);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
|
HTableDescriptor tableDesc = new HTableDescriptor(tableName.toString());
|
||||||
HColumnDescriptor columnDesc = null;
|
HColumnDescriptor columnDesc = null;
|
||||||
Set<String> columns = columnSpecMap.keySet();
|
Set<String> columns = columnSpecMap.keySet();
|
||||||
for (String column : columns) {
|
for (String column : columns) {
|
||||||
|
@ -66,8 +74,8 @@ public class CreateCommand extends SchemaModificationCommand {
|
||||||
* Sets the table to be created.
|
* Sets the table to be created.
|
||||||
* @param table Table to be created
|
* @param table Table to be created
|
||||||
*/
|
*/
|
||||||
public void setTable(String table) {
|
public void setTable(String tableName) {
|
||||||
this.tableName = table;
|
this.tableName = new Text(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.HBaseAdmin;
|
import org.apache.hadoop.hbase.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
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.hbase.HTable;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
|
||||||
|
@ -46,6 +48,11 @@ public class DeleteCommand extends BasicCommand {
|
||||||
throw new IllegalArgumentException("Column list is null");
|
throw new IllegalArgumentException("Column list is null");
|
||||||
}
|
}
|
||||||
try {
|
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);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
HTable hTable = new HTable(conf, new Text(tableName));
|
HTable hTable = new HTable(conf, new Text(tableName));
|
||||||
long lockID = hTable.startUpdate(new Text(rowKey));
|
long lockID = hTable.startUpdate(new Text(rowKey));
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.io.Writer;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.HBaseAdmin;
|
import org.apache.hadoop.hbase.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
|
import org.apache.hadoop.hbase.HConnection;
|
||||||
|
import org.apache.hadoop.hbase.HConnectionManager;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +41,11 @@ public class EnableCommand extends BasicCommand {
|
||||||
public ReturnMsg execute(HBaseConfiguration conf) {
|
public ReturnMsg execute(HBaseConfiguration conf) {
|
||||||
assert tableName != null;
|
assert tableName != null;
|
||||||
try {
|
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);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
admin.enableTable(new Text(tableName));
|
admin.enableTable(new Text(tableName));
|
||||||
return new ReturnMsg(1, "Table enabled successfully.");
|
return new ReturnMsg(1, "Table enabled successfully.");
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.io.Writer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
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.hbase.HTable;
|
||||||
import org.apache.hadoop.io.Text;
|
import org.apache.hadoop.io.Text;
|
||||||
|
|
||||||
|
@ -44,6 +46,11 @@ public class InsertCommand extends BasicCommand {
|
||||||
if (this.tableName == null || this.values == null || this.rowKey == null)
|
if (this.tableName == null || this.values == null || this.rowKey == null)
|
||||||
return new ReturnMsg(0, "Syntax error : Please check 'Insert' syntax.");
|
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())
|
if (this.columnfamilies.size() != this.values.size())
|
||||||
return new ReturnMsg(0,
|
return new ReturnMsg(0,
|
||||||
"Mismatch between values list and columnfamilies list");
|
"Mismatch between values list and columnfamilies list");
|
||||||
|
|
|
@ -30,6 +30,8 @@ import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.HBaseAdmin;
|
import org.apache.hadoop.hbase.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
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.HConstants;
|
||||||
import org.apache.hadoop.hbase.HScannerInterface;
|
import org.apache.hadoop.hbase.HScannerInterface;
|
||||||
import org.apache.hadoop.hbase.HStoreKey;
|
import org.apache.hadoop.hbase.HStoreKey;
|
||||||
|
@ -80,6 +82,11 @@ public class SelectCommand extends BasicCommand {
|
||||||
return new ReturnMsg(0, "Syntax error : Please check 'Select' syntax.");
|
return new ReturnMsg(0, "Syntax error : Please check 'Select' syntax.");
|
||||||
}
|
}
|
||||||
try {
|
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);
|
HTable table = new HTable(conf, this.tableName);
|
||||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
Loading…
Reference in New Issue