You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2009/01/29 17:51:26 UTC
svn commit: r738927 - in /hadoop/hbase/trunk: ./ bin/
src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/client/
Author: jdcryans
Date: Thu Jan 29 16:51:26 2009
New Revision: 738927
URL: http://svn.apache.org/viewvc?rev=738927&view=rev
Log:
HBASE-845 HCM.isTableEnabled doesn't really tell if it is, or not
HBASE-903 [shell] Can't set table descriptor attributes when I alter a table
Modified:
hadoop/hbase/trunk/CHANGES.txt
hadoop/hbase/trunk/bin/HBase.rb
hadoop/hbase/trunk/bin/hirb.rb
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Thu Jan 29 16:51:26 2009
@@ -29,6 +29,8 @@
HBASE-1064 HBase REST xml/json improvements (Brian Beggs working of
initial Michael Gottesman work via Stack)
HBASE-5121 Fix shell usage for format.width
+ HBASE-845 HCM.isTableEnabled doesn't really tell if it is, or not
+ HBASE-903 [shell] Can't set table descriptor attributes when I alter a table
Release 0.19.0 - 01/21/2009
INCOMPATIBLE CHANGES
Modified: hadoop/hbase/trunk/bin/HBase.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/HBase.rb?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/HBase.rb (original)
+++ hadoop/hbase/trunk/bin/HBase.rb Thu Jan 29 16:51:26 2009
@@ -8,6 +8,7 @@
# whether the table exists and returns nil regardless.
include Java
include_class('java.lang.Integer') {|package,name| "J#{name}" }
+include_class('java.lang.Long') {|package,name| "J#{name}" }
include_class('java.lang.Boolean') {|package,name| "J#{name}" }
import org.apache.hadoop.hbase.client.HBaseAdmin
@@ -203,6 +204,15 @@
method = args.delete(METHOD)
if method == "delete"
@admin.deleteColumn(tableName, makeColumnName(args[NAME]))
+ elsif method == "table_att"
+ args[MAX_FILESIZE]? htd.setMaxFileSize(JLong.valueOf(args[MAX_FILESIZE])) :
+ htd.setMaxFileSize(HTableDescriptor::DEFAULT_MAX_FILESIZE);
+ args[READONLY]? htd.setReadOnly(JBoolean.valueOf(args[READONLY])) :
+ htd.setReadOnly(HTableDescriptor::DEFAULT_READONLY);
+ args[MEMCACHE_FLUSHSIZE]?
+ htd.setMemcacheFlushSize(JLong.valueOf(args[MEMCACHE_FLUSHSIZE])) :
+ htd.setMemcacheFlushSize(HTableDescriptor::DEFAULT_MEMCACHE_FLUSH_SIZE);
+ @admin.modifyTable(tableName.to_java_bytes,htd)
else
descriptor = hcd(args)
if (htd.hasFamily(descriptor.getNameAsString().to_java_bytes))
Modified: hadoop/hbase/trunk/bin/hirb.rb
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/bin/hirb.rb?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/bin/hirb.rb (original)
+++ hadoop/hbase/trunk/bin/hirb.rb Thu Jan 29 16:51:26 2009
@@ -155,6 +155,12 @@
To delete the 'f1' column family in table 't1', do:
hbase> alter 't1', {NAME => 'f1', METHOD => 'delete'}
+
+ You can also change table-scope attributes like MAX_FILESIZE
+ MEMCACHE_FLUSHSIZE and READONLY.
+
+ For example, to change the max size of a family to 128MB, do:
+ hbase> alter 't1', {METHOD => 'table_att', MAX_FILESIZE => '134217728'}
count Count the number of rows in a table. This operation may take a LONG
time (Run '$HADOOP_HOME/bin/hadoop jar hbase.jar rowcount' to run a
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java Thu Jan 29 16:51:26 2009
@@ -91,6 +91,8 @@
public static final boolean DEFAULT_READONLY = false;
public static final int DEFAULT_MEMCACHE_FLUSH_SIZE = 1024*1024*64;
+
+ public static final int DEFAULT_MAX_FILESIZE = 1024*1024*256;
private volatile Boolean meta = null;
private volatile Boolean root = null;
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Thu Jan 29 16:51:26 2009
@@ -366,7 +366,7 @@
// Wait until all regions are disabled
for (int tries = 0;
- (tries < numRetries) && (isTableEnabled(tableName));
+ (tries < numRetries) && (!isTableDisabled(tableName));
tries++) {
if (LOG.isDebugEnabled()) {
LOG.debug("Sleep. Waiting for all regions to be disabled from " +
@@ -382,7 +382,7 @@
Bytes.toString(tableName));
}
}
- if (isTableEnabled(tableName)) {
+ if (!isTableDisabled(tableName)) {
throw new RegionException("Retries exhausted, it took too long to wait"+
" for the table " + Bytes.toString(tableName) + " to be disabled.");
}
@@ -405,6 +405,15 @@
public boolean isTableEnabled(byte[] tableName) throws IOException {
return connection.isTableEnabled(tableName);
}
+
+ /**
+ * @param tableName name of table to check
+ * @return true if table is off-line
+ * @throws IOException
+ */
+ public boolean isTableDisabled(byte[] tableName) throws IOException {
+ return connection.isTableDisabled(tableName);
+ }
/**
* Add a column to an existing table
@@ -634,6 +643,17 @@
Object [] args = regionName == null? null: new byte [][] {regionName};
modifyTable(tableName == null? null: tableName, op, args);
}
+
+ /**
+ * Modify an existing table, more IRB friendly version.
+ * @param tableName name of table.
+ * @param htd modified description of the table
+ * @throws IOException
+ */
+ public void modifyTable(final byte [] tableName, HTableDescriptor htd)
+ throws IOException {
+ modifyTable(tableName, HConstants.MODIFY_TABLE_SET_HTD, htd);
+ }
/**
* Modify an existing table
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnection.java Thu Jan 29 16:51:26 2009
@@ -54,6 +54,9 @@
throws MasterNotRunningException;
/**
+ * A table that isTableEnabled == false and isTableDisabled == false
+ * is possible. This happens when a table has a lot of regions
+ * that must be processed.
* @param tableName
* @return true if the table is enabled, false otherwise
* @throws IOException
@@ -61,6 +64,13 @@
public boolean isTableEnabled(byte[] tableName) throws IOException;
/**
+ * @param tableName
+ * @return true if the table is disabled, false otherwise
+ * @throws IOException
+ */
+ public boolean isTableDisabled(byte[] tableName) throws IOException;
+
+ /**
* List all the userspace tables. In other words, scan the META table.
*
* If we wanted this to be really fast, we could implement a special
Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=738927&r1=738926&r2=738927&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Thu Jan 29 16:51:26 2009
@@ -315,8 +315,25 @@
return uniqueTables.toArray(new HTableDescriptor[uniqueTables.size()]);
}
-
+
public boolean isTableEnabled(byte[] tableName) throws IOException {
+ return testTableOnlineState(tableName, true);
+ }
+
+ public boolean isTableDisabled(byte[] tableName) throws IOException {
+ return testTableOnlineState(tableName, false);
+ }
+
+ /*
+ * If online == true
+ * Returns true if all regions are online
+ * Returns false in any other case
+ * If online == false
+ * Returns true if all regions are offline
+ * Returns false in any other case
+ */
+ private boolean testTableOnlineState(byte[] tableName,
+ boolean online) throws IOException {
if (!tableExists(tableName)) {
throw new TableNotFoundException(Bytes.toString(tableName));
}
@@ -325,38 +342,30 @@
return true;
}
- boolean result = true;
int rowsScanned = 0;
+ int rowsOffline = 0;
byte[] startKey =
HRegionInfo.createRegionName(tableName, null, HConstants.ZEROES);
+ byte[] endKey = null;
HRegionInfo currentRegion = null;
- do {
- if (currentRegion != null) {
- byte[] endKey = currentRegion.getEndKey();
- if (endKey == null ||
- HStoreKey.equalsTwoRowKeys(currentRegion, endKey,
- HConstants.EMPTY_BYTE_ARRAY)) {
- // We have reached the end of the table and we're done
- break;
- }
- }
- HRegionInfo oldRegion = currentRegion;
- if (oldRegion != null) {
- startKey = oldRegion.getEndKey();
- }
- ScannerCallable s = new ScannerCallable(this,
- (Bytes.equals(tableName, HConstants.META_TABLE_NAME) ?
- HConstants.ROOT_TABLE_NAME : HConstants.META_TABLE_NAME),
- HConstants.COL_REGIONINFO_ARRAY, startKey,
- HConstants.LATEST_TIMESTAMP, null
- );
+ ScannerCallable s = new ScannerCallable(this,
+ (Bytes.equals(tableName, HConstants.META_TABLE_NAME) ?
+ HConstants.ROOT_TABLE_NAME : HConstants.META_TABLE_NAME),
+ HConstants.COL_REGIONINFO_ARRAY, startKey,
+ HConstants.LATEST_TIMESTAMP, null
+ );
+ try {
// Open scanner
getRegionServerWithRetries(s);
- currentRegion = s.getHRegionInfo();
- try {
+ do {
+ HRegionInfo oldRegion = currentRegion;
+ if (oldRegion != null) {
+ startKey = oldRegion.getEndKey();
+ }
+ currentRegion = s.getHRegionInfo();
RowResult r = null;
RowResult[] rrs = null;
- while (result && (rrs = getRegionServerWithRetries(s)) != null) {
+ while ((rrs = getRegionServerWithRetries(s)) != null) {
r = rrs[0];
Cell c = r.get(HConstants.COL_REGIONINFO);
if (c != null) {
@@ -366,18 +375,23 @@
if (info != null) {
if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
rowsScanned += 1;
- result = !info.isOffline();
+ rowsOffline += info.isOffline() ? 1 : 0;
}
}
}
}
}
- } finally {
- s.setClose();
- getRegionServerWithRetries(s);
- }
- } while (result);
- return rowsScanned > 0 && result;
+ endKey = currentRegion.getEndKey();
+ } while (!(endKey == null || HStoreKey.equalsTwoRowKeys(currentRegion,
+ endKey, HConstants.EMPTY_BYTE_ARRAY)));
+ }
+ finally {
+ s.setClose();
+ }
+ boolean onlineOffline =
+ online ? rowsOffline == 0 : rowsOffline == rowsScanned;
+ return rowsScanned > 0 && onlineOffline;
+
}
private class HTableDescriptorFinder