@Override public synchronized void removeServers(Set<Address> servers) throws IOException { Map<String, RSGroupInfo> rsGroupInfos = new HashMap<String, RSGroupInfo>(); for (Address el : servers) { RSGroupInfo rsGroupInfo = getRSGroupOfServer(el); if (rsGroupInfo != null) { RSGroupInfo newRsGroupInfo = rsGroupInfos.get(rsGroupInfo.getName()); if (newRsGroupInfo == null) { rsGroupInfo.removeServer(el); rsGroupInfos.put(rsGroupInfo.getName(), rsGroupInfo); } else { newRsGroupInfo.removeServer(el); rsGroupInfos.put(newRsGroupInfo.getName(), newRsGroupInfo); } } else { LOG.warn("Server " + el + " does not belong to any rsgroup."); } } if (rsGroupInfos.size() > 0) { Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.putAll(rsGroupInfos); flushConfig(newGroupMap); } }
@Override public synchronized Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException { RSGroupInfo src = getRSGroupInfo(srcGroup); RSGroupInfo dst = getRSGroupInfo(dstGroup); // If destination is 'default' rsgroup, only add servers that are online. If not online, drop // it. If not 'default' group, add server to 'dst' rsgroup EVEN IF IT IS NOT online (could be a // rsgroup of dead servers that are to come back later). Set<Address> onlineServers = dst.getName().equals(RSGroupInfo.DEFAULT_GROUP) ? getOnlineServers(this.masterServices) : null; for (Address el : servers) { src.removeServer(el); if (onlineServers != null) { if (!onlineServers.contains(el)) { if (LOG.isDebugEnabled()) { LOG.debug("Dropping " + el + " during move-to-default rsgroup because not online"); } continue; } } dst.addServer(el); } Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(src.getName(), src); newGroupMap.put(dst.getName(), dst); flushConfig(newGroupMap); return dst.getServers(); }
@Override public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException { // get server's group RSGroupInfo srcGroupInfo = getRSGroupInfo(srcGroup); RSGroupInfo dstGroupInfo = getRSGroupInfo(dstGroup); // move servers for (Address el : servers) { srcGroupInfo.removeServer(el); dstGroupInfo.addServer(el); } // move tables for (TableName tableName : tables) { srcGroupInfo.removeTable(tableName); dstGroupInfo.addTable(tableName); } // flush changed groupinfo Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(srcGroupInfo.getName(), srcGroupInfo); newGroupMap.put(dstGroupInfo.getName(), dstGroupInfo); flushConfig(newGroupMap); }
@Override public synchronized void removeServers(Set<Address> servers) throws IOException { Map<String, RSGroupInfo> rsGroupInfos = new HashMap<String, RSGroupInfo>(); for (Address el: servers) { RSGroupInfo rsGroupInfo = getRSGroupOfServer(el); if (rsGroupInfo != null) { RSGroupInfo newRsGroupInfo = rsGroupInfos.get(rsGroupInfo.getName()); if (newRsGroupInfo == null) { rsGroupInfo.removeServer(el); rsGroupInfos.put(rsGroupInfo.getName(), rsGroupInfo); } else { newRsGroupInfo.removeServer(el); rsGroupInfos.put(newRsGroupInfo.getName(), newRsGroupInfo); } }else { LOG.warn("Server " + el + " does not belong to any rsgroup."); } } if (rsGroupInfos.size() > 0) { Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.putAll(rsGroupInfos); flushConfig(newGroupMap); } }
@Override public synchronized void removeServers(Set<Address> servers) throws IOException { Map<String, RSGroupInfo> rsGroupInfos = new HashMap<String, RSGroupInfo>(); for (Address el: servers) { RSGroupInfo rsGroupInfo = getRSGroupOfServer(el); if (rsGroupInfo != null) { RSGroupInfo newRsGroupInfo = rsGroupInfos.get(rsGroupInfo.getName()); if (newRsGroupInfo == null) { rsGroupInfo.removeServer(el); rsGroupInfos.put(rsGroupInfo.getName(), rsGroupInfo); } else { newRsGroupInfo.removeServer(el); rsGroupInfos.put(newRsGroupInfo.getName(), newRsGroupInfo); } }else { LOG.warn("Server " + el + " does not belong to any rsgroup."); } } if (rsGroupInfos.size() > 0) { Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.putAll(rsGroupInfos); flushConfig(newGroupMap); } }
@Override public synchronized Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException { RSGroupInfo src = getRSGroupInfo(srcGroup); RSGroupInfo dst = getRSGroupInfo(dstGroup); // If destination is 'default' rsgroup, only add servers that are online. If not online, drop // it. If not 'default' group, add server to 'dst' rsgroup EVEN IF IT IS NOT online (could be a // rsgroup of dead servers that are to come back later). Set<Address> onlineServers = dst.getName().equals(RSGroupInfo.DEFAULT_GROUP)? Utility.getOnlineServers(this.masterServices): null; for (Address el: servers) { src.removeServer(el); if (onlineServers != null) { if (!onlineServers.contains(el)) { if (LOG.isDebugEnabled()) { LOG.debug("Dropping " + el + " during move-to-default rsgroup because not online"); } continue; } } dst.addServer(el); } Map<String,RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(src.getName(), src); newGroupMap.put(dst.getName(), dst); flushConfig(newGroupMap); return dst.getServers(); }
@Override public synchronized Set<Address> moveServers(Set<Address> servers, String srcGroup, String dstGroup) throws IOException { RSGroupInfo src = getRSGroupInfo(srcGroup); RSGroupInfo dst = getRSGroupInfo(dstGroup); // If destination is 'default' rsgroup, only add servers that are online. If not online, drop // it. If not 'default' group, add server to 'dst' rsgroup EVEN IF IT IS NOT online (could be a // rsgroup of dead servers that are to come back later). Set<Address> onlineServers = dst.getName().equals(RSGroupInfo.DEFAULT_GROUP)? Utility.getOnlineServers(this.masterServices): null; for (Address el: servers) { src.removeServer(el); if (onlineServers != null) { if (!onlineServers.contains(el)) { if (LOG.isDebugEnabled()) { LOG.debug("Dropping " + el + " during move-to-default rsgroup because not online"); } continue; } } dst.addServer(el); } Map<String,RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(src.getName(), src); newGroupMap.put(dst.getName(), dst); flushConfig(newGroupMap); return dst.getServers(); }
@Override public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException { //get server's group RSGroupInfo srcGroupInfo = getRSGroupInfo(srcGroup); RSGroupInfo dstGroupInfo = getRSGroupInfo(dstGroup); //move servers for (Address el: servers) { srcGroupInfo.removeServer(el); dstGroupInfo.addServer(el); } //move tables for(TableName tableName: tables) { srcGroupInfo.removeTable(tableName); dstGroupInfo.addTable(tableName); } //flush changed groupinfo Map<String,RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(srcGroupInfo.getName(), srcGroupInfo); newGroupMap.put(dstGroupInfo.getName(), dstGroupInfo); flushConfig(newGroupMap); }
@Override public void moveServersAndTables(Set<Address> servers, Set<TableName> tables, String srcGroup, String dstGroup) throws IOException { //get server's group RSGroupInfo srcGroupInfo = getRSGroupInfo(srcGroup); RSGroupInfo dstGroupInfo = getRSGroupInfo(dstGroup); //move servers for (Address el: servers) { srcGroupInfo.removeServer(el); dstGroupInfo.addServer(el); } //move tables for(TableName tableName: tables) { srcGroupInfo.removeTable(tableName); dstGroupInfo.addTable(tableName); } //flush changed groupinfo Map<String,RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap); newGroupMap.put(srcGroupInfo.getName(), srcGroupInfo); newGroupMap.put(dstGroupInfo.getName(), dstGroupInfo); flushConfig(newGroupMap); }