HBASE-5936 Add Column-level PB-based calls to HMasterInterface
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1345390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b075efb1ca
commit
06618e6623
@ -1130,7 +1130,7 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
|
|||||||
* @param cfs
|
* @param cfs
|
||||||
* @return An {@link HColumnDescriptor} made from the passed in <code>cfs</code>
|
* @return An {@link HColumnDescriptor} made from the passed in <code>cfs</code>
|
||||||
*/
|
*/
|
||||||
static HColumnDescriptor convert(final ColumnFamilySchema cfs) {
|
public static HColumnDescriptor convert(final ColumnFamilySchema cfs) {
|
||||||
// Use the empty constructor so we preserve the initial values set on construction for things
|
// Use the empty constructor so we preserve the initial values set on construction for things
|
||||||
// like maxVersion. Otherwise, we pick up wrong values on deserialization which makes for
|
// like maxVersion. Otherwise, we pick up wrong values on deserialization which makes for
|
||||||
// unrelated-looking test failures that are hard to trace back to here.
|
// unrelated-looking test failures that are hard to trace back to here.
|
||||||
@ -1145,7 +1145,7 @@ public class HColumnDescriptor implements WritableComparable<HColumnDescriptor>
|
|||||||
/**
|
/**
|
||||||
* @return Convert this instance to a the pb column family type
|
* @return Convert this instance to a the pb column family type
|
||||||
*/
|
*/
|
||||||
ColumnFamilySchema convert() {
|
public ColumnFamilySchema convert() {
|
||||||
ColumnFamilySchema.Builder builder = ColumnFamilySchema.newBuilder();
|
ColumnFamilySchema.Builder builder = ColumnFamilySchema.newBuilder();
|
||||||
builder.setName(ByteString.copyFrom(getName()));
|
builder.setName(ByteString.copyFrom(getName()));
|
||||||
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e: this.values.entrySet()) {
|
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e: this.values.entrySet()) {
|
||||||
|
@ -1251,7 +1251,7 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
|
|||||||
/**
|
/**
|
||||||
* @return Convert the current {@link HTableDescriptor} into a pb TableSchema instance.
|
* @return Convert the current {@link HTableDescriptor} into a pb TableSchema instance.
|
||||||
*/
|
*/
|
||||||
TableSchema convert() {
|
public TableSchema convert() {
|
||||||
TableSchema.Builder builder = TableSchema.newBuilder();
|
TableSchema.Builder builder = TableSchema.newBuilder();
|
||||||
builder.setName(ByteString.copyFrom(getName()));
|
builder.setName(ByteString.copyFrom(getName()));
|
||||||
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e: this.values.entrySet()) {
|
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> e: this.values.entrySet()) {
|
||||||
@ -1270,7 +1270,7 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
|
|||||||
* @param ts A pb TableSchema instance.
|
* @param ts A pb TableSchema instance.
|
||||||
* @return An {@link HTableDescriptor} made from the passed in pb <code>ts</code>.
|
* @return An {@link HTableDescriptor} made from the passed in pb <code>ts</code>.
|
||||||
*/
|
*/
|
||||||
static HTableDescriptor convert(final TableSchema ts) {
|
public static HTableDescriptor convert(final TableSchema ts) {
|
||||||
List<ColumnFamilySchema> list = ts.getColumnFamiliesList();
|
List<ColumnFamilySchema> list = ts.getColumnFamiliesList();
|
||||||
HColumnDescriptor [] hcds = new HColumnDescriptor[list.size()];
|
HColumnDescriptor [] hcds = new HColumnDescriptor[list.size()];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -74,6 +74,19 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.RollWALWriterRespo
|
|||||||
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.StopServerRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.StopServerRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
|
||||||
@ -493,8 +506,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
|
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.createTable(desc, splitKeys);
|
CreateTableRequest request = RequestConverter.buildCreateTableRequest(desc, splitKeys);
|
||||||
|
master.createTable(null, request);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -525,8 +539,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
|
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.deleteTable(tableName);
|
DeleteTableRequest req = RequestConverter.buildDeleteTableRequest(tableName);
|
||||||
|
master.deleteTable(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -554,19 +569,21 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
// HMaster removes the table from its HTableDescriptors
|
// HMaster removes the table from its HTableDescriptors
|
||||||
if (values == null || values.length == 0) {
|
if (values == null || values.length == 0) {
|
||||||
tableExists = false;
|
tableExists = false;
|
||||||
HTableDescriptor[] htds;
|
GetTableDescriptorsResponse htds;
|
||||||
MasterKeepAliveConnection master = connection.getKeepAliveMaster();
|
MasterKeepAliveConnection master = connection.getKeepAliveMaster();
|
||||||
try {
|
try {
|
||||||
htds = master.getHTableDescriptors();
|
GetTableDescriptorsRequest req =
|
||||||
|
RequestConverter.buildGetTableDescriptorsRequest(null);
|
||||||
|
htds = master.getTableDescriptors(null, req);
|
||||||
|
} catch (ServiceException se) {
|
||||||
|
throw ProtobufUtil.getRemoteException(se);
|
||||||
} finally {
|
} finally {
|
||||||
master.close();
|
master.close();
|
||||||
}
|
}
|
||||||
if (htds != null && htds.length > 0) {
|
for (TableSchema ts : htds.getTableSchemaList()) {
|
||||||
for (HTableDescriptor htd: htds) {
|
if (Bytes.equals(tableName, ts.getName().toByteArray())) {
|
||||||
if (Bytes.equals(tableName, htd.getName())) {
|
tableExists = true;
|
||||||
tableExists = true;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!tableExists) {
|
if (!tableExists) {
|
||||||
@ -709,9 +726,10 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
LOG.info("Started enable of " + Bytes.toString(tableName));
|
LOG.info("Started enable of " + Bytes.toString(tableName));
|
||||||
master.enableTable(tableName);
|
EnableTableRequest req = RequestConverter.buildEnableTableRequest(tableName);
|
||||||
|
master.enableTable(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -778,9 +796,10 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
public void disableTableAsync(final byte [] tableName) throws IOException {
|
public void disableTableAsync(final byte [] tableName) throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
LOG.info("Started disable of " + Bytes.toString(tableName));
|
LOG.info("Started disable of " + Bytes.toString(tableName));
|
||||||
master.disableTable(tableName);
|
DisableTableRequest req = RequestConverter.buildDisableTableRequest(tableName);
|
||||||
|
master.disableTable(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -948,8 +967,14 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
HTableDescriptor.isLegalTableName(tableName);
|
HTableDescriptor.isLegalTableName(tableName);
|
||||||
return execute(new MasterCallable<Pair<Integer, Integer>>() {
|
return execute(new MasterCallable<Pair<Integer, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Pair<Integer, Integer> call() throws IOException {
|
public Pair<Integer, Integer> call() throws ServiceException {
|
||||||
return master.getAlterStatus(tableName);
|
GetSchemaAlterStatusRequest req =
|
||||||
|
RequestConverter.buildGetSchemaAlterStatusRequest(tableName);
|
||||||
|
GetSchemaAlterStatusResponse ret = master.getSchemaAlterStatus(null,req);
|
||||||
|
Pair<Integer,Integer> pair =
|
||||||
|
new Pair<Integer,Integer>(
|
||||||
|
new Integer(ret.getYetToUpdateRegions()),new Integer(ret.getTotalRegions()));
|
||||||
|
return pair;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -979,8 +1004,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.addColumn(tableName, column);
|
AddColumnRequest req = RequestConverter.buildAddColumnRequest(tableName, column);
|
||||||
|
master.addColumn(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1011,8 +1037,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.deleteColumn(tableName, columnName);
|
DeleteColumnRequest req = RequestConverter.buildDeleteColumnRequest(tableName, columnName);
|
||||||
|
master.deleteColumn(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1045,8 +1072,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.modifyColumn(tableName, descriptor);
|
ModifyColumnRequest req = RequestConverter.buildModifyColumnRequest(tableName, descriptor);
|
||||||
|
master.modifyColumn(null,req);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1425,6 +1453,21 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Special method, only used by hbck.
|
||||||
|
*/
|
||||||
|
public void offline(final byte [] regionName)
|
||||||
|
throws IOException {
|
||||||
|
MasterKeepAliveConnection master = connection.getKeepAliveMaster();
|
||||||
|
try {
|
||||||
|
master.offlineRegion(null,RequestConverter.buildOfflineRegionRequest(regionName));
|
||||||
|
} catch (ServiceException se) {
|
||||||
|
throw ProtobufUtil.getRemoteException(se);
|
||||||
|
} finally {
|
||||||
|
master.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn the load balancer on or off.
|
* Turn the load balancer on or off.
|
||||||
* @param b If true, enable balancer. If false, disable balancer.
|
* @param b If true, enable balancer. If false, disable balancer.
|
||||||
@ -1565,8 +1608,9 @@ public class HBaseAdmin implements Abortable, Closeable {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
execute(new MasterCallable<Void>() {
|
execute(new MasterCallable<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws IOException {
|
public Void call() throws ServiceException {
|
||||||
master.modifyTable(tableName, htd);
|
ModifyTableRequest request = RequestConverter.buildModifyTableRequest(tableName, htd);
|
||||||
|
master.modifyTable(null, request);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -79,6 +79,9 @@ import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
|||||||
import org.apache.hadoop.hbase.ipc.VersionedProtocol;
|
import org.apache.hadoop.hbase.ipc.VersionedProtocol;
|
||||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
import org.apache.hadoop.hbase.protobuf.RequestConverter;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
|
||||||
import org.apache.hadoop.hbase.security.User;
|
import org.apache.hadoop.hbase.security.User;
|
||||||
import org.apache.hadoop.hbase.util.Addressing;
|
import org.apache.hadoop.hbase.util.Addressing;
|
||||||
@ -1586,10 +1589,6 @@ public class HConnectionManager {
|
|||||||
if (cause instanceof UndeclaredThrowableException) {
|
if (cause instanceof UndeclaredThrowableException) {
|
||||||
cause = cause.getCause();
|
cause = cause.getCause();
|
||||||
}
|
}
|
||||||
if (cause instanceof ServiceException) {
|
|
||||||
ServiceException se = (ServiceException)cause;
|
|
||||||
cause = ProtobufUtil.getRemoteException(se);
|
|
||||||
}
|
|
||||||
throw cause;
|
throw cause;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2245,7 +2244,11 @@ public class HConnectionManager {
|
|||||||
public HTableDescriptor[] listTables() throws IOException {
|
public HTableDescriptor[] listTables() throws IOException {
|
||||||
MasterKeepAliveConnection master = getKeepAliveMaster();
|
MasterKeepAliveConnection master = getKeepAliveMaster();
|
||||||
try {
|
try {
|
||||||
return master.getHTableDescriptors();
|
GetTableDescriptorsRequest req =
|
||||||
|
RequestConverter.buildGetTableDescriptorsRequest(null);
|
||||||
|
return ProtobufUtil.getHTableDescriptorArray(master.getTableDescriptors(null, req));
|
||||||
|
} catch (ServiceException se) {
|
||||||
|
throw ProtobufUtil.getRemoteException(se);
|
||||||
} finally {
|
} finally {
|
||||||
master.close();
|
master.close();
|
||||||
}
|
}
|
||||||
@ -2256,8 +2259,12 @@ public class HConnectionManager {
|
|||||||
if (tableNames == null || tableNames.isEmpty()) return new HTableDescriptor[0];
|
if (tableNames == null || tableNames.isEmpty()) return new HTableDescriptor[0];
|
||||||
MasterKeepAliveConnection master = getKeepAliveMaster();
|
MasterKeepAliveConnection master = getKeepAliveMaster();
|
||||||
try {
|
try {
|
||||||
return master.getHTableDescriptors(tableNames);
|
GetTableDescriptorsRequest req =
|
||||||
}finally {
|
RequestConverter.buildGetTableDescriptorsRequest(tableNames);
|
||||||
|
return ProtobufUtil.getHTableDescriptorArray(master.getTableDescriptors(null, req));
|
||||||
|
} catch (ServiceException se) {
|
||||||
|
throw ProtobufUtil.getRemoteException(se);
|
||||||
|
} finally {
|
||||||
master.close();
|
master.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2280,17 +2287,19 @@ public class HConnectionManager {
|
|||||||
return HTableDescriptor.META_TABLEDESC;
|
return HTableDescriptor.META_TABLEDESC;
|
||||||
}
|
}
|
||||||
MasterKeepAliveConnection master = getKeepAliveMaster();
|
MasterKeepAliveConnection master = getKeepAliveMaster();
|
||||||
HTableDescriptor[] htds;
|
GetTableDescriptorsResponse htds;
|
||||||
try {
|
try {
|
||||||
htds = master.getHTableDescriptors();
|
GetTableDescriptorsRequest req =
|
||||||
}finally {
|
RequestConverter.buildGetTableDescriptorsRequest(null);
|
||||||
|
htds = master.getTableDescriptors(null, req);
|
||||||
|
} catch (ServiceException se) {
|
||||||
|
throw ProtobufUtil.getRemoteException(se);
|
||||||
|
} finally {
|
||||||
master.close();
|
master.close();
|
||||||
}
|
}
|
||||||
if (htds != null && htds.length > 0) {
|
for (TableSchema ts : htds.getTableSchemaList()) {
|
||||||
for (HTableDescriptor htd: htds) {
|
if (Bytes.equals(tableName, ts.getName().toByteArray())) {
|
||||||
if (Bytes.equals(tableName, htd.getName())) {
|
return HTableDescriptor.convert(ts);
|
||||||
return htd;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new TableNotFoundException(Bytes.toString(tableName));
|
throw new TableNotFoundException(Bytes.toString(tableName));
|
||||||
|
@ -27,10 +27,32 @@ import org.apache.hadoop.classification.InterfaceStability;
|
|||||||
import org.apache.hadoop.hbase.ClusterStatus;
|
import org.apache.hadoop.hbase.ClusterStatus;
|
||||||
import org.apache.hadoop.hbase.HColumnDescriptor;
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.SetBalancerRunningResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
||||||
@ -94,85 +116,106 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
* Creates a new table asynchronously. If splitKeys are specified, then the
|
* Creates a new table asynchronously. If splitKeys are specified, then the
|
||||||
* table will be created with an initial set of multiple regions.
|
* table will be created with an initial set of multiple regions.
|
||||||
* If splitKeys is null, the table will be created with a single region.
|
* If splitKeys is null, the table will be created with a single region.
|
||||||
* @param desc table descriptor
|
* @param controller Unused (set to null).
|
||||||
* @param splitKeys
|
* @param req CreateTableRequest that contains:<br>
|
||||||
* @throws IOException
|
* - tablesSchema: table descriptor<br>
|
||||||
|
* - splitKeys
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void createTable(HTableDescriptor desc, byte [][] splitKeys)
|
public CreateTableResponse createTable(RpcController controller, CreateTableRequest req)
|
||||||
throws IOException;
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a table
|
* Deletes a table
|
||||||
* @param tableName table to delete
|
* @param controller Unused (set to null).
|
||||||
* @throws IOException e
|
* @param req DeleteTableRequest that contains:<br>
|
||||||
|
* - tableName: table to delete
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void deleteTable(final byte [] tableName) throws IOException;
|
public DeleteTableResponse deleteTable(RpcController controller, DeleteTableRequest req)
|
||||||
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the client to get the number of regions that have received the
|
* Used by the client to get the number of regions that have received the
|
||||||
* updated schema
|
* updated schema
|
||||||
*
|
*
|
||||||
* @param tableName
|
* @param controller Unused (set to null).
|
||||||
* @return Pair indicating the number of regions updated Pair.getFirst() is the
|
* @param req GetSchemaAlterStatusRequest that contains:<br>
|
||||||
* regions that are yet to be updated Pair.getSecond() is the total number
|
* - tableName
|
||||||
* of regions of the table
|
* @return GetSchemaAlterStatusResponse indicating the number of regions updated.
|
||||||
* @throws IOException
|
* yetToUpdateRegions is the regions that are yet to be updated totalRegions
|
||||||
|
* is the total number of regions of the table
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public Pair<Integer, Integer> getAlterStatus(byte[] tableName)
|
public GetSchemaAlterStatusResponse getSchemaAlterStatus(
|
||||||
throws IOException;
|
RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a column to the specified table
|
* Adds a column to the specified table
|
||||||
* @param tableName table to modify
|
* @param controller Unused (set to null).
|
||||||
* @param column column descriptor
|
* @param req AddColumnRequest that contains:<br>
|
||||||
* @throws IOException e
|
* - tableName: table to modify<br>
|
||||||
|
* - column: column descriptor
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void addColumn(final byte [] tableName, HColumnDescriptor column)
|
public AddColumnResponse addColumn(RpcController controller, AddColumnRequest req)
|
||||||
throws IOException;
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifies an existing column on the specified table
|
* Modifies an existing column on the specified table
|
||||||
* @param tableName table name
|
* @param controller Unused (set to null).
|
||||||
* @param descriptor new column descriptor
|
* @param req ModifyColumnRequest that contains:<br>
|
||||||
|
* - tableName: table name<br>
|
||||||
|
* - descriptor: new column descriptor
|
||||||
* @throws IOException e
|
* @throws IOException e
|
||||||
*/
|
*/
|
||||||
public void modifyColumn(final byte [] tableName, HColumnDescriptor descriptor)
|
public ModifyColumnResponse modifyColumn(RpcController controller, ModifyColumnRequest req)
|
||||||
throws IOException;
|
throws ServiceException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a column from the specified table. Table must be disabled.
|
* Deletes a column from the specified table. Table must be disabled.
|
||||||
* @param tableName table to alter
|
* @param controller Unused (set to null).
|
||||||
* @param columnName column family to remove
|
* @param req DeleteColumnRequest that contains:<br>
|
||||||
* @throws IOException e
|
* - tableName: table to alter<br>
|
||||||
|
* - columnName: column family to remove
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void deleteColumn(final byte [] tableName, final byte [] columnName)
|
public DeleteColumnResponse deleteColumn(RpcController controller, DeleteColumnRequest req)
|
||||||
throws IOException;
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Puts the table on-line (only needed if table has been previously taken offline)
|
* Puts the table on-line (only needed if table has been previously taken offline)
|
||||||
* @param tableName table to enable
|
* @param controller Unused (set to null).
|
||||||
* @throws IOException e
|
* @param req EnableTableRequest that contains:<br>
|
||||||
|
* - tableName: table to enable
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void enableTable(final byte [] tableName) throws IOException;
|
public EnableTableResponse enableTable(RpcController controller, EnableTableRequest req)
|
||||||
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take table offline
|
* Take table offline
|
||||||
*
|
*
|
||||||
* @param tableName table to take offline
|
* @param controller Unused (set to null).
|
||||||
* @throws IOException e
|
* @param req DisableTableRequest that contains:<br>
|
||||||
|
* - tableName: table to take offline
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void disableTable(final byte [] tableName) throws IOException;
|
public DisableTableResponse disableTable(RpcController controller, DisableTableRequest req)
|
||||||
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modify a table's metadata
|
* Modify a table's metadata
|
||||||
*
|
*
|
||||||
* @param tableName table to modify
|
* @param controller Unused (set to null).
|
||||||
* @param htd new descriptor for table
|
* @param req ModifyTableRequest that contains:<br>
|
||||||
* @throws IOException e
|
* - tableName: table to modify<br>
|
||||||
|
* - tableSchema: new descriptor for table
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void modifyTable(byte[] tableName, HTableDescriptor htd)
|
public ModifyTableResponse modifyTable(RpcController controller, ModifyTableRequest req)
|
||||||
throws IOException;
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown an HBase cluster.
|
* Shutdown an HBase cluster.
|
||||||
@ -206,11 +249,14 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
* region should be in a closed state and there will be no attempt to
|
* region should be in a closed state and there will be no attempt to
|
||||||
* automatically reassign the region as in unassign. This is a special
|
* automatically reassign the region as in unassign. This is a special
|
||||||
* method, and should only be used by experts or hbck.
|
* method, and should only be used by experts or hbck.
|
||||||
* @param regionName Region to offline. Will clear any existing RegionPlan
|
* @param controller Unused (set to null).
|
||||||
|
* @param request OfflineRegionRequest that contains:<br>
|
||||||
|
* - region: Region to offline. Will clear any existing RegionPlan
|
||||||
* if one found.
|
* if one found.
|
||||||
* @throws IOException
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public void offline(final byte[] regionName) throws IOException;
|
public OfflineRegionResponse offlineRegion(RpcController controller, OfflineRegionRequest request)
|
||||||
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the balancer. Will run the balancer and if regions to move, it will
|
* Run the balancer. Will run the balancer and if regions to move, it will
|
||||||
@ -239,17 +285,15 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
throws ServiceException;
|
throws ServiceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get array of all HTDs.
|
* Get list of TableDescriptors for requested tables.
|
||||||
* @return array of HTableDescriptor
|
* @param controller Unused (set to null).
|
||||||
|
* @param req GetTableDescriptorsRequest that contains:<br>
|
||||||
|
* - tableNames: requested tables, or if empty, all are requested
|
||||||
|
* @return GetTableDescriptorsResponse
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public HTableDescriptor[] getHTableDescriptors();
|
public GetTableDescriptorsResponse getTableDescriptors(
|
||||||
|
RpcController controller, GetTableDescriptorsRequest req) throws ServiceException;
|
||||||
/**
|
|
||||||
* Get array of HTDs for requested tables.
|
|
||||||
* @param tableNames
|
|
||||||
* @return array of HTableDescriptor
|
|
||||||
*/
|
|
||||||
public HTableDescriptor[] getHTableDescriptors(List<String> tableNames);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a region to a server chosen at random.
|
* Assign a region to a server chosen at random.
|
||||||
@ -267,7 +311,7 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
* back to the same server. Use {@link #moveRegion(RpcController,MoveRegionRequest}
|
* back to the same server. Use {@link #moveRegion(RpcController,MoveRegionRequest}
|
||||||
* if you want to control the region movement.
|
* if you want to control the region movement.
|
||||||
* @param controller Unused (set to null).
|
* @param controller Unused (set to null).
|
||||||
* @param req The request which contains:<br>
|
* @param req The request that contains:<br>
|
||||||
* - region: Region to unassign. Will clear any existing RegionPlan
|
* - region: Region to unassign. Will clear any existing RegionPlan
|
||||||
* if one found.<br>
|
* if one found.<br>
|
||||||
* - force: If true, force unassign (Will remove region from
|
* - force: If true, force unassign (Will remove region from
|
||||||
@ -281,7 +325,7 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
/**
|
/**
|
||||||
* Move a region to a specified destination server.
|
* Move a region to a specified destination server.
|
||||||
* @param controller Unused (set to null).
|
* @param controller Unused (set to null).
|
||||||
* @param req The request which contains:<br>
|
* @param req The request that contains:<br>
|
||||||
* - region: The encoded region name; i.e. the hash that makes
|
* - region: The encoded region name; i.e. the hash that makes
|
||||||
* up the region name suffix: e.g. if regionname is
|
* up the region name suffix: e.g. if regionname is
|
||||||
* <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
|
* <code>TestTable,0094429456,1289497600452.527db22f95c8a9e0116f0cc13c680396.</code>,
|
||||||
@ -294,5 +338,5 @@ public interface HMasterInterface extends VersionedProtocol {
|
|||||||
* region named <code>encodedRegionName</code>
|
* region named <code>encodedRegionName</code>
|
||||||
*/
|
*/
|
||||||
public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req)
|
public MoveRegionResponse moveRegion(RpcController controller, MoveRegionRequest req)
|
||||||
throws ServiceException;
|
throws ServiceException;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ public class Invocation extends VersionedWritable implements Configurable {
|
|||||||
PROTOBUF_PROTOCOLS.add(ClientProtocol.class);
|
PROTOBUF_PROTOCOLS.add(ClientProtocol.class);
|
||||||
PROTOBUF_PROTOCOLS.add(AdminProtocol.class);
|
PROTOBUF_PROTOCOLS.add(AdminProtocol.class);
|
||||||
PROTOBUF_PROTOCOLS.add(RegionServerStatusProtocol.class);
|
PROTOBUF_PROTOCOLS.add(RegionServerStatusProtocol.class);
|
||||||
|
PROTOBUF_PROTOCOLS.add(HMasterInterface.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte RPC_VERSION = 1;
|
private static byte RPC_VERSION = 1;
|
||||||
|
@ -69,15 +69,6 @@ class WritableRpcEngine implements RpcEngine {
|
|||||||
// DEBUG log level does NOT emit RPC-level logging.
|
// DEBUG log level does NOT emit RPC-level logging.
|
||||||
private static final Log LOG = LogFactory.getLog("org.apache.hadoop.ipc.RPCEngine");
|
private static final Log LOG = LogFactory.getLog("org.apache.hadoop.ipc.RPCEngine");
|
||||||
|
|
||||||
// For protobuf protocols, which use ServiceException, instead of IOException
|
|
||||||
protected static final Set<Class<?>>
|
|
||||||
PROTOBUF_PROTOCOLS = new HashSet<Class<?>>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
PROTOBUF_PROTOCOLS.add(ClientProtocol.class);
|
|
||||||
PROTOBUF_PROTOCOLS.add(AdminProtocol.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cache a client using its socket factory as the hash key */
|
/* Cache a client using its socket factory as the hash key */
|
||||||
static private class ClientCache {
|
static private class ClientCache {
|
||||||
private Map<SocketFactory, HBaseClient> clients =
|
private Map<SocketFactory, HBaseClient> clients =
|
||||||
|
@ -124,10 +124,32 @@ import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.Re
|
|||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
|
||||||
import com.google.protobuf.RpcController;
|
import com.google.protobuf.RpcController;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionResponse;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionResponse;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionResponse;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
|
||||||
@ -1005,7 +1027,7 @@ Server {
|
|||||||
resp.addMapEntries(entry.build());
|
resp.addMapEntries(entry.build());
|
||||||
|
|
||||||
return resp.build();
|
return resp.build();
|
||||||
} catch(IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new ServiceException(ioe);
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1050,7 +1072,7 @@ Server {
|
|||||||
// Up our metrics.
|
// Up our metrics.
|
||||||
this.metrics.incrementRequests(sl.getTotalNumberOfRequests());
|
this.metrics.incrementRequests(sl.getTotalNumberOfRequests());
|
||||||
}
|
}
|
||||||
} catch(IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new ServiceException(ioe);
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1248,7 +1270,7 @@ Server {
|
|||||||
|
|
||||||
if (type != RegionSpecifierType.ENCODED_REGION_NAME) {
|
if (type != RegionSpecifierType.ENCODED_REGION_NAME) {
|
||||||
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.ENCODED_REGION_NAME
|
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.ENCODED_REGION_NAME
|
||||||
+ " actual: " + RegionSpecifierType.REGION_NAME);
|
+ " actual: " + type);
|
||||||
}
|
}
|
||||||
Pair<HRegionInfo, ServerName> p =
|
Pair<HRegionInfo, ServerName> p =
|
||||||
this.assignmentManager.getAssignment(encodedRegionName);
|
this.assignmentManager.getAssignment(encodedRegionName);
|
||||||
@ -1296,6 +1318,7 @@ Server {
|
|||||||
return mrr;
|
return mrr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createTable(HTableDescriptor hTableDescriptor,
|
public void createTable(HTableDescriptor hTableDescriptor,
|
||||||
byte [][] splitKeys)
|
byte [][] splitKeys)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@ -1312,10 +1335,23 @@ Server {
|
|||||||
this.executorService.submit(new CreateTableHandler(this,
|
this.executorService.submit(new CreateTableHandler(this,
|
||||||
this.fileSystemManager, this.serverManager, hTableDescriptor, conf,
|
this.fileSystemManager, this.serverManager, hTableDescriptor, conf,
|
||||||
newRegions, catalogTracker, assignmentManager));
|
newRegions, catalogTracker, assignmentManager));
|
||||||
|
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
cpHost.postCreateTable(hTableDescriptor, newRegions);
|
cpHost.postCreateTable(hTableDescriptor, newRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CreateTableResponse createTable(RpcController controller, CreateTableRequest req)
|
||||||
|
throws ServiceException {
|
||||||
|
HTableDescriptor hTableDescriptor = HTableDescriptor.convert(req.getTableSchema());
|
||||||
|
byte [][] splitKeys = ProtobufUtil.getSplitKeysArray(req);
|
||||||
|
try {
|
||||||
|
createTable(hTableDescriptor,splitKeys);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
|
}
|
||||||
|
return CreateTableResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private HRegionInfo[] getHRegionInfos(HTableDescriptor hTableDescriptor,
|
private HRegionInfo[] getHRegionInfos(HTableDescriptor hTableDescriptor,
|
||||||
@ -1345,15 +1381,23 @@ Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteTable(final byte [] tableName) throws IOException {
|
public DeleteTableResponse deleteTable(RpcController controller, DeleteTableRequest request)
|
||||||
checkInitialized();
|
throws ServiceException {
|
||||||
if (cpHost != null) {
|
byte [] tableName = request.getTableName().toByteArray();
|
||||||
cpHost.preDeleteTable(tableName);
|
try {
|
||||||
}
|
checkInitialized();
|
||||||
this.executorService.submit(new DeleteTableHandler(tableName, this, this));
|
if (cpHost != null) {
|
||||||
if (cpHost != null) {
|
cpHost.preDeleteTable(tableName);
|
||||||
cpHost.postDeleteTable(tableName);
|
}
|
||||||
|
this.executorService.submit(new DeleteTableHandler(tableName, this, this));
|
||||||
|
|
||||||
|
if (cpHost != null) {
|
||||||
|
cpHost.postDeleteTable(tableName);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
|
return DeleteTableResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1364,81 +1408,132 @@ Server {
|
|||||||
* of regions of the table
|
* of regions of the table
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public Pair<Integer, Integer> getAlterStatus(byte[] tableName)
|
@Override
|
||||||
throws IOException {
|
public GetSchemaAlterStatusResponse getSchemaAlterStatus(
|
||||||
|
RpcController controller, GetSchemaAlterStatusRequest req) throws ServiceException {
|
||||||
// TODO: currently, we query using the table name on the client side. this
|
// TODO: currently, we query using the table name on the client side. this
|
||||||
// may overlap with other table operations or the table operation may
|
// may overlap with other table operations or the table operation may
|
||||||
// have completed before querying this API. We need to refactor to a
|
// have completed before querying this API. We need to refactor to a
|
||||||
// transaction system in the future to avoid these ambiguities.
|
// transaction system in the future to avoid these ambiguities.
|
||||||
return this.assignmentManager.getReopenStatus(tableName);
|
byte [] tableName = req.getTableName().toByteArray();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Pair<Integer,Integer> pair = this.assignmentManager.getReopenStatus(tableName);
|
||||||
|
GetSchemaAlterStatusResponse.Builder ret = GetSchemaAlterStatusResponse.newBuilder();
|
||||||
|
ret.setYetToUpdateRegions(pair.getFirst());
|
||||||
|
ret.setTotalRegions(pair.getSecond());
|
||||||
|
return ret.build();
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addColumn(byte [] tableName, HColumnDescriptor column)
|
public AddColumnResponse addColumn(RpcController controller, AddColumnRequest req)
|
||||||
throws IOException {
|
throws ServiceException {
|
||||||
checkInitialized();
|
byte [] tableName = req.getTableName().toByteArray();
|
||||||
if (cpHost != null) {
|
HColumnDescriptor column = HColumnDescriptor.convert(req.getColumnFamilies());
|
||||||
if (cpHost.preAddColumn(tableName, column)) {
|
|
||||||
return;
|
try {
|
||||||
|
checkInitialized();
|
||||||
|
if (cpHost != null) {
|
||||||
|
if (cpHost.preAddColumn(tableName, column)) {
|
||||||
|
return AddColumnResponse.newBuilder().build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
new TableAddFamilyHandler(tableName, column, this, this).process();
|
||||||
new TableAddFamilyHandler(tableName, column, this, this).process();
|
if (cpHost != null) {
|
||||||
if (cpHost != null) {
|
cpHost.postAddColumn(tableName, column);
|
||||||
cpHost.postAddColumn(tableName, column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void modifyColumn(byte [] tableName, HColumnDescriptor descriptor)
|
|
||||||
throws IOException {
|
|
||||||
checkInitialized();
|
|
||||||
if (cpHost != null) {
|
|
||||||
if (cpHost.preModifyColumn(tableName, descriptor)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
new TableModifyFamilyHandler(tableName, descriptor, this, this).process();
|
return AddColumnResponse.newBuilder().build();
|
||||||
if (cpHost != null) {
|
|
||||||
cpHost.postModifyColumn(tableName, descriptor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteColumn(final byte [] tableName, final byte [] c)
|
public ModifyColumnResponse modifyColumn(RpcController controller, ModifyColumnRequest req)
|
||||||
throws IOException {
|
throws ServiceException {
|
||||||
checkInitialized();
|
byte [] tableName = req.getTableName().toByteArray();
|
||||||
if (cpHost != null) {
|
HColumnDescriptor descriptor = HColumnDescriptor.convert(req.getColumnFamilies());
|
||||||
if (cpHost.preDeleteColumn(tableName, c)) {
|
|
||||||
return;
|
try {
|
||||||
|
checkInitialized();
|
||||||
|
if (cpHost != null) {
|
||||||
|
if (cpHost.preModifyColumn(tableName, descriptor)) {
|
||||||
|
return ModifyColumnResponse.newBuilder().build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
new TableModifyFamilyHandler(tableName, descriptor, this, this).process();
|
||||||
|
if (cpHost != null) {
|
||||||
|
cpHost.postModifyColumn(tableName, descriptor);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
new TableDeleteFamilyHandler(tableName, c, this, this).process();
|
return ModifyColumnResponse.newBuilder().build();
|
||||||
if (cpHost != null) {
|
|
||||||
cpHost.postDeleteColumn(tableName, c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableTable(final byte [] tableName) throws IOException {
|
@Override
|
||||||
checkInitialized();
|
public DeleteColumnResponse deleteColumn(RpcController controller, DeleteColumnRequest req)
|
||||||
if (cpHost != null) {
|
throws ServiceException {
|
||||||
cpHost.preEnableTable(tableName);
|
final byte [] tableName = req.getTableName().toByteArray();
|
||||||
}
|
final byte [] columnName = req.getColumnName().toByteArray();
|
||||||
this.executorService.submit(new EnableTableHandler(this, tableName,
|
try {
|
||||||
catalogTracker, assignmentManager, false));
|
checkInitialized();
|
||||||
|
if (cpHost != null) {
|
||||||
if (cpHost != null) {
|
if (cpHost.preDeleteColumn(tableName, columnName)) {
|
||||||
cpHost.postEnableTable(tableName);
|
return DeleteColumnResponse.newBuilder().build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new TableDeleteFamilyHandler(tableName, columnName, this, this).process();
|
||||||
|
if (cpHost != null) {
|
||||||
|
cpHost.postDeleteColumn(tableName, columnName);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
|
return DeleteColumnResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disableTable(final byte [] tableName) throws IOException {
|
@Override
|
||||||
checkInitialized();
|
public EnableTableResponse enableTable(RpcController controller, EnableTableRequest request)
|
||||||
if (cpHost != null) {
|
throws ServiceException {
|
||||||
cpHost.preDisableTable(tableName);
|
byte [] tableName = request.getTableName().toByteArray();
|
||||||
}
|
try {
|
||||||
this.executorService.submit(new DisableTableHandler(this, tableName,
|
checkInitialized();
|
||||||
catalogTracker, assignmentManager, false));
|
if (cpHost != null) {
|
||||||
|
cpHost.preEnableTable(tableName);
|
||||||
|
}
|
||||||
|
this.executorService.submit(new EnableTableHandler(this, tableName,
|
||||||
|
catalogTracker, assignmentManager, false));
|
||||||
|
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
cpHost.postDisableTable(tableName);
|
cpHost.postEnableTable(tableName);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
|
return EnableTableResponse.newBuilder().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DisableTableResponse disableTable(RpcController controller, DisableTableRequest request)
|
||||||
|
throws ServiceException {
|
||||||
|
byte [] tableName = request.getTableName().toByteArray();
|
||||||
|
try {
|
||||||
|
checkInitialized();
|
||||||
|
if (cpHost != null) {
|
||||||
|
cpHost.preDisableTable(tableName);
|
||||||
|
}
|
||||||
|
this.executorService.submit(new DisableTableHandler(this, tableName,
|
||||||
|
catalogTracker, assignmentManager, false));
|
||||||
|
|
||||||
|
if (cpHost != null) {
|
||||||
|
cpHost.postDisableTable(tableName);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
|
}
|
||||||
|
return DisableTableResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1477,19 +1572,26 @@ Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyTable(final byte[] tableName, HTableDescriptor htd)
|
public ModifyTableResponse modifyTable(RpcController controller, ModifyTableRequest req)
|
||||||
throws IOException {
|
throws ServiceException {
|
||||||
checkInitialized();
|
final byte [] tableName = req.getTableName().toByteArray();
|
||||||
if (cpHost != null) {
|
HTableDescriptor htd = HTableDescriptor.convert(req.getTableSchema());
|
||||||
cpHost.preModifyTable(tableName, htd);
|
try {
|
||||||
}
|
checkInitialized();
|
||||||
TableEventHandler tblHandle = new ModifyTableHandler(tableName, htd, this, this);
|
if (cpHost != null) {
|
||||||
this.executorService.submit(tblHandle);
|
cpHost.preModifyTable(tableName, htd);
|
||||||
tblHandle.waitForPersist();
|
}
|
||||||
|
TableEventHandler tblHandle = new ModifyTableHandler(tableName, htd, this, this);
|
||||||
|
this.executorService.submit(tblHandle);
|
||||||
|
tblHandle.waitForPersist();
|
||||||
|
|
||||||
if (cpHost != null) {
|
if (cpHost != null) {
|
||||||
cpHost.postModifyTable(tableName, htd);
|
cpHost.postModifyTable(tableName, htd);
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
}
|
}
|
||||||
|
return ModifyTableResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1856,7 +1958,7 @@ Server {
|
|||||||
checkInitialized();
|
checkInitialized();
|
||||||
if (type != RegionSpecifierType.REGION_NAME) {
|
if (type != RegionSpecifierType.REGION_NAME) {
|
||||||
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
||||||
+ " actual: " + RegionSpecifierType.ENCODED_REGION_NAME);
|
+ " actual: " + type);
|
||||||
}
|
}
|
||||||
Pair<HRegionInfo, ServerName> pair =
|
Pair<HRegionInfo, ServerName> pair =
|
||||||
MetaReader.getRegion(this.catalogTracker, regionName);
|
MetaReader.getRegion(this.catalogTracker, regionName);
|
||||||
@ -1893,7 +1995,7 @@ Server {
|
|||||||
checkInitialized();
|
checkInitialized();
|
||||||
if (type != RegionSpecifierType.REGION_NAME) {
|
if (type != RegionSpecifierType.REGION_NAME) {
|
||||||
LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
LOG.warn("unassignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
||||||
+ " actual: " + RegionSpecifierType.ENCODED_REGION_NAME);
|
+ " actual: " + type);
|
||||||
}
|
}
|
||||||
Pair<HRegionInfo, ServerName> pair =
|
Pair<HRegionInfo, ServerName> pair =
|
||||||
MetaReader.getRegion(this.catalogTracker, regionName);
|
MetaReader.getRegion(this.catalogTracker, regionName);
|
||||||
@ -1921,39 +2023,43 @@ Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get HTD array for given tables
|
* Get list of TableDescriptors for requested tables.
|
||||||
* @param tableNames
|
* @param controller Unused (set to null).
|
||||||
* @return HTableDescriptor[]
|
* @param req GetTableDescriptorsRequest that contains:
|
||||||
|
* - tableNames: requested tables, or if empty, all are requested
|
||||||
|
* @return GetTableDescriptorsResponse
|
||||||
|
* @throws ServiceException
|
||||||
*/
|
*/
|
||||||
public HTableDescriptor[] getHTableDescriptors(List<String> tableNames) {
|
public GetTableDescriptorsResponse getTableDescriptors(
|
||||||
List<HTableDescriptor> list =
|
RpcController controller, GetTableDescriptorsRequest req) throws ServiceException {
|
||||||
new ArrayList<HTableDescriptor>(tableNames.size());
|
GetTableDescriptorsResponse.Builder builder = GetTableDescriptorsResponse.newBuilder();
|
||||||
for (String s: tableNames) {
|
if (req.getTableNamesCount() == 0) {
|
||||||
HTableDescriptor htd = null;
|
// request for all TableDescriptors
|
||||||
|
Map<String, HTableDescriptor> descriptors = null;
|
||||||
try {
|
try {
|
||||||
htd = this.tableDescriptors.get(s);
|
descriptors = this.tableDescriptors.getAll();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.warn("Failed getting descriptor for " + s, e);
|
LOG.warn("Failed getting all descriptors", e);
|
||||||
|
}
|
||||||
|
if (descriptors != null) {
|
||||||
|
for (HTableDescriptor htd : descriptors.values()) {
|
||||||
|
builder.addTableSchema(htd.convert());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (htd == null) continue;
|
|
||||||
list.add(htd);
|
|
||||||
}
|
}
|
||||||
return list.toArray(new HTableDescriptor [] {});
|
else {
|
||||||
}
|
for (String s: req.getTableNamesList()) {
|
||||||
|
HTableDescriptor htd = null;
|
||||||
/**
|
try {
|
||||||
* Get all table descriptors
|
htd = this.tableDescriptors.get(s);
|
||||||
* @return All descriptors or null if none.
|
} catch (IOException e) {
|
||||||
*/
|
LOG.warn("Failed getting descriptor for " + s, e);
|
||||||
public HTableDescriptor [] getHTableDescriptors() {
|
}
|
||||||
Map<String, HTableDescriptor> descriptors = null;
|
if (htd == null) continue;
|
||||||
try {
|
builder.addTableSchema(htd.convert());
|
||||||
descriptors = this.tableDescriptors.getAll();
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
LOG.warn("Failed getting all descriptors", e);
|
|
||||||
}
|
}
|
||||||
return descriptors == null?
|
return builder.build();
|
||||||
null: descriptors.values().toArray(new HTableDescriptor [] {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1970,12 +2076,25 @@ Server {
|
|||||||
* Special method, only used by hbck.
|
* Special method, only used by hbck.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void offline(final byte[] regionName) throws IOException {
|
public OfflineRegionResponse offlineRegion(RpcController controller, OfflineRegionRequest request)
|
||||||
Pair<HRegionInfo, ServerName> pair =
|
throws ServiceException {
|
||||||
MetaReader.getRegion(this.catalogTracker, regionName);
|
final byte [] regionName = request.getRegion().getValue().toByteArray();
|
||||||
if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
|
RegionSpecifierType type = request.getRegion().getType();
|
||||||
HRegionInfo hri = pair.getFirst();
|
if (type != RegionSpecifierType.REGION_NAME) {
|
||||||
this.assignmentManager.regionOffline(hri);
|
LOG.warn("moveRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME
|
||||||
|
+ " actual: " + type);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Pair<HRegionInfo, ServerName> pair =
|
||||||
|
MetaReader.getRegion(this.catalogTracker, regionName);
|
||||||
|
if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
|
||||||
|
HRegionInfo hri = pair.getFirst();
|
||||||
|
this.assignmentManager.regionOffline(hri);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
throw new ServiceException(ioe);
|
||||||
|
}
|
||||||
|
return OfflineRegionResponse.newBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.DoNotRetryIOException;
|
|||||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.client.Action;
|
import org.apache.hadoop.hbase.client.Action;
|
||||||
@ -104,6 +105,8 @@ import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
|
|||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionInfo;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionInfo;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionLoad;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TableSchema;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
import org.apache.hadoop.hbase.regionserver.wal.HLog;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
|
import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
|
||||||
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
||||||
@ -289,6 +292,36 @@ public final class ProtobufUtil {
|
|||||||
return new ServerName(hostName, port, startCode);
|
return new ServerName(hostName, port, startCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get HTableDescriptor[] from GetTableDescriptorsResponse protobuf
|
||||||
|
*
|
||||||
|
* @param proto the GetTableDescriptorsResponse
|
||||||
|
* @return HTableDescriptor[]
|
||||||
|
*/
|
||||||
|
public static HTableDescriptor[] getHTableDescriptorArray(GetTableDescriptorsResponse proto) {
|
||||||
|
if (proto == null) return null;
|
||||||
|
|
||||||
|
HTableDescriptor[] ret = new HTableDescriptor[proto.getTableSchemaCount()];
|
||||||
|
for (int i = 0; i < proto.getTableSchemaCount(); ++i) {
|
||||||
|
ret[i] = HTableDescriptor.convert(proto.getTableSchema(i));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the split keys in form "byte [][]" from a CreateTableRequest proto
|
||||||
|
*
|
||||||
|
* @param proto the CreateTableRequest
|
||||||
|
* @return the split keys
|
||||||
|
*/
|
||||||
|
public static byte [][] getSplitKeysArray(final CreateTableRequest proto) {
|
||||||
|
byte [][] splitKeys = new byte[proto.getSplitKeysCount()][];
|
||||||
|
for (int i = 0; i < proto.getSplitKeysCount(); ++i) {
|
||||||
|
splitKeys[i] = proto.getSplitKeys(i).toByteArray();
|
||||||
|
}
|
||||||
|
return splitKeys;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a protocol buffer Get to a client Get
|
* Convert a protocol buffer Get to a client Get
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,9 @@ import java.util.UUID;
|
|||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.hbase.DeserializationException;
|
import org.apache.hadoop.hbase.DeserializationException;
|
||||||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||||
|
import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.KeyValue;
|
import org.apache.hadoop.hbase.KeyValue;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.client.Action;
|
import org.apache.hadoop.hbase.client.Action;
|
||||||
@ -78,8 +80,19 @@ import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
|
|||||||
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.UnlockRowRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.UnlockRowRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AddColumnRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.AssignRegionRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.CreateTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DeleteTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.DisableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.EnableTableRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyColumnRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.ModifyTableRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MoveRegionRequest;
|
||||||
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.OfflineRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.UnassignRegionRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.BalanceRequest;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
|
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsMasterRunningRequest;
|
||||||
@ -856,6 +869,51 @@ public final class RequestConverter {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a protocol buffer AddColumnRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @param column
|
||||||
|
* @return an AddColumnRequest
|
||||||
|
*/
|
||||||
|
public static AddColumnRequest buildAddColumnRequest(
|
||||||
|
final byte [] tableName, final HColumnDescriptor column) {
|
||||||
|
AddColumnRequest.Builder builder = AddColumnRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
builder.setColumnFamilies(column.convert());
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a protocol buffer DeleteColumnRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @param columnName
|
||||||
|
* @return a DeleteColumnRequest
|
||||||
|
*/
|
||||||
|
public static DeleteColumnRequest buildDeleteColumnRequest(
|
||||||
|
final byte [] tableName, final byte [] columnName) {
|
||||||
|
DeleteColumnRequest.Builder builder = DeleteColumnRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
builder.setColumnName(ByteString.copyFrom(columnName));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a protocol buffer ModifyColumnRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @param column
|
||||||
|
* @return an ModifyColumnRequest
|
||||||
|
*/
|
||||||
|
public static ModifyColumnRequest buildModifyColumnRequest(
|
||||||
|
final byte [] tableName, final HColumnDescriptor column) {
|
||||||
|
ModifyColumnRequest.Builder builder = ModifyColumnRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
builder.setColumnFamilies(column.convert());
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a protocol buffer MoveRegionRequest
|
* Create a protocol buffer MoveRegionRequest
|
||||||
*
|
*
|
||||||
@ -880,7 +938,7 @@ public final class RequestConverter {
|
|||||||
* Create a protocol buffer AssignRegionRequest
|
* Create a protocol buffer AssignRegionRequest
|
||||||
*
|
*
|
||||||
* @param regionName
|
* @param regionName
|
||||||
* @return An AssignRegionRequest
|
* @return an AssignRegionRequest
|
||||||
*/
|
*/
|
||||||
public static AssignRegionRequest buildAssignRegionRequest(final byte [] regionName) {
|
public static AssignRegionRequest buildAssignRegionRequest(final byte [] regionName) {
|
||||||
AssignRegionRequest.Builder builder = AssignRegionRequest.newBuilder();
|
AssignRegionRequest.Builder builder = AssignRegionRequest.newBuilder();
|
||||||
@ -893,7 +951,7 @@ public final class RequestConverter {
|
|||||||
*
|
*
|
||||||
* @param regionName
|
* @param regionName
|
||||||
* @param force
|
* @param force
|
||||||
* @return An UnassignRegionRequest
|
* @return an UnassignRegionRequest
|
||||||
*/
|
*/
|
||||||
public static UnassignRegionRequest buildUnassignRegionRequest(
|
public static UnassignRegionRequest buildUnassignRegionRequest(
|
||||||
final byte [] regionName, final boolean force) {
|
final byte [] regionName, final boolean force) {
|
||||||
@ -903,6 +961,118 @@ public final class RequestConverter {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer OfflineRegionRequest
|
||||||
|
*
|
||||||
|
* @param regionName
|
||||||
|
* @return an OfflineRegionRequest
|
||||||
|
*/
|
||||||
|
public static OfflineRegionRequest buildOfflineRegionRequest(final byte [] regionName) {
|
||||||
|
OfflineRegionRequest.Builder builder = OfflineRegionRequest.newBuilder();
|
||||||
|
builder.setRegion(buildRegionSpecifier(RegionSpecifierType.REGION_NAME,regionName));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer DeleteTableRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @return a DeleteTableRequest
|
||||||
|
*/
|
||||||
|
public static DeleteTableRequest buildDeleteTableRequest(final byte [] tableName) {
|
||||||
|
DeleteTableRequest.Builder builder = DeleteTableRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer EnableTableRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @return an EnableTableRequest
|
||||||
|
*/
|
||||||
|
public static EnableTableRequest buildEnableTableRequest(final byte [] tableName) {
|
||||||
|
EnableTableRequest.Builder builder = EnableTableRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer DisableTableRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @return a DisableTableRequest
|
||||||
|
*/
|
||||||
|
public static DisableTableRequest buildDisableTableRequest(final byte [] tableName) {
|
||||||
|
DisableTableRequest.Builder builder = DisableTableRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(tableName));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer CreateTableRequest
|
||||||
|
*
|
||||||
|
* @param hTableDesc
|
||||||
|
* @param splitKeys
|
||||||
|
* @return a CreateTableRequest
|
||||||
|
*/
|
||||||
|
public static CreateTableRequest buildCreateTableRequest(
|
||||||
|
final HTableDescriptor hTableDesc, final byte [][] splitKeys) {
|
||||||
|
CreateTableRequest.Builder builder = CreateTableRequest.newBuilder();
|
||||||
|
builder.setTableSchema(hTableDesc.convert());
|
||||||
|
if (splitKeys != null) {
|
||||||
|
for (byte [] splitKey : splitKeys) {
|
||||||
|
builder.addSplitKeys(ByteString.copyFrom(splitKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer ModifyTableRequest
|
||||||
|
*
|
||||||
|
* @param table
|
||||||
|
* @param hTableDesc
|
||||||
|
* @return a ModifyTableRequest
|
||||||
|
*/
|
||||||
|
public static ModifyTableRequest buildModifyTableRequest(
|
||||||
|
final byte [] table, final HTableDescriptor hTableDesc) {
|
||||||
|
ModifyTableRequest.Builder builder = ModifyTableRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(table));
|
||||||
|
builder.setTableSchema(hTableDesc.convert());
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer GetSchemaAlterStatusRequest
|
||||||
|
*
|
||||||
|
* @param tableName
|
||||||
|
* @return a GetSchemaAlterStatusRequest
|
||||||
|
*/
|
||||||
|
public static GetSchemaAlterStatusRequest buildGetSchemaAlterStatusRequest(final byte [] table) {
|
||||||
|
GetSchemaAlterStatusRequest.Builder builder = GetSchemaAlterStatusRequest.newBuilder();
|
||||||
|
builder.setTableName(ByteString.copyFrom(table));
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a protocol buffer GetTableDescriptorsRequest
|
||||||
|
*
|
||||||
|
* @param tableNames
|
||||||
|
* @return a GetTableDescriptorsRequest
|
||||||
|
*/
|
||||||
|
public static GetTableDescriptorsRequest buildGetTableDescriptorsRequest(
|
||||||
|
final List<String> tableNames) {
|
||||||
|
GetTableDescriptorsRequest.Builder builder = GetTableDescriptorsRequest.newBuilder();
|
||||||
|
if (tableNames != null) {
|
||||||
|
for (String str : tableNames) {
|
||||||
|
builder.addTableNames(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a protocol buffer IsMasterRunningRequest
|
* Creates a protocol buffer IsMasterRunningRequest
|
||||||
*
|
*
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1198,7 +1198,7 @@ public class HBaseFsck {
|
|||||||
// first time we assume the rs's supports #offline.
|
// first time we assume the rs's supports #offline.
|
||||||
try {
|
try {
|
||||||
LOG.info("Offlining region " + regionString);
|
LOG.info("Offlining region " + regionString);
|
||||||
admin.getMaster().offline(regionName);
|
admin.offline(regionName);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
String notFoundMsg = "java.lang.NoSuchMethodException: " +
|
String notFoundMsg = "java.lang.NoSuchMethodException: " +
|
||||||
"org.apache.hadoop.hbase.master.HMaster.offline([B)";
|
"org.apache.hadoop.hbase.master.HMaster.offline([B)";
|
||||||
|
@ -26,6 +26,32 @@ option optimize_for = SPEED;
|
|||||||
|
|
||||||
import "hbase.proto";
|
import "hbase.proto";
|
||||||
|
|
||||||
|
/* Column-level protobufs */
|
||||||
|
|
||||||
|
message AddColumnRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
required ColumnFamilySchema columnFamilies = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AddColumnResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteColumnRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
required bytes columnName = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteColumnResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message ModifyColumnRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
required ColumnFamilySchema columnFamilies = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ModifyColumnResponse {
|
||||||
|
}
|
||||||
|
|
||||||
/* Region-level Protos */
|
/* Region-level Protos */
|
||||||
|
|
||||||
message MoveRegionRequest {
|
message MoveRegionRequest {
|
||||||
@ -51,6 +77,52 @@ message UnassignRegionRequest {
|
|||||||
message UnassignRegionResponse {
|
message UnassignRegionResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message OfflineRegionRequest {
|
||||||
|
required RegionSpecifier region = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message OfflineRegionResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Table-level protobufs */
|
||||||
|
|
||||||
|
message CreateTableRequest {
|
||||||
|
required TableSchema tableSchema = 1;
|
||||||
|
repeated bytes splitKeys = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateTableResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteTableRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeleteTableResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message EnableTableRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EnableTableResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message DisableTableRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DisableTableResponse {
|
||||||
|
}
|
||||||
|
|
||||||
|
message ModifyTableRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
required TableSchema tableSchema = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ModifyTableResponse {
|
||||||
|
}
|
||||||
|
|
||||||
/* Cluster-level protobufs */
|
/* Cluster-level protobufs */
|
||||||
|
|
||||||
message IsMasterRunningRequest {
|
message IsMasterRunningRequest {
|
||||||
@ -88,7 +160,36 @@ message SetBalancerRunningResponse {
|
|||||||
optional bool prevBalanceValue = 1;
|
optional bool prevBalanceValue = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message GetSchemaAlterStatusRequest {
|
||||||
|
required bytes tableName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetSchemaAlterStatusResponse {
|
||||||
|
optional uint32 yetToUpdateRegions = 1;
|
||||||
|
optional uint32 totalRegions = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTableDescriptorsRequest {
|
||||||
|
repeated string tableNames = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message GetTableDescriptorsResponse {
|
||||||
|
repeated TableSchema tableSchema = 1;
|
||||||
|
}
|
||||||
|
|
||||||
service MasterService {
|
service MasterService {
|
||||||
|
/** Adds a column to the specified table. */
|
||||||
|
rpc addColumn(AddColumnRequest)
|
||||||
|
returns(AddColumnResponse);
|
||||||
|
|
||||||
|
/** Deletes a column from the specified table. Table must be disabled. */
|
||||||
|
rpc deleteColumn(DeleteColumnRequest)
|
||||||
|
returns(DeleteColumnResponse);
|
||||||
|
|
||||||
|
/** Modifies an existing column on the specified table. */
|
||||||
|
rpc modifyColumn(ModifyColumnRequest)
|
||||||
|
returns(ModifyColumnResponse);
|
||||||
|
|
||||||
/** Move the region region to the destination server. */
|
/** Move the region region to the destination server. */
|
||||||
rpc moveRegion(MoveRegionRequest)
|
rpc moveRegion(MoveRegionRequest)
|
||||||
returns(MoveRegionResponse);
|
returns(MoveRegionResponse);
|
||||||
@ -106,6 +207,35 @@ service MasterService {
|
|||||||
rpc unassignRegion(UnassignRegionRequest)
|
rpc unassignRegion(UnassignRegionRequest)
|
||||||
returns(UnassignRegionResponse);
|
returns(UnassignRegionResponse);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Offline a region from the assignment manager's in-memory state. The
|
||||||
|
* region should be in a closed state and there will be no attempt to
|
||||||
|
* automatically reassign the region as in unassign. This is a special
|
||||||
|
* method, and should only be used by experts or hbck.
|
||||||
|
*/
|
||||||
|
rpc offlineRegion(OfflineRegionRequest)
|
||||||
|
returns(OfflineRegionResponse);
|
||||||
|
|
||||||
|
/** Deletes a table */
|
||||||
|
rpc deleteTable(DeleteTableRequest)
|
||||||
|
returns(DeleteTableResponse);
|
||||||
|
|
||||||
|
/** Puts the table on-line (only needed if table has been previously taken offline) */
|
||||||
|
rpc enableTable(EnableTableRequest)
|
||||||
|
returns(EnableTableResponse);
|
||||||
|
|
||||||
|
/** Take table offline */
|
||||||
|
rpc disableTable(DisableTableRequest)
|
||||||
|
returns(DisableTableResponse);
|
||||||
|
|
||||||
|
/** Modify a table's metadata */
|
||||||
|
rpc modifyTable(ModifyTableRequest)
|
||||||
|
returns(ModifyTableResponse);
|
||||||
|
|
||||||
|
/** Creates a new table asynchronously */
|
||||||
|
rpc createTable(CreateTableRequest)
|
||||||
|
returns(CreateTableResponse);
|
||||||
|
|
||||||
/** return true if master is available */
|
/** return true if master is available */
|
||||||
rpc isMasterRunning(IsMasterRunningRequest)
|
rpc isMasterRunning(IsMasterRunningRequest)
|
||||||
returns(IsMasterRunningResponse);
|
returns(IsMasterRunningResponse);
|
||||||
@ -132,4 +262,12 @@ service MasterService {
|
|||||||
*/
|
*/
|
||||||
rpc setBalancerRunning(SetBalancerRunningRequest)
|
rpc setBalancerRunning(SetBalancerRunningRequest)
|
||||||
returns(SetBalancerRunningResponse);
|
returns(SetBalancerRunningResponse);
|
||||||
}
|
|
||||||
|
/** Used by the client to get the number of regions that have received the updated schema */
|
||||||
|
rpc getSchemaAlterStatus(GetSchemaAlterStatusRequest)
|
||||||
|
returns(GetSchemaAlterStatusResponse);
|
||||||
|
|
||||||
|
/** Get list of TableDescriptors for requested tables. */
|
||||||
|
rpc getTableDescriptors(GetTableDescriptorsRequest)
|
||||||
|
returns(GetTableDescriptorsResponse);
|
||||||
|
}
|
||||||
|
@ -196,7 +196,7 @@ public class TestHBaseFsck {
|
|||||||
HRegionInfo hri) throws IOException, InterruptedException {
|
HRegionInfo hri) throws IOException, InterruptedException {
|
||||||
try {
|
try {
|
||||||
HBaseFsckRepair.closeRegionSilentlyAndWait(admin, sn, hri);
|
HBaseFsckRepair.closeRegionSilentlyAndWait(admin, sn, hri);
|
||||||
admin.getMaster().offline(hri.getRegionName());
|
admin.offline(hri.getRegionName());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOG.warn("Got exception when attempting to offline region "
|
LOG.warn("Got exception when attempting to offline region "
|
||||||
+ Bytes.toString(hri.getRegionName()), ioe);
|
+ Bytes.toString(hri.getRegionName()), ioe);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user