Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,14 @@ public void renameRSGroup(String oldName, String newName) throws IOException {
if (oldName.equals(RSGroupInfo.DEFAULT_GROUP)) {
throw new ConstraintException("Can't rename default rsgroup");
}
RSGroupInfo oldGroup = getRSGroup(oldName);
if (oldGroup == null) {
throw new ConstraintException("RSGroup " + oldName + " does not exist");
}
if (rsGroupMap.containsKey(newName)) {
throw new ConstraintException("Group already exists: " + newName);
}

RSGroupInfo oldGroup = getRSGroup(oldName);
Map<String,RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
newGroupMap.remove(oldName);
RSGroupInfo newGroup = new RSGroupInfo(newName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,14 @@ public void testRenameRSGroupConstraints() throws Exception {
assertNotNull(anotherGroup);
assertEquals(1, anotherGroup.getServers().size());

//Rename a non existing RSGroup
try {
rsGroupAdmin.renameRSGroup("nonExistingRSGroup", "newRSGroup1");
fail("ConstraintException was expected.");
} catch (ConstraintException e) {
assertTrue(e.getMessage().contains("does not exist"));
}

//Rename to existing group
try {
rsGroupAdmin.renameRSGroup(oldGroup.getName(), anotherRSGroupName);
Expand Down