@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(); }
/** * Construct group info, with each group having at least one server. * * @param servers the servers * @param groups the groups * @return the map */ protected static Map<String, RSGroupInfo> constructGroupInfo( List<ServerName> servers, String[] groups) { assertTrue(servers != null); assertTrue(servers.size() >= groups.length); int index = 0; Map<String, RSGroupInfo> groupMap = new HashMap<>(); for (String grpName : groups) { RSGroupInfo RSGroupInfo = new RSGroupInfo(grpName); RSGroupInfo.addServer(servers.get(index).getAddress()); groupMap.put(grpName, RSGroupInfo); index++; } while (index < servers.size()) { int grpIndex = rand.nextInt(groups.length); groupMap.get(groups[grpIndex]).addServer( servers.get(index).getAddress()); index++; } return groupMap; }
@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); }
static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(HBaseProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(HBaseProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(TableProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }
@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(); }
/** * Construct group info, with each group having at least one server. * * @param servers the servers * @param groups the groups * @return the map */ private static Map<String, RSGroupInfo> constructGroupInfo( List<ServerName> servers, String[] groups) { assertTrue(servers != null); assertTrue(servers.size() >= groups.length); int index = 0; Map<String, RSGroupInfo> groupMap = new HashMap<>(); for (String grpName : groups) { RSGroupInfo RSGroupInfo = new RSGroupInfo(grpName); RSGroupInfo.addServer(servers.get(index).getAddress()); groupMap.put(grpName, RSGroupInfo); index++; } while (index < servers.size()) { int grpIndex = rand.nextInt(groups.length); groupMap.get(groups[grpIndex]).addServer( servers.get(index).getAddress()); index++; } return groupMap; }
@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); }
public static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(TableProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }
static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(TableProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }
static RSGroupInfo toGroupInfo(RSGroupProtos.RSGroupInfo proto) { RSGroupInfo RSGroupInfo = new RSGroupInfo(proto.getName()); for(HBaseProtos.ServerName el: proto.getServersList()) { RSGroupInfo.addServer(Address.fromParts(el.getHostName(), el.getPort())); } for(TableProtos.TableName pTableName: proto.getTablesList()) { RSGroupInfo.addTable(ProtobufUtil.toTableName(pTableName)); } return RSGroupInfo; }