HBASE-14769 Remove unused functions and duplicate javadocs from HBaseAdmin
This commit is contained in:
parent
9511150bd6
commit
bebcc09fb3
|
@ -487,7 +487,10 @@ public interface Admin extends Abortable, Closeable {
|
||||||
* @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
|
* @return Pair indicating the number of regions updated Pair.getFirst() is the regions that are
|
||||||
* yet to be updated Pair.getSecond() is the total number of regions of the table
|
* yet to be updated Pair.getSecond() is the total number of regions of the table
|
||||||
* @throws IOException if a remote or network exception occurs
|
* @throws IOException if a remote or network exception occurs
|
||||||
|
* @deprecated Since 2.0.0. Will be removed in 3.0.0. Use {@link #getAlterStatus(TableName)}
|
||||||
|
* instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
Pair<Integer, Integer> getAlterStatus(final byte[] tableName) throws IOException;
|
Pair<Integer, Integer> getAlterStatus(final byte[] tableName) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1181,9 +1184,8 @@ public interface Admin extends Abortable, Closeable {
|
||||||
throws IOException, SnapshotCreationException, IllegalArgumentException;
|
throws IOException, SnapshotCreationException, IllegalArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public void snapshot(final String snapshotName, Create a timestamp consistent snapshot for the
|
* Create a timestamp consistent snapshot for the given table. Snapshots are considered unique
|
||||||
* given table. final byte[] tableName) throws IOException, Snapshots are considered unique based
|
* based on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even
|
||||||
* on <b>the name of the snapshot</b>. Attempts to take a snapshot with the same name (even a
|
|
||||||
* different type or with different parameters) will fail with a {@link SnapshotCreationException}
|
* different type or with different parameters) will fail with a {@link SnapshotCreationException}
|
||||||
* indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
|
* indicating the duplicate naming. Snapshot names follow the same naming constraints as tables in
|
||||||
* HBase.
|
* HBase.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -718,7 +718,7 @@ public class IntegrationTestDDLMasterFailover extends IntegrationTestBase {
|
||||||
}
|
}
|
||||||
TableName tableName = selected.getTableName();
|
TableName tableName = selected.getTableName();
|
||||||
LOG.info("Deleting column family: " + cfd + " from table: " + tableName);
|
LOG.info("Deleting column family: " + cfd + " from table: " + tableName);
|
||||||
admin.deleteColumn(tableName, cfd.getName());
|
admin.deleteColumnFamily(tableName, cfd.getName());
|
||||||
// assertion
|
// assertion
|
||||||
HTableDescriptor freshTableDesc = admin.getTableDescriptor(tableName);
|
HTableDescriptor freshTableDesc = admin.getTableDescriptor(tableName);
|
||||||
Assert.assertFalse("Column family: " + cfd + " was not added",
|
Assert.assertFalse("Column family: " + cfd + " was not added",
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class IntegrationTestIngestWithMOB extends IntegrationTestIngest {
|
||||||
if(Arrays.equals(columnDescriptor.getName(), mobColumnFamily)) {
|
if(Arrays.equals(columnDescriptor.getName(), mobColumnFamily)) {
|
||||||
columnDescriptor.setMobEnabled(true);
|
columnDescriptor.setMobEnabled(true);
|
||||||
columnDescriptor.setMobThreshold((long) threshold);
|
columnDescriptor.setMobThreshold((long) threshold);
|
||||||
admin.modifyColumn(tableName, columnDescriptor);
|
admin.modifyColumnFamily(tableName, columnDescriptor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.info("Enabling table " + getTablename());
|
LOG.info("Enabling table " + getTablename());
|
||||||
|
|
|
@ -2682,13 +2682,15 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Admin instance.
|
* Returns a Admin instance.
|
||||||
* This instance is shared between HBaseTestingUtility instance users.
|
* This instance is shared between HBaseTestingUtility instance users. Closing it has no effect,
|
||||||
* Closing it has no effect, it will be closed automatically when the
|
* it will be closed automatically when the cluster shutdowns
|
||||||
* cluster shutdowns
|
|
||||||
*
|
*
|
||||||
* @return An Admin instance.
|
* @return HBaseAdmin instance which is guaranteed to support only {@link Admin} interface.
|
||||||
* @throws IOException
|
* Functions in HBaseAdmin not provided by {@link Admin} interface can be changed/deleted
|
||||||
|
* anytime.
|
||||||
|
* @deprecated Since 2.0. Will be removed in 3.0. Use {@link #getAdmin()} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public synchronized HBaseAdmin getHBaseAdmin()
|
public synchronized HBaseAdmin getHBaseAdmin()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (hbaseAdmin == null){
|
if (hbaseAdmin == null){
|
||||||
|
@ -2697,8 +2699,18 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
return hbaseAdmin;
|
return hbaseAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HBaseAdmin hbaseAdmin = null;
|
/**
|
||||||
|
* Returns an Admin instance which is shared between HBaseTestingUtility instance users.
|
||||||
|
* Closing it has no effect, it will be closed automatically when the cluster shutdowns
|
||||||
|
*/
|
||||||
|
public synchronized Admin getAdmin() throws IOException {
|
||||||
|
if (hbaseAdmin == null){
|
||||||
|
this.hbaseAdmin = (HBaseAdmin) getConnection().getAdmin();
|
||||||
|
}
|
||||||
|
return hbaseAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HBaseAdmin hbaseAdmin = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a ZooKeeperWatcher instance.
|
* Returns a ZooKeeperWatcher instance.
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class TestAcidGuarantees implements Tool {
|
||||||
// force mob enabled such that all data is mob data
|
// force mob enabled such that all data is mob data
|
||||||
hcd.setMobEnabled(true);
|
hcd.setMobEnabled(true);
|
||||||
hcd.setMobThreshold(4);
|
hcd.setMobThreshold(4);
|
||||||
util.getHBaseAdmin().modifyColumn(TABLE_NAME, hcd);
|
util.getHBaseAdmin().modifyColumnFamily(TABLE_NAME, hcd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,8 +465,8 @@ public class TestAdmin2 {
|
||||||
onlineRegions.contains(info));
|
onlineRegions.contains(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Admin createTable(TableName tableName) throws IOException {
|
private HBaseAdmin createTable(TableName tableName) throws IOException {
|
||||||
Admin admin = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||||
|
|
||||||
HTableDescriptor htd = new HTableDescriptor(tableName);
|
HTableDescriptor htd = new HTableDescriptor(tableName);
|
||||||
HColumnDescriptor hcd = new HColumnDescriptor("value");
|
HColumnDescriptor hcd = new HColumnDescriptor("value");
|
||||||
|
|
|
@ -400,8 +400,8 @@ public class TestMetaWithReplicas {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(moveToServer != null);
|
assert(moveToServer != null);
|
||||||
String tableName = "randomTable5678";
|
TableName tableName = TableName.valueOf("randomTable5678");
|
||||||
TEST_UTIL.createTable(TableName.valueOf(tableName), "f");
|
TEST_UTIL.createTable(tableName, "f");
|
||||||
assertTrue(TEST_UTIL.getHBaseAdmin().tableExists(tableName));
|
assertTrue(TEST_UTIL.getHBaseAdmin().tableExists(tableName));
|
||||||
TEST_UTIL.getHBaseAdmin().move(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(),
|
TEST_UTIL.getHBaseAdmin().move(HRegionInfo.FIRST_META_REGIONINFO.getEncodedNameAsBytes(),
|
||||||
Bytes.toBytes(moveToServer.getServerName()));
|
Bytes.toBytes(moveToServer.getServerName()));
|
||||||
|
@ -413,8 +413,8 @@ public class TestMetaWithReplicas {
|
||||||
i++;
|
i++;
|
||||||
} while (!moveToServer.equals(currentServer) && i < 1000); //wait for 10 seconds overall
|
} while (!moveToServer.equals(currentServer) && i < 1000); //wait for 10 seconds overall
|
||||||
assert(i != 1000);
|
assert(i != 1000);
|
||||||
TEST_UTIL.getHBaseAdmin().disableTable("randomTable5678");
|
TEST_UTIL.getHBaseAdmin().disableTable(tableName);
|
||||||
assertTrue(TEST_UTIL.getHBaseAdmin().isTableDisabled("randomTable5678"));
|
assertTrue(TEST_UTIL.getHBaseAdmin().isTableDisabled(tableName));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class TestExpiredMobFileCleaner {
|
||||||
int timeToLive = expireDays * secondsOfDay();
|
int timeToLive = expireDays * secondsOfDay();
|
||||||
hcd.setTimeToLive(timeToLive);
|
hcd.setTimeToLive(timeToLive);
|
||||||
|
|
||||||
admin.modifyColumn(tableName, hcd);
|
admin.modifyColumnFamily(tableName, hcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putKVAndFlush(BufferedMutator table, byte[] row, byte[] value, long ts)
|
private void putKVAndFlush(BufferedMutator table, byte[] row, byte[] value, long ts)
|
||||||
|
|
|
@ -21,7 +21,6 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
import org.apache.hadoop.hbase.regionserver.HStore;
|
import org.apache.hadoop.hbase.regionserver.HStore;
|
||||||
import org.apache.hadoop.hbase.regionserver.Region;
|
import org.apache.hadoop.hbase.regionserver.Region;
|
||||||
import org.apache.hadoop.hbase.regionserver.Store;
|
import org.apache.hadoop.hbase.regionserver.Store;
|
||||||
import org.apache.hadoop.hbase.regionserver.StoreFile;
|
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -151,7 +149,7 @@ public class TestFIFOCompactionPolicy {
|
||||||
TEST_UTIL.startMiniCluster(1);
|
TEST_UTIL.startMiniCluster(1);
|
||||||
|
|
||||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||||
String tableName = this.tableName.getNameAsString()+"-TTL";
|
TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-TTL");
|
||||||
if (admin.tableExists(tableName)) {
|
if (admin.tableExists(tableName)) {
|
||||||
admin.disableTable(tableName);
|
admin.disableTable(tableName);
|
||||||
admin.deleteTable(tableName);
|
admin.deleteTable(tableName);
|
||||||
|
@ -180,7 +178,7 @@ public class TestFIFOCompactionPolicy {
|
||||||
TEST_UTIL.startMiniCluster(1);
|
TEST_UTIL.startMiniCluster(1);
|
||||||
|
|
||||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||||
String tableName = this.tableName.getNameAsString()+"-MinVersion";
|
TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-MinVersion");
|
||||||
if (admin.tableExists(tableName)) {
|
if (admin.tableExists(tableName)) {
|
||||||
admin.disableTable(tableName);
|
admin.disableTable(tableName);
|
||||||
admin.deleteTable(tableName);
|
admin.deleteTable(tableName);
|
||||||
|
@ -211,7 +209,7 @@ public class TestFIFOCompactionPolicy {
|
||||||
TEST_UTIL.startMiniCluster(1);
|
TEST_UTIL.startMiniCluster(1);
|
||||||
|
|
||||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||||
String tableName = this.tableName.getNameAsString()+"-MinVersion";
|
TableName tableName = TableName.valueOf(getClass().getSimpleName() + "-BlockingStoreFiles");
|
||||||
if (admin.tableExists(tableName)) {
|
if (admin.tableExists(tableName)) {
|
||||||
admin.disableTable(tableName);
|
admin.disableTable(tableName);
|
||||||
admin.deleteTable(tableName);
|
admin.deleteTable(tableName);
|
||||||
|
|
|
@ -210,7 +210,7 @@ module Hbase
|
||||||
def enable(table_name)
|
def enable(table_name)
|
||||||
tableExists(table_name)
|
tableExists(table_name)
|
||||||
return if enabled?(table_name)
|
return if enabled?(table_name)
|
||||||
@admin.enableTable(table_name)
|
@admin.enableTable(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
@ -225,7 +225,7 @@ module Hbase
|
||||||
def disable(table_name)
|
def disable(table_name)
|
||||||
tableExists(table_name)
|
tableExists(table_name)
|
||||||
return if disabled?(table_name)
|
return if disabled?(table_name)
|
||||||
@admin.disableTable(table_name)
|
@admin.disableTable(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
@ -244,14 +244,15 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Is table disabled?
|
# Is table disabled?
|
||||||
def disabled?(table_name)
|
def disabled?(table_name)
|
||||||
@admin.isTableDisabled(table_name)
|
@admin.isTableDisabled(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Drops a table
|
# Drops a table
|
||||||
def drop(table_name)
|
def drop(table_name)
|
||||||
tableExists(table_name)
|
tableExists(table_name)
|
||||||
raise ArgumentError, "Table #{table_name} is enabled. Disable it first." if enabled?(table_name)
|
raise ArgumentError, "Table #{table_name} is enabled. Disable it first." if enabled?(
|
||||||
|
table_name)
|
||||||
|
|
||||||
@admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
@admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
@ -447,15 +448,17 @@ module Hbase
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Truncates table (deletes all records by recreating the table)
|
# Truncates table (deletes all records by recreating the table)
|
||||||
def truncate(table_name, conf = @conf)
|
def truncate(table_name_str, conf = @conf)
|
||||||
table_description = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
table_name = TableName.valueOf(table_name_str)
|
||||||
raise ArgumentError, "Table #{table_name} is not enabled. Enable it first." unless enabled?(table_name)
|
table_description = @admin.getTableDescriptor(table_name)
|
||||||
|
raise ArgumentError, "Table #{table_name_str} is not enabled. Enable it first." unless
|
||||||
|
enabled?(table_name_str)
|
||||||
yield 'Disabling table...' if block_given?
|
yield 'Disabling table...' if block_given?
|
||||||
@admin.disableTable(table_name)
|
@admin.disableTable(table_name)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield 'Truncating table...' if block_given?
|
yield 'Truncating table...' if block_given?
|
||||||
@admin.truncateTable(org.apache.hadoop.hbase.TableName.valueOf(table_name), false)
|
@admin.truncateTable(table_name, false)
|
||||||
rescue => e
|
rescue => e
|
||||||
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
||||||
raise e unless e.respond_to?(:cause) && e.cause != nil
|
raise e unless e.respond_to?(:cause) && e.cause != nil
|
||||||
|
@ -463,7 +466,7 @@ module Hbase
|
||||||
if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
|
if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
|
||||||
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
||||||
yield 'Dropping table...' if block_given?
|
yield 'Dropping table...' if block_given?
|
||||||
@admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
@admin.deleteTable(table_name)
|
||||||
|
|
||||||
yield 'Creating table...' if block_given?
|
yield 'Creating table...' if block_given?
|
||||||
@admin.createTable(table_description)
|
@admin.createTable(table_description)
|
||||||
|
@ -475,9 +478,10 @@ module Hbase
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Truncates table while maintaing region boundaries (deletes all records by recreating the table)
|
# Truncates table while maintaing region boundaries (deletes all records by recreating the table)
|
||||||
def truncate_preserve(table_name, conf = @conf)
|
def truncate_preserve(table_name_str, conf = @conf)
|
||||||
h_table = @connection.getTable(TableName.valueOf(table_name))
|
table_name = TableName.valueOf(table_name_str)
|
||||||
locator = @connection.getRegionLocator(TableName.valueOf(table_name))
|
h_table = @connection.getTable(table_name)
|
||||||
|
locator = @connection.getRegionLocator(table_name)
|
||||||
begin
|
begin
|
||||||
splits = locator.getAllRegionLocations().
|
splits = locator.getAllRegionLocations().
|
||||||
map{|i| Bytes.toString(i.getRegionInfo().getStartKey)}.
|
map{|i| Bytes.toString(i.getRegionInfo().getStartKey)}.
|
||||||
|
@ -486,13 +490,13 @@ module Hbase
|
||||||
locator.close()
|
locator.close()
|
||||||
end
|
end
|
||||||
|
|
||||||
table_description = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
table_description = @admin.getTableDescriptor(table_name)
|
||||||
yield 'Disabling table...' if block_given?
|
yield 'Disabling table...' if block_given?
|
||||||
disable(table_name)
|
disable(table_name_str)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
yield 'Truncating table...' if block_given?
|
yield 'Truncating table...' if block_given?
|
||||||
@admin.truncateTable(org.apache.hadoop.hbase.TableName.valueOf(table_name), true)
|
@admin.truncateTable(table_name, true)
|
||||||
rescue => e
|
rescue => e
|
||||||
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
||||||
raise e unless e.respond_to?(:cause) && e.cause != nil
|
raise e unless e.respond_to?(:cause) && e.cause != nil
|
||||||
|
@ -500,7 +504,7 @@ module Hbase
|
||||||
if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
|
if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
|
||||||
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
# Handle the compatibility case, where the truncate method doesn't exists on the Master
|
||||||
yield 'Dropping table...' if block_given?
|
yield 'Dropping table...' if block_given?
|
||||||
@admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
|
@admin.deleteTable(table_name)
|
||||||
|
|
||||||
yield 'Creating table with region boundaries...' if block_given?
|
yield 'Creating table with region boundaries...' if block_given?
|
||||||
@admin.createTable(table_description, splits)
|
@admin.createTable(table_description, splits)
|
||||||
|
@ -534,18 +538,21 @@ module Hbase
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Change table structure or table options
|
# Change table structure or table options
|
||||||
def alter(table_name, wait = true, *args)
|
def alter(table_name_str, wait = true, *args)
|
||||||
# Table name should be a string
|
# Table name should be a string
|
||||||
raise(ArgumentError, "Table name must be of type String") unless table_name.kind_of?(String)
|
raise(ArgumentError, "Table name must be of type String") unless
|
||||||
|
table_name_str.kind_of?(String)
|
||||||
|
|
||||||
# Table should exist
|
# Table should exist
|
||||||
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
raise(ArgumentError, "Can't find a table: #{table_name_str}") unless exists?(table_name_str)
|
||||||
|
|
||||||
# There should be at least one argument
|
# There should be at least one argument
|
||||||
raise(ArgumentError, "There should be at least one argument but the table name") if args.empty?
|
raise(ArgumentError, "There should be at least one argument but the table name") if args.empty?
|
||||||
|
|
||||||
|
table_name = TableName.valueOf(table_name_str)
|
||||||
|
|
||||||
# Get table descriptor
|
# Get table descriptor
|
||||||
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
htd = @admin.getTableDescriptor(table_name)
|
||||||
|
|
||||||
# Process all args
|
# Process all args
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
|
@ -573,11 +580,11 @@ module Hbase
|
||||||
|
|
||||||
if wait == true
|
if wait == true
|
||||||
puts "Updating all regions with the new schema..."
|
puts "Updating all regions with the new schema..."
|
||||||
alter_status(table_name)
|
alter_status(table_name_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
# We bypass descriptor when adding column families; refresh it to apply other args correctly.
|
# We bypass descriptor when adding column families; refresh it to apply other args correctly.
|
||||||
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
htd = @admin.getTableDescriptor(table_name)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -587,7 +594,7 @@ module Hbase
|
||||||
# Delete column family
|
# Delete column family
|
||||||
if method == "delete"
|
if method == "delete"
|
||||||
raise(ArgumentError, "NAME parameter missing for delete method") unless name
|
raise(ArgumentError, "NAME parameter missing for delete method") unless name
|
||||||
@admin.deleteColumn(table_name, name)
|
@admin.deleteColumn(table_name, name.to_java_bytes)
|
||||||
# Unset table attributes
|
# Unset table attributes
|
||||||
elsif method == "table_att_unset"
|
elsif method == "table_att_unset"
|
||||||
raise(ArgumentError, "NAME parameter missing for table_att_unset method") unless name
|
raise(ArgumentError, "NAME parameter missing for table_att_unset method") unless name
|
||||||
|
@ -604,7 +611,7 @@ module Hbase
|
||||||
end
|
end
|
||||||
htd.remove(name)
|
htd.remove(name)
|
||||||
end
|
end
|
||||||
@admin.modifyTable(table_name.to_java_bytes, htd)
|
@admin.modifyTable(table_name, htd)
|
||||||
# Unknown method
|
# Unknown method
|
||||||
else
|
else
|
||||||
raise ArgumentError, "Unknown method: #{method}"
|
raise ArgumentError, "Unknown method: #{method}"
|
||||||
|
@ -616,12 +623,12 @@ module Hbase
|
||||||
|
|
||||||
if wait == true
|
if wait == true
|
||||||
puts "Updating all regions with the new schema..."
|
puts "Updating all regions with the new schema..."
|
||||||
alter_status(table_name)
|
alter_status(table_name_str)
|
||||||
end
|
end
|
||||||
|
|
||||||
if method == "delete"
|
if method == "delete"
|
||||||
# We bypass descriptor when deleting column families; refresh it to apply other args correctly.
|
# We bypass descriptor when deleting column families; refresh it to apply other args correctly.
|
||||||
htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
|
htd = @admin.getTableDescriptor(table_name)
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -667,7 +674,7 @@ module Hbase
|
||||||
arg.delete(key)
|
arg.delete(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
@admin.modifyTable(table_name.to_java_bytes, htd)
|
@admin.modifyTable(table_name, htd)
|
||||||
|
|
||||||
arg.each_key do |unknown_key|
|
arg.each_key do |unknown_key|
|
||||||
puts("Unknown argument ignored: %s" % [unknown_key])
|
puts("Unknown argument ignored: %s" % [unknown_key])
|
||||||
|
@ -675,7 +682,7 @@ module Hbase
|
||||||
|
|
||||||
if wait == true
|
if wait == true
|
||||||
puts "Updating all regions with the new schema..."
|
puts "Updating all regions with the new schema..."
|
||||||
alter_status(table_name)
|
alter_status(table_name_str)
|
||||||
end
|
end
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
@ -792,13 +799,13 @@ module Hbase
|
||||||
|
|
||||||
# Does table exist?
|
# Does table exist?
|
||||||
def exists?(table_name)
|
def exists?(table_name)
|
||||||
@admin.tableExists(table_name)
|
@admin.tableExists(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Is table enabled
|
# Is table enabled
|
||||||
def enabled?(table_name)
|
def enabled?(table_name)
|
||||||
@admin.isTableEnabled(table_name)
|
@admin.isTableEnabled(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
@ -910,14 +917,23 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Take a snapshot of specified table
|
# Take a snapshot of specified table
|
||||||
def snapshot(table, snapshot_name, *args)
|
def snapshot(table, snapshot_name, *args)
|
||||||
|
# Table name should be a string
|
||||||
|
raise(ArgumentError, "Table name must be of type String") unless table.kind_of?(String)
|
||||||
|
|
||||||
|
# Snapshot name should be a string
|
||||||
|
raise(ArgumentError, "Snapshot name must be of type String") unless
|
||||||
|
snapshot_name.kind_of?(String)
|
||||||
|
|
||||||
|
table_name = TableName.valueOf(table)
|
||||||
if args.empty?
|
if args.empty?
|
||||||
@admin.snapshot(snapshot_name.to_java_bytes, table.to_java_bytes)
|
@admin.snapshot(snapshot_name, table_name)
|
||||||
else
|
else
|
||||||
args.each do |arg|
|
args.each do |arg|
|
||||||
if arg[SKIP_FLUSH] == true
|
if arg[SKIP_FLUSH] == true
|
||||||
@admin.snapshot(snapshot_name.to_java_bytes, table.to_java_bytes, SnapshotDescription::Type::SKIPFLUSH)
|
@admin.snapshot(snapshot_name, table_name,
|
||||||
|
SnapshotDescription::Type::SKIPFLUSH)
|
||||||
else
|
else
|
||||||
@admin.snapshot(snapshot_name.to_java_bytes, table.to_java_bytes)
|
@admin.snapshot(snapshot_name, table_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -926,19 +942,19 @@ module Hbase
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Restore specified snapshot
|
# Restore specified snapshot
|
||||||
def restore_snapshot(snapshot_name)
|
def restore_snapshot(snapshot_name)
|
||||||
@admin.restoreSnapshot(snapshot_name.to_java_bytes)
|
@admin.restoreSnapshot(snapshot_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Create a new table by cloning the snapshot content
|
# Create a new table by cloning the snapshot content
|
||||||
def clone_snapshot(snapshot_name, table)
|
def clone_snapshot(snapshot_name, table)
|
||||||
@admin.cloneSnapshot(snapshot_name.to_java_bytes, table.to_java_bytes)
|
@admin.cloneSnapshot(snapshot_name, TableName.valueOf(table))
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
# Delete specified snapshot
|
# Delete specified snapshot
|
||||||
def delete_snapshot(snapshot_name)
|
def delete_snapshot(snapshot_name)
|
||||||
@admin.deleteSnapshot(snapshot_name.to_java_bytes)
|
@admin.deleteSnapshot(snapshot_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
#----------------------------------------------------------------------------------------------
|
#----------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -64,7 +64,7 @@ module Hbase
|
||||||
# Table should exist
|
# Table should exist
|
||||||
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
||||||
|
|
||||||
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name.to_java_bytes)
|
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name)
|
||||||
htd = @admin.getTableDescriptor(tableName)
|
htd = @admin.getTableDescriptor(tableName)
|
||||||
|
|
||||||
if (family != nil)
|
if (family != nil)
|
||||||
|
@ -106,7 +106,7 @@ module Hbase
|
||||||
# Table should exist
|
# Table should exist
|
||||||
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
|
||||||
|
|
||||||
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name.to_java_bytes)
|
tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name)
|
||||||
htd = @admin.getTableDescriptor(tableName)
|
htd = @admin.getTableDescriptor(tableName)
|
||||||
|
|
||||||
if (family != nil)
|
if (family != nil)
|
||||||
|
@ -165,7 +165,7 @@ module Hbase
|
||||||
|
|
||||||
# Does table exist?
|
# Does table exist?
|
||||||
def exists?(table_name)
|
def exists?(table_name)
|
||||||
@admin.tableExists(table_name)
|
@admin.tableExists(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
|
|
||||||
def isNamespace?(table_name)
|
def isNamespace?(table_name)
|
||||||
|
|
|
@ -153,7 +153,7 @@ module Hbase
|
||||||
|
|
||||||
# Does table exist?
|
# Does table exist?
|
||||||
def exists?(table_name)
|
def exists?(table_name)
|
||||||
@admin.tableExists(table_name)
|
@admin.tableExists(TableName.valueOf(table_name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -405,21 +405,21 @@ module Hbase
|
||||||
end
|
end
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
define_test "Snapshot should fail with non-string snapshot name" do
|
define_test "Snapshot should fail with non-string table name" do
|
||||||
assert_raise(NoMethodError) do
|
assert_raise(ArgumentError) do
|
||||||
admin.snapshot(123, 'xxx')
|
admin.snapshot(123, 'xxx')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
define_test "Snapshot should fail with non-string table name" do
|
define_test "Snapshot should fail with non-string snapshot name" do
|
||||||
assert_raise(NoMethodError) do
|
assert_raise(ArgumentError) do
|
||||||
admin.snapshot(@create_test_snapshot, 123)
|
admin.snapshot(@test_name, 123)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
define_test "Snapshot should fail without table name" do
|
define_test "Snapshot should fail without snapshot name" do
|
||||||
assert_raise(ArgumentError) do
|
assert_raise(ArgumentError) do
|
||||||
admin.snapshot("hbase_create_test_snapshot")
|
admin.snapshot(@test_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ onwards.
|
||||||
+
|
+
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
String tableName = "users";
|
TableName tableName = TableName.valueOf("users");
|
||||||
String path = "hdfs://<namenode>:<port>/user/<hadoop-user>/coprocessor.jar";
|
String path = "hdfs://<namenode>:<port>/user/<hadoop-user>/coprocessor.jar";
|
||||||
Configuration conf = HBaseConfiguration.create();
|
Configuration conf = HBaseConfiguration.create();
|
||||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||||
|
|
|
@ -741,7 +741,7 @@ the data, and deletes the table.
|
||||||
[source,jython]
|
[source,jython]
|
||||||
----
|
----
|
||||||
import java.lang
|
import java.lang
|
||||||
from org.apache.hadoop.hbase import HBaseConfiguration, HTableDescriptor, HColumnDescriptor, HConstants
|
from org.apache.hadoop.hbase import HBaseConfiguration, HTableDescriptor, HColumnDescriptor, HConstants, TableName
|
||||||
from org.apache.hadoop.hbase.client import HBaseAdmin, HTable, Get
|
from org.apache.hadoop.hbase.client import HBaseAdmin, HTable, Get
|
||||||
from org.apache.hadoop.hbase.io import Cell, RowResult
|
from org.apache.hadoop.hbase.io import Cell, RowResult
|
||||||
|
|
||||||
|
@ -753,7 +753,7 @@ conf = HBaseConfiguration()
|
||||||
# Create a table named 'test' that has two column families,
|
# Create a table named 'test' that has two column families,
|
||||||
# one named 'content, and the other 'anchor'. The colons
|
# one named 'content, and the other 'anchor'. The colons
|
||||||
# are required for column family names.
|
# are required for column family names.
|
||||||
tablename = "test"
|
tablename = TableName.valueOf("test")
|
||||||
|
|
||||||
desc = HTableDescriptor(tablename)
|
desc = HTableDescriptor(tablename)
|
||||||
desc.addFamily(HColumnDescriptor("content:"))
|
desc.addFamily(HColumnDescriptor("content:"))
|
||||||
|
|
|
@ -2214,7 +2214,7 @@ or in code it would be as follows:
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
void rename(Admin admin, String oldTableName, String newTableName) {
|
void rename(Admin admin, String oldTableName, TableName newTableName) {
|
||||||
String snapshotName = randomName();
|
String snapshotName = randomName();
|
||||||
admin.disableTable(oldTableName);
|
admin.disableTable(oldTableName);
|
||||||
admin.snapshot(snapshotName, oldTableName);
|
admin.snapshot(snapshotName, oldTableName);
|
||||||
|
|
|
@ -53,7 +53,7 @@ Tables must be disabled when making ColumnFamily modifications, for example:
|
||||||
|
|
||||||
Configuration config = HBaseConfiguration.create();
|
Configuration config = HBaseConfiguration.create();
|
||||||
Admin admin = new Admin(conf);
|
Admin admin = new Admin(conf);
|
||||||
String table = "myTable";
|
TableName table = TableName.valueOf("myTable");
|
||||||
|
|
||||||
admin.disableTable(table);
|
admin.disableTable(table);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue