Skip to content

Commit 4a22c74

Browse files
committed
Revert "HBASE-22820 Do not need to persist default rs group now (#482)"
This reverts commit 97ec5d5.
1 parent 64581fa commit 4a22c74

2 files changed

Lines changed: 16 additions & 49 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,11 @@ private void flushConfigTable(Map<String, RSGroupInfo> groupMap) throws IOExcept
396396
}
397397

398398
// populate puts
399-
for (RSGroupInfo gi : groupMap.values()) {
400-
if (!gi.getName().equals(RSGroupInfo.DEFAULT_GROUP)) {
401-
RSGroupProtos.RSGroupInfo proto = ProtobufUtil.toProtoGroupInfo(gi);
402-
Put p = new Put(Bytes.toBytes(gi.getName()));
403-
p.addColumn(META_FAMILY_BYTES, META_QUALIFIER_BYTES, proto.toByteArray());
404-
mutations.add(p);
405-
}
399+
for (RSGroupInfo RSGroupInfo : groupMap.values()) {
400+
RSGroupProtos.RSGroupInfo proto = ProtobufUtil.toProtoGroupInfo(RSGroupInfo);
401+
Put p = new Put(Bytes.toBytes(RSGroupInfo.getName()));
402+
p.addColumn(META_FAMILY_BYTES, META_QUALIFIER_BYTES, proto.toByteArray());
403+
mutations.add(p);
406404
}
407405

408406
if (mutations.size() > 0) {
@@ -451,12 +449,7 @@ private synchronized void flushConfig(Map<String, RSGroupInfo> newGroupMap) thro
451449

452450
// Make changes visible after having been persisted to the source of truth
453451
resetRSGroupMap(newGroupMap);
454-
saveRSGroupMapToZK(newGroupMap);
455452

456-
updateCacheOfRSGroups(newGroupMap.keySet());
457-
}
458-
459-
private void saveRSGroupMapToZK(Map<String, RSGroupInfo> newGroupMap) throws IOException {
460453
try {
461454
String groupBasePath =
462455
ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, RS_GROUP_ZNODE);
@@ -470,16 +463,14 @@ private void saveRSGroupMapToZK(Map<String, RSGroupInfo> newGroupMap) throws IOE
470463
}
471464
}
472465

473-
for (RSGroupInfo gi : newGroupMap.values()) {
474-
if (!gi.getName().equals(RSGroupInfo.DEFAULT_GROUP)) {
475-
String znode = ZNodePaths.joinZNode(groupBasePath, gi.getName());
476-
RSGroupProtos.RSGroupInfo proto = ProtobufUtil.toProtoGroupInfo(gi);
477-
LOG.debug("Updating znode: " + znode);
478-
ZKUtil.createAndFailSilent(watcher, znode);
479-
zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode));
480-
zkOps.add(ZKUtil.ZKUtilOp.createAndFailSilent(znode,
481-
ProtobufUtil.prependPBMagic(proto.toByteArray())));
482-
}
466+
for (RSGroupInfo RSGroupInfo : newGroupMap.values()) {
467+
String znode = ZNodePaths.joinZNode(groupBasePath, RSGroupInfo.getName());
468+
RSGroupProtos.RSGroupInfo proto = ProtobufUtil.toProtoGroupInfo(RSGroupInfo);
469+
LOG.debug("Updating znode: " + znode);
470+
ZKUtil.createAndFailSilent(watcher, znode);
471+
zkOps.add(ZKUtil.ZKUtilOp.deleteNodeFailSilent(znode));
472+
zkOps.add(ZKUtil.ZKUtilOp.createAndFailSilent(znode,
473+
ProtobufUtil.prependPBMagic(proto.toByteArray())));
483474
}
484475
LOG.debug("Writing ZK GroupInfo count: " + zkOps.size());
485476

@@ -489,6 +480,7 @@ private void saveRSGroupMapToZK(Map<String, RSGroupInfo> newGroupMap) throws IOE
489480
masterServices.abort("Failed to write to rsGroupZNode", e);
490481
throw new IOException("Failed to write to rsGroupZNode", e);
491482
}
483+
updateCacheOfRSGroups(newGroupMap.keySet());
492484
}
493485

494486
/**
@@ -548,12 +540,12 @@ private SortedSet<Address> getDefaultServers() throws IOException {
548540

549541
// Called by ServerEventsListenerThread. Synchronize on this because redoing
550542
// the rsGroupMap then writing it out.
551-
private synchronized void updateDefaultServers(SortedSet<Address> servers) {
543+
private synchronized void updateDefaultServers(SortedSet<Address> servers) throws IOException {
552544
RSGroupInfo info = rsGroupMap.get(RSGroupInfo.DEFAULT_GROUP);
553545
RSGroupInfo newInfo = new RSGroupInfo(info.getName(), servers);
554546
HashMap<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
555547
newGroupMap.put(newInfo.getName(), newInfo);
556-
resetRSGroupMap(newGroupMap);
548+
flushConfig(newGroupMap);
557549
}
558550

559551
/**

hbase-server/src/test/java/org/apache/hadoop/hbase/rsgroup/VerifyingRSGroupAdminClient.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.Set;
29-
import java.util.SortedSet;
30-
import java.util.regex.Pattern;
3129
import org.apache.hadoop.conf.Configuration;
3230
import org.apache.hadoop.hbase.NamespaceDescriptor;
33-
import org.apache.hadoop.hbase.ServerName;
3431
import org.apache.hadoop.hbase.TableName;
3532
import org.apache.hadoop.hbase.client.Admin;
3633
import org.apache.hadoop.hbase.client.Connection;
@@ -136,13 +133,6 @@ public void verify() throws IOException {
136133
tds.addAll(admin.listTableDescriptors());
137134
tds.addAll(admin.listTableDescriptorsByNamespace(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME));
138135
}
139-
SortedSet<Address> lives = Sets.newTreeSet();
140-
for (ServerName sn : conn.getAdmin().getClusterMetrics().getLiveServerMetrics().keySet()) {
141-
lives.add(sn.getAddress());
142-
}
143-
for (ServerName sn : conn.getAdmin().listDecommissionedRegionServers()) {
144-
lives.remove(sn.getAddress());
145-
}
146136
try (Table table = conn.getTable(RSGroupInfoManagerImpl.RSGROUP_TABLE_NAME);
147137
ResultScanner scanner = table.getScanner(new Scan())) {
148138
for (;;) {
@@ -154,22 +144,8 @@ public void verify() throws IOException {
154144
RSGroupInfoManagerImpl.META_FAMILY_BYTES, RSGroupInfoManagerImpl.META_QUALIFIER_BYTES));
155145
RSGroupInfo rsGroupInfo = ProtobufUtil.toGroupInfo(proto);
156146
groupMap.put(proto.getName(), RSGroupUtil.fillTables(rsGroupInfo, tds));
157-
for(Address address : rsGroupInfo.getServers()){
158-
lives.remove(address);
159-
}
160147
}
161148
}
162-
SortedSet<TableName> tables = Sets.newTreeSet();
163-
for (TableDescriptor td : conn.getAdmin().listTableDescriptors(Pattern.compile(".*"),
164-
true)){
165-
String groupName = td.getRegionServerGroup().orElse(RSGroupInfo.DEFAULT_GROUP);
166-
if (groupName.equals(RSGroupInfo.DEFAULT_GROUP)) {
167-
tables.add(td.getTableName());
168-
}
169-
}
170-
171-
groupMap.put(RSGroupInfo.DEFAULT_GROUP,
172-
new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, lives, tables));
173149
assertEquals(Sets.newHashSet(groupMap.values()), Sets.newHashSet(wrapped.listRSGroups()));
174150
try {
175151
String groupBasePath = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "rsgroup");
@@ -184,7 +160,6 @@ public void verify() throws IOException {
184160
zList.add(RSGroupUtil.fillTables(rsGroupInfo, tds));
185161
}
186162
}
187-
groupMap.remove(RSGroupInfo.DEFAULT_GROUP);
188163
assertEquals(zList.size(), groupMap.size());
189164
for (RSGroupInfo rsGroupInfo : zList) {
190165
assertTrue(groupMap.get(rsGroupInfo.getName()).equals(rsGroupInfo));

0 commit comments

Comments
 (0)