HBASE-24431 RSGroupInfo add configuration map to store something extra (#1782)
Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Nick Dimiduk <ndimiduk@apache.org> Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
b556343292
commit
4b89ee24f3
|
@ -2428,4 +2428,12 @@ public interface Admin extends Abortable, Closeable {
|
||||||
*/
|
*/
|
||||||
void renameRSGroup(String oldName, String newName) throws IOException;
|
void renameRSGroup(String oldName, String newName) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update RSGroup configuration
|
||||||
|
* @param groupName the group name
|
||||||
|
* @param configuration new configuration of the group name to be set
|
||||||
|
* @throws IOException if a remote or network exception occurs
|
||||||
|
*/
|
||||||
|
void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1041,4 +1041,10 @@ class AdminOverAsyncAdmin implements Admin {
|
||||||
public void renameRSGroup(String oldName, String newName) throws IOException {
|
public void renameRSGroup(String oldName, String newName) throws IOException {
|
||||||
get(admin.renameRSGroup(oldName, newName));
|
get(admin.renameRSGroup(oldName, newName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRSGroupConfig(String groupName, Map<String, String> configuration)
|
||||||
|
throws IOException {
|
||||||
|
get(admin.updateRSGroupConfig(groupName, configuration));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1639,4 +1639,12 @@ public interface AsyncAdmin {
|
||||||
* @throws IOException if a remote or network exception occurs
|
* @throws IOException if a remote or network exception occurs
|
||||||
*/
|
*/
|
||||||
CompletableFuture<Void> renameRSGroup(String oldName, String newName);
|
CompletableFuture<Void> renameRSGroup(String oldName, String newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update RSGroup configuration
|
||||||
|
* @param groupName the group name
|
||||||
|
* @param configuration new configuration of the group name to be set
|
||||||
|
* @throws IOException if a remote or network exception occurs
|
||||||
|
*/
|
||||||
|
CompletableFuture<Void> updateRSGroupConfig(String groupName, Map<String, String> configuration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -918,4 +918,10 @@ class AsyncHBaseAdmin implements AsyncAdmin {
|
||||||
public CompletableFuture<Void> renameRSGroup(String oldName, String newName) {
|
public CompletableFuture<Void> renameRSGroup(String oldName, String newName) {
|
||||||
return wrap(rawAdmin.renameRSGroup(oldName, newName));
|
return wrap(rawAdmin.renameRSGroup(oldName, newName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void>
|
||||||
|
updateRSGroupConfig(String groupName, Map<String, String> configuration) {
|
||||||
|
return wrap(rawAdmin.updateRSGroupConfig(groupName, configuration));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.StopServerR
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationRequest;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateConfigurationResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameStringPair;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ProcedureDescription;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.TableSchema;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.TableSchema;
|
||||||
|
@ -311,6 +312,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.Remo
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigRequest;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerRequest;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.AddReplicationPeerResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos.DisableReplicationPeerRequest;
|
||||||
|
@ -4164,4 +4167,22 @@ class RawAsyncHBaseAdmin implements AsyncAdmin {
|
||||||
)
|
)
|
||||||
).call();
|
).call();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void>
|
||||||
|
updateRSGroupConfig(String groupName, Map<String, String> configuration) {
|
||||||
|
UpdateRSGroupConfigRequest.Builder request = UpdateRSGroupConfigRequest.newBuilder()
|
||||||
|
.setGroupName(groupName);
|
||||||
|
if (configuration != null) {
|
||||||
|
configuration.entrySet().forEach(e ->
|
||||||
|
request.addConfiguration(NameStringPair.newBuilder().setName(e.getKey())
|
||||||
|
.setValue(e.getValue()).build()));
|
||||||
|
}
|
||||||
|
return this.<Void> newMasterCaller()
|
||||||
|
.action(((controller, stub) ->
|
||||||
|
this.<UpdateRSGroupConfigRequest, UpdateRSGroupConfigResponse, Void> call(
|
||||||
|
controller, stub, request.build(),
|
||||||
|
(s, c, req, done) -> s.updateRSGroupConfig(c, req, done), resp -> null))
|
||||||
|
).call();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3514,14 +3514,16 @@ public final class ProtobufUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
|
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) {
|
||||||
RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName());
|
RSGroupInfo rsGroupInfo = new RSGroupInfo(proto.getName());
|
||||||
for (HBaseProtos.ServerName el : proto.getServersList()) {
|
for (HBaseProtos.ServerName el : proto.getServersList()) {
|
||||||
RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort()));
|
rsGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort()));
|
||||||
}
|
}
|
||||||
for (HBaseProtos.TableName pTableName : proto.getTablesList()) {
|
for (HBaseProtos.TableName pTableName : proto.getTablesList()) {
|
||||||
RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName));
|
rsGroupInfo.addTable(ProtobufUtil.toTableName(pTableName));
|
||||||
}
|
}
|
||||||
return RSGroupInfo;
|
proto.getConfigurationList().forEach(pair ->
|
||||||
|
rsGroupInfo.setConfiguration(pair.getName(), pair.getValue()));
|
||||||
|
return rsGroupInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
|
public static RSGroupProtos.RSGroupInfo toProtoGroupInfo(RSGroupInfo pojo) {
|
||||||
|
@ -3534,7 +3536,11 @@ public final class ProtobufUtil {
|
||||||
hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
|
hostports.add(HBaseProtos.ServerName.newBuilder().setHostName(el.getHostname())
|
||||||
.setPort(el.getPort()).build());
|
.setPort(el.getPort()).build());
|
||||||
}
|
}
|
||||||
|
List<NameStringPair> configuration = pojo.getConfiguration().entrySet()
|
||||||
|
.stream().map(entry -> NameStringPair.newBuilder()
|
||||||
|
.setName(entry.getKey()).setValue(entry.getValue()).build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
|
return RSGroupProtos.RSGroupInfo.newBuilder().setName(pojo.getName()).addAllServers(hostports)
|
||||||
.addAllTables(tables).build();
|
.addAllTables(tables).addAllConfiguration(configuration).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
package org.apache.hadoop.hbase.rsgroup;
|
package org.apache.hadoop.hbase.rsgroup;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
|
@ -46,6 +50,8 @@ public class RSGroupInfo {
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private final SortedSet<TableName> tables;
|
private final SortedSet<TableName> tables;
|
||||||
|
|
||||||
|
private final Map<String, String> configuration;
|
||||||
|
|
||||||
public RSGroupInfo(String name) {
|
public RSGroupInfo(String name) {
|
||||||
this(name, new TreeSet<Address>(), new TreeSet<TableName>());
|
this(name, new TreeSet<Address>(), new TreeSet<TableName>());
|
||||||
}
|
}
|
||||||
|
@ -54,6 +60,7 @@ public class RSGroupInfo {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.servers = servers == null ? new TreeSet<>() : new TreeSet<>(servers);
|
this.servers = servers == null ? new TreeSet<>() : new TreeSet<>(servers);
|
||||||
this.tables = new TreeSet<>();
|
this.tables = new TreeSet<>();
|
||||||
|
configuration = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +72,7 @@ public class RSGroupInfo {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.servers = (servers == null) ? new TreeSet<>() : new TreeSet<>(servers);
|
this.servers = (servers == null) ? new TreeSet<>() : new TreeSet<>(servers);
|
||||||
this.tables = (tables == null) ? new TreeSet<>() : new TreeSet<>(tables);
|
this.tables = (tables == null) ? new TreeSet<>() : new TreeSet<>(tables);
|
||||||
|
configuration = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RSGroupInfo(RSGroupInfo src) {
|
public RSGroupInfo(RSGroupInfo src) {
|
||||||
|
@ -114,6 +122,30 @@ public class RSGroupInfo {
|
||||||
return servers.remove(hostPort);
|
return servers.remove(hostPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for fetching an unmodifiable {@link #configuration} map.
|
||||||
|
*/
|
||||||
|
public Map<String, String> getConfiguration() {
|
||||||
|
// shallow pointer copy
|
||||||
|
return Collections.unmodifiableMap(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for storing a configuration setting in {@link #configuration} map.
|
||||||
|
* @param key Config key.
|
||||||
|
* @param value String value.
|
||||||
|
*/
|
||||||
|
public void setConfiguration(String key, String value) {
|
||||||
|
configuration.put(key, Objects.requireNonNull(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a config setting represented by the key from the {@link #configuration} map
|
||||||
|
*/
|
||||||
|
public void removeConfiguration(final String key) {
|
||||||
|
configuration.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get set of tables that are members of the group.
|
* Get set of tables that are members of the group.
|
||||||
* @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information will be stored in
|
* @deprecated Since 3.0.0, will be removed in 4.0.0. The rsgroup information will be stored in
|
||||||
|
|
|
@ -1117,6 +1117,9 @@ service MasterService {
|
||||||
|
|
||||||
rpc RenameRSGroup(RenameRSGroupRequest)
|
rpc RenameRSGroup(RenameRSGroupRequest)
|
||||||
returns (RenameRSGroupResponse);
|
returns (RenameRSGroupResponse);
|
||||||
|
|
||||||
|
rpc UpdateRSGroupConfig(UpdateRSGroupConfigRequest)
|
||||||
|
returns (UpdateRSGroupConfigResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HBCK Service definitions.
|
// HBCK Service definitions.
|
||||||
|
|
|
@ -30,4 +30,5 @@ message RSGroupInfo {
|
||||||
required string name = 1;
|
required string name = 1;
|
||||||
repeated ServerName servers = 4;
|
repeated ServerName servers = 4;
|
||||||
repeated TableName tables = 3;
|
repeated TableName tables = 3;
|
||||||
|
repeated NameStringPair configuration = 5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,14 @@ message RenameRSGroupRequest {
|
||||||
message RenameRSGroupResponse {
|
message RenameRSGroupResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UpdateRSGroupConfigRequest {
|
||||||
|
required string group_name = 1;
|
||||||
|
repeated NameStringPair configuration = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UpdateRSGroupConfigResponse {
|
||||||
|
}
|
||||||
|
|
||||||
service RSGroupAdminService {
|
service RSGroupAdminService {
|
||||||
rpc GetRSGroupInfo(GetRSGroupInfoRequest)
|
rpc GetRSGroupInfo(GetRSGroupInfoRequest)
|
||||||
returns (GetRSGroupInfoResponse);
|
returns (GetRSGroupInfoResponse);
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.coprocessor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.hadoop.hbase.ClusterMetrics;
|
import org.apache.hadoop.hbase.ClusterMetrics;
|
||||||
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
||||||
|
@ -1358,6 +1359,26 @@ public interface MasterObserver {
|
||||||
default void postRenameRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
default void postRenameRSGroup(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||||
final String oldName, final String newName) throws IOException {}
|
final String oldName, final String newName) throws IOException {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before update rsgroup config.
|
||||||
|
* @param ctx the environment to interact with the framework and master
|
||||||
|
* @param groupName the group name
|
||||||
|
* @param configuration new configuration of the group name to be set
|
||||||
|
*/
|
||||||
|
default void preUpdateRSGroupConfig(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||||
|
final String groupName, final Map<String, String> configuration)
|
||||||
|
throws IOException {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after update rsgroup config.
|
||||||
|
* @param ctx the environment to interact with the framework and master
|
||||||
|
* @param groupName the group name
|
||||||
|
* @param configuration new configuration of the group name to be set
|
||||||
|
*/
|
||||||
|
default void postUpdateRSGroupConfig(final ObserverContext<MasterCoprocessorEnvironment> ctx,
|
||||||
|
final String groupName, final Map<String, String> configuration)
|
||||||
|
throws IOException {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before getting the configured namespaces and tables in the region server group.
|
* Called before getting the configured namespaces and tables in the region server group.
|
||||||
* @param ctx the environment to interact with the framework and master
|
* @param ctx the environment to interact with the framework and master
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.master;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.ClusterMetrics;
|
import org.apache.hadoop.hbase.ClusterMetrics;
|
||||||
|
@ -1562,6 +1563,26 @@ public class MasterCoprocessorHost
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void preUpdateRSGroupConfig(final String groupName,
|
||||||
|
final Map<String, String> configuration) throws IOException {
|
||||||
|
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||||
|
@Override
|
||||||
|
protected void call(MasterObserver observer) throws IOException {
|
||||||
|
observer.preUpdateRSGroupConfig(this, groupName, configuration);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postUpdateRSGroupConfig(final String groupName,
|
||||||
|
final Map<String, String> configuration) throws IOException {
|
||||||
|
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||||
|
@Override
|
||||||
|
protected void call(MasterObserver observer) throws IOException {
|
||||||
|
observer.postUpdateRSGroupConfig(this, groupName, configuration);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void preGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
|
public void preGetConfiguredNamespacesAndTablesInRSGroup(final String groupName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
|
||||||
|
|
|
@ -345,6 +345,8 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.Remo
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RemoveServersResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupRequest;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.RenameRSGroupResponse;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigRequest;
|
||||||
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RSGroupAdminProtos.UpdateRSGroupConfigResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.FileArchiveNotificationRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.FileArchiveNotificationRequest;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.FileArchiveNotificationResponse;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.FileArchiveNotificationResponse;
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.GetLastFlushedSequenceIdRequest;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.GetLastFlushedSequenceIdRequest;
|
||||||
|
@ -3248,4 +3250,28 @@ public class MasterRpcServices extends RSRpcServices implements
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpdateRSGroupConfigResponse updateRSGroupConfig(RpcController controller,
|
||||||
|
UpdateRSGroupConfigRequest request)
|
||||||
|
throws ServiceException {
|
||||||
|
UpdateRSGroupConfigResponse.Builder builder = UpdateRSGroupConfigResponse.newBuilder();
|
||||||
|
String groupName = request.getGroupName();
|
||||||
|
Map<String, String> configuration = new HashMap<>();
|
||||||
|
request.getConfigurationList().forEach(p -> configuration.put(p.getName(), p.getValue()));
|
||||||
|
LOG.info("{} update rsgroup {} configuration {}", master.getClientIdAuditPrefix(), groupName,
|
||||||
|
configuration);
|
||||||
|
try {
|
||||||
|
if (master.getMasterCoprocessorHost() != null) {
|
||||||
|
master.getMasterCoprocessorHost().preUpdateRSGroupConfig(groupName, configuration);
|
||||||
|
}
|
||||||
|
master.getRSGroupInfoManager().updateRSGroupConfig(groupName, configuration);
|
||||||
|
if (master.getMasterCoprocessorHost() != null) {
|
||||||
|
master.getMasterCoprocessorHost().postUpdateRSGroupConfig(groupName, configuration);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ServiceException(e);
|
||||||
|
}
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.rsgroup;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
@ -125,4 +126,9 @@ class DisabledRSGroupInfoManager implements RSGroupInfoManager {
|
||||||
public void renameRSGroup(String oldName, String newName) throws IOException {
|
public void renameRSGroup(String oldName, String newName) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRSGroupConfig(String groupName, Map<String, String> configuration)
|
||||||
|
throws IOException {
|
||||||
|
throw new DoNotRetryIOException("RSGroup is disabled");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.rsgroup;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.master.MasterServices;
|
import org.apache.hadoop.hbase.master.MasterServices;
|
||||||
|
@ -114,4 +115,12 @@ public interface RSGroupInfoManager {
|
||||||
*/
|
*/
|
||||||
void renameRSGroup(String oldName, String newName) throws IOException;
|
void renameRSGroup(String oldName, String newName) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update RSGroup configuration
|
||||||
|
* @param groupName the group name
|
||||||
|
* @param configuration new configuration of the group name to be set
|
||||||
|
* @throws IOException if a remote or network exception occurs
|
||||||
|
*/
|
||||||
|
void updateRSGroupConfig(String groupName, Map<String, String> configuration) throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1244,4 +1244,12 @@ final class RSGroupInfoManagerImpl implements RSGroupInfoManager {
|
||||||
setRSGroup(updateTables, newName);
|
setRSGroup(updateTables, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void updateRSGroupConfig(String groupName, Map<String, String> configuration)
|
||||||
|
throws IOException {
|
||||||
|
RSGroupInfo rsGroupInfo = getRSGroupInfo(groupName);
|
||||||
|
rsGroupInfo.getConfiguration().forEach((k, v) -> rsGroupInfo.removeConfiguration(k));
|
||||||
|
configuration.forEach((k, v) -> rsGroupInfo.setConfiguration(k, v));
|
||||||
|
flushConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.hadoop.hbase.rsgroup;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
|
import org.apache.hadoop.hbase.testclassification.RSGroupTests;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.ClassRule;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.junit.rules.TestName;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import org.apache.hbase.thirdparty.com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
@Category({ RSGroupTests.class, MediumTests.class })
|
||||||
|
public class TestRSGroupConfig extends TestRSGroupsBase {
|
||||||
|
|
||||||
|
@ClassRule
|
||||||
|
public static final HBaseClassTestRule CLASS_RULE =
|
||||||
|
HBaseClassTestRule.forClass(TestRSGroupConfig.class);
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TestName name = new TestName();
|
||||||
|
|
||||||
|
protected static final Logger LOG = LoggerFactory.getLogger(TestRSGroupConfig.class);
|
||||||
|
|
||||||
|
private static Admin admin;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
TestRSGroupsBase.setUpTestBeforeClass();
|
||||||
|
admin = TEST_UTIL.getAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDownAfterClass() throws Exception {
|
||||||
|
TestRSGroupsBase.tearDownAfterClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetDefaultGroupConfiguration() throws IOException {
|
||||||
|
testSetConfiguration(RSGroupInfo.DEFAULT_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSetNonDefaultGroupConfiguration() throws IOException {
|
||||||
|
String group = GROUP_PREFIX + name.getMethodName();
|
||||||
|
admin.addRSGroup(group);
|
||||||
|
testSetConfiguration(RSGroupInfo.DEFAULT_GROUP);
|
||||||
|
admin.removeRSGroup(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testSetConfiguration(String group) throws IOException {
|
||||||
|
Map<String, String> configuration = new HashMap<>();
|
||||||
|
configuration.put("aaa", "111");
|
||||||
|
configuration.put("bbb", "222");
|
||||||
|
admin.updateRSGroupConfig(group, configuration);
|
||||||
|
RSGroupInfo rsGroup = admin.getRSGroup(group);
|
||||||
|
Map<String, String> configFromGroup = Maps.newHashMap(rsGroup.getConfiguration());
|
||||||
|
assertNotNull(configFromGroup);
|
||||||
|
assertEquals(2, configFromGroup.size());
|
||||||
|
assertEquals("111", configFromGroup.get("aaa"));
|
||||||
|
// unset configuration
|
||||||
|
admin.updateRSGroupConfig(group, null);
|
||||||
|
rsGroup = admin.getRSGroup(group);
|
||||||
|
configFromGroup = rsGroup.getConfiguration();
|
||||||
|
assertNotNull(configFromGroup);
|
||||||
|
assertEquals(0, configFromGroup.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -822,6 +822,13 @@ public class VerifyingRSGroupAdmin implements Admin, Closeable {
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRSGroupConfig(String groupName, Map<String, String> configuration)
|
||||||
|
throws IOException {
|
||||||
|
admin.updateRSGroupConfig(groupName, configuration);
|
||||||
|
verify();
|
||||||
|
}
|
||||||
|
|
||||||
private void verify() throws IOException {
|
private void verify() throws IOException {
|
||||||
Map<String, RSGroupInfo> groupMap = Maps.newHashMap();
|
Map<String, RSGroupInfo> groupMap = Maps.newHashMap();
|
||||||
Set<RSGroupInfo> zList = Sets.newHashSet();
|
Set<RSGroupInfo> zList = Sets.newHashSet();
|
||||||
|
|
|
@ -191,5 +191,42 @@ module Hbase
|
||||||
def rename_rsgroup(oldname, newname)
|
def rename_rsgroup(oldname, newname)
|
||||||
@admin.renameRSGroup(oldname, newname)
|
@admin.renameRSGroup(oldname, newname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------------------------
|
||||||
|
# modify a rsgroup configuration
|
||||||
|
def alter_rsgroup_config(rsgroup_name, *args)
|
||||||
|
# Fail if table name is not a string
|
||||||
|
raise(ArgumentError, 'RSGroup name must be of type String') unless rsgroup_name.is_a?(String)
|
||||||
|
|
||||||
|
group = @admin.getRSGroup(rsgroup_name)
|
||||||
|
|
||||||
|
raise(ArgumentError, 'RSGroup does not exist') unless group
|
||||||
|
|
||||||
|
configuration = java.util.HashMap.new
|
||||||
|
configuration.putAll(group.getConfiguration)
|
||||||
|
|
||||||
|
# Flatten params array
|
||||||
|
args = args.flatten.compact
|
||||||
|
|
||||||
|
# Start defining the table
|
||||||
|
args.each do |arg|
|
||||||
|
unless arg.is_a?(Hash)
|
||||||
|
raise(ArgumentError, "#{arg.class} of #{arg.inspect} is not of Hash type")
|
||||||
|
end
|
||||||
|
method = arg[METHOD]
|
||||||
|
if method == 'unset'
|
||||||
|
configuration.remove(arg[NAME])
|
||||||
|
elsif method == 'set'
|
||||||
|
arg.delete(METHOD)
|
||||||
|
for k, v in arg
|
||||||
|
v = v.to_s unless v.nil?
|
||||||
|
configuration.put(k, v)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise(ArgumentError, "Unknown method #{method}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@admin.updateRSGroupConfig(rsgroup_name, configuration)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -509,5 +509,7 @@ Shell.load_command_group(
|
||||||
get_table_rsgroup
|
get_table_rsgroup
|
||||||
remove_servers_rsgroup
|
remove_servers_rsgroup
|
||||||
rename_rsgroup
|
rename_rsgroup
|
||||||
|
alter_rsgroup_config
|
||||||
|
show_rsgroup_config
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
module Shell
|
||||||
|
module Commands
|
||||||
|
class AlterRsgroupConfig < Command
|
||||||
|
def help
|
||||||
|
<<-EOF
|
||||||
|
Alter RSGroup configuration.
|
||||||
|
Example:
|
||||||
|
hbase> alter_rsgroup_config 'grp1', {METHOD => 'set', 'PROPERTY_NAME' => 'PROPERTY_VALUE'}
|
||||||
|
To delete a property:
|
||||||
|
hbase> alter_rsgroup_config 'grp1', {METHOD => 'unset', NAME=>'PROPERTY_NAME'}
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
|
||||||
|
def command(group, args)
|
||||||
|
rsgroup_admin.alter_rsgroup_config(group, args)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,43 @@
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you under the Apache License, Version 2.0 (the
|
||||||
|
# "License"); you may not use this file except in compliance
|
||||||
|
# with the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
module Shell
|
||||||
|
module Commands
|
||||||
|
class ShowRsgroupConfig < Command
|
||||||
|
def help
|
||||||
|
<<-EOF
|
||||||
|
Show the configuration of a special RSGroup.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
hbase> show_rsgroup_config 'group'
|
||||||
|
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
|
||||||
|
def command(group)
|
||||||
|
formatter.header(%w['KEY' 'VALUE'])
|
||||||
|
config = rsgroup_admin.get_rsgroup(group).getConfiguration
|
||||||
|
config.each { |key, val|
|
||||||
|
formatter.row([key, val])
|
||||||
|
}
|
||||||
|
formatter.footer(config.size)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -140,5 +140,19 @@ module Hbase
|
||||||
assert_equal(1, @admin.listTablesInRSGroup(new_rs_group_name).count)
|
assert_equal(1, @admin.listTablesInRSGroup(new_rs_group_name).count)
|
||||||
assert_true(@admin.listTablesInRSGroup(new_rs_group_name).contains(org.apache.hadoop.hbase.TableName.valueOf(table_name)))
|
assert_true(@admin.listTablesInRSGroup(new_rs_group_name).contains(org.apache.hadoop.hbase.TableName.valueOf(table_name)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
define_test 'Test alter rsgroup configuration' do
|
||||||
|
group_name = 'grp1'
|
||||||
|
@shell.command('add_rsgroup', group_name)
|
||||||
|
assert_not_nil(@admin.getRSGroup(group_name))
|
||||||
|
|
||||||
|
@hbase.rsgroup_admin.alter_rsgroup_config(group_name, {'METHOD' => 'set', 'a' => 'a'})
|
||||||
|
assert_equal(1, @admin.getRSGroup(group_name).getConfiguration.size)
|
||||||
|
@hbase.rsgroup_admin.alter_rsgroup_config(group_name, {'METHOD' => 'unset', 'NAME' => 'a'})
|
||||||
|
assert_equal(0, @admin.getRSGroup(group_name).getConfiguration.size)
|
||||||
|
|
||||||
|
@shell.command('remove_rsgroup', group_name)
|
||||||
|
assert_nil(@admin.getRSGroup(group_name))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1261,4 +1261,10 @@ public class ThriftAdmin implements Admin {
|
||||||
public void renameRSGroup(String oldName, String newName) throws IOException {
|
public void renameRSGroup(String oldName, String newName) throws IOException {
|
||||||
throw new NotImplementedException("renameRSGroup not supported in ThriftAdmin");
|
throw new NotImplementedException("renameRSGroup not supported in ThriftAdmin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRSGroupConfig(String groupName, Map<String, String> configuration)
|
||||||
|
throws IOException {
|
||||||
|
throw new NotImplementedException("updateRSGroupConfig not supported in ThriftAdmin");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue